From mboxrd@z Thu Jan 1 00:00:00 1970 From: Robin Murphy Subject: Re: [PATCH v2 1/2] iommu: add support for drivers that manage iommu explicitly Date: Tue, 10 Sep 2019 17:51:57 +0100 Message-ID: <4b5b59bb-39a4-0757-e2bb-0961cfc7e4c1@arm.com> References: <20190906214409.26677-1-robdclark@gmail.com> <20190906214409.26677-2-robdclark@gmail.com> <20190910081415.GB3247@8bytes.org> Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit Return-path: In-Reply-To: Content-Language: en-GB Sender: linux-kernel-owner@vger.kernel.org To: Rob Clark Cc: "list@263.net:IOMMU DRIVERS" , Joerg Roedel iommu@lists.linux-foundation.org, dri-devel , linux-arm-msm , Will Deacon , Rob Clark , Greg Kroah-Hartman , "Rafael J. Wysocki" , Andrew Morton , Suzuki K Poulose , Rasmus Villemoes , Heikki Krogerus , Bartosz Golaszewski , Sudeep Holla , Joe Perches , Arnd Bergmann , open list List-Id: dri-devel@lists.freedesktop.org On 10/09/2019 16:34, Rob Clark wrote: > On Tue, Sep 10, 2019 at 1:14 AM Joerg Roedel wrote: >> >> On Fri, Sep 06, 2019 at 02:44:01PM -0700, Rob Clark wrote: >>> @@ -674,7 +674,7 @@ int iommu_group_add_device(struct iommu_group *group, struct device *dev) >>> >>> mutex_lock(&group->mutex); >>> list_add_tail(&device->list, &group->devices); >>> - if (group->domain) >>> + if (group->domain && !(dev->driver && dev->driver->driver_manages_iommu)) >> >> Hmm, this code usually runs at enumeration time when no driver is >> attached to the device. Actually it would be pretty dangerous when this >> code runs while a driver is attached to the device. How does that change >> make things work for you? >> > > I was seeing this get called via the path driver_probe_device() -> > platform_dma_configure() -> of_dma_configure() -> of_iommu_configure() > -> iommu_probe_device() -> ... > > The only cases I was seeing where dev->driver is NULL where a few > places that drivers call of_dma_configure() on their own sub-devices. > But maybe there are some other paths that I did not notice? For the of_iommu flow, it very much depends on your DT layout and driver probe order as to whether you catch the "proper" call from iommu_bus_notifier()/iommu_bus_init() or the late "replay" from of_iommu_configure(). I wouldn't make any assumptions of consistency. Robin.