From patchwork Tue Jun 14 15:17:20 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Octavian Purdila X-Patchwork-Id: 9175747 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 0B95460772 for ; Tue, 14 Jun 2016 12:19:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F06B5200F4 for ; Tue, 14 Jun 2016 12:19:51 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E4FFE24151; Tue, 14 Jun 2016 12:19:51 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=unavailable version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9DDF027E78 for ; Tue, 14 Jun 2016 12:19:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751647AbcFNMRz (ORCPT ); Tue, 14 Jun 2016 08:17:55 -0400 Received: from mga04.intel.com ([192.55.52.120]:46232 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751794AbcFNMRv (ORCPT ); Tue, 14 Jun 2016 08:17:51 -0400 Received: from orsmga003.jf.intel.com ([10.7.209.27]) by fmsmga104.fm.intel.com with ESMTP; 14 Jun 2016 05:17:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.26,470,1459839600"; d="scan'208";a="827775989" Received: from opurdila-mobl4.rb.intel.com ([10.237.104.54]) by orsmga003.jf.intel.com with ESMTP; 14 Jun 2016 05:17:47 -0700 From: Octavian Purdila To: "Rafael J . Wysocki" , Len Brown , Matt Fleming , Mark Brown , Wolfram Sang Cc: Joel Becker , linux-acpi@vger.kernel.org, linux-efi@vger.kernel.org, linux-i2c@vger.kernel.org, linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, irina.tirdea@intel.com, Octavian Purdila Subject: [PATCH v3 2/8] acpi: fix enumeration (visited) flags for bus rescans Date: Tue, 14 Jun 2016 18:17:20 +0300 Message-Id: <1465917446-14043-3-git-send-email-octavian.purdila@intel.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1465917446-14043-1-git-send-email-octavian.purdila@intel.com> References: <1465917446-14043-1-git-send-email-octavian.purdila@intel.com> Sender: linux-spi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP If the ACPI tables changes 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. Signed-off-by: Octavian Purdila --- drivers/acpi/scan.c | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/scan.c b/drivers/acpi/scan.c index 5f28cf7..7656ea4 100644 --- a/drivers/acpi/scan.c +++ b/drivers/acpi/scan.c @@ -1670,7 +1670,7 @@ static int acpi_check_spi_i2c_slave(struct acpi_resource *ares, void *data) return -1; } -static void acpi_default_enumeration(struct acpi_device *device) +static bool acpi_default_enumeration(struct acpi_device *device) { struct list_head resource_list; bool is_spi_i2c_slave = false; @@ -1685,6 +1685,7 @@ static void acpi_default_enumeration(struct acpi_device *device) acpi_dev_free_resource_list(&resource_list); if (!is_spi_i2c_slave) acpi_create_platform_device(device); + return !is_spi_i2c_slave; } static const struct acpi_device_id generic_device_ids[] = { @@ -1744,6 +1745,7 @@ static void acpi_bus_attach(struct acpi_device *device) struct acpi_device *child; acpi_handle ejd; int ret; + bool enumerated = true; if (ACPI_SUCCESS(acpi_bus_get_ejd(device->handle, &ejd))) register_dock_dependent_device(device, ejd); @@ -1766,7 +1768,7 @@ static void acpi_bus_attach(struct acpi_device *device) device->flags.initialized = true; } - device->flags.visited = false; + ret = acpi_scan_attach_handler(device); if (ret < 0) return; @@ -1778,9 +1780,10 @@ static void acpi_bus_attach(struct acpi_device *device) return; if (!ret && device->pnp.type.platform_id) - acpi_default_enumeration(device); + enumerated = acpi_default_enumeration(device); } - device->flags.visited = true; + if (enumerated) + device->flags.visited = true; ok: list_for_each_entry(child, &device->children, node)