aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorOctavian Purdila <octavian.purdila@intel.com>2016-07-08 12:13:08 -0400
committerRafael J. Wysocki <rafael.j.wysocki@intel.com>2016-07-08 15:52:34 -0400
commit10c7e20b2ff3caa5a8c0e7d60aef5a9c86e60ce8 (patch)
tree8931f22bd95059c3872b4363314ba2bb547703ee
parent14d24c39e7f4de1bd3aa3a0379ad3c0d8129a155 (diff)
ACPI / scan: fix enumeration (visited) flags for bus rescans
If the ACPI tables change as a result of a dinamically loaded table and a bus rescan is required the enumeration/visited flag are not consistent. I2C/SPI are not directly enumerated in acpi_bus_attach(), however the visited flag is set. This makes it impossible to check if an ACPI device has already been enumerated by the I2C and SPI subsystems. To fix this issue we only set the visited flags if the device is not I2C or SPI. With this change we also need to remove setting visited to false from acpi_bus_attach(), otherwise if we rescan already enumerated I2C/SPI devices we try to re-enumerate them. Note that I2C/SPI devices can be enumerated either via a scan handler (when using PRP0001) or via regular device_attach(). In either case the flow goes through acpi_default_enumeration() which makes it the ideal place to mark the ACPI device as enumerated. Signed-off-by: Octavian Purdila <octavian.purdila@intel.com> Reviewed-by: Mika Westerberg <mika.westerberg@linux.intel.com> Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
-rw-r--r--drivers/acpi/scan.c13
-rw-r--r--include/linux/acpi.h18
2 files changed, 25 insertions, 6 deletions
diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c
index 5f28cf778349..f80f8a747294 100644
--- a/drivers/acpi/scan.c
+++ b/drivers/acpi/scan.c
@@ -1406,7 +1406,7 @@ void acpi_init_device_object(struct acpi_device *device, acpi_handle handle,
1406 acpi_bus_get_flags(device); 1406 acpi_bus_get_flags(device);
1407 device->flags.match_driver = false; 1407 device->flags.match_driver = false;
1408 device->flags.initialized = true; 1408 device->flags.initialized = true;
1409 device->flags.visited = false; 1409 acpi_device_clear_enumerated(device);
1410 device_initialize(&device->dev); 1410 device_initialize(&device->dev);
1411 dev_set_uevent_suppress(&device->dev, true); 1411 dev_set_uevent_suppress(&device->dev, true);
1412 acpi_init_coherency(device); 1412 acpi_init_coherency(device);
@@ -1683,8 +1683,10 @@ static void acpi_default_enumeration(struct acpi_device *device)
1683 acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave, 1683 acpi_dev_get_resources(device, &resource_list, acpi_check_spi_i2c_slave,
1684 &is_spi_i2c_slave); 1684 &is_spi_i2c_slave);
1685 acpi_dev_free_resource_list(&resource_list); 1685 acpi_dev_free_resource_list(&resource_list);
1686 if (!is_spi_i2c_slave) 1686 if (!is_spi_i2c_slave) {
1687 acpi_create_platform_device(device); 1687 acpi_create_platform_device(device);
1688 acpi_device_set_enumerated(device);
1689 }
1688} 1690}
1689 1691
1690static const struct acpi_device_id generic_device_ids[] = { 1692static const struct acpi_device_id generic_device_ids[] = {
@@ -1751,7 +1753,7 @@ static void acpi_bus_attach(struct acpi_device *device)
1751 acpi_bus_get_status(device); 1753 acpi_bus_get_status(device);
1752 /* Skip devices that are not present. */ 1754 /* Skip devices that are not present. */
1753 if (!acpi_device_is_present(device)) { 1755 if (!acpi_device_is_present(device)) {
1754 device->flags.visited = false; 1756 acpi_device_clear_enumerated(device);
1755 device->flags.power_manageable = 0; 1757 device->flags.power_manageable = 0;
1756 return; 1758 return;
1757 } 1759 }
@@ -1766,7 +1768,7 @@ static void acpi_bus_attach(struct acpi_device *device)
1766 1768
1767 device->flags.initialized = true; 1769 device->flags.initialized = true;
1768 } 1770 }
1769 device->flags.visited = false; 1771
1770 ret = acpi_scan_attach_handler(device); 1772 ret = acpi_scan_attach_handler(device);
1771 if (ret < 0) 1773 if (ret < 0)
1772 return; 1774 return;
@@ -1780,7 +1782,6 @@ static void acpi_bus_attach(struct acpi_device *device)
1780 if (!ret && device->pnp.type.platform_id) 1782 if (!ret && device->pnp.type.platform_id)
1781 acpi_default_enumeration(device); 1783 acpi_default_enumeration(device);
1782 } 1784 }
1783 device->flags.visited = true;
1784 1785
1785 ok: 1786 ok:
1786 list_for_each_entry(child, &device->children, node) 1787 list_for_each_entry(child, &device->children, node)
@@ -1872,7 +1873,7 @@ void acpi_bus_trim(struct acpi_device *adev)
1872 */ 1873 */
1873 acpi_device_set_power(adev, ACPI_STATE_D3_COLD); 1874 acpi_device_set_power(adev, ACPI_STATE_D3_COLD);
1874 adev->flags.initialized = false; 1875 adev->flags.initialized = false;
1875 adev->flags.visited = false; 1876 acpi_device_clear_enumerated(adev);
1876} 1877}
1877EXPORT_SYMBOL_GPL(acpi_bus_trim); 1878EXPORT_SYMBOL_GPL(acpi_bus_trim);
1878 1879
diff --git a/include/linux/acpi.h b/include/linux/acpi.h
index ef2ad26abede..db680e8788c4 100644
--- a/include/linux/acpi.h
+++ b/include/linux/acpi.h
@@ -531,6 +531,16 @@ void acpi_walk_dep_device_list(acpi_handle handle);
531struct platform_device *acpi_create_platform_device(struct acpi_device *); 531struct platform_device *acpi_create_platform_device(struct acpi_device *);
532#define ACPI_PTR(_ptr) (_ptr) 532#define ACPI_PTR(_ptr) (_ptr)
533 533
534static inline void acpi_device_set_enumerated(struct acpi_device *adev)
535{
536 adev->flags.visited = true;
537}
538
539static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
540{
541 adev->flags.visited = false;
542}
543
534#else /* !CONFIG_ACPI */ 544#else /* !CONFIG_ACPI */
535 545
536#define acpi_disabled 1 546#define acpi_disabled 1
@@ -676,6 +686,14 @@ static inline enum dev_dma_attr acpi_get_dma_attr(struct acpi_device *adev)
676 686
677#define ACPI_PTR(_ptr) (NULL) 687#define ACPI_PTR(_ptr) (NULL)
678 688
689static inline void acpi_device_set_enumerated(struct acpi_device *adev)
690{
691}
692
693static inline void acpi_device_clear_enumerated(struct acpi_device *adev)
694{
695}
696
679#endif /* !CONFIG_ACPI */ 697#endif /* !CONFIG_ACPI */
680 698
681#ifdef CONFIG_ACPI 699#ifdef CONFIG_ACPI