From patchwork Thu Jul 4 08:58:44 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mika Westerberg X-Patchwork-Id: 2822461 X-Patchwork-Delegate: bhelgaas@google.com Return-Path: X-Original-To: patchwork-linux-pci@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork1.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.19.201]) by patchwork1.web.kernel.org (Postfix) with ESMTP id D45319F3C3 for ; Thu, 4 Jul 2013 08:54:31 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 84B6D2010A for ; Thu, 4 Jul 2013 08:54:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 6184E200CF for ; Thu, 4 Jul 2013 08:54:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S933686Ab3GDIxq (ORCPT ); Thu, 4 Jul 2013 04:53:46 -0400 Received: from mga14.intel.com ([143.182.124.37]:19969 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S933661Ab3GDIxj (ORCPT ); Thu, 4 Jul 2013 04:53:39 -0400 Received: from azsmga002.ch.intel.com ([10.2.17.35]) by azsmga102.ch.intel.com with ESMTP; 04 Jul 2013 01:53:20 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="4.87,993,1363158000"; d="scan'208";a="264010180" Received: from lahna.fi.intel.com ([10.237.72.166]) by AZSMGA002.ch.intel.com with ESMTP; 04 Jul 2013 01:53:15 -0700 Received: from westeri by lahna.fi.intel.com with local (Exim 4.77) (envelope-from ) id 1UufNF-0005YD-ED; Thu, 04 Jul 2013 11:58:45 +0300 Date: Thu, 4 Jul 2013 11:58:44 +0300 From: Mika Westerberg To: "Rafael J. Wysocki" Cc: Greg Kroah-Hartman , Bjorn Helgaas , "Rafael J. Wysocki" , Jesse Barnes , Yinghai Lu , john.ronciak@intel.com, miles.j.penner@intel.com, bruce.w.allan@intel.com, Heikki Krogerus , "Kirill A. Shutemov" , linux-kernel@vger.kernel.org, linux-acpi@vger.kernel.org, linux-pci@vger.kernel.org, x86@kernel.org Subject: Re: [PATCH v2 6/8] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5 Message-ID: <20130704085844.GF4898@intel.com> References: <1372860295-8306-1-git-send-email-mika.westerberg@linux.intel.com> <1372860295-8306-7-git-send-email-mika.westerberg@linux.intel.com> <1444243.g9GbxN3NM0@vostro.rjw.lan> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <1444243.g9GbxN3NM0@vostro.rjw.lan> Organization: Intel Finland Oy - BIC 0357606-4 - Westendinkatu 7, 02160 Espoo User-Agent: Mutt/1.5.21 (2010-09-15) Sender: linux-pci-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-pci@vger.kernel.org X-Spam-Status: No, score=-7.1 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 On Wed, Jul 03, 2013 at 11:40:42PM +0200, Rafael J. Wysocki wrote: > On Wednesday, July 03, 2013 05:04:53 PM Mika Westerberg wrote: > > From: "Kirill A. Shutemov" > > > > Correct ACPI PCI hotplug imeplementation should have _RMV method in a > > PCI slot (device under pci bridge). In Acer Aspire S5 case we have it > > deeper in hierarchy: > > > > Device (RP05) > > { > > // ... > > Device (HRUP) > > { > > // ... > > Device (HRDN) > > { > > // ... > > Device (EPUP) > > { > > // ... > > Method (_RMV, 0, NotSerialized) // _RMV: Removal Status > > { > > Return (One) > > } > > } > > } > > } > > } > > > > Signed-off-by: Kirill A. Shutemov > > Signed-off-by: Mika Westerberg > > --- > > drivers/pci/hotplug/acpi_pcihp.c | 13 +++++++++++++ > > 1 file changed, 13 insertions(+) > > > > diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c > > index 2a47e82..d92ebfb 100644 > > --- a/drivers/pci/hotplug/acpi_pcihp.c > > +++ b/drivers/pci/hotplug/acpi_pcihp.c > > @@ -422,6 +422,19 @@ static int pcihp_is_ejectable(acpi_handle handle) > > status = acpi_evaluate_integer(handle, "_RMV", NULL, &removable); > > if (ACPI_SUCCESS(status) && removable) > > return 1; > > + > > + /* > > + * Workaround for Thunderbolt implementation on Acer Aspire S5. > > + * > > + * Correct ACPI PCI hotplug imeplementation has _RMV method in a PCI > > + * slot (device under pci bridge). In Acer Aspire S5 case we have it > > + * deeper in hierarchy. > > + */ > > + status = acpi_evaluate_integer(handle, "HRDN.EPUP._RMV", NULL, > > + &removable); > > Well, calling stuff like this directly from a general function is kind of ugly. > > Can we use something like a quirk instead? A DMI check or something? Sure we can. How about something like the patch below? From: Mika Westerberg Subject: [PATCH] PCI: acpiphp: workaround for Thunderbolt on Acer Aspire S5 The acpiphp driver finds out whether the device is removable by checking whether it has _RMV method directly behind it (and if it returns 1). However, at least on Acer Aspire S5 with Thunderbolt host router has this method placed behind a device called EPUP (endpoint upstream port?) and not in the usual place expected by the acpiphp driver. The ASL code below shows how this is done on that machine: Device (RP05) { ... Device (HRUP) { Name (_ADR, Zero) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (HRDN) { Name (_ADR, 0x00040000) Name (_PRW, Package (0x02) { 0x09, 0x04 }) Device (EPUP) { Name (_ADR, Zero) Method (_RMV, 0, NotSerialized) { Return (One) } } } } ... Fix this by adding a DMI quirk for the Acer Aspire S5 machine that gives an alternative path to the _RMV method. Signed-off-by: Kirill A. Shutemov Signed-off-by: Mika Westerberg --- drivers/pci/hotplug/acpi_pcihp.c | 57 ++++++++++++++++++++++++++++++++++++---- 1 file changed, 52 insertions(+), 5 deletions(-) diff --git a/drivers/pci/hotplug/acpi_pcihp.c b/drivers/pci/hotplug/acpi_pcihp.c index 2a47e82..99fccf3 100644 --- a/drivers/pci/hotplug/acpi_pcihp.c +++ b/drivers/pci/hotplug/acpi_pcihp.c @@ -33,6 +33,7 @@ #include #include #include +#include #define MY_NAME "acpi_pcihp" @@ -408,21 +409,67 @@ got_one: } EXPORT_SYMBOL(acpi_get_hp_hw_control_from_firmware); +/** + * pcihp_is_removable - is the given ACPI device removable + * @handle: ACPI handle of the device + * + * Try to find out whether the given ACPI device is removable by evaluating + * its _RMV and returning the result. If we can't find the _RMV directly + * under the device use system specific quirks to locate it. + */ +static bool pcihp_is_removable(acpi_handle handle) +{ + static const struct dmi_system_id rmv_paths[] = { + { + /* + * On Acer Aspire S5 the _RMV method for the + * Thunderbolt host router upstream port is not + * located directly under the device but it is + * instead placed a bit deeper in the hierarchy. + */ + .ident = "Acer Aspire S5", + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "Acer"), + DMI_MATCH(DMI_PRODUCT_NAME, "Aspire S5-391"), + }, + .driver_data = "HRDN.EPUP._RMV", + }, + { } + }; + const struct dmi_system_id *id; + unsigned long long removable; + acpi_status status; + + status = acpi_evaluate_integer(handle, "_RMV", NULL, &removable); + if (ACPI_SUCCESS(status)) + return !!removable; + + /* Try system specific quirks */ + id = dmi_first_match(rmv_paths); + if (id && id->driver_data) { + char path[64]; + + strlcpy(path, id->driver_data, sizeof(path)); + status = acpi_evaluate_integer(handle, path, NULL, &removable); + if (ACPI_SUCCESS(status)) + return !!removable; + } + + return false; +} + static int pcihp_is_ejectable(acpi_handle handle) { acpi_status status; acpi_handle tmp; - unsigned long long removable; + status = acpi_get_handle(handle, "_ADR", &tmp); if (ACPI_FAILURE(status)) return 0; status = acpi_get_handle(handle, "_EJ0", &tmp); if (ACPI_SUCCESS(status)) return 1; - status = acpi_evaluate_integer(handle, "_RMV", NULL, &removable); - if (ACPI_SUCCESS(status) && removable) - return 1; - return 0; + return pcihp_is_removable(handle); } /**