From patchwork Thu Jun 8 18:55:00 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Hans de Goede X-Patchwork-Id: 9776289 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 5BC286034B for ; Thu, 8 Jun 2017 18:55:08 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4E19428418 for ; Thu, 8 Jun 2017 18:55:08 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 41CDC2843F; Thu, 8 Jun 2017 18:55:08 +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=ham 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 8CFB728418 for ; Thu, 8 Jun 2017 18:55:07 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751467AbdFHSzG (ORCPT ); Thu, 8 Jun 2017 14:55:06 -0400 Received: from mx1.redhat.com ([209.132.183.28]:48294 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751448AbdFHSzG (ORCPT ); Thu, 8 Jun 2017 14:55:06 -0400 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id EA5A86686E; Thu, 8 Jun 2017 18:55:05 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mx1.redhat.com EA5A86686E Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; dmarc=none (p=none dis=none) header.from=redhat.com Authentication-Results: ext-mx01.extmail.prod.ext.phx2.redhat.com; spf=pass smtp.mailfrom=hdegoede@redhat.com DKIM-Filter: OpenDKIM Filter v2.11.0 mx1.redhat.com EA5A86686E Received: from shalem.localdomain.com (ovpn-116-86.ams2.redhat.com [10.36.116.86]) by smtp.corp.redhat.com (Postfix) with ESMTP id B5E25183F9; Thu, 8 Jun 2017 18:55:04 +0000 (UTC) From: Hans de Goede To: Adrian Hunter , Ulf Hansson Cc: Hans de Goede , linux-mmc@vger.kernel.org Subject: [PATCH v4 2/2] mmc: sdhci-acpi: Add DMI based blacklist Date: Thu, 8 Jun 2017 20:55:00 +0200 Message-Id: <20170608185500.3317-2-hdegoede@redhat.com> In-Reply-To: <20170608185500.3317-1-hdegoede@redhat.com> References: <20170608185500.3317-1-hdegoede@redhat.com> X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Greylist: Sender IP whitelisted, not delayed by milter-greylist-4.5.16 (mx1.redhat.com [10.5.110.25]); Thu, 08 Jun 2017 18:55:06 +0000 (UTC) Sender: linux-mmc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-mmc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Add a DMI based blacklist for systems where probing some sdio interfaces is harmful (e.g. causes pci-e based wifi to not work). BugLink: https://bbs.archlinux.org/viewtopic.php?id=224086 Fixes: db52d4f8a4bd ("mmc: sdhci-acpi: support 80860F14 UID 2 SDIO bus") Signed-off-by: Hans de Goede --- Changes in v2: -Adjust for changes in mmc: sdhci-acpi: Add fix_up_power_blacklist module option -Only use a single fix_up_power_dmi_blacklist for the GPDwin further testing has shown that the DMI strings are unique enough that we do not need the bios-date in there Changes in v3: -Adjust for changes to "mmc: sdhci-acpi: Add blacklist module option" Changes in v4: -Rename blacklist to dmi_probe_blacklist as it now blacklists probing, rather then calling acpi_device_fix_up_power. -Also check bios-date against known bios-dates for the GPD win, to avoid possible false positives due to the use of quite generic DMI strings -Add Fixes and BugLink tags --- drivers/mmc/host/sdhci-acpi.c | 64 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 64 insertions(+) diff --git a/drivers/mmc/host/sdhci-acpi.c b/drivers/mmc/host/sdhci-acpi.c index ecc3aefd4643..3e12a6a8ad99 100644 --- a/drivers/mmc/host/sdhci-acpi.c +++ b/drivers/mmc/host/sdhci-acpi.c @@ -36,6 +36,7 @@ #include #include #include +#include #include #include @@ -83,6 +84,11 @@ struct sdhci_acpi_host { bool use_runtime_pm; }; +struct dmi_probe_blacklist_data { + const char *hid_uid; + const char * const *bios_dates; +}; + static char *blacklist; static bool sdhci_acpi_compare_hid_uid(const char *match, const char *hid, @@ -116,6 +122,34 @@ static bool sdhci_acpi_compare_hid_uid(const char *match, const char *hid, return false; } +static const char *sdhci_acpi_get_dmi_blacklist(const struct dmi_system_id *bl) +{ + const struct dmi_system_id *dmi_id; + const struct dmi_probe_blacklist_data *bl_data; + const char *bios_date; + int i; + + dmi_id = dmi_first_match(bl); + if (!dmi_id) + return NULL; + + bl_data = dmi_id->driver_data; + + if (!bl_data->bios_dates) + return bl_data->hid_uid; + + bios_date = dmi_get_system_info(DMI_BIOS_DATE); + if (!bios_date) + return NULL; + + for (i = 0; bl_data->bios_dates[i]; i++) { + if (strcmp(bl_data->bios_dates[i], bios_date) == 0) + return bl_data->hid_uid; + } + + return NULL; +} + static inline bool sdhci_acpi_flag(struct sdhci_acpi_host *c, unsigned int flag) { return c->slot && (c->slot->flags & flag); @@ -391,6 +425,33 @@ static const struct acpi_device_id sdhci_acpi_ids[] = { }; MODULE_DEVICE_TABLE(acpi, sdhci_acpi_ids); +const struct dmi_probe_blacklist_data gpd_win_bl_data = { + .hid_uid = "80860F14:2", + .bios_dates = (const char * const []){ + "10/25/2016", "11/18/2016", "02/21/2017", NULL }, +}; + +static const struct dmi_system_id dmi_probe_blacklist[] = { + { + /* + * Match for the GPDwin which unfortunately uses somewhat + * generic dmi strings, which is why we test for 4 strings + * and a known BIOS date. + * Comparing against 29 other byt/cht boards, board_name is + * unique to the GPDwin, where as only 2 other boards have the + * same board_serial and 3 others have the same board_vendor + */ + .driver_data = (void *)&gpd_win_bl_data, + .matches = { + DMI_MATCH(DMI_BOARD_VENDOR, "AMI Corporation"), + DMI_MATCH(DMI_BOARD_NAME, "Default string"), + DMI_MATCH(DMI_BOARD_SERIAL, "Default string"), + DMI_MATCH(DMI_PRODUCT_NAME, "Default string"), + }, + }, + { } +}; + static const struct sdhci_acpi_slot *sdhci_acpi_get_slot(const char *hid, const char *uid) { @@ -427,6 +488,9 @@ static int sdhci_acpi_probe(struct platform_device *pdev) hid = acpi_device_hid(device); uid = device->pnp.unique_id; + if (!bl) + bl = sdhci_acpi_get_dmi_blacklist(dmi_probe_blacklist); + if (sdhci_acpi_compare_hid_uid(bl, hid, uid)) return -ENODEV;