From: Baolu Lu <baolu.lu@linux.intel.com>
To: Jason Gunthorpe <jgg@ziepe.ca>, Vasant Hegde <vasant.hegde@amd.com>
Cc: baolu.lu@linux.intel.com, iommu@lists.linux.dev, joro@8bytes.org,
suravee.suthikulpanit@amd.com,
Dheeraj Kumar Srivastava <dheerajkumar.srivastava@amd.com>
Subject: Re: [PATCH v2 iommu/next] iommu: Fix default domain setup
Date: Fri, 23 Jun 2023 11:08:56 +0800 [thread overview]
Message-ID: <febaefc7-9b2c-5634-ea1d-0286b57b1766@linux.intel.com> (raw)
In-Reply-To: <ZJRSuBsVBVSi8Swn@ziepe.ca>
On 6/22/23 9:55 PM, Jason Gunthorpe wrote:
> On Thu, Jun 22, 2023 at 10:29:58AM +0530, Vasant Hegde wrote:
>> Hi Baolu, Jason,
>>
>>
>> On 6/20/2023 5:12 PM, Jason Gunthorpe wrote:
>>> On Tue, Jun 20, 2023 at 02:31:43PM +0800, Baolu Lu wrote:
>>>>> err_restore:
>>>>> if (old_dom) {
>>>>> __iommu_group_set_domain_internal(
>>>>> group, old_dom, IOMMU_SET_DOMAIN_MUST_SUCCEED);
>>>>> + group->default_domain = old_dom;
>>>>> iommu_domain_free(dom);
>>>>> old_dom = NULL;
>>>>> }
>>>> The err_restore branch doesn't work if old_dom is NULL. We have no means
>>>> to restore a group from a successful first-time attaching to NULL
>>>> attaching.
>>> Yes, this is what I fixed in my alternative version
>> Not really. Even your version has
> I though what Baolu means is that it crashes in some of the cases.
>
>> +err_restore_domain:
>> + if (old_dom)
>>
>>
>> Only first time we will have old_dom is NULL and this functions returns error
>> code. iommu_probe_device()/bus_iommu_probe() handler error path properly and
>> frees resources. So I think this is fine.
> Yes, the design is to leave it as-is and know that the error unwind
> will fail to attach the device and free the domain after
> release. There is a comment explaining this.
>
I thought that perhaps we could throw a warning to the driver when
old_dom is NULL. Something like this:
if (!old_dom)
pr_warn("can't restore to old domain\n");
else
goto err_restore_domain;
But as Vasant said the only caller can handle this error case
gracefully. Then it's fine to keep the code as it is.
Best regards,
baolu
next prev parent reply other threads:[~2023-06-23 3:10 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-06-19 8:49 [PATCH v2 iommu/next] iommu: Fix default domain setup Vasant Hegde
2023-06-19 11:31 ` Jason Gunthorpe
2023-06-20 5:11 ` Vasant Hegde
2023-06-20 6:31 ` Baolu Lu
2023-06-20 11:42 ` Jason Gunthorpe
2023-06-22 4:59 ` Vasant Hegde
2023-06-22 13:55 ` Jason Gunthorpe
2023-06-23 3:08 ` Baolu Lu [this message]
2023-06-23 4:38 ` Vasant Hegde
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=febaefc7-9b2c-5634-ea1d-0286b57b1766@linux.intel.com \
--to=baolu.lu@linux.intel.com \
--cc=dheerajkumar.srivastava@amd.com \
--cc=iommu@lists.linux.dev \
--cc=jgg@ziepe.ca \
--cc=joro@8bytes.org \
--cc=suravee.suthikulpanit@amd.com \
--cc=vasant.hegde@amd.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