Commit 12e27b11 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki

ACPI / ia64 / sba_iommu: Restore the working initialization ordering

Commit 66345d5f (ACPI / ia64 / sba_iommu: Use ACPI scan handler
for device discovery) changed the ordering of SBA (System Bus Adapter)
IOMMU initialization with respect to the PCI host bridge initialization
which broke things inadvertently, because the SBA IOMMU initialization
code has to run after the PCI host bridge has been initialized.

Fix that by reworking the SBA IOMMU ACPI scan handler so that it
claims the discovered matching ACPI device objects without attempting
to initialize anything and move the entire SBA IOMMU initialization
to sba_init() that runs after the PCI bus has been enumerated.

Link: https://bugzilla.kernel.org/show_bug.cgi?id=76691
Fixes: 66345d5f (ACPI / ia64 / sba_iommu: Use ACPI scan handler for device discovery)
Reported-and-tested-by: default avatarÉmeric Maschino <emeric.maschino@gmail.com>
Cc: Tony Luck <tony.luck@intel.com>
Cc: 3.11+ <stable@vger.kernel.org> # 3.11+
Signed-off-by: default avatarRafael J. Wysocki <rafael.j.wysocki@intel.com>
parent 7171511e
...@@ -242,7 +242,7 @@ struct ioc { ...@@ -242,7 +242,7 @@ struct ioc {
struct pci_dev *sac_only_dev; struct pci_dev *sac_only_dev;
}; };
static struct ioc *ioc_list; static struct ioc *ioc_list, *ioc_found;
static int reserve_sba_gart = 1; static int reserve_sba_gart = 1;
static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t); static SBA_INLINE void sba_mark_invalid(struct ioc *, dma_addr_t, size_t);
...@@ -1809,20 +1809,13 @@ static struct ioc_iommu ioc_iommu_info[] __initdata = { ...@@ -1809,20 +1809,13 @@ static struct ioc_iommu ioc_iommu_info[] __initdata = {
{ SX2000_IOC_ID, "sx2000", NULL }, { SX2000_IOC_ID, "sx2000", NULL },
}; };
static struct ioc * static void ioc_init(unsigned long hpa, struct ioc *ioc)
ioc_init(unsigned long hpa, void *handle)
{ {
struct ioc *ioc;
struct ioc_iommu *info; struct ioc_iommu *info;
ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
if (!ioc)
return NULL;
ioc->next = ioc_list; ioc->next = ioc_list;
ioc_list = ioc; ioc_list = ioc;
ioc->handle = handle;
ioc->ioc_hpa = ioremap(hpa, 0x1000); ioc->ioc_hpa = ioremap(hpa, 0x1000);
ioc->func_id = READ_REG(ioc->ioc_hpa + IOC_FUNC_ID); ioc->func_id = READ_REG(ioc->ioc_hpa + IOC_FUNC_ID);
...@@ -1863,8 +1856,6 @@ ioc_init(unsigned long hpa, void *handle) ...@@ -1863,8 +1856,6 @@ ioc_init(unsigned long hpa, void *handle)
"%s %d.%d HPA 0x%lx IOVA space %dMb at 0x%lx\n", "%s %d.%d HPA 0x%lx IOVA space %dMb at 0x%lx\n",
ioc->name, (ioc->rev >> 4) & 0xF, ioc->rev & 0xF, ioc->name, (ioc->rev >> 4) & 0xF, ioc->rev & 0xF,
hpa, ioc->iov_size >> 20, ioc->ibase); hpa, ioc->iov_size >> 20, ioc->ibase);
return ioc;
} }
...@@ -2031,22 +2022,21 @@ sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle) ...@@ -2031,22 +2022,21 @@ sba_map_ioc_to_node(struct ioc *ioc, acpi_handle handle)
#endif #endif
} }
static int static void acpi_sba_ioc_add(struct ioc *ioc)
acpi_sba_ioc_add(struct acpi_device *device,
const struct acpi_device_id *not_used)
{ {
struct ioc *ioc; acpi_handle handle = ioc->handle;
acpi_status status; acpi_status status;
u64 hpa, length; u64 hpa, length;
struct acpi_device_info *adi; struct acpi_device_info *adi;
status = hp_acpi_csr_space(device->handle, &hpa, &length); ioc_found = ioc->next;
status = hp_acpi_csr_space(handle, &hpa, &length);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return 1; goto err;
status = acpi_get_object_info(device->handle, &adi); status = acpi_get_object_info(handle, &adi);
if (ACPI_FAILURE(status)) if (ACPI_FAILURE(status))
return 1; goto err;
/* /*
* For HWP0001, only SBA appears in ACPI namespace. It encloses the PCI * For HWP0001, only SBA appears in ACPI namespace. It encloses the PCI
...@@ -2067,13 +2057,13 @@ acpi_sba_ioc_add(struct acpi_device *device, ...@@ -2067,13 +2057,13 @@ acpi_sba_ioc_add(struct acpi_device *device,
if (!iovp_shift) if (!iovp_shift)
iovp_shift = 12; iovp_shift = 12;
ioc = ioc_init(hpa, device->handle); ioc_init(hpa, ioc);
if (!ioc)
return 1;
/* setup NUMA node association */ /* setup NUMA node association */
sba_map_ioc_to_node(ioc, device->handle); sba_map_ioc_to_node(ioc, handle);
return 0; return;
err:
kfree(ioc);
} }
static const struct acpi_device_id hp_ioc_iommu_device_ids[] = { static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
...@@ -2081,9 +2071,26 @@ static const struct acpi_device_id hp_ioc_iommu_device_ids[] = { ...@@ -2081,9 +2071,26 @@ static const struct acpi_device_id hp_ioc_iommu_device_ids[] = {
{"HWP0004", 0}, {"HWP0004", 0},
{"", 0}, {"", 0},
}; };
static int acpi_sba_ioc_attach(struct acpi_device *device,
const struct acpi_device_id *not_used)
{
struct ioc *ioc;
ioc = kzalloc(sizeof(*ioc), GFP_KERNEL);
if (!ioc)
return -ENOMEM;
ioc->next = ioc_found;
ioc_found = ioc;
ioc->handle = device->handle;
return 1;
}
static struct acpi_scan_handler acpi_sba_ioc_handler = { static struct acpi_scan_handler acpi_sba_ioc_handler = {
.ids = hp_ioc_iommu_device_ids, .ids = hp_ioc_iommu_device_ids,
.attach = acpi_sba_ioc_add, .attach = acpi_sba_ioc_attach,
}; };
static int __init acpi_sba_ioc_init_acpi(void) static int __init acpi_sba_ioc_init_acpi(void)
...@@ -2118,9 +2125,12 @@ sba_init(void) ...@@ -2118,9 +2125,12 @@ sba_init(void)
#endif #endif
/* /*
* ioc_list should be populated by the acpi_sba_ioc_handler's .attach() * ioc_found should be populated by the acpi_sba_ioc_handler's .attach()
* routine, but that only happens if acpi_scan_init() has already run. * routine, but that only happens if acpi_scan_init() has already run.
*/ */
while (ioc_found)
acpi_sba_ioc_add(ioc_found);
if (!ioc_list) { if (!ioc_list) {
#ifdef CONFIG_IA64_GENERIC #ifdef CONFIG_IA64_GENERIC
/* /*
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment