From: Baolu Lu <baolu.lu@linux.intel.com>
To: Nicolin Chen <nicolinc@nvidia.com>, jgg@nvidia.com, kevin.tian@intel.com
Cc: baolu.lu@linux.intel.com, joro@8bytes.org, will@kernel.org,
robin.murphy@arm.com, iommu@lists.linux.dev,
linux-kernel@vger.kernel.org, yi.l.liu@intel.com
Subject: Re: [PATCH 1/2] iommufd/device: Drop enforce_cache_coherency in iommufd_device_do_replace
Date: Sat, 21 Oct 2023 09:25:18 +0800 [thread overview]
Message-ID: <f840af3a-45fe-477e-bd45-2bee95b8c8d5@linux.intel.com> (raw)
In-Reply-To: <5593200da9015fee7b2e8195c2998f36148d83de.1697848510.git.nicolinc@nvidia.com>
On 2023/10/21 8:37, Nicolin Chen wrote:
> According to the conversion in the following link:
> https://lore.kernel.org/linux-iommu/20231020135501.GG3952@nvidia.com/
>
> The enforce_cache_coherency should be set/enforced in the hwpt allocation
> routine. The iommu driver in its attach_dev() op should decide whether to
> reject or not a device that doesn't match with the configuration of cache
> coherency. Drop the enforce_cache_coherency piece in replace(). Also move
> the remaining "num_devices++" piece closer to the refcount that uses this
> num_devices.
>
> Cc: stable@vger.kernel.org
> Fixes: e88d4ec154a8 ("iommufd: Add iommufd_device_replace()")
> Suggested-by: Tian, Kevin <kevin.tian@intel.com>
> Signed-off-by: Nicolin Chen <nicolinc@nvidia.com>
> ---
> drivers/iommu/iommufd/device.c | 12 ++----------
> 1 file changed, 2 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/iommu/iommufd/device.c b/drivers/iommu/iommufd/device.c
> index e88fa73a45e6..c93f3478f808 100644
> --- a/drivers/iommu/iommufd/device.c
> +++ b/drivers/iommu/iommufd/device.c
> @@ -429,16 +429,6 @@ iommufd_device_do_replace(struct iommufd_device *idev,
> return NULL;
> }
>
> - /* Try to upgrade the domain we have */
> - list_for_each_entry(cur, &igroup->device_list, group_item) {
> - num_devices++;
> - if (cur->enforce_cache_coherency) {
> - rc = iommufd_hw_pagetable_enforce_cc(hwpt);
> - if (rc)
> - goto err_unlock;
> - }
> - }
> -
> old_hwpt = igroup->hwpt;
> if (hwpt->ioas != old_hwpt->ioas) {
> list_for_each_entry(cur, &igroup->device_list, group_item) {
> @@ -465,6 +455,8 @@ iommufd_device_do_replace(struct iommufd_device *idev,
>
> igroup->hwpt = hwpt;
>
> + list_for_each_entry(cur, &igroup->device_list, group_item)
> + num_devices++;
Minor: How about using list_count_nodes()?
> /*
> * Move the refcounts held by the device_list to the new hwpt. Retain a
> * refcount for this thread as the caller will free it.
Either way,
Reviewed-by: Lu Baolu <baolu.lu@linux.intel.com>
Best regards,
baolu
next prev parent reply other threads:[~2023-10-21 1:25 UTC|newest]
Thread overview: 10+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-10-21 0:37 [PATCH 0/2] iommufd: Only enforce_cache_coherency when allocating hwpt Nicolin Chen
2023-10-21 0:37 ` [PATCH 1/2] iommufd/device: Drop enforce_cache_coherency in iommufd_device_do_replace Nicolin Chen
2023-10-21 1:25 ` Baolu Lu [this message]
2023-10-23 0:25 ` Nicolin Chen
2023-10-21 0:37 ` [PATCH 2/2] iommufd/device: Drop enforce_cache_coherency in iommufd_hw_pagetable_attach Nicolin Chen
2023-10-21 1:26 ` Baolu Lu
2023-10-21 1:32 ` [PATCH 0/2] iommufd: Only enforce_cache_coherency when allocating hwpt Baolu Lu
2023-10-21 16:39 ` Jason Gunthorpe
2023-10-23 2:55 ` Tian, Kevin
2023-10-23 3:09 ` 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=f840af3a-45fe-477e-bd45-2bee95b8c8d5@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@nvidia.com \
--cc=joro@8bytes.org \
--cc=kevin.tian@intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=nicolinc@nvidia.com \
--cc=robin.murphy@arm.com \
--cc=will@kernel.org \
--cc=yi.l.liu@intel.com \
/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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox