diff mbox series

[v6,3/6] iommu/arm-smmu-v3: Make arm_smmu_cmdq_init reusable

Message ID 47a2ec844ec42694872d3c3b1a09f1b870712f78.1714451595.git.nicolinc@nvidia.com
State Superseded
Headers show
Series Add Tegra241 (Grace) CMDQV Support (part 1/2) | expand

Commit Message

Nicolin Chen April 30, 2024, 4:43 a.m. UTC
The CMDQV extension in NVIDIA Tegra241 SoC resues the arm_smmu_cmdq
structure while the queue location isn't same as smmu->cmdq.

Add a cmdq argument to arm_smmu_cmdq_init() function and shares its
define in the header for CMDQV driver to use.

Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 +++---
 drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 +++
 2 files changed, 6 insertions(+), 3 deletions(-)

Comments

Jason Gunthorpe April 30, 2024, 2:24 p.m. UTC | #1
On Mon, Apr 29, 2024 at 09:43:46PM -0700, Nicolin Chen wrote:
> The CMDQV extension in NVIDIA Tegra241 SoC resues the arm_smmu_cmdq
> structure while the queue location isn't same as smmu->cmdq.
> 
> Add a cmdq argument to arm_smmu_cmdq_init() function and shares its
> define in the header for CMDQV driver to use.
> 
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 +++---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 +++
>  2 files changed, 6 insertions(+), 3 deletions(-)

I would squash this patch and the next together:

iommu/arm-smm-v3: Make symbols public

The symbols arm_smmu_cmdq_init() and __arm_smmu_cmdq_skip_err() need
to be used by the tegra241-cmdqv.c compilation unit in the next
patch. Remove the static and put prototypes in the header.

But the code is fine

Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Jason
Nicolin Chen April 30, 2024, 3:50 p.m. UTC | #2
On Tue, Apr 30, 2024 at 11:24:08AM -0300, Jason Gunthorpe wrote:
> On Mon, Apr 29, 2024 at 09:43:46PM -0700, Nicolin Chen wrote:
> > The CMDQV extension in NVIDIA Tegra241 SoC resues the arm_smmu_cmdq
> > structure while the queue location isn't same as smmu->cmdq.
> > 
> > Add a cmdq argument to arm_smmu_cmdq_init() function and shares its
> > define in the header for CMDQV driver to use.
> > 
> > Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> > ---
> >  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 6 +++---
> >  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 3 +++
> >  2 files changed, 6 insertions(+), 3 deletions(-)
> 
> I would squash this patch and the next together:
> 
> iommu/arm-smm-v3: Make symbols public
> 
> The symbols arm_smmu_cmdq_init() and __arm_smmu_cmdq_skip_err() need
> to be used by the tegra241-cmdqv.c compilation unit in the next
> patch. Remove the static and put prototypes in the header.
> 
> But the code is fine
> 
> Reviewed-by: Jason Gunthorpe <jgg@nvidia.com>

Then, arm_smmu_init_one_queue could be moved to this patch too.

Thanks
Nicolin
diff mbox series

Patch

diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
index b3d03ca01adc..538850059bdd 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -3145,9 +3145,9 @@  static int arm_smmu_init_one_queue(struct arm_smmu_device *smmu,
 	return 0;
 }
 
-static int arm_smmu_cmdq_init(struct arm_smmu_device *smmu)
+int arm_smmu_cmdq_init(struct arm_smmu_device *smmu,
+		       struct arm_smmu_cmdq *cmdq)
 {
-	struct arm_smmu_cmdq *cmdq = &smmu->cmdq;
 	unsigned int nents = 1 << cmdq->q.llq.max_n_shift;
 
 	atomic_set(&cmdq->owner_prod, 0);
@@ -3172,7 +3172,7 @@  static int arm_smmu_init_queues(struct arm_smmu_device *smmu)
 	if (ret)
 		return ret;
 
-	ret = arm_smmu_cmdq_init(smmu);
+	ret = arm_smmu_cmdq_init(smmu, &smmu->cmdq);
 	if (ret)
 		return ret;
 
diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
index bbee08e82943..ab2824e46ac5 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
@@ -760,6 +760,9 @@  bool arm_smmu_free_asid(struct arm_smmu_ctx_desc *cd);
 int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, int ssid,
 			    unsigned long iova, size_t size);
 
+int arm_smmu_cmdq_init(struct arm_smmu_device *smmu,
+		       struct arm_smmu_cmdq *cmdq);
+
 #ifdef CONFIG_ARM_SMMU_V3_SVA
 bool arm_smmu_sva_supported(struct arm_smmu_device *smmu);
 bool arm_smmu_master_sva_supported(struct arm_smmu_master *master);