mirror of
https://github.com/BobTheBlinker/android_kernel_motorola_sm6375.git
synced 2026-10-28 18:51:56 -04:00
Hisilicon fixes for v5.3-rc
- Fixed RCU usage in logical PIO - Added a function to unregister a logical PIO range in logical PIO to support the fixes in the hisi-lpc driver - Fixed and optimized hisi-lpc driver to avoid potential use-after-free and driver unbind crash -----BEGIN PGP SIGNATURE----- Version: GnuPG v1 iQIcBAABAgAGBQJdVhtCAAoJEAvIV27ZiWZcP80P/0XIMAV5pFFXDuMNUciNg07v 6E0GZbbEViY07D4XvwUcZx/b2nJzHi66H9kVTZ757QfsEiAQEyviG8NlYinwDUmD yOxdgg3g8BtNieahqEwUjewW7NwyERbrCNIhUYGsr2wC+4D0Fycj03mUgfKaziwv HWF3b7kXOGbZiUE4N/UogKzYsG+Pm8k+h33wjiagXctiZvu4w/FRhGcpS2fu0AZ3 Oetp+2HPRwHM+eBQW8fLNlV9yV1tAODFKzVMv+JGHWpx+XJgzUwFSI1s/Q2ioN3k vEiXrmSaR1XT52yEe8qviV4NCD0XEtWeVmIMa8ZplsbmRzshTUcRPYO4nOJBiB6j tffPXv40AXI0vUwQnZ21NLbt+pfNWbxdMQV8rQWtmD4WmCg+7W11ARMCOA0eppAu GU8NXrNUO6+LU/w0snOLByEY+x3X9Vst5X0yIvS1uooEqtDK6RFGVy/KLAnWmPk5 GracF2utVudo0SnzANywWmvI1xML1n7tgknunUpE8tbmogHiaNAJvI6xExh6aQqh bkBN5LBFWVHtGyCJbGGemC7ddADjaxjFxiErW4zayAlTWUs9EQNYTRfoV7oBEKff Zb1XiT3vfhYYje5FRZvV5pvuskWceQd9Pi5JsYm57NEcW2SAGe653ADMWIfsjOxe /eM48ilxlGbP2SYxSmoL =BnY2 -----END PGP SIGNATURE----- Merge tag 'hisi-fixes-for-5.3' of git://github.com/hisilicon/linux-hisi into arm/fixes Hisilicon fixes for v5.3-rc - Fixed RCU usage in logical PIO - Added a function to unregister a logical PIO range in logical PIO to support the fixes in the hisi-lpc driver - Fixed and optimized hisi-lpc driver to avoid potential use-after-free and driver unbind crash * tag 'hisi-fixes-for-5.3' of git://github.com/hisilicon/linux-hisi: bus: hisi_lpc: Add .remove method to avoid driver unbind crash bus: hisi_lpc: Unregister logical PIO range to avoid potential use-after-free lib: logic_pio: Add logic_pio_unregister_range() lib: logic_pio: Avoid possible overlap for unregistering regions lib: logic_pio: Fix RCU usage Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Arnd Bergmann <[email protected]>
This commit is contained in:
commit
34614c30bf
3 changed files with 96 additions and 25 deletions
|
|
@ -456,6 +456,17 @@ struct hisi_lpc_acpi_cell {
|
|||
size_t pdata_size;
|
||||
};
|
||||
|
||||
static void hisi_lpc_acpi_remove(struct device *hostdev)
|
||||
{
|
||||
struct acpi_device *adev = ACPI_COMPANION(hostdev);
|
||||
struct acpi_device *child;
|
||||
|
||||
device_for_each_child(hostdev, NULL, hisi_lpc_acpi_remove_subdev);
|
||||
|
||||
list_for_each_entry(child, &adev->children, node)
|
||||
acpi_device_clear_enumerated(child);
|
||||
}
|
||||
|
||||
/*
|
||||
* hisi_lpc_acpi_probe - probe children for ACPI FW
|
||||
* @hostdev: LPC host device pointer
|
||||
|
|
@ -555,8 +566,7 @@ static int hisi_lpc_acpi_probe(struct device *hostdev)
|
|||
return 0;
|
||||
|
||||
fail:
|
||||
device_for_each_child(hostdev, NULL,
|
||||
hisi_lpc_acpi_remove_subdev);
|
||||
hisi_lpc_acpi_remove(hostdev);
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
@ -569,6 +579,10 @@ static int hisi_lpc_acpi_probe(struct device *dev)
|
|||
{
|
||||
return -ENODEV;
|
||||
}
|
||||
|
||||
static void hisi_lpc_acpi_remove(struct device *hostdev)
|
||||
{
|
||||
}
|
||||
#endif // CONFIG_ACPI
|
||||
|
||||
/*
|
||||
|
|
@ -606,24 +620,27 @@ static int hisi_lpc_probe(struct platform_device *pdev)
|
|||
range->fwnode = dev->fwnode;
|
||||
range->flags = LOGIC_PIO_INDIRECT;
|
||||
range->size = PIO_INDIRECT_SIZE;
|
||||
range->hostdata = lpcdev;
|
||||
range->ops = &hisi_lpc_ops;
|
||||
lpcdev->io_host = range;
|
||||
|
||||
ret = logic_pio_register_range(range);
|
||||
if (ret) {
|
||||
dev_err(dev, "register IO range failed (%d)!\n", ret);
|
||||
return ret;
|
||||
}
|
||||
lpcdev->io_host = range;
|
||||
|
||||
/* register the LPC host PIO resources */
|
||||
if (acpi_device)
|
||||
ret = hisi_lpc_acpi_probe(dev);
|
||||
else
|
||||
ret = of_platform_populate(dev->of_node, NULL, NULL, dev);
|
||||
if (ret)
|
||||
if (ret) {
|
||||
logic_pio_unregister_range(range);
|
||||
return ret;
|
||||
}
|
||||
|
||||
lpcdev->io_host->hostdata = lpcdev;
|
||||
lpcdev->io_host->ops = &hisi_lpc_ops;
|
||||
dev_set_drvdata(dev, lpcdev);
|
||||
|
||||
io_end = lpcdev->io_host->io_start + lpcdev->io_host->size;
|
||||
dev_info(dev, "registered range [%pa - %pa]\n",
|
||||
|
|
@ -632,6 +649,23 @@ static int hisi_lpc_probe(struct platform_device *pdev)
|
|||
return ret;
|
||||
}
|
||||
|
||||
static int hisi_lpc_remove(struct platform_device *pdev)
|
||||
{
|
||||
struct device *dev = &pdev->dev;
|
||||
struct acpi_device *acpi_device = ACPI_COMPANION(dev);
|
||||
struct hisi_lpc_dev *lpcdev = dev_get_drvdata(dev);
|
||||
struct logic_pio_hwaddr *range = lpcdev->io_host;
|
||||
|
||||
if (acpi_device)
|
||||
hisi_lpc_acpi_remove(dev);
|
||||
else
|
||||
of_platform_depopulate(dev);
|
||||
|
||||
logic_pio_unregister_range(range);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct of_device_id hisi_lpc_of_match[] = {
|
||||
{ .compatible = "hisilicon,hip06-lpc", },
|
||||
{ .compatible = "hisilicon,hip07-lpc", },
|
||||
|
|
@ -645,5 +679,6 @@ static struct platform_driver hisi_lpc_driver = {
|
|||
.acpi_match_table = ACPI_PTR(hisi_lpc_acpi_match),
|
||||
},
|
||||
.probe = hisi_lpc_probe,
|
||||
.remove = hisi_lpc_remove,
|
||||
};
|
||||
builtin_platform_driver(hisi_lpc_driver);
|
||||
|
|
|
|||
Loading…
Reference in a new issue