Received: by 2002:a25:c593:0:0:0:0:0 with SMTP id v141csp6232362ybe; Tue, 17 Sep 2019 23:27:30 -0700 (PDT) X-Google-Smtp-Source: APXvYqyQi3SwoI/fWR3hhJAWyJBpwxqIQI2On9vCOqtiYe4Gz3+UwUdSnMv971r/6e1/aI25hPHl X-Received: by 2002:a05:6402:1297:: with SMTP id w23mr8680275edv.204.1568788050472; Tue, 17 Sep 2019 23:27:30 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1568788050; cv=none; d=google.com; s=arc-20160816; b=pOn0Zf21nfNiyLCHDzxHGC1SO7uTY2ZqsPE1+kb1Aa3FgMCaIUKPyI9WvvcdVdaSmM pXfqNvrp/iwCyzmf7f12zf7s2SVuIHM26aIPzfbjj2ZwZq8Ew3EYwWzKRffuaCqbdDBQ YiKaSUB5X9Bj8EJDXIf8Oa+FKilbbKsA8iD9upb6Ghtd4mdSIgZs1DIhsnqQmeYBZwys VKVIBnFBEE6p0n/Bm3h1SAk9DdmiKub70NMD7dAFN9GhJiL1TxezKi/B573WS3hXmeV4 4AHZDT6RbXqPF5JDvjftcsuFJlsxclS+/Ky/8KCWlRODZSJddh0a7luEDFejWVwN4+uT /pdg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=7Pw85SqpbU7hAvUg97SR2/UOAXi+F6d86aytr8Wd1h8=; b=o3rxkG5fg95FsQxgEHBTH48EbF6qfpY8Sm1ZQH4PVVs2cHworaaGIReACZyaKmhHk6 XteqDhB/R0xSb+TIOBfH8A6jmTJ2VY0iuoR0Cuy6Fjhpzm3ut0DymL7c5j+Km7u77wvM q77iZawJn6vhZjQ2LyX4uSElop8GfzPPuRj0PMvUqKLpkCsOBpiVxBMyNI5tkybm9CeT RnX3kXMcZpl2vTxoBreYi40hnc07Bj0VWyY2ewFT5+xMNZ5OpVgpvy6n5+nA4Znh8+8h AAajrvlmJJr4i5oz4eZ5YJ2Cmnyynh0sfIWjxcGcA5h8NhOW9sYAXlb7tShPRiYCYshq avrQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vx6dXzeR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id k9si2760774edb.56.2019.09.17.23.27.07; Tue, 17 Sep 2019 23:27:30 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vx6dXzeR; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729394AbfIRGWW (ORCPT + 99 others); Wed, 18 Sep 2019 02:22:22 -0400 Received: from mail.kernel.org ([198.145.29.99]:42202 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729370AbfIRGWU (ORCPT ); Wed, 18 Sep 2019 02:22:20 -0400 Received: from localhost (83-86-89-107.cable.dynamic.v4.ziggo.nl [83.86.89.107]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 7400F21906; Wed, 18 Sep 2019 06:22:18 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1568787739; bh=nohuGyc7hfdYqZ6sL9+EviD0Dgpon4dbSK9zLX7rpCI=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Vx6dXzeR1sr9h/iSLkL9JvRUhaztOWWFGkuEk+u84DsdWm/G7C/CZ0Elu678kVuaM i3Ne0kv4344/ByThFtxbFM/ssk6UL1vNB1P9EbcsIR/xUR7dOmLiB7hAlanC2V6fo1 XtDm+7un/Bq+xVsACfnUD/grSeQsFSd8jUj19vhE= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Daniel Drake , Ian W MORRISON , Hans de Goede , Mika Westerberg , Andy Shevchenko , Linus Walleij Subject: [PATCH 4.19 16/50] gpiolib: acpi: Add gpiolib_acpi_run_edge_events_on_boot option and blacklist Date: Wed, 18 Sep 2019 08:18:59 +0200 Message-Id: <20190918061224.680169319@linuxfoundation.org> X-Mailer: git-send-email 2.23.0 In-Reply-To: <20190918061223.116178343@linuxfoundation.org> References: <20190918061223.116178343@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Hans de Goede commit 61f7f7c8f978b1c0d80e43c83b7d110ca0496eb4 upstream. Another day; another DSDT bug we need to workaround... Since commit ca876c7483b6 ("gpiolib-acpi: make sure we trigger edge events at least once on boot") we call _AEI edge handlers at boot. In some rare cases this causes problems. One example of this is the Minix Neo Z83-4 mini PC, this device has a clear DSDT bug where it has some copy and pasted code for dealing with Micro USB-B connector host/device role switching, while the mini PC does not even have a micro-USB connector. This code, which should not be there, messes with the DDC data pin from the HDMI connector (switching it to GPIO mode) breaking HDMI support. To avoid problems like this, this commit adds a new gpiolib_acpi.run_edge_events_on_boot kernel commandline option, which allows disabling the running of _AEI edge event handlers at boot. The default value is -1/auto which uses a DMI based blacklist, the initial version of this blacklist contains the Neo Z83-4 fixing the HDMI breakage. Cc: stable@vger.kernel.org Cc: Daniel Drake Cc: Ian W MORRISON Reported-by: Ian W MORRISON Suggested-by: Ian W MORRISON Fixes: ca876c7483b6 ("gpiolib-acpi: make sure we trigger edge events at least once on boot") Signed-off-by: Hans de Goede Link: https://lore.kernel.org/r/20190827202835.213456-1-hdegoede@redhat.com Acked-by: Mika Westerberg Reviewed-by: Andy Shevchenko Tested-by: Ian W MORRISON Signed-off-by: Linus Walleij Signed-off-by: Greg Kroah-Hartman --- drivers/gpio/gpiolib-acpi.c | 42 ++++++++++++++++++++++++++++++++++++++---- 1 file changed, 38 insertions(+), 4 deletions(-) --- a/drivers/gpio/gpiolib-acpi.c +++ b/drivers/gpio/gpiolib-acpi.c @@ -10,6 +10,7 @@ * published by the Free Software Foundation. */ +#include #include #include #include @@ -23,6 +24,11 @@ #include "gpiolib.h" +static int run_edge_events_on_boot = -1; +module_param(run_edge_events_on_boot, int, 0444); +MODULE_PARM_DESC(run_edge_events_on_boot, + "Run edge _AEI event-handlers at boot: 0=no, 1=yes, -1=auto"); + /** * struct acpi_gpio_event - ACPI GPIO event handler data * @@ -174,10 +180,13 @@ static void acpi_gpiochip_request_irq(st event->irq_requested = true; /* Make sure we trigger the initial state of edge-triggered IRQs */ - value = gpiod_get_raw_value_cansleep(event->desc); - if (((event->irqflags & IRQF_TRIGGER_RISING) && value == 1) || - ((event->irqflags & IRQF_TRIGGER_FALLING) && value == 0)) - event->handler(event->irq, event); + if (run_edge_events_on_boot && + (event->irqflags & (IRQF_TRIGGER_RISING | IRQF_TRIGGER_FALLING))) { + value = gpiod_get_raw_value_cansleep(event->desc); + if (((event->irqflags & IRQF_TRIGGER_RISING) && value == 1) || + ((event->irqflags & IRQF_TRIGGER_FALLING) && value == 0)) + event->handler(event->irq, event); + } } static void acpi_gpiochip_request_irqs(struct acpi_gpio_chip *acpi_gpio) @@ -1253,3 +1262,28 @@ static int acpi_gpio_handle_deferred_req } /* We must use _sync so that this runs after the first deferred_probe run */ late_initcall_sync(acpi_gpio_handle_deferred_request_irqs); + +static const struct dmi_system_id run_edge_events_on_boot_blacklist[] = { + { + .matches = { + DMI_MATCH(DMI_SYS_VENDOR, "MINIX"), + DMI_MATCH(DMI_PRODUCT_NAME, "Z83-4"), + } + }, + {} /* Terminating entry */ +}; + +static int acpi_gpio_setup_params(void) +{ + if (run_edge_events_on_boot < 0) { + if (dmi_check_system(run_edge_events_on_boot_blacklist)) + run_edge_events_on_boot = 0; + else + run_edge_events_on_boot = 1; + } + + return 0; +} + +/* Directly after dmi_setup() which runs as core_initcall() */ +postcore_initcall(acpi_gpio_setup_params);