Create a common function to get the SMMU sid
Now the PCI drivers have a common interface to read the IOMMU xref and SID create a common function to read it. This fixes an issue where we will call into an ACPI specific function when booting with FDT when both are enabled. Sponsored by: Arm Ltd Differential Revision: https://reviews.freebsd.org/D39183
This commit is contained in:
parent
913d04deed
commit
49ee1a7ef0
@ -1799,34 +1799,8 @@ smmu_set_buswide(device_t dev, struct smmu_domain *domain,
|
||||
return (0);
|
||||
}
|
||||
|
||||
#ifdef DEV_ACPI
|
||||
static int
|
||||
smmu_pci_get_sid_acpi(device_t child, u_int *xref0, u_int *sid0)
|
||||
{
|
||||
uint16_t rid;
|
||||
u_int xref;
|
||||
int seg;
|
||||
int err;
|
||||
int sid;
|
||||
|
||||
seg = pci_get_domain(child);
|
||||
rid = pci_get_rid(child);
|
||||
|
||||
err = acpi_iort_map_pci_smmuv3(seg, rid, &xref, &sid);
|
||||
if (err == 0) {
|
||||
if (sid0)
|
||||
*sid0 = sid;
|
||||
if (xref0)
|
||||
*xref0 = xref;
|
||||
}
|
||||
|
||||
return (err);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef FDT
|
||||
static int
|
||||
smmu_pci_get_sid_fdt(device_t child, u_int *xref0, u_int *sid0)
|
||||
smmu_pci_get_sid(device_t child, u_int *xref0, u_int *sid0)
|
||||
{
|
||||
struct pci_id_ofw_iommu pi;
|
||||
int err;
|
||||
@ -1841,7 +1815,6 @@ smmu_pci_get_sid_fdt(device_t child, u_int *xref0, u_int *sid0)
|
||||
|
||||
return (err);
|
||||
}
|
||||
#endif
|
||||
|
||||
static struct iommu_ctx *
|
||||
smmu_ctx_alloc(device_t dev, struct iommu_domain *iodom, device_t child,
|
||||
@ -1885,11 +1858,7 @@ smmu_ctx_init(device_t dev, struct iommu_ctx *ioctx)
|
||||
|
||||
pci_class = devclass_find("pci");
|
||||
if (device_get_devclass(device_get_parent(ctx->dev)) == pci_class) {
|
||||
#ifdef DEV_ACPI
|
||||
err = smmu_pci_get_sid_acpi(ctx->dev, NULL, &sid);
|
||||
#else
|
||||
err = smmu_pci_get_sid_fdt(ctx->dev, NULL, &sid);
|
||||
#endif
|
||||
err = smmu_pci_get_sid(ctx->dev, NULL, &sid);
|
||||
if (err)
|
||||
return (err);
|
||||
|
||||
@ -2000,11 +1969,7 @@ smmu_find(device_t dev, device_t child)
|
||||
|
||||
sc = device_get_softc(dev);
|
||||
|
||||
#ifdef DEV_ACPI
|
||||
err = smmu_pci_get_sid_acpi(child, &xref, NULL);
|
||||
#else
|
||||
err = smmu_pci_get_sid_fdt(child, &xref, NULL);
|
||||
#endif
|
||||
err = smmu_pci_get_sid(child, &xref, NULL);
|
||||
if (err)
|
||||
return (ENOENT);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user