All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jason Gunthorpe <jgg@nvidia.com>
To: Michael Shavit <mshavit@google.com>
Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, nicolinc@nvidia.com,
	tina.zhang@intel.com, jean-philippe@linaro.org, will@kernel.org,
	robin.murphy@arm.com, Dawei Li <set_pte_at@outlook.com>,
	Joerg Roedel <joro@8bytes.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [RFC PATCH v2 1/9] iommu/arm-smmu-v3: group attached devices by smmu
Date: Tue, 22 Aug 2023 09:49:19 -0300	[thread overview]
Message-ID: <ZOSuz+16JD5E0k3z@nvidia.com> (raw)
In-Reply-To: <20230822185632.RFC.v2.1.Ib87a2696f25414e0fc39cc22dc74e31a4415c2a1@changeid>

On Tue, Aug 22, 2023 at 06:56:57PM +0800, Michael Shavit wrote:
> Always insert a new master in the devices_list besides other masters
> that belong to the same smmu.
> This allows code to batch commands by SMMU when iterating over masters
> that a domain is attached to.
> 
> Signed-off-by: Michael Shavit <mshavit@google.com>
> ---
> 
> Changes in v2:
> - New commit
> 
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 22 ++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 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 f17704c35858d..37b9223c145ba 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2382,6 +2382,24 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master)
>  		arm_smmu_write_ctx_desc(master, 0, NULL);
>  }
>  
> +static void arm_smmu_domain_device_list_add(struct arm_smmu_domain *smmu_domain,
> +					   struct arm_smmu_master *master)
> +{
> +	struct arm_smmu_master *iter;
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&smmu_domain->devices_lock, flags);
> +	if (list_empty(&smmu_domain->devices))
> +		list_add(&master->domain_head, &smmu_domain->devices);
> +	else {
> +		list_for_each_entry(iter, &smmu_domain->devices, domain_head)
> +			if (iter->smmu == master->smmu)
> +				break;
> +		list_add(&master->domain_head, &iter->domain_head);
> +	}

IIRC you are not supposed to touch iter after the list_for_each. Like this:

 list_for_each_entry(iter, &smmu_domain->devices, domain_head) {
      if (iter->smmu == master->smmu) {
          list_add(&master->domain_head, iter->domain_head);
 	  goto out;
      }
 }
 list_add(&master->domain_head, &smmu_domain->devices);
out:
 spin_unlock_irqrestore(&smmu_domain->devices_lock, flags);

Jason

WARNING: multiple messages have this Message-ID (diff)
From: Jason Gunthorpe <jgg@nvidia.com>
To: Michael Shavit <mshavit@google.com>
Cc: iommu@lists.linux.dev, linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, nicolinc@nvidia.com,
	tina.zhang@intel.com, jean-philippe@linaro.org, will@kernel.org,
	robin.murphy@arm.com, Dawei Li <set_pte_at@outlook.com>,
	Joerg Roedel <joro@8bytes.org>,
	"Kirill A. Shutemov" <kirill.shutemov@linux.intel.com>,
	Lu Baolu <baolu.lu@linux.intel.com>,
	Mark Brown <broonie@kernel.org>
Subject: Re: [RFC PATCH v2 1/9] iommu/arm-smmu-v3: group attached devices by smmu
Date: Tue, 22 Aug 2023 09:49:19 -0300	[thread overview]
Message-ID: <ZOSuz+16JD5E0k3z@nvidia.com> (raw)
In-Reply-To: <20230822185632.RFC.v2.1.Ib87a2696f25414e0fc39cc22dc74e31a4415c2a1@changeid>

On Tue, Aug 22, 2023 at 06:56:57PM +0800, Michael Shavit wrote:
> Always insert a new master in the devices_list besides other masters
> that belong to the same smmu.
> This allows code to batch commands by SMMU when iterating over masters
> that a domain is attached to.
> 
> Signed-off-by: Michael Shavit <mshavit@google.com>
> ---
> 
> Changes in v2:
> - New commit
> 
>  drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 22 ++++++++++++++++++---
>  1 file changed, 19 insertions(+), 3 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 f17704c35858d..37b9223c145ba 100644
> --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c
> @@ -2382,6 +2382,24 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master)
>  		arm_smmu_write_ctx_desc(master, 0, NULL);
>  }
>  
> +static void arm_smmu_domain_device_list_add(struct arm_smmu_domain *smmu_domain,
> +					   struct arm_smmu_master *master)
> +{
> +	struct arm_smmu_master *iter;
> +	unsigned long flags;
> +
> +	spin_lock_irqsave(&smmu_domain->devices_lock, flags);
> +	if (list_empty(&smmu_domain->devices))
> +		list_add(&master->domain_head, &smmu_domain->devices);
> +	else {
> +		list_for_each_entry(iter, &smmu_domain->devices, domain_head)
> +			if (iter->smmu == master->smmu)
> +				break;
> +		list_add(&master->domain_head, &iter->domain_head);
> +	}

IIRC you are not supposed to touch iter after the list_for_each. Like this:

 list_for_each_entry(iter, &smmu_domain->devices, domain_head) {
      if (iter->smmu == master->smmu) {
          list_add(&master->domain_head, iter->domain_head);
 	  goto out;
      }
 }
 list_add(&master->domain_head, &smmu_domain->devices);
out:
 spin_unlock_irqrestore(&smmu_domain->devices_lock, flags);

Jason

_______________________________________________
linux-arm-kernel mailing list
linux-arm-kernel@lists.infradead.org
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel

  reply	other threads:[~2023-08-22 12:49 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-08-22 10:56 [RFC PATCH v2 0/9] Install domain onto multiple smmus Michael Shavit
2023-08-22 10:56 ` Michael Shavit
2023-08-22 10:56 ` [RFC PATCH v2 1/9] iommu/arm-smmu-v3: group attached devices by smmu Michael Shavit
2023-08-22 10:56   ` Michael Shavit
2023-08-22 12:49   ` Jason Gunthorpe [this message]
2023-08-22 12:49     ` Jason Gunthorpe
2023-08-22 10:56 ` [RFC PATCH v2 2/9] iommu/arm-smmu-v3-sva: Move SVA optimization into arm_smmu_tlb_inv_range_asid Michael Shavit
2023-08-22 10:56   ` Michael Shavit
2023-08-22 10:56 ` [RFC PATCH v2 3/9] iommu/arm-smmu-v3: Issue invalidations commands to multiple SMMUs Michael Shavit
2023-08-22 10:56   ` Michael Shavit
2023-08-22 13:14   ` Jason Gunthorpe
2023-08-22 13:14     ` Jason Gunthorpe
2023-08-22 10:57 ` [RFC PATCH v2 4/9] iommu/arm-smmu-v3-sva: Allocate new ASID from installed_smmus Michael Shavit
2023-08-22 10:57   ` Michael Shavit
2023-08-22 13:19   ` Jason Gunthorpe
2023-08-22 13:19     ` Jason Gunthorpe
2023-08-23  7:26     ` Michael Shavit
2023-08-23  7:26       ` Michael Shavit
2023-08-22 10:57 ` [RFC PATCH v2 5/9] iommu/arm-smmu-v3: Alloc vmid from global pool Michael Shavit
2023-08-22 10:57   ` Michael Shavit
2023-08-22 10:57 ` [RFC PATCH v2 6/9] iommu/arm-smmu-v3: check smmu compatibility on attach Michael Shavit
2023-08-22 10:57   ` Michael Shavit
2023-08-22 10:57 ` [RFC PATCH v2 7/9] iommu/arm-smmu-v3: Add arm_smmu_device as a parameter to domain_finalise Michael Shavit
2023-08-22 10:57   ` Michael Shavit
2023-08-22 10:57 ` [RFC PATCH v2 8/9] iommu/arm-smmu-v3: check for domain initialization using pgtbl_ops Michael Shavit
2023-08-22 10:57   ` Michael Shavit
2023-08-22 10:57 ` [RFC PATCH v2 9/9] iommu/arm-smmu-v3: allow multi-SMMU domain installs Michael Shavit
2023-08-22 10:57   ` Michael Shavit
2023-08-23  2:42 ` [RFC PATCH v2 0/9] Install domain onto multiple smmus Baolu Lu
2023-08-23  2:42   ` Baolu Lu

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ZOSuz+16JD5E0k3z@nvidia.com \
    --to=jgg@nvidia.com \
    --cc=baolu.lu@linux.intel.com \
    --cc=broonie@kernel.org \
    --cc=iommu@lists.linux.dev \
    --cc=jean-philippe@linaro.org \
    --cc=joro@8bytes.org \
    --cc=kirill.shutemov@linux.intel.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mshavit@google.com \
    --cc=nicolinc@nvidia.com \
    --cc=robin.murphy@arm.com \
    --cc=set_pte_at@outlook.com \
    --cc=tina.zhang@intel.com \
    --cc=will@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.