net: hns3: add IOMMU_SUPPORT dependency
Subsystems (3)
PATCH 1/1 net: hns3: add IOMMU_SUPPORT dependency
From: Arnd Bergmann <[email protected]>
The hns3 driver started filling iommu_iotlb_gather structures itself, which requires CONFIG_IOMMU_SUPPORT is enabled:
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c: In function 'hns3_dma_map_sync':drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:395:14: error: 'struct iommu_iotlb_gather' has no member named 'start'
395 | iotlb_gather.start = iova;
| ^drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:396:14: error: 'struct iommu_iotlb_gather' has no member named 'end'
396 | iotlb_gather.end = iova + granule - 1;
| ^drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:397:14: error: 'struct iommu_iotlb_gather' has no member named 'pgsize'
397 | iotlb_gather.pgsize = granule;
| ^
Add a Kconfig dependency to make it build in random configurations.
---
I noticed that no other driver does this, so it would be good to have a confirmation from the iommu maintainers that this is how the interface and the dependency is intended to be used.
--- drivers/net/ethernet/hisilicon/Kconfig | 1 + 1 file changed, 1 insertion(+)
drivers/net/ethernet/hisilicon/Kconfig +1 -0
@@ -91,6 +91,7 @@ config HNS_ENET config HNS3 tristate "Hisilicon Network Subsystem Support HNS3 (Framework)" depends on PCI + depends on IOMMU_SUPPORT select NET_DEVLINK select PAGE_POOL help
Signature · 1 line
2.39.5
Quoted 24 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The hns3 driver started filling
iommu_iotlb_gatherstructures itself, which requiresCONFIG_IOMMU_SUPPORTis enabled:
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c: In function 'hns3_dma_map_sync':drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:395:14: error: 'structiommu_iotlb_gather' has no member named 'start'
395 | iotlb_gather.start = iova;
| ^drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:396:14: error: 'structiommu_iotlb_gather' has no member named 'end'
396 | iotlb_gather.end = iova + granule - 1;
| ^drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:397:14: error: 'structiommu_iotlb_gather' has no member named 'pgsize'
397 | iotlb_gather.pgsize = granule;
| ^Add a
Kconfigdependency to make it build in random configurations.Cc Will Deacon <[email protected]>Cc Joerg Roedel <[email protected]>Cc Robin Murphy <[email protected]>Fixes f2c14899caba ("net: hns3: add sync command to sync io-pgtable")Signed-off-by Arnd Bergmann <[email protected]>
Quoted 4 lines
---
I noticed that no other driver does this, so it would be good to have a confirmation from the iommu maintainers that this is how the interface and the dependency is intended to be used.
WTF is that patch doing!? No, random device drivers should absolutely not be poking into IOMMU driver internals, this is egregiously wrong and the correct action is to drop it entirely.
Thanks,
Robin.
Quoted 16 lines
--- drivers/net/ethernet/hisilicon/Kconfig | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/hisilicon/Kconfig +1
-0@@ -91,6 +91,7 @@ config HNS_ENET config HNS3 tristate "Hisilicon Network Subsystem Support HNS3 (Framework)" depends on PCI + depends on IOMMU_SUPPORT select NET_DEVLINK select PAGE_POOL help
HI Robin,
Quoted 48 lines
From: Robin Murphy <[email protected]>
Sent: Monday, November 4, 2024 10:29 AM
To: Arnd Bergmann <[email protected]>; shenjian (K) <[email protected]>; Salil Mehta <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Will Deacon <[email protected]>; Joerg Roedel <[email protected]>; [email protected]; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>; Eric Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; shaojijie <[email protected]>; wangpeiyang <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] [net-next] net: hns3: addIOMMU_SUPPORTdependencyQuoted 6 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The hns3 driver started filling
iommu_iotlb_gatherstructures itself, which requiresCONFIG_IOMMU_SUPPORTis enabled:
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c: In function'
hns3_dma_map_sync':Quoted 1 line
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:395:14: error: 'struct
iommu_iotlb_gather' has no member named 'start'Quoted 3 lines
395 | iotlb_gather.start = iova; | ^
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:396:14: error: 'struct
iommu_iotlb_gather' has no member named 'end'Quoted 3 lines
396 | iotlb_gather.end = iova + granule - 1; | ^
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:397:14: error: 'struct
iommu_iotlb_gather' has no member named 'pgsize'Quoted 11 lines
397 | iotlb_gather.pgsize = granule; | ^Add a
Kconfigdependency to make it build in random configurations.Cc Will Deacon <[email protected]>Cc Joerg Roedel <[email protected]>Cc Robin Murphy <[email protected]>Fixes f2c14899caba ("net: hns3: add sync command to sync io-pgtable")Signed-off-by Arnd Bergmann <[email protected]>Quoted 4 lines
---
I noticed that no other driver does this, so it would be good to have a confirmation from the iommu maintainers that this is how the interface and the dependency is intended to be used.
Quoted 3 lines
WTF is that patch doing!? No, random device drivers should absolutely not be poking into IOMMU driver internals, this is egregiously wrong and the correct action is to drop it entirely.
Absolutely agree with it. Sorry I haven't been in touch for quite some time. Let me catch the whole story. Feel free to drop this patch.
Thanks
Salil.
Quoted 22 lines
Thanks,
Robin.Quoted 17 lines
--- drivers/net/ethernet/hisilicon/Kconfig | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/hisilicon/Kconfig +1
-0@@ -91,6 +91,7 @@ config HNS_ENET config HNS3 tristate "Hisilicon Network Subsystem Support HNS3 (Framework)" depends on PCI + depends on IOMMU_SUPPORT select NET_DEVLINK select PAGE_POOL help
Quoted 54 lines
From: Salil Mehta <[email protected]>
Sent: Monday, November 4, 2024 10:41 AM
To: Robin Murphy <[email protected]>; Arnd Bergmann <[email protected]>; shenjian (K) <[email protected]>HI Robin,
Quoted 7 lines
From: Robin Murphy <[email protected]>
Sent: Monday, November 4, 2024 10:29 AM
To: Arnd Bergmann <[email protected]>; shenjian (K)
<[email protected]>; Salil Mehta <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Will Deacon <[email protected]>;
Joerg Roedel <[email protected]>; [email protected]; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>;Eric
Quoted 39 lines
Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; shaojijie <[email protected]>; wangpeiyang <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] [net-next] net: hns3: addIOMMU_SUPPORT
dependencyQuoted 1 line · Arnd Bergmann
From: Arnd Bergmann <[email protected]> > > The hns3 driver started
filling
iommu_iotlb_gatherstructures itself, > which requiresCONFIG_IOMMU_SUPPORTis enabled:Quoted 2 lines
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c: In function'
hns3_dma_map_sync':Quoted 1 line
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:395:14: error:'struct
iommu_iotlb_gather' has no member named 'start'Quoted 3 lines
395 | iotlb_gather.start = iova; | ^
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:396:14: error:'struct
iommu_iotlb_gather' has no member named 'end'Quoted 3 lines
396 | iotlb_gather.end = iova + granule - 1; | ^
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:397:14: error:'struct
iommu_iotlb_gather' has no member named 'pgsize'Quoted 8 lines
397 | iotlb_gather.pgsize = granule; | ^Add a
Kconfigdependency to make it build in random configurations.Cc Will Deacon <[email protected]>Cc Joerg Roedel <[email protected]>Cc Robin Murphy <[email protected]> > Cc:[email protected] > Fixes:
f2c14899caba("net: hns3: add sync command to sync io-pgtable") > Signed-off-by: Arnd Bergmann <[email protected]> > --- > I noticed that no other driver does this, so it would be good to have > a confirmation from the iommu maintainers that this is how the > interface and the dependency is intended to be used.
Quoted 7 lines
Quoted 3 lines
WTF is that patch doing!? No, random device drivers should absolutely
not be poking into IOMMU driver internals, this is egregiously wrong and the correct action is to drop it entirely.Absolutely agree with it. Sorry I haven't been in touch for quite some time. Let me catch the whole story. Feel free to drop this patch.
Just to make it clear I meant the culprit patch:
https://lore.kernel.org/netdev/[email protected]/
Quoted 26 lines
Thanks
Salil.Quoted 22 lines
Thanks,
Robin.drivers/net/ethernet/hisilicon/Kconfig
Quoted 7 lines
--- drivers/net/ethernet/hisilicon/Kconfig | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/hisilicon/Kconfig +0
-0a/drivers/net/ethernet/hisilicon/Kconfig
Quoted 9 lines
+++ b/drivers/net/ethernet/hisilicon/Kconfig
drivers/net/ethernet/hisilicon/Kconfig +1
-0@@ -91,6 +91,7 @@ config HNS_ENET config HNS3 tristate "Hisilicon Network Subsystem Support HNS3 (Framework)" depends on PCI + depends on IOMMU_SUPPORT select NET_DEVLINK select PAGE_POOL help
Quoted 30 lines · Robin Murphy
Quoted 24 lines · Arnd Bergmann
From: Arnd Bergmann <[email protected]>
The hns3 driver started filling
iommu_iotlb_gatherstructures itself, which requiresCONFIG_IOMMU_SUPPORTis enabled:
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c: In function 'hns3_dma_map_sync':drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:395:14: error: 'structiommu_iotlb_gather' has no member named 'start'
395 | iotlb_gather.start = iova;
| ^drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:396:14: error: 'structiommu_iotlb_gather' has no member named 'end'
396 | iotlb_gather.end = iova + granule - 1;
| ^drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:397:14: error: 'structiommu_iotlb_gather' has no member named 'pgsize'
397 | iotlb_gather.pgsize = granule;
| ^Add a
Kconfigdependency to make it build in random configurations.Cc Will Deacon <[email protected]>Cc Joerg Roedel <[email protected]>Cc Robin Murphy <[email protected]>Fixes f2c14899caba ("net: hns3: add sync command to sync io-pgtable")Signed-off-by Arnd Bergmann <[email protected]>Quoted 4 lines
---
I noticed that no other driver does this, so it would be good to have a confirmation from the iommu maintainers that this is how the interface and the dependency is intended to be used.
Quoted 3 lines
WTF is that patch doing!? No, random device drivers should absolutely not be poking into IOMMU driver internals, this is egregiously wrong and the correct action is to drop it entirely.
+1. Device drivers shouldn't poke into IOMMU internals.
Quoted 3 lines
Thanks,
Robin.
I see that the requirement in [1] is to somehow flush / sync the iotlb right after dma mapping an address as a work around for a HW bug, right?
I'd like to point out that the dma_map* API take care of this if the underlying iommu implements the iotlb_sync_map op (check iommu_map).
Thus, in case you require it and your iommu driver does NOT support iotlb_sync_map, the right way would be to add this functionality to *that* iommu driver instead of letting the device driver poke into IOMMU
Another thing worth noting is, we do have some quirks to address broken hardware in the iommu drivers. For example, a broken pre-fetch command for hisilicon HI161x in arm-smmu-v3 driver[2]. Such options can be added to iommu drivers after discussion with the relevant stakeholders.
Thanks,
Praan
[1]
https://lore.kernel.org/netdev/[email protected]/
[2]
https://elixir.bootlin.com/linux/v6.11.6/source/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c#L81
Quoted 19 lines
Quoted 17 lines
--- drivers/net/ethernet/hisilicon/Kconfig | 1 + 1 file changed, 1 insertion(+)drivers/net/ethernet/hisilicon/Kconfig +1
-0@@ -91,6 +91,7 @@ config HNS_ENET config HNS3 tristate "Hisilicon Network Subsystem Support HNS3 (Framework)" depends on PCI + depends on IOMMU_SUPPORT select NET_DEVLINK select PAGE_POOL help
Quoted 59 lines · Salil Mehta
Quoted 59 lines
From: Salil Mehta <[email protected]>
Sent: Monday, November 4, 2024 10:41 AM
To: Robin Murphy <[email protected]>; Arnd Bergmann <[email protected]>; shenjian (K) <[email protected]>HI Robin,
Quoted 7 lines
From: Robin Murphy <[email protected]>
Sent: Monday, November 4, 2024 10:29 AM
To: Arnd Bergmann <[email protected]>; shenjian (K)
<[email protected]>; Salil Mehta <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Will Deacon <[email protected]>;
Joerg Roedel <[email protected]>; [email protected]; Andrew Lunn <[email protected]>; David S. Miller <[email protected]>;Eric
Quoted 42 lines
Dumazet <[email protected]>; Jakub Kicinski <[email protected]>; Paolo Abeni <[email protected]>; shaojijie <[email protected]>; wangpeiyang <[email protected]>; [email protected]; [email protected]
Subject: Re: [PATCH] [net-next] net: hns3: addIOMMU_SUPPORT
dependencyQuoted 1 line · Arnd Bergmann
From: Arnd Bergmann <[email protected]> > > The hns3 driver started
filling
iommu_iotlb_gatherstructures itself, > which requiresCONFIG_IOMMU_SUPPORTis enabled:Quoted 2 lines
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c: In function'
hns3_dma_map_sync':Quoted 1 line
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:395:14: error:'struct
iommu_iotlb_gather' has no member named 'start'Quoted 3 lines
395 | iotlb_gather.start = iova; | ^
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:396:14: error:'struct
iommu_iotlb_gather' has no member named 'end'Quoted 3 lines
396 | iotlb_gather.end = iova + granule - 1; | ^
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:397:14: error:'struct
iommu_iotlb_gather' has no member named 'pgsize'Quoted 8 lines
397 | iotlb_gather.pgsize = granule; | ^Add a
Kconfigdependency to make it build in random configurations.Cc Will Deacon <[email protected]>Cc Joerg Roedel <[email protected]>Cc Robin Murphy <[email protected]> > Cc:[email protected] > Fixes:
f2c14899caba("net: hns3: add sync command to sync io-pgtable") > Signed-off-by: Arnd Bergmann <[email protected]> > --- > I noticed that no other driver does this, so it would be good to have > a confirmation from the iommu maintainers that this is how the > interface and the dependency is intended to be used.WTF is that patch doing!? No, random device drivers should absolutely
not be poking into IOMMU driver internals, this is egregiously wrong and the correct action is to drop it entirely.
Quoted 6 lines
Quoted 2 lines
Absolutely agree with it. Sorry I haven't been in touch for quite some time. Let me catch the whole story. Feel free to drop this patch.
Just to make it clear I meant the culprit patch:
https://lore.kernel.org/netdev/[email protected]/
Right, if the HIP09 SMMU has a bug which requires an iommu_domain_ops::iotlb_sync_map workaround, then the SMMU driver should detect the HIP09 SMMU and implement that workaround for it. HNS3 trying to reach in to the SMMU driver's data and open-code iotlb_sync_map on its behalf is just as plain illogical as it is unacceptable.
Thanks,
Robin.
Jakub Kicinski
maintainerQuoted 3 lines · On Mon, 4 Nov 2024 10:29:28 +0000 Robin Murphy wrote:
WTF is that patch doing!? No, random device drivers should absolutely not be poking into IOMMU driver internals, this is egregiously wrong and the correct action is to drop it entirely.
Sorry, reverted in
https://git.kernel.org/pub/scm/linux/kernel/git/netdev/net.git/commit/?id=249cfa318fb1b77eb726c2ff4f74c9685f04e568
Hi Robin,
Sorry for the late reply. I was on a leave yesterday.
Quoted 82 lines
From: Robin Murphy <[email protected]>
Sent: Monday, November 4, 2024 4:35 PM
To: Salil Mehta <[email protected]>; Arnd Bergmann <[email protected]>; shenjian (K) <[email protected]>Quoted 5 lines · Salil Mehta
Quoted 5 lines
From: Salil Mehta <[email protected]>
Sent: Monday, November 4, 2024 10:41 AM
To: Robin Murphy <[email protected]>; Arnd Bergmann <[email protected]>; shenjian (K) <[email protected]>Quoted 7 lines
Quoted 7 lines
HI Robin,
Quoted 5 lines
From: Robin Murphy <[email protected]>
Sent: Monday, November 4, 2024 10:29 AM
To: Arnd Bergmann <[email protected]>; shenjian (K)
<[email protected]>; Salil Mehta <[email protected]>
Cc: Arnd Bergmann <[email protected]>; Will DeaconQuoted 1 line
Quoted 1 line
Quoted 1 line
Joerg Roedel <[email protected]>; [email protected]; Andrew
Lunn
Quoted 1 line
Quoted 1 line
Quoted 1 line
<[email protected]>; David S. Miller
Quoted 2 lines
Quoted 2 lines
Eric
Quoted 1 line
Dumazet <[email protected]>; Jakub Kicinski
Quoted 1 line
Quoted 1 line
Quoted 1 line
Paolo Abeni <[email protected]>; shaojijie
Quoted 1 line
Quoted 1 line
Quoted 1 line
wangpeiyang <[email protected]>;
Quoted 6 lines
Quoted 6 lines
Quoted 6 lines
[email protected]
Subject: Re: [PATCH] [net-next] net: hns3: addIOMMU_SUPPORT
dependencyQuoted 1 line · Arnd Bergmann
From: Arnd Bergmann <[email protected]> > > The hns3 driver
started
Quoted 18 lines
Quoted 18 lines
Quoted 18 lines
filling
iommu_iotlb_gatherstructures itself, > which requiresCONFIG_IOMMU_SUPPORTis enabled:Quoted 2 lines
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c: In function'
hns3_dma_map_sync':Quoted 1 line
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:395:14: error:'struct
iommu_iotlb_gather' has no member named 'start'Quoted 3 lines
395 | iotlb_gather.start = iova; | ^
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:396:14: error:'struct
iommu_iotlb_gather' has no member named 'end'Quoted 3 lines
396 | iotlb_gather.end = iova + granule - 1; | ^
drivers/net/ethernet/hisilicon/hns3/hns3_enet.c:397:14: error:'struct
iommu_iotlb_gather' has no member named 'pgsize'Quoted 3 lines
397 | iotlb_gather.pgsize = granule; | ^Quoted 1 line
Quoted 1 line
Quoted 1 line
Quoted 1 line
Add a
Kconfigdependency to make it build in randomconfigurations.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 4 lines
Cc Will Deacon <[email protected]>Cc Joerg Roedel <[email protected]>Cc Robin Murphy <[email protected]> > Cc:[email protected] > Fixes:
f2c14899caba("net: hns3: add sync command to sync io-pgtable") > Signed-off-by: Arnd Bergmann <[email protected]> > --- > I noticed that no other driver does this, so it would be good to have > a confirmation from the iommumaintainers
Quoted 4 lines
Quoted 4 lines
Quoted 4 lines
that this is how the > interface and the dependency is intended to be used.
WTF is that patch doing!? No, random device drivers should
absolutely
Quoted 5 lines
Quoted 5 lines
Quoted 2 lines
not be poking into IOMMU driver internals, this is egregiously wrong and the correct action is to drop it entirely.
Absolutely agree with it. Sorry I haven't been in touch for quite some
time.
Quoted 5 lines
Quoted 1 line
Let me catch the whole story. Feel free to drop this patch.
Just to make it clear I meant the culprit patch:
https://lore.kernel.org/netdev/20241025092938.2912958-3-
Quoted 8 lines
shaojijie@huaw
Quoted 1 line
ei.com/
Right, if the HIP09 SMMU has a bug which requires an
iommu_domain_ops::iotlb_sync_mapworkaround, then the SMMU driver should detect the HIP09 SMMU and implement that workaround for it. HNS3 trying to reach in to the SMMU driver's data and open-codeiotlb_sync_mapon its behalf is just as plain illogical as it is unacceptable.
Totally agree with that. It breaks the design of the kernel fundamentally. This was a mistake and on Monday I've requested the stakeholders to address it exactly in the realms of what you have suggested above.
Rest assured, we will address that in the correct way. Sorry, if this caused any inconvenience to anymore including the MAINTAINER of netdev I would have caught this much earlier had I been following the ML closely but unfortunately I've not been in touch for long.
Thanks for the nudge though 😊
Cheers
Salil.
Quoted 3 lines
Thanks,
Robin.