Re: [PATCH] iommu/vt-d: Try info->iommu in device_to_iommu()

From: Nicolin Chen
Date: Fri May 13 2022 - 12:48:53 EST


On Fri, May 13, 2022 at 08:50:32AM -0300, Jason Gunthorpe wrote:

> > Perhaps, we can make device_to_iommu() only for probe_device() where the
> > per-device info data is not initialized yet. After probe_device(), iommu
> > and sid are retrieved through other helpers by looking up the device
> > info directly?
>
> This design makes the most sense to me... Nicolin you said there was a
> case where attach was happening before probe though??

I was testing on top of our IOMMUFD dev branch actually, which
is still on 5.17 where priv/info seems to be set at the end of
first ->attach_dev() call. In 5.18, Baolu has already cleaned
away some code. So now, just eyeballing here, it should be set
at driver's ->probe_device() call, so it'd be safe to get info
in attach_dev (and in the new op that we are adding).

I am also rebasing our dev branch to more recent version btw.

Thanks
Nic