Linux IOMMU Development
 help / color / mirror / Atom feed
From: Guixin Liu <kanie@linux.alibaba.com>
To: Jason Gunthorpe <jgg@ziepe.ca>
Cc: Joerg Roedel <joro@8bytes.org>, Will Deacon <will@kernel.org>,
	Robin Murphy <robin.murphy@arm.com>,
	Kevin Tian <kevin.tian@intel.com>,
	iommu@lists.linux.dev
Subject: Re: [PATCH v3] iommu: Fix iommu selftest running test mock domain fail
Date: Thu, 25 Sep 2025 10:29:23 +0800	[thread overview]
Message-ID: <3697dc65-63fd-477b-8622-0236741babbc@linux.alibaba.com> (raw)
In-Reply-To: <20250924125352.GI2547959@ziepe.ca>



在 2025/9/24 20:53, Jason Gunthorpe 写道:
> On Wed, Sep 24, 2025 at 03:43:59PM +0800, Guixin Liu wrote:
>> @@ -1077,6 +1077,7 @@ static void mock_dev_release(struct device *dev)
>>   {
>>   	struct mock_dev *mdev = to_mock_dev(dev);
>>   
>> +	iommu_mock_device_abort(&mdev->dev);
>>   	ida_free(&mock_dev_ida, mdev->id);
>>   	kfree(mdev);
>>   }
> I don't think this call is necessary? Once device_add() completes the
> iommu_bus_notifier() should be active for the device.
>
> BUS_NOTIFY_REMOVED_DEVICE triggers iommu_release_device() which does
> dev_iommu_free() and frees the fwspec automatically.
>
> The only unnatural condition is if device_add() fails then the
> notifier can't run and the caller has to clean it up.
>
> Yes?
You are right, I didn't consider it comprehensively.
>
>> @@ -1126,6 +1127,10 @@ static struct mock_dev *mock_dev_create(unsigned long dev_flags)
>>   		goto err_put;
>>   	}
>>   
>> +	rc = iommu_mock_device_init(&mdev->dev, &mock_iommu.iommu_dev);
>> +	if (rc)
>> +		goto err_put;
>> +
>>   	rc = device_add(&mdev->dev);
>>   	if (rc)
>>   		goto err_put;
> So I will suggest one further refinement to pull the device_add() into
> iommu_mock_device_add() and then it can internally free the fwspec on
> error and don't bother with iommu_mock_device_abort().
Nice idea, I will change it in v4, thanks.

Best Regards,
Guixin Liu
> But other than that little note this looks fine to me.
>
> Jason


      reply	other threads:[~2025-09-25  2:29 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-09-24  7:43 [PATCH v3] iommu: Fix iommu selftest running test mock domain fail Guixin Liu
2025-09-24 12:53 ` Jason Gunthorpe
2025-09-25  2:29   ` Guixin Liu [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=3697dc65-63fd-477b-8622-0236741babbc@linux.alibaba.com \
    --to=kanie@linux.alibaba.com \
    --cc=iommu@lists.linux.dev \
    --cc=jgg@ziepe.ca \
    --cc=joro@8bytes.org \
    --cc=kevin.tian@intel.com \
    --cc=robin.murphy@arm.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