ACPI/IORT: Fix build error when IOMMU_SUPPORT disabled
Subsystems (3)
PATCH 1/1 ACPI/IORT: Fix build error when IOMMU_SUPPORT disabled
drivers/acpi/arm64/iort.c: In function iort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: struct iommu_fwspec has no member named flags
dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS;
^~
drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS
undeclared (first use in this function)
dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS;
^~~~~~~~~~~~~~~~~~~~~~~drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears in
--- drivers/acpi/arm64/iort.c | 2 +- include/linux/iommu.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/acpi/arm64/iort.c +1 -1
@@ -1076,7 +1076,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev) iort_pci_iommu_init, &info);if (!err &&iort_pci_rc_supports_ats (node)) - dev->iommu_fwspec->flags |=IOMMU_FWSPEC_PCI_RC_ATS ; +iommu_fwspec_set_ats_flags (dev); }else {int i =0 ;
include/linux/iommu.h +9 -0
@@ -479,6 +479,11 @@ static inline void dev_iommu_fwspec_set(struct device *dev, dev->iommu_fwspec = fwspec; } +static inline void iommu_fwspec_set_ats_flags (struct device *dev) +{ + dev->iommu_fwspec->flags |=IOMMU_FWSPEC_PCI_RC_ATS ; +} +int iommu_probe_device (struct device *dev);void iommu_release_device (struct device *dev);
@@ -770,6 +775,10 @@ static inline void iommu_fwspec_free(struct device *dev) { } +static inline void iommu_fwspec_set_ats_flags (struct device *dev) +{ +} +static inline int iommu_fwspec_add_ids (struct device *dev,u32 *ids,int num_ids) {
Signature · 1 line
2.20.1
PATCH RESEND 1/1 ACPI/IORT: Fix build error when IOMMU_SUPPORT disabled
drivers/acpi/arm64/iort.c: In function iort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: struct iommu_fwspec has no member named flags
dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS;
^~
drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS
undeclared (first use in this function)
dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS;
^~~~~~~~~~~~~~~~~~~~~~~drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears in
If IOMMU_SUPPORT not enabled, struct iommu_fwspec without members and IOMMU_FWSPEC_PCI_RC_ATS not defined, add new iommu_fwspec_set_ats_flags() to set IOMMU_FWSPEC_PCI_RC_ATS flags to solve build error.
--- drivers/acpi/arm64/iort.c | 2 +- include/linux/iommu.h | 9 +++++++++ 2 files changed, 10 insertions(+), 1 deletion(-)
drivers/acpi/arm64/iort.c +1 -1
@@ -1076,7 +1076,7 @@ const struct iommu_ops *iort_iommu_configure(struct device *dev) iort_pci_iommu_init, &info);if (!err &&iort_pci_rc_supports_ats (node)) - dev->iommu_fwspec->flags |=IOMMU_FWSPEC_PCI_RC_ATS ; +iommu_fwspec_set_ats_flags (dev); }else {int i =0 ;
include/linux/iommu.h +9 -0
@@ -479,6 +479,11 @@ static inline void dev_iommu_fwspec_set(struct device *dev, dev->iommu_fwspec = fwspec; } +static inline void iommu_fwspec_set_ats_flags (struct device *dev) +{ + dev->iommu_fwspec->flags |=IOMMU_FWSPEC_PCI_RC_ATS ; +} +int iommu_probe_device (struct device *dev);void iommu_release_device (struct device *dev);
@@ -770,6 +775,10 @@ static inline void iommu_fwspec_free(struct device *dev) { } +static inline void iommu_fwspec_set_ats_flags (struct device *dev) +{ +} +static inline int iommu_fwspec_add_ids (struct device *dev,u32 *ids,int num_ids) {
Signature · 1 line
2.20.1
Quoted 10 lines · Kefeng Wang
drivers/acpi/arm64/iort.c: In functioniort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: structiommu_fwspechas no member named flagsdev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~ drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS undeclared (first use in this function) dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears in
Quoted 8 lines
If
IOMMU_SUPPORTnot enabled, structiommu_fwspecwithout members andIOMMU_FWSPEC_PCI_RC_ATSnot defined, add newiommu_fwspec_set_ats_flags()to setIOMMU_FWSPEC_PCI_RC_ATSflags to solve build error.Cc Jean-Philippe Brucker <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Reported-by Hulk Robot <[email protected]>
What's this "Hulk Robot"? Does it report things publicly?
Anyway, I can pick this up if Lorenzo acks it.
Will
[+Joerg, Robin]
Quoted 15 lines · Will Deacon
Quoted 14 lines · Kefeng Wang
drivers/acpi/arm64/iort.c: In functioniort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: structiommu_fwspechas no member named flagsdev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~ drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS undeclared (first use in this function) dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears inIf
IOMMU_SUPPORTnot enabled, structiommu_fwspecwithout members andIOMMU_FWSPEC_PCI_RC_ATSnot defined, add newiommu_fwspec_set_ats_flags()to setIOMMU_FWSPEC_PCI_RC_ATSflags to solve build error.
Quoted 6 lines
Quoted 4 lines
Cc Jean-Philippe Brucker <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Reported-by Hulk Robot <[email protected]>What's this "Hulk Robot"? Does it report things publicly?
AFAIK it is Huawei CI system, I had some doubts about leaving that tag for other patches I dealt with, I am not sure it is really useful (other than giving Hulk some credit).
Quoted 1 line
Anyway, I can pick this up if Lorenzo acks it.
Actually I think we should compile out iort_iommu_configure() for !IOMMU_SUPPORT unless I am missing something, so that we are removing this source of errors.
If that does not cut it, for this patch:
iommu_fwspec_set_ats_flags() should be iommu_fwspec_set_ats_flag()
The commit log should be fixed (it is pretty weird to start with the build error and then explain it):
"If IOMMU_SUPPORT is not enabled, struct iommu_fwspec is an empty struct and IOMMU_FWSPEC_PCI_RC_ATS is not defined, resulting in the following build error:
drivers/acpi/arm64/iort.c: In function iort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: struct iommu_fwspec has no member named flags
dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS;
^~
drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS
undeclared (first use in this function)
dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS;
^~~~~~~~~~~~~~~~~~~~~~~drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears in
Add a iommu_fwspec_set_ats_flag() helper function (that is an empty stub on !IOMMU_SUPPORT) to fix it."
Robin Murphy
reviewerQuoted 29 lines · Lorenzo Pieralisi
[+Joerg, Robin]
Quoted 15 lines · Will Deacon
Quoted 14 lines · Kefeng Wang
drivers/acpi/arm64/iort.c: In functioniort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: structiommu_fwspechas no member named flagsdev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~ drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS undeclared (first use in this function) dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears inIf
IOMMU_SUPPORTnot enabled, structiommu_fwspecwithout members andIOMMU_FWSPEC_PCI_RC_ATSnot defined, add newiommu_fwspec_set_ats_flags()to setIOMMU_FWSPEC_PCI_RC_ATSflags to solve build error.Quoted 6 lines
Quoted 4 lines
Cc Jean-Philippe Brucker <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Reported-by Hulk Robot <[email protected]>What's this "Hulk Robot"? Does it report things publicly?
AFAIK it is Huawei CI system, I had some doubts about leaving that tag for other patches I dealt with, I am not sure it is really useful (other than giving Hulk some credit).
Quoted 5 lines
Quoted 1 line
Anyway, I can pick this up if Lorenzo acks it.
Actually I think we should compile out
iort_iommu_configure()for !IOMMU_SUPPORT unless I am missing something, so that we are removing this source of errors.
Indeed, much as I like the compile coverage of not having things #ifdefed out in general, this particular case seems like a fairly atypical configuration so I'm not sure all the extra fluff of struct accessors is really worth it.
Robin.
Quoted 24 lines
If that does not cut it, for this patch:
iommu_fwspec_set_ats_flags()should beiommu_fwspec_set_ats_flag()The commit log should be fixed (it is pretty weird to start with the build error and then explain it):
"If
IOMMU_SUPPORTis not enabled, structiommu_fwspecis an empty struct andIOMMU_FWSPEC_PCI_RC_ATSis not defined, resulting in the following build error:
drivers/acpi/arm64/iort.c: In functioniort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: structiommu_fwspechas no member named flagsdev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~ drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS undeclared (first use in this function) dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears inAdd a
iommu_fwspec_set_ats_flag()helper function (that is an empty stub on !IOMMU_SUPPORT) to fix it."
Quoted 32 lines · Robin Murphy
Quoted 31 lines · Lorenzo Pieralisi
[+Joerg, Robin]
Quoted 15 lines · Will Deacon
Quoted 14 lines · Kefeng Wang
drivers/acpi/arm64/iort.c: In functioniort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: structiommu_fwspechas no member named flagsdev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~ drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS undeclared (first use in this function) dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears inIf
IOMMU_SUPPORTnot enabled, structiommu_fwspecwithout members andIOMMU_FWSPEC_PCI_RC_ATSnot defined, add newiommu_fwspec_set_ats_flags()to setIOMMU_FWSPEC_PCI_RC_ATSflags to solve build error.Quoted 6 lines
Quoted 4 lines
Cc Jean-Philippe Brucker <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Reported-by Hulk Robot <[email protected]>What's this "Hulk Robot"? Does it report things publicly?
AFAIK it is Huawei CI system, I had some doubts about leaving that tag for other patches I dealt with, I am not sure it is really useful (other than giving Hulk some credit).
Quoted 1 line
Anyway, I can pick this up if Lorenzo acks it.
Quoted 8 lines
Quoted 3 lines
Actually I think we should compile out
iort_iommu_configure()for !IOMMU_SUPPORT unless I am missing something, so that we are removing this source of errors.Indeed, much as I like the compile coverage of not having things #ifdefed out in general, this particular case seems like a fairly atypical configuration so I'm not sure all the extra fluff of struct accessors is really worth it.
Ok, I will send a patch shortly to address this issue, if Kefeng does not object I will drop the CI bot as reporter and add him instead.
Thanks,
Lorenzo
Quoted 27 lines
Robin.
Quoted 24 lines
If that does not cut it, for this patch:
iommu_fwspec_set_ats_flags()should beiommu_fwspec_set_ats_flag()The commit log should be fixed (it is pretty weird to start with the build error and then explain it):
"If
IOMMU_SUPPORTis not enabled, structiommu_fwspecis an empty struct andIOMMU_FWSPEC_PCI_RC_ATSis not defined, resulting in the following build error:
drivers/acpi/arm64/iort.c: In functioniort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: structiommu_fwspechas no member named flagsdev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~ drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS undeclared (first use in this function) dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears inAdd a
iommu_fwspec_set_ats_flag()helper function (that is an empty stub on !IOMMU_SUPPORT) to fix it."
Quoted 20 lines · Lorenzo Pieralisi
Quoted 19 lines · Robin Murphy
Quoted 18 lines · Lorenzo Pieralisi
[+Joerg, Robin]
Quoted 15 lines · Will Deacon
Quoted 14 lines · Kefeng Wang
drivers/acpi/arm64/iort.c: In functioniort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: structiommu_fwspechas no member named flagsdev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~ drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS undeclared (first use in this function) dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears inIf
IOMMU_SUPPORTnot enabled, structiommu_fwspecwithout members andIOMMU_FWSPEC_PCI_RC_ATSnot defined, add newiommu_fwspec_set_ats_flags()to setIOMMU_FWSPEC_PCI_RC_ATSflags to solve build error.
Quoted 8 lines
Quoted 8 lines
Quoted 8 lines
Quoted 5 lines
Quoted 4 lines
Cc Jean-Philippe Brucker <[email protected]>Cc Lorenzo Pieralisi <[email protected]>Cc Will Deacon <[email protected]>Reported-by Hulk Robot <[email protected]>What's this "Hulk Robot"? Does it report things publicly?
AFAIK it is Huawei CI system, I had some doubts about leaving that tag for other patches I dealt with, I am not sure it is really useful (other than giving Hulk some credit).
As Lorenzo said, it is Huawei CI system to improve the robustness of
our inner Linux kernel version, we also use it to test the latest Linux kernel.
The system is still being developed, and still need to enhance and improve.
Quoted 9 lines
Quoted 9 lines
Quoted 5 lines
Quoted 2 lines
Anyway, I can pick this up if Lorenzo acks it.
Actually I think we should compile out
iort_iommu_configure()for !IOMMU_SUPPORT unless I am missing something, so that we are removing this source of errors.Indeed, much as I like the compile coverage of not having things #ifdefed out in general, this particular case seems like a fairly atypical configuration so I'm not sure all the extra fluff of struct accessors is really worth it.
This is founded by randconfig built, it seems that no one use this kind of configuration
Quoted 3 lines
Ok, I will send a patch shortly to address this issue, if Kefeng does not object I will drop the CI bot as reporter and add him instead.
Either way is ok, thanks.
Quoted 27 lines
Thanks,
LorenzoQuoted 23 lines
Robin.
Quoted 21 lines
If that does not cut it, for this patch:
iommu_fwspec_set_ats_flags()should beiommu_fwspec_set_ats_flag()The commit log should be fixed (it is pretty weird to start with the build error and then explain it):
"If
IOMMU_SUPPORTis not enabled, structiommu_fwspecis an empty struct andIOMMU_FWSPEC_PCI_RC_ATSis not defined, resulting in the following build error:
drivers/acpi/arm64/iort.c: In functioniort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: structiommu_fwspechas no member named flagsdev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~ drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS undeclared (first use in this function) dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS; ^~~~~~~~~~~~~~~~~~~~~~~
drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears in
Quoted 5 lines
Quoted 3 lines
Quoted 3 lines
Add a
iommu_fwspec_set_ats_flag()helper function (that is an empty stub on !IOMMU_SUPPORT) to fix it.".
_______________________________________________
linux-arm-kernel mailing list
[email protected]
http://lists.infradead.org/mailman/listinfo/linux-arm-kernel
PATCH v2 1/1 ACPI/IORT: Fix build error when IOMMU_SUPPORT is disabled
In reply to Kefeng WangIf IOMMU_SUPPORT is not enabled (and therefore IOMMU_API is not selected), struct iommu_fwspec is an empty struct and IOMMU_FWSPEC_PCI_RC_ATS is not defined, resulting in the following compilation errors:
drivers/acpi/arm64/iort.c: In function iort_iommu_configure:drivers/acpi/arm64/iort.c:1079:21: error: struct iommu_fwspec has no member named flag:
dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS;
^~
drivers/acpi/arm64/iort.c:1079:32: error: IOMMU_FWSPEC_PCI_RC_ATS
undeclared (first use in this function)
dev->iommu_fwspec->flags |= IOMMU_FWSPEC_PCI_RC_ATS;
^~~~~~~~~~~~~~~~~~~~~~~drivers/acpi/arm64/iort.c:1079:32: note: each undeclared identifier is reported only once for each function it appears in
Move iort_iommu_configure() (and the helpers functions it relies on) into CONFIG_IOMMU_API preprocessor guarded code so that when CONFIG_IOMMU_SUPPORT is not enabled we prevent compiling code that is basically equivalent to no-OP, fixing the build errors.
--- drivers/acpi/arm64/iort.c | 238 +++++++++++++++++++------------------- 1 file changed, 120 insertions(+), 118 deletions(-)
drivers/acpi/arm64/iort.c +120 -118
@@ -753,31 +753,6 @@ static int __maybe_unused __get_pci_rid(struct pci_dev *pdev, u16 alias,return 0 ; } -static int arm_smmu_iort_xlate (struct device *dev,u32 streamid, -struct fwnode_handle *fwnode, -const struct iommu_ops *ops) -{ -int ret =iommu_fwspec_init (dev, fwnode, ops); - -if (!ret) - ret =iommu_fwspec_add_ids (dev, &streamid,1 ); - -return ret; -} - -static inline bool iort_iommu_driver_enabled (u8 type) -{ -switch (type) { -case ACPI_IORT_NODE_SMMU_V3 : -return IS_BUILTIN (CONFIG_ARM_SMMU_V3 ); -case ACPI_IORT_NODE_SMMU : -return IS_BUILTIN (CONFIG_ARM_SMMU ); -default : -pr_warn ("IORT node type %u does not describe an SMMU\n" , type); -return false; - } -} -#ifdef CONFIG_IOMMU_API static struct acpi_iort_node *iort_get_msi_resv_iommu (struct device *dev) {
@@ -878,15 +853,39 @@ int iort_iommu_msi_get_resv_regions(struct device *dev, struct list_head *head)return (resv == its->its_count) ? resv : -ENODEV ; } -#else -static inline const struct iommu_ops *iort_fwspec_iommu_ops (struct device *dev) -{return NULL ; } -static inline int iort_add_device_replay (const struct iommu_ops *ops, -struct device *dev) -{return 0 ; } -int iort_iommu_msi_get_resv_regions (struct device *dev,struct list_head *head) -{return 0 ; } -#endif + +static inline bool iort_iommu_driver_enabled (u8 type) +{ +switch (type) { +case ACPI_IORT_NODE_SMMU_V3 : +return IS_BUILTIN (CONFIG_ARM_SMMU_V3 ); +case ACPI_IORT_NODE_SMMU : +return IS_BUILTIN (CONFIG_ARM_SMMU ); +default : +pr_warn ("IORT node type %u does not describe an SMMU\n" , type); +return false; + } +} + +static int arm_smmu_iort_xlate (struct device *dev,u32 streamid, +struct fwnode_handle *fwnode, +const struct iommu_ops *ops) +{ +int ret =iommu_fwspec_init (dev, fwnode, ops); + +if (!ret) + ret =iommu_fwspec_add_ids (dev, &streamid,1 ); + +return ret; +} + +static bool iort_pci_rc_supports_ats (struct acpi_iort_node *node) +{ +struct acpi_iort_root_complex *pci_rc; + + pci_rc = (struct acpi_iort_root_complex *)node->node_data; +return pci_rc->ats_attribute &ACPI_IORT_ATS_SUPPORTED ; +}static int iort_iommu_xlate (struct device *dev,struct acpi_iort_node *node,u32 streamid)
@@ -933,6 +932,93 @@ static int iort_pci_iommu_init(struct pci_dev *pdev, u16 alias, void *data) return iort_iommu_xlate(info->dev, parent, streamid); } +/** +* iort_iommu_configure - Set-up IOMMU configuration for a device. +* +* @dev: device to configure +* +* Returns: iommu_ops pointer on configuration success +* NULL on configuration failure +*/ +const struct iommu_ops *iort_iommu_configure (struct device *dev) +{ +struct acpi_iort_node *node, *parent; +const struct iommu_ops *ops; +u32 streamid =0 ; +int err = -ENODEV ; + +/* +* If we already translated the fwspec there +* is nothing left to do, return the iommu_ops. +*/ + ops =iort_fwspec_iommu_ops (dev); +if (ops) +return ops; + +if (dev_is_pci (dev)) { +struct pci_bus *bus =to_pci_dev (dev)->bus; +struct iort_pci_alias_info info = { .dev = dev }; + + node =iort_scan_node (ACPI_IORT_NODE_PCI_ROOT_COMPLEX , + iort_match_node_callback, &bus->dev); +if (!node) +return NULL ; + + info.node = node; + err =pci_for_each_dma_alias (to_pci_dev (dev), + iort_pci_iommu_init, &info); + +if (!err &&iort_pci_rc_supports_ats (node)) + dev->iommu_fwspec->flags |=IOMMU_FWSPEC_PCI_RC_ATS ; + }else { +int i =0 ; + + node =iort_scan_node (ACPI_IORT_NODE_NAMED_COMPONENT , + iort_match_node_callback, dev); +if (!node) +return NULL ; + +do { + parent =iort_node_map_platform_id (node, &streamid, +IORT_IOMMU_TYPE , + i++); + +if (parent) + err =iort_iommu_xlate (dev, parent, streamid); + }while (parent && !err); + } + +/* +* If we have reason to believe the IOMMU driver missed the initial +* add_device callback for dev, replay it to get things in order. +*/ +if (!err) { + ops =iort_fwspec_iommu_ops (dev); + err =iort_add_device_replay (ops, dev); + } + +/* Ignore all other errors apart from EPROBE_DEFER */ +if (err == -EPROBE_DEFER ) { + ops =ERR_PTR (err); + }else if (err) { +dev_dbg (dev,"Adding to IOMMU failed: %d\n" , err); + ops =NULL ; + } + +return ops; +} +#else +static inline const struct iommu_ops *iort_fwspec_iommu_ops (struct device *dev) +{return NULL ; } +static inline int iort_add_device_replay (const struct iommu_ops *ops, +struct device *dev) +{return 0 ; } +int iort_iommu_msi_get_resv_regions (struct device *dev,struct list_head *head) +{return 0 ; } +const struct iommu_ops *iort_iommu_configure (struct device *dev) +{return NULL ; } +#endif +static int nc_dma_get_range (struct device *dev,u64 *size) {struct acpi_iort_node *node;
@@ -1031,90 +1117,6 @@ void iort_dma_setup(struct device *dev, u64 *dma_addr, u64 *dma_size)dev_dbg (dev,"dma_pfn_offset(%#08llx)\n" , offset); } -static bool iort_pci_rc_supports_ats (struct acpi_iort_node *node) -{ -struct acpi_iort_root_complex *pci_rc; - - pci_rc = (struct acpi_iort_root_complex *)node->node_data; -return pci_rc->ats_attribute &ACPI_IORT_ATS_SUPPORTED ; -} - -/** -* iort_iommu_configure - Set-up IOMMU configuration for a device. -* -* @dev: device to configure -* -* Returns: iommu_ops pointer on configuration success -* NULL on configuration failure -*/ -const struct iommu_ops *iort_iommu_configure (struct device *dev) -{ -struct acpi_iort_node *node, *parent; -const struct iommu_ops *ops; -u32 streamid =0 ; -int err = -ENODEV ; - -/* -* If we already translated the fwspec there -* is nothing left to do, return the iommu_ops. -*/ - ops =iort_fwspec_iommu_ops (dev); -if (ops) -return ops; - -if (dev_is_pci (dev)) { -struct pci_bus *bus =to_pci_dev (dev)->bus; -struct iort_pci_alias_info info = { .dev = dev }; - - node =iort_scan_node (ACPI_IORT_NODE_PCI_ROOT_COMPLEX , - iort_match_node_callback, &bus->dev); -if (!node) -return NULL ; - - info.node = node; - err =pci_for_each_dma_alias (to_pci_dev (dev), - iort_pci_iommu_init, &info); - -if (!err &&iort_pci_rc_supports_ats (node)) - dev->iommu_fwspec->flags |=IOMMU_FWSPEC_PCI_RC_ATS ; - }else { -int i =0 ; - - node =iort_scan_node (ACPI_IORT_NODE_NAMED_COMPONENT , - iort_match_node_callback, dev); -if (!node) -return NULL ; - -do { - parent =iort_node_map_platform_id (node, &streamid, -IORT_IOMMU_TYPE , - i++); - -if (parent) - err =iort_iommu_xlate (dev, parent, streamid); - }while (parent && !err); - } - -/* -* If we have reason to believe the IOMMU driver missed the initial -* add_device callback for dev, replay it to get things in order. -*/ -if (!err) { - ops =iort_fwspec_iommu_ops (dev); - err =iort_add_device_replay (ops, dev); - } - -/* Ignore all other errors apart from EPROBE_DEFER */ -if (err == -EPROBE_DEFER ) { - ops =ERR_PTR (err); - }else if (err) { -dev_dbg (dev,"Adding to IOMMU failed: %d\n" , err); - ops =NULL ; - } - -return ops; -} -static void __init acpi_iort_register_irq (int hwirq,const char *name,int trigger,struct resource *res)
Signature · 1 line
2.21.0