From patchwork Wed Jul 3 14:04:52 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 2817601 Return-Path: X-Original-To: patchwork-linux-acpi@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 47879BF4A1 for ; Wed, 3 Jul 2013 14:08:16 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 1F6A2201D0 for ; Wed, 3 Jul 2013 14:08:15 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 5BF5D201D3 for ; Wed, 3 Jul 2013 14:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932302Ab3GCOCb (ORCPT ); Wed, 3 Jul 2013 10:02:31 -0400 Received: from mga11.intel.com ([192.55.52.93]:53044 "EHLO mga11.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932081Ab3GCOC2 (ORCPT ); Wed, 3 Jul 2013 10:02:28 -0400 Received: from fmsmga002.fm.intel.com ([10.253.24.26]) by fmsmga102.fm.intel.com with ESMTP; 03 Jul 2013 07:03:51 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,988,1363158000"; d="scan'208";a="364753090" Received: from blue.fi.intel.com ([10.237.72.156]) by fmsmga002.fm.intel.com with ESMTP; 03 Jul 2013 07:02:02 -0700 Received: by blue.fi.intel.com (Postfix, from userid 1004) id B0B12E0094; Wed, 3 Jul 2013 17:04:55 +0300 (EEST) From: Mika Westerberg To: Greg Kroah-Hartman , Bjorn Helgaas , "Rafael J. Wysocki" Cc: Jesse Barnes , Yinghai Lu , john.ronciak@intel.com, miles.j.penner@intel.com, bruce.w.allan@intel.com, Heikki Krogerus , "Kirill A. Shutemov" , Mika Westerberg , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org Subject: [PATCH v2 5/8] PCI: acpiphp: kill SLOT_ENABLED in favor of always re-enumerating the devices Date: Wed, 3 Jul 2013 17:04:52 +0300 Message-Id: <1372860295-8306-6-git-send-email-mika.westerberg@linux.intel.com> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1372860295-8306-1-git-send-email-mika.westerberg@linux.intel.com> References: <1372860295-8306-1-git-send-email-mika.westerberg@linux.intel.com> Sender: linux-acpi-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-acpi@vger.kernel.org X-Spam-Status: No, score=-6.9 required=5.0 tests=BAYES_00, RCVD_IN_DNSWL_HI, RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=unavailable version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP The acpiphp driver checks SLOT_ENABLED flag only in aciphp_enable_slot() to prevent re-enumeration of the already enabled slot. Because of that it is not possible to add new devices behind the slot later on (like it is the case with Thunderbolt devices). Now, there are two places where acpiphp_enable_slot() gets called: 1) On Bus Check event for a function (in case of a dock). 2) When userpace enables a slot by writing '1' to /sys/bus/pci/slots/*/power. In the first case it doesn't make sense to do the check because we are ought to re-enumerate the bus anyway and see if there are any new devices added farther in the hierarchy, according the the ACPI specification. The second case where userspace explicitly enables the device also doesn't need this check as we already check if the slot is powered on or off in power_on_slot() and don't do it twice. So get rid of the SLOT_ENABLED flag and always re-enumerate devices behind a slot when acpiphp_enable_slot() is called. In addition doing this allows userspace to simulate Bus Check event by writing '1' to the 'power' file under the slot. Signed-off-by: Kirill A. Shutemov Signed-off-by: Mika Westerberg --- drivers/pci/hotplug/acpiphp.h | 1 - drivers/pci/hotplug/acpiphp_glue.c | 18 +----------------- 2 files changed, 1 insertion(+), 18 deletions(-) diff --git a/drivers/pci/hotplug/acpiphp.h b/drivers/pci/hotplug/acpiphp.h index 6fdd49c..ecc61b7 100644 --- a/drivers/pci/hotplug/acpiphp.h +++ b/drivers/pci/hotplug/acpiphp.h @@ -154,7 +154,6 @@ struct acpiphp_attention_info /* slot flags */ #define SLOT_POWEREDON (0x00000001) -#define SLOT_ENABLED (0x00000002) #define SLOT_MULTIFUNCTION (0x00000004) /* function flags */ diff --git a/drivers/pci/hotplug/acpiphp_glue.c b/drivers/pci/hotplug/acpiphp_glue.c index c9ec06e..506f38f 100644 --- a/drivers/pci/hotplug/acpiphp_glue.c +++ b/drivers/pci/hotplug/acpiphp_glue.c @@ -304,7 +304,7 @@ register_slot(acpi_handle handle, u32 lvl, void *context, void **rv) if (pci_bus_read_dev_vendor_id(pbus, PCI_DEVFN(device, function), &val, 60*1000)) - slot->flags |= (SLOT_ENABLED | SLOT_POWEREDON); + slot->flags |= SLOT_POWEREDON; if (is_dock_device(handle)) { /* we don't want to call this device's _EJ0 @@ -725,18 +725,6 @@ static int __ref enable_device(struct acpiphp_slot *slot) pci_bus_add_devices(bus); - slot->flags |= SLOT_ENABLED; - list_for_each_entry(func, &slot->funcs, sibling) { - dev = pci_get_slot(bus, PCI_DEVFN(slot->device, - func->function)); - if (!dev) { - /* Do not set SLOT_ENABLED flag if some funcs - are not added. */ - slot->flags &= (~SLOT_ENABLED); - continue; - } - } - return 0; } @@ -782,8 +770,6 @@ static int disable_device(struct acpiphp_slot *slot) acpiphp_bus_trim(func->handle); } - slot->flags &= (~SLOT_ENABLED); - return 0; } @@ -1229,8 +1215,6 @@ int acpiphp_enable_slot(struct acpiphp_slot *slot) goto err_exit; if (get_slot_status(slot) == ACPI_STA_ALL) { - if (slot->flags & SLOT_ENABLED) - goto err_exit; /* configure all functions */ retval = enable_device(slot); if (retval)