Linux IOMMU Development
 help / color / mirror / Atom feed
From: Vasant Hegde <vasant.hegde@amd.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: iommu@lists.linux.dev, joro@8bytes.org, will@kernel.org,
	robin.murphy@arm.com, suravee.suthikulpanit@amd.com,
	Joerg Roedel <jroedel@suse.de>
Subject: Re: [PATCH v3 10/10] iommu/amd: Improve amd_iommu_release_device()
Date: Thu, 24 Oct 2024 20:00:21 +0530	[thread overview]
Message-ID: <2a3916f4-3162-4ea0-95eb-25e79325c4a9@amd.com> (raw)
In-Reply-To: <20241017133918.GT4020792@ziepe.ca>

Jason,

On 10/17/2024 7:09 PM, Jason Gunthorpe wrote:
> On Wed, Oct 16, 2024 at 05:35:01AM +0000, Vasant Hegde wrote:
> 
>> @@ -2251,7 +2234,18 @@ static void amd_iommu_release_device(struct device *dev)
>>  	if (!iommu)
>>  		return;
>>  
>> -	amd_iommu_uninit_device(dev);
>> +	dev_data = dev_iommu_priv_get(dev);
>> +	if (!dev_data)
>> +		return;
> 
> This can never happen, the core code never calls an op unless
> probe_device succeeded.

Correct. Let me remove this check.

> 
>> +	if (dev_data->domain)
>> +		detach_device(dev);
> 
> This is also can't happen. The driver sets release_domain then the
> core code never calls this with anything other than release_domain
> attached.

I wanted to implement ops->release_domain  after this series. May be I can put
it as part of this series itself. We already have all the support. Should be
easy to add.


> 
> Suggest just 
> 
>  struct iommu_dev_data *dev_data = dev_iommu_priv_get(dev);
> 
>  WARN_ON(dev->data->domain);
> 
>> +	/*
>> +	 * We keep dev_data around for unplugged devices and reuse it when the
>> +	 * device is re-plugged - not doing so would introduce a ton of races.
>> +	 */
>> +
> 
> Yikes.. Sounds sketchy. Why doesn't any other driver have these races?

I don't know. Suravee/Joerg may know have historical details. I just moved this
from amd_iommu_uninit_device() to here.

-Vasant

      reply	other threads:[~2024-10-24 14:31 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-10-16  5:34 [PATCH v3 00/10] iommu/amd: Improve domain allocator and device attach code path Vasant Hegde
2024-10-16  5:34 ` [PATCH v3 01/10] iommu/amd: Use ida interface to manage protection domain ID Vasant Hegde
2024-10-17 13:14   ` Jason Gunthorpe
2024-10-25 12:16     ` Vasant Hegde
2024-10-16  5:34 ` [PATCH v3 02/10] iommu/amd: Remove protection_domain.dev_cnt variable Vasant Hegde
2024-10-17 13:14   ` Jason Gunthorpe
2024-10-16  5:34 ` [PATCH v3 03/10] iommu/amd: xarray to track protection_domain->iommu list Vasant Hegde
2024-10-17 13:19   ` Jason Gunthorpe
2024-10-25 11:23     ` Vasant Hegde
2024-10-16  5:34 ` [PATCH v3 04/10] iommu/amd: Remove unused amd_iommus variable Vasant Hegde
2024-10-17 13:20   ` Jason Gunthorpe
2024-10-16  5:34 ` [PATCH v3 05/10] iommu/amd: Do not detach devices in domain free path Vasant Hegde
2024-10-17 13:22   ` Jason Gunthorpe
2024-10-16  5:34 ` [PATCH v3 06/10] iommu/amd: Reduce domain lock scope in attach device path Vasant Hegde
2024-10-17 13:32   ` Jason Gunthorpe
2024-10-18  2:38     ` Baolu Lu
2024-10-18 11:54       ` Jason Gunthorpe
2024-10-21  4:58         ` Baolu Lu
2024-10-24 14:41     ` Vasant Hegde
2024-10-16  5:34 ` [PATCH v3 07/10] iommu/amd: Rearrange attach device code Vasant Hegde
2024-10-17 13:33   ` Jason Gunthorpe
2024-10-16  5:34 ` [PATCH v3 08/10] iommu/amd: Convert dev_data lock from spinlock to mutex Vasant Hegde
2024-10-17 13:33   ` Jason Gunthorpe
2024-10-16  5:35 ` [PATCH v3 09/10] iommu/amd: Reorder attach device code Vasant Hegde
2024-10-17 13:35   ` Jason Gunthorpe
2024-10-16  5:35 ` [PATCH v3 10/10] iommu/amd: Improve amd_iommu_release_device() Vasant Hegde
2024-10-17 13:39   ` Jason Gunthorpe
2024-10-24 14:30     ` Vasant Hegde [this message]

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=2a3916f4-3162-4ea0-95eb-25e79325c4a9@amd.com \
    --to=vasant.hegde@amd.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=jroedel@suse.de \
    --cc=robin.murphy@arm.com \
    --cc=suravee.suthikulpanit@amd.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox