Skip to contentSkip to conversation

iommu: intel: don't dereference iommu_device if IOMMU_API is not built

PATCH Applied Bartosz Golaszewski 4 participants 8 messages Oct 13, 2020 – Oct 19, 2020

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 iommu: intel: don't dereference iommu_device if IOMMU_API is not built

From: Bartosz Golaszewski <[email protected]>

Since commit c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths") dmar.c needs struct iommu_device to be selected. We can drop this dependency by not dereferencing struct iommu_device if IOMMU_API is not selected and by reusing the information stored in iommu->drhd->ignored instead.

This fixes the following build error when IOMMU_API is not selected:

drivers/iommu/intel/dmar.c: In function ‘free_iommu’:
drivers/iommu/intel/dmar.c:1139:41: error: ‘struct iommu_device’ has no member named ‘ops’

 1139 |  if (intel_iommu_enabled && iommu->iommu.ops) {
                                                ^
Fixes c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths")
---
 drivers/iommu/intel/dmar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel/dmar.c +1 -1
index 2d70d56d8e0d..404b40af31cb 100644
@@ -1136,7 +1136,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
 
 static void free_iommu(struct intel_iommu *iommu)
 {
-	if (intel_iommu_enabled && iommu->iommu.ops) {
+	if (intel_iommu_enabled && !iommu->drhd->ignored) {
 		iommu_device_unregister(&iommu->iommu);
 		iommu_device_sysfs_remove(&iommu->iommu);
 	}
Signature · 1 line
2.28.0
maintainer Acked-by on v1 1/1
#1 lore raw
Quoted 10 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Since commit c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths") dmar.c needs struct iommu_device to be selected. We can drop this dependency by not dereferencing struct iommu_device if IOMMU_API is not selected and by reusing the information stored in iommu->drhd->ignored instead.

This fixes the following build error when IOMMU_API is not selected:

Quoted 7 lines

drivers/iommu/intel/dmar.c: In function ‘free_iommu’:
drivers/iommu/intel/dmar.c:1139:41: error: ‘struct iommu_device’ has no member named ‘ops’

 1139 |  if (intel_iommu_enabled && iommu->iommu.ops) {
                                                ^
Fixes c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths")

Oops, apologies for that. Thanks for fixing it.

_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

maintainer Acked-by on v1 1/1
#2 lore raw
In reply to Bartosz Golaszewski
Quoted 10 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Since commit c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths") dmar.c needs struct iommu_device to be selected. We can drop this dependency by not dereferencing struct iommu_device if IOMMU_API is not selected and by reusing the information stored in iommu->drhd->ignored instead.

This fixes the following build error when IOMMU_API is not selected:

Quoted 7 lines

drivers/iommu/intel/dmar.c: In function ‘free_iommu’:
drivers/iommu/intel/dmar.c:1139:41: error: ‘struct iommu_device’ has no member named ‘ops’

  1139 |  if (intel_iommu_enabled && iommu->iommu.ops) {
                                                 ^
Fixes c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths")

With commit title adjusted to "iommu/vt-d: Don't dereference iommu_device if IOMMU_API is not built",

Best regards,
baolu

Quoted 18 lines
---
  drivers/iommu/intel/dmar.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
drivers/iommu/intel/dmar.c +1 -1
index 2d70d56d8e0d..404b40af31cb 100644
@@ -1136,7 +1136,7 @@ static int alloc_iommu(struct dmar_drhd_unit *drhd)
 
  static void free_iommu(struct intel_iommu *iommu)
  {
-	if (intel_iommu_enabled && iommu->iommu.ops) {
+	if (intel_iommu_enabled && !iommu->drhd->ignored) {
  		iommu_device_unregister(&iommu->iommu);
  		iommu_device_sysfs_remove(&iommu->iommu);
  	}
#3 lore raw
Quoted 17 lines · Lu Baolu
Quoted 15 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Since commit c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths") dmar.c needs struct iommu_device to be selected. We can drop this dependency by not dereferencing struct iommu_device if IOMMU_API is not selected and by reusing the information stored in iommu->drhd->ignored instead.

This fixes the following build error when IOMMU_API is not selected:

drivers/iommu/intel/dmar.c: In function ‘free_iommu’:
drivers/iommu/intel/dmar.c:1139:41: error: ‘struct iommu_device’ has no member named ‘ops’

  1139 |  if (intel_iommu_enabled && iommu->iommu.ops) {
                                                 ^
Quoted 8 lines
Quoted 2 lines
Fixes c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths")

With commit title adjusted to "iommu/vt-d: Don't dereference iommu_device if IOMMU_API is not built",

Do you want me to resend it again with a changed title or can you fix it up when applying? Or should someone else pick it up?

Bartosz
_______________________________________________
iommu mailing list
[email protected]
https://lists.linuxfoundation.org/mailman/listinfo/iommu

maintainer
#4 lore raw

Hi Bartosz,

Quoted 21 lines · Bartosz Golaszewski
Quoted 20 lines · Lu Baolu
Quoted 17 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Since commit c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths") dmar.c needs struct iommu_device to be selected. We can drop this dependency by not dereferencing struct iommu_device if IOMMU_API is not selected and by reusing the information stored in iommu->drhd->ignored instead.

This fixes the following build error when IOMMU_API is not selected:

drivers/iommu/intel/dmar.c: In function ‘free_iommu’:
drivers/iommu/intel/dmar.c:1139:41: error: ‘struct iommu_device’ has no member named ‘ops’

   1139 |  if (intel_iommu_enabled && iommu->iommu.ops) {
                                                  ^
Fixes c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths")
Quoted 8 lines
Quoted 5 lines

With commit title adjusted to "iommu/vt-d: Don't dereference iommu_device if IOMMU_API is not built",

Do you want me to resend it again with a changed title or can you fix it up when applying? Or should someone else pick it up?

I suppose Joerg will pick this up. I guess you don't need to resend it unless Joerg asks you to do.

Best regards,
baolu

maintainer
#5 lore raw
Quoted 2 lines · Lu Baolu

I suppose Joerg will pick this up. I guess you don't need to resend it unless Joerg asks you to do.

Yes, will pick this up soon, no need to re-send.

Thanks,

Joerg

maintainer Applied
#7 lore raw
In reply to Bartosz Golaszewski
Quoted 12 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

Since commit c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths") dmar.c needs struct iommu_device to be selected. We can drop this dependency by not dereferencing struct iommu_device if IOMMU_API is not selected and by reusing the information stored in iommu->drhd->ignored instead.

This fixes the following build error when IOMMU_API is not selected:

drivers/iommu/intel/dmar.c: In function ‘free_iommu’:
drivers/iommu/intel/dmar.c:1139:41: error: ‘struct iommu_device’ has no member named ‘ops’

Quoted 8 lines
 1139 |  if (intel_iommu_enabled && iommu->iommu.ops) {
                                                ^
Fixes c40aaaac1018 ("iommu/vt-d: Gracefully handle DMAR units with no supported address widths")
---
 drivers/iommu/intel/dmar.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Applied, thanks.