diff mbox series

[v6,4/6] iommu/arm-smmu-v3: Make __arm_smmu_cmdq_skip_err reusable

Message ID 25150aec77edf5590bca81f4a418ef1ee7b21952.1714451595.git.nicolinc@nvidia.com (mailing list archive)
State New, archived
Headers show
Series Add Tegra241 (Grace) CMDQV Support (part 1/2) | expand

Commit Message

Nicolin Chen April 30, 2024, 4:43 a.m. UTC
Allow __arm_smmu_cmdq_skip_err function to be reused by NVIDIA Tegra241
CMDQV unit since it will use the same data structure for q. And include
the CMDQ_QUIRK_SYNC_CS_NONE_ONLY quirk when inserting a CMD_SYNC.

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

Comments

Jason Gunthorpe April 30, 2024, 2:06 p.m. UTC | #1
On Mon, Apr 29, 2024 at 09:43:47PM -0700, Nicolin Chen wrote:
> Allow __arm_smmu_cmdq_skip_err function to be reused by NVIDIA Tegra241
> CMDQV unit since it will use the same data structure for q. And include
> the CMDQ_QUIRK_SYNC_CS_NONE_ONLY quirk when inserting a CMD_SYNC.
> 
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 +++++--
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 ++
>  2 files changed, 7 insertions(+), 2 deletions(-)
> 
> 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 538850059bdd..5111859347d5 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -379,8 +379,8 @@ static void arm_smmu_cmdq_build_sync_cmd(u64 *cmd, struct arm_smmu_device *smmu,
>  	arm_smmu_cmdq_build_cmd(cmd, &ent);
>  }
>  
> -static void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
> -				     struct arm_smmu_queue *q)
> +void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
> +			      struct arm_smmu_queue *q)
>  {
>  	static const char * const cerror_str[] = {
>  		[CMDQ_ERR_CERROR_NONE_IDX]	= "No error",
> @@ -428,6 +428,9 @@ static void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
>  	for (i = 0; i < ARRAY_SIZE(cmd); ++i)
>  		dev_err(smmu->dev, "\t0x%016llx\n", (unsigned long long)cmd[i]);
>  
> +	if (q->quirks & CMDQ_QUIRK_SYNC_CS_NONE_ONLY)
> +		cmd_sync.sync.cs_none = true;

This hunk should be in "iommu/arm-smmu-v3: Add CS_NONE quirk" ?

Jason
Nicolin Chen April 30, 2024, 3:48 p.m. UTC | #2
On Tue, Apr 30, 2024 at 11:06:00AM -0300, Jason Gunthorpe wrote:
> On Mon, Apr 29, 2024 at 09:43:47PM -0700, Nicolin Chen wrote:
> > Allow __arm_smmu_cmdq_skip_err function to be reused by NVIDIA Tegra241
> > CMDQV unit since it will use the same data structure for q. And include
> > the CMDQ_QUIRK_SYNC_CS_NONE_ONLY quirk when inserting a CMD_SYNC.
> > 
> > Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> > ---
> >  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 7 +++++--
> >  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h | 2 ++
> >  2 files changed, 7 insertions(+), 2 deletions(-)
> > 
> > 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 538850059bdd..5111859347d5 100644
> > --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> > @@ -379,8 +379,8 @@ static void arm_smmu_cmdq_build_sync_cmd(u64 *cmd, struct arm_smmu_device *smmu,
> >  	arm_smmu_cmdq_build_cmd(cmd, &ent);
> >  }
> >  
> > -static void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
> > -				     struct arm_smmu_queue *q)
> > +void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
> > +			      struct arm_smmu_queue *q)
> >  {
> >  	static const char * const cerror_str[] = {
> >  		[CMDQ_ERR_CERROR_NONE_IDX]	= "No error",
> > @@ -428,6 +428,9 @@ static void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
> >  	for (i = 0; i < ARRAY_SIZE(cmd); ++i)
> >  		dev_err(smmu->dev, "\t0x%016llx\n", (unsigned long long)cmd[i]);
> >  
> > +	if (q->quirks & CMDQ_QUIRK_SYNC_CS_NONE_ONLY)
> > +		cmd_sync.sync.cs_none = true;
> 
> This hunk should be in "iommu/arm-smmu-v3: Add CS_NONE quirk" ?

Oh, yea. Will move it.

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 538850059bdd..5111859347d5 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
@@ -379,8 +379,8 @@  static void arm_smmu_cmdq_build_sync_cmd(u64 *cmd, struct arm_smmu_device *smmu,
 	arm_smmu_cmdq_build_cmd(cmd, &ent);
 }
 
-static void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
-				     struct arm_smmu_queue *q)
+void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
+			      struct arm_smmu_queue *q)
 {
 	static const char * const cerror_str[] = {
 		[CMDQ_ERR_CERROR_NONE_IDX]	= "No error",
@@ -428,6 +428,9 @@  static void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
 	for (i = 0; i < ARRAY_SIZE(cmd); ++i)
 		dev_err(smmu->dev, "\t0x%016llx\n", (unsigned long long)cmd[i]);
 
+	if (q->quirks & CMDQ_QUIRK_SYNC_CS_NONE_ONLY)
+		cmd_sync.sync.cs_none = true;
+
 	/* Convert the erroneous command into a CMD_SYNC */
 	arm_smmu_cmdq_build_cmd(cmd, &cmd_sync);
 
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 ab2824e46ac5..32e7fc5e1794 100644
--- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
+++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.h
@@ -762,6 +762,8 @@  int arm_smmu_atc_inv_domain(struct arm_smmu_domain *smmu_domain, int ssid,
 
 int arm_smmu_cmdq_init(struct arm_smmu_device *smmu,
 		       struct arm_smmu_cmdq *cmdq);
+void __arm_smmu_cmdq_skip_err(struct arm_smmu_device *smmu,
+			      struct arm_smmu_queue *q);
 
 #ifdef CONFIG_ARM_SMMU_V3_SVA
 bool arm_smmu_sva_supported(struct arm_smmu_device *smmu);