From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-wm1-f51.google.com (mail-wm1-f51.google.com [209.85.128.51]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CA4273D4116 for ; Thu, 7 May 2026 10:13:21 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.51 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778148804; cv=none; b=V0Ko9YMF4tRuqCA3JVMuTtcOXJTBl/bpn6k3acpPvwVvIamAgmdQUO4kO7JJavnj3HWrDWFq/2gbTqgHG4AtYXcLyiCifuC6EDb30sn5H9sM8drtPUV7qHtzwwcdcebzedPi8e0Mx+yGFJyUqA4kPOrzn4ESEbCzog2TfsFvzLI= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1778148804; c=relaxed/simple; bh=iHSSMm5XmsR+SC8q2k1hfxidjzifsoc17tRBa7hWxWk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=R6Zx/uy3jzSFm7mUp28xZAfKsiX8fy6t067cJK/YKIi0CsIIJNMoglArXkLtN06XuBi+RyHOwpmPS7Xngodv+/go0ZKnFppvVgznRwztdNQ3GsMBUU7tWzTbtw6dOS2QLCB+QyyXvrejb3i0WJsh4nXxDiEpxw40gnk094mxlR8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=ZPxIGS6F; arc=none smtp.client-ip=209.85.128.51 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="ZPxIGS6F" Received: by mail-wm1-f51.google.com with SMTP id 5b1f17b1804b1-48d1c670255so83965e9.0 for ; Thu, 07 May 2026 03:13:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1778148799; x=1778753599; darn=vger.kernel.org; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:from:to :cc:subject:date:message-id:reply-to; bh=4DTS0qUVxwfbisiyGTh7vOJzKa4BtZMrsDae9RELKmk=; b=ZPxIGS6F64Ewk3BnccXHr9NXrqN97YCHyBgHCQT1xWZVaOUgUah3To3vUBGPABgZux YeeeVetsT9Bycw32dNLgYM3uEAGcYkCYb92D+J6N9AA8oUQ/9Zelss/PDFt8GmbwCaji +ao+TVrD1DLiLtsvcVzxKqtbd2Twwy3hgoR3KES0YPDxWyPZvZeehas/41gD8CccLczh j0BabkWNtlg9lwQFmE9Kd2e6wb9wZgR9IBAemdrb4HJvZZTE1rEgaDzLSuYMGV6E685c g75loxUj0/4j6FIbEOmE0q3+fx8KUzkFXTf7eQXnsjFrvC1wO2yZaI2aixZQ9r8ZwwL1 Ypcg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1778148799; x=1778753599; h=in-reply-to:content-transfer-encoding:content-disposition :mime-version:references:message-id:subject:cc:to:from:date:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=4DTS0qUVxwfbisiyGTh7vOJzKa4BtZMrsDae9RELKmk=; b=YzSKO/BtvQxv4jgaIX9AqCvf2bAm3C89O8boMw841oW/jXQ8nrmTWLH9HAD9SegGrF CgpM5yZwgyljiUBYqzA06zf5UdgbdQz0KUBfFqR2354WLJ+fSAMFwgrNDlXNH16HAnc/ g/pzSd1qYxW3g1Poru39Y1GTFdAvgIFAtIwhWG4VFA/xFsJFdCPW4Up61rvhc3Vn3cYo f4YJUN23xEw9FEPkr4WUuY6TGKqlwncoRTC1lVASM90COQV6P4rgJOxaBaUjSp5FOaba lvrLfqUV/gKaxKTIiL2r5NqQXjKhO0GPLXwvXcwuBYCF3QejhwlMy2sTn7g5PHPUD1GN htGQ== X-Forwarded-Encrypted: i=1; AFNElJ/1DLPFIQlgGk1bvjxb5DuW6xaHWpjQOF2Ry1Ren+PEwGwGukMbZcAEatgwM8gnOrpm52QjVRIUyD0fi8U=@vger.kernel.org X-Gm-Message-State: AOJu0Yy1J9j/YVU9hfHlsUzVnRT1aMXimgvaTe9MBzcoFJOafGwFAzRN OXwoW33fhYfj8zub0wBp002KdxbKR5Wf1RgwghRw+Tkw/B+fxtbctqTPnwc0RWim0g== X-Gm-Gg: AeBDiesLydtU/7An4uaX9TrSE96QJjDMjIF33bnJPkcmGL2SMtOmucfWn+iFQoZUGK+ V3s3++wPtgHzJ0ooOyZCcOKXoidhazUCh1apmiHvZ0LoJai17pC/mAuGA6BxJK4CZ4BDrU/kMca Qes4gNZz5BYy2oHkkoqaFWgBRIwP3N/581kBzSHSNvQQHlOYpmxUvmyHuFntR1FZ3muycEJ3a3V 9Njd4SGdc9wvRDz4rI6gbHGP5cuFHMCbNae38mpdbBb+XBix4uTmAmR0Jxz6EsXO8r3J4rSldwV Yjx7s9vHqQ9QVh4UY4LtxAqVNUW7Y6Kh94FXY87X4oa8zT30wUdXaTcXbFN6JDqGUVodynnaJz5 r63Ei+oV0eHoS+0+yEXXuYCizaTmbK1NbHlHBlChKWB2ty2O7fr1ry4siUp8xaYHNFR+duAIOhB HJcf7R3TfpPUlpGpHIi1TXWCusniK+XAo7yiKumV9PWX/YYTOZgMYnLTHZCUav3XzkTBQTww24S mGmYg== X-Received: by 2002:a05:600c:8886:b0:483:6a76:11a6 with SMTP id 5b1f17b1804b1-48e52d0a2cemr1856915e9.5.1778148798935; Thu, 07 May 2026 03:13:18 -0700 (PDT) Received: from google.com (8.181.38.34.bc.googleusercontent.com. [34.38.181.8]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-48e530fdc50sm57573975e9.5.2026.05.07.03.13.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 07 May 2026 03:13:18 -0700 (PDT) Date: Thu, 7 May 2026 10:13:13 +0000 From: Mostafa Saleh To: Jason Gunthorpe Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, kvmarm@lists.linux.dev, iommu@lists.linux.dev, catalin.marinas@arm.com, will@kernel.org, maz@kernel.org, oliver.upton@linux.dev, joey.gouly@arm.com, suzuki.poulose@arm.com, yuzenghui@huawei.com, joro@8bytes.org, jean-philippe@linaro.org, mark.rutland@arm.com, qperret@google.com, tabba@google.com, vdonnefort@google.com, sebastianene@google.com, keirf@google.com Subject: Re: [PATCH v6 05/25] iommu/arm-smmu-v3: Move IDR parsing to common functions Message-ID: References: <20260501111928.259252-1-smostafa@google.com> <20260501111928.259252-6-smostafa@google.com> <20260501124716.GD6912@ziepe.ca> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: On Wed, May 06, 2026 at 06:56:31AM -0300, Jason Gunthorpe wrote: > On Tue, May 05, 2026 at 04:48:08PM +0000, Mostafa Saleh wrote: > > On Tue, May 05, 2026 at 01:27:45PM -0300, Jason Gunthorpe wrote: > > > On Mon, May 04, 2026 at 12:16:13PM +0000, Mostafa Saleh wrote: > > > > On Fri, May 01, 2026 at 09:47:16AM -0300, Jason Gunthorpe wrote: > > > > > On Fri, May 01, 2026 at 11:19:07AM +0000, Mostafa Saleh wrote: > > > > > > Move parsing of IDRs to functions so that it can be re-used > > > > > > +unsigned long smmu_idr5_to_pgsize(u32 reg) > > > > > > +{ > > > > > > + unsigned long pgsize_bitmap = 0; > > > > > > + > > > > > > + if (reg & IDR5_GRAN64K) > > > > > > + pgsize_bitmap |= SZ_64K | SZ_512M; > > > > > > + if (reg & IDR5_GRAN16K) > > > > > > + pgsize_bitmap |= SZ_16K | SZ_32M; > > > > > > + if (reg & IDR5_GRAN4K) > > > > > > + pgsize_bitmap |= SZ_4K | SZ_2M | SZ_1G; > > > > > > + return pgsize_bitmap; > > > > > > +} > > > > > > > > > > I think this should include: > > > > > > > > > > > + smmu->oas = smmu_idr5_to_oas(reg); > > > > > > + if (smmu->oas == 52) > > > > > > smmu->pgsize_bitmap |= 1ULL << 42; /* 4TB */ > > > > > > - break; > > > > > > > > > > ie it should return the supported page sizes by inspecting all the > > > > > idrs and don't leave this tricky bit to be open coded.. > > > > > > > > This way was easier as each function only returns one thing, otherwise > > > > we have to pass stuff by address as we can’t pass the smmu struct as it > > > > is not shared between the drivers. > > > > But no strong opinion, I can change that. > > > > > > Could you share the struct? With multi-compilation you do get two > > > structs with the same name and different layout, it is OK? > > > > > > That would give a cleaner setup too because you can just shove all > > > this into a function and have it setup the same struct which is more a > > > copy and paste than break up into little functions? > > > > Yes, that’s possible, but I didn't want to contaminate the main struct, > > also we can’t compile the main one for KVM because of things such as > > “struct device, struct mutex...” > > May we can do: > > - struct arm_smmu_device_common: Basic stuff (ioaddress, features, > > oas...) > > - arm_smmu_device: For the main driver which inherits arm_smmu_device_common > > - arm_smmu_nested_device for KVM which also inherits arm_smmu_device_common > > Less keen on this, it would need more usages to justify it > > > What do you think? > > I was thinking more like > > #define arm_smmu arm_pkvm_smmu > > Before the pkvm compile of the shared code. Oh, so we rely on arm_pkvm_smmu and arm_smmu having the same field names and types? I don’t think that’s better for maintainability, I can look into it if Robin and Will are OK with that. > > How does pkvm compilation work anyhow? Is it all rolled into a unique > link, or do you have to worry about symbol conflicts with the main > kernel? All pkvm symbols are prefixed with __kvm_nvhe_ in the main kernel. Thanks, Mostafa > > Jason