linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/1] iommu: Fix deferred domain attachment in iommu_probe_device()
@ 2020-10-26  6:30 Lu Baolu
  2020-11-03 13:23 ` Joerg Roedel
  0 siblings, 1 reply; 3+ messages in thread
From: Lu Baolu @ 2020-10-26  6:30 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: iommu, linux-kernel, Lu Baolu, stable

The IOMMU core has support for deferring the attachment of default domain
to device. Fix a missed deferred attaching check in iommu_probe_device().

Fixes: cf193888bfbd3 ("iommu: Move new probe_device path to separate function")
Cc: stable@vger.kernel.org # v5.8+
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/iommu/iommu.c | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/iommu/iommu.c b/drivers/iommu/iommu.c
index 6d847027d35e..690abf60239d 100644
--- a/drivers/iommu/iommu.c
+++ b/drivers/iommu/iommu.c
@@ -93,6 +93,8 @@ static void __iommu_detach_group(struct iommu_domain *domain,
 static int iommu_create_device_direct_mappings(struct iommu_group *group,
 					       struct device *dev);
 static struct iommu_group *iommu_group_get_for_dev(struct device *dev);
+static bool iommu_is_attach_deferred(struct iommu_domain *domain,
+				     struct device *dev);
 
 #define IOMMU_GROUP_ATTR(_name, _mode, _show, _store)		\
 struct iommu_group_attribute iommu_group_attr_##_name =		\
@@ -264,7 +266,8 @@ int iommu_probe_device(struct device *dev)
 	 */
 	iommu_alloc_default_domain(group, dev);
 
-	if (group->default_domain)
+	if (group->default_domain &&
+	    !iommu_is_attach_deferred(group->default_domain, dev))
 		ret = __iommu_attach_device(group->default_domain, dev);
 
 	iommu_create_device_direct_mappings(group, dev);
-- 
2.17.1


^ permalink raw reply related	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] iommu: Fix deferred domain attachment in iommu_probe_device()
  2020-10-26  6:30 [PATCH 1/1] iommu: Fix deferred domain attachment in iommu_probe_device() Lu Baolu
@ 2020-11-03 13:23 ` Joerg Roedel
  2020-11-04  1:01   ` Lu Baolu
  0 siblings, 1 reply; 3+ messages in thread
From: Joerg Roedel @ 2020-11-03 13:23 UTC (permalink / raw)
  To: Lu Baolu; +Cc: iommu, linux-kernel, stable

Hi Baolu,

On Mon, Oct 26, 2020 at 02:30:08PM +0800, Lu Baolu wrote:
> @@ -264,7 +266,8 @@ int iommu_probe_device(struct device *dev)
>  	 */
>  	iommu_alloc_default_domain(group, dev);
>  
> -	if (group->default_domain)
> +	if (group->default_domain &&
> +	    !iommu_is_attach_deferred(group->default_domain, dev))
>  		ret = __iommu_attach_device(group->default_domain, dev);

This is the hotplug path, not used for boot-initialization. Have you
seen failures from the missing check here?

Regards,

	Joerg

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] iommu: Fix deferred domain attachment in iommu_probe_device()
  2020-11-03 13:23 ` Joerg Roedel
@ 2020-11-04  1:01   ` Lu Baolu
  0 siblings, 0 replies; 3+ messages in thread
From: Lu Baolu @ 2020-11-04  1:01 UTC (permalink / raw)
  To: Joerg Roedel; +Cc: baolu.lu, iommu, linux-kernel, stable

Hi Joerg,

On 11/3/20 9:23 PM, Joerg Roedel wrote:
> Hi Baolu,
> 
> On Mon, Oct 26, 2020 at 02:30:08PM +0800, Lu Baolu wrote:
>> @@ -264,7 +266,8 @@ int iommu_probe_device(struct device *dev)
>>   	 */
>>   	iommu_alloc_default_domain(group, dev);
>>   
>> -	if (group->default_domain)
>> +	if (group->default_domain &&
>> +	    !iommu_is_attach_deferred(group->default_domain, dev))
>>   		ret = __iommu_attach_device(group->default_domain, dev);
> 
> This is the hotplug path, not used for boot-initialization. Have you
> seen failures from the missing check here?

I haven't seen any failure. Just wondered why deferred attaching was not
checked here. It's fine to me if it's only for hotplug path.

Please ignore this change.

Best regards,
baolu

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2020-11-04  1:08 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-10-26  6:30 [PATCH 1/1] iommu: Fix deferred domain attachment in iommu_probe_device() Lu Baolu
2020-11-03 13:23 ` Joerg Roedel
2020-11-04  1:01   ` Lu Baolu

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).