Skip to contentSkip to conversation

HISI LPC: Don't fail probe for unrecognised child devices

PATCH In review John Garry 3 participants 4 messages Jan 3, 2019 – Feb 8, 2019 HiSilicon lpc bus driver

lore
Share & tools
lore

John Garry

author
#0 lore raw

PATCH 1/1 HISI LPC: Don't fail probe for unrecognised child devices

Currently for ACPI-based FW we fail the probe for an unrecognised child HID.

However, there is FW in the field with LPC child devices having fake HIDs, namely "IPI0002", which was an IPMI device invented to support the initial out-of-tree LPC host driver, different from the final mainline version.

To provide compatibility support for these dodgy FWs, just discard the unrecognised HIDs instead of failing the probe altogether.

drivers/bus/hisi_lpc.c +2 -3
index d5f8545..19d7b6f 100644
@@ -522,10 +522,9 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
 
 		if (!found) {
 			dev_warn(hostdev,
-				 "could not find cell for child device (%s)\n",
+				 "could not find cell for child device (%s), discarding\n",
 				 hid);
-			ret = -ENODEV;
-			goto fail;
+			continue;
 		}
 
 		pdev = platform_device_alloc(cell->name, PLATFORM_DEVID_AUTO);
Signature · 1 line
1.9.1
#1 lore raw
Quoted 19 lines · John Garry

Currently for ACPI-based FW we fail the probe for an unrecognised child HID.

However, there is FW in the field with LPC child devices having fake HIDs, namely "IPI0002", which was an IPMI device invented to support the initial out-of-tree LPC host driver, different from the final mainline version.

To provide compatibility support for these dodgy FWs, just discard the unrecognised HIDs instead of failing the probe altogether.

drivers/bus/hisi_lpc.c +0 -0
index d5f8545..19d7b6f 100644

drivers/bus/hisi_lpc.c static int hisi_lpc_acpi_probe(struct device *hostdev) · line 528

Quoted 10 lines
drivers/bus/hisi_lpc.c +2 -3
@@ -522,10 +522,9 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
 
 		if (!found) {
 			dev_warn(hostdev,
-				 "could not find cell for child device (%s)\n",
+				 "could not find cell for child device (%s), discarding\n",
 				 hid);
-			ret = -ENODEV;
-			goto fail;
+			continue;
 		}

This driver is the equivalent of a board file. Wasn't ACPI supposed to spare us from these platform device tables? It even has hardcoded clock information in it. :(

Also, we were told that there'll be expectations for users to update their ACPI tables if they're incompatible our out of date. Can that be done here as well?

-Olof

author
#2 lore raw
Quoted 21 lines · Olof Johansson
Quoted 20 lines · John Garry

Currently for ACPI-based FW we fail the probe for an unrecognised child HID.

However, there is FW in the field with LPC child devices having fake HIDs, namely "IPI0002", which was an IPMI device invented to support the initial out-of-tree LPC host driver, different from the final mainline version.

To provide compatibility support for these dodgy FWs, just discard the unrecognised HIDs instead of failing the probe altogether.

drivers/bus/hisi_lpc.c +0 -0
index d5f8545..19d7b6f 100644
@@ -522,10 +522,9 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
 
Quoted 10 lines

drivers/bus/hisi_lpc.c static int hisi_lpc_acpi_probe(struct device *hostdev) · line 528

Quoted 9 lines
drivers/bus/hisi_lpc.c +2 -3
 		if (!found) {
 			dev_warn(hostdev,
-				 "could not find cell for child device (%s)\n",
+				 "could not find cell for child device (%s), discarding\n",
 				 hid);
-			ret = -ENODEV;
-			goto fail;
+			continue;
 		}

Hi Olof,

Quoted 3 lines

This driver is the equivalent of a board file. Wasn't ACPI supposed to spare us from these platform device tables? It even has hardcoded clock information in it. :(

For sure, we should not need a look-up table like this. The background is complex. I think that if you check these thread+patches then you may get a better idea of why we require the table:

https://lkml.org/lkml/2018/4/20/278

https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/drivers/acpi/scan.c?h=v5.0-rc1&id=dfda4492322ed0a1eb9c4d4715c4b90c9af57352

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/bus/hisi_lpc.c?h=next-20190107&id=e0aa1563f8945d9b8f472426d100bed190a4308f

https://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git/commit/drivers/bus/hisi_lpc.c?h=next-20190107&id=adf3457b4ce6940885be3e5ee832c6949fba4166

To summarize:
For child devices, we use indirect-PIO method to access. In this, we need to create a new device with updated resources (see call to hisi_lpc_acpi_set_io_res() call and drivers/acpi/scan.c:acpi_is_indirect_io_slave()) for logical PIO space.

One of the child devices is a 8250-compatible UART. For ACPI, we should use the 8250 PNP driver for this device, i.e. use PNP0501. However PNP code does not support this indirect-PIO child probe. So we use the generic 8250 platform device driver instead. Hence the look-up table.

We saw this as the least disruptive method to support this legacy host controller.

As for the clock info in the driver, we're just setting some driver wait times depending on fixed clock information. So not configuring clocks or the like.

Quoted 4 lines

Also, we were told that there'll be expectations for users to update their ACPI tables if they're incompatible our out of date. Can that be done here as well?

If you're referring to this comment "To provide compatibility support for these dodgy FWs", we're saying that if the FW has IPI0001 and IPI0002 (this being invalid) child devices, then we can handle it by just discarding IPI0002.

Thanks,
John

Quoted 5 lines

-Olof

#3 lore raw
In reply to John Garry

Hi John,

Quoted 8 lines · John Garry

Currently for ACPI-based FW we fail the probe for an unrecognised child HID.

However, there is FW in the field with LPC child devices having fake HIDs, namely "IPI0002", which was an IPMI device invented to support the initial out-of-tree LPC host driver, different from the final mainline version.

Quoted 5 lines

To provide compatibility support for these dodgy FWs, just discard the unrecognised HIDs instead of failing the probe altogether.

Updated the subject as "bus: hisi_lpc: xxx" to follow the style and applied to the hisilicon tree.
Thanks!

Best Regards,
Wei

Quoted 19 lines
drivers/bus/hisi_lpc.c +2 -3
index d5f8545..19d7b6f 100644
@@ -522,10 +522,9 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
 
 		if (!found) {
 			dev_warn(hostdev,
-				 "could not find cell for child device (%s)\n",
+				 "could not find cell for child device (%s), discarding\n",
 				 hid);
-			ret = -ENODEV;
-			goto fail;
+			continue;
 		}
 
 		pdev = platform_device_alloc(cell->name, PLATFORM_DEVID_AUTO);