From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.2 required=3.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A4D2CC3A5A4 for ; Wed, 28 Aug 2019 12:20:38 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.kernel.org (Postfix) with ESMTP id 8662E233FF for ; Wed, 28 Aug 2019 12:20:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726253AbfH1MUh (ORCPT ); Wed, 28 Aug 2019 08:20:37 -0400 Received: from mx1.redhat.com ([209.132.183.28]:33574 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726300AbfH1MUh (ORCPT ); Wed, 28 Aug 2019 08:20:37 -0400 Received: from mail-ed1-f72.google.com (mail-ed1-f72.google.com [209.85.208.72]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mx1.redhat.com (Postfix) with ESMTPS id B14852A09D8 for ; Wed, 28 Aug 2019 12:20:36 +0000 (UTC) Received: by mail-ed1-f72.google.com with SMTP id e9so1553182edv.18 for ; Wed, 28 Aug 2019 05:20:36 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:to:cc:references:from:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=pdH1GkwHzd4V3Un7iWCji7Bvc2KPgsbgbEWrgbKOEAI=; b=QSE7ijbPtkpMYfUtLUpO6pOmSbaV4kNKgtH1YjbfJEmoyUbpxsQbVQUT8vM/0521rz Kl2c5Uewi0yhGup1JrmqYoC59mw3mK5j/yJc/Y8B/fxb+NVR3trT2sR7czqSL0HIjuxb ManWtrBZ9AzmkTA3bn2F7t5jh5KKrYTdfTd4tMqcdLRHiQUQGKqvUhmZjJuKVnXtO5Xg UyL86g4mqzPV7UlfmyrR7JT1qzMMOCD47eWFQxalySRCyVeDPqTu4s+q+aDEOPau32EO OH5V1RqXE2aEC6Q61WxazB0d99apF5fhSiF4i+VJVgnInjlsQ/21K/hzRX+2kp7QgcuW pxAg== X-Gm-Message-State: APjAAAWDgIlb49NaKCcFEDCJrzZdTis+iVBsU1lvCVmloC9tuh2q6/V+ aKdSueVPIKtYsM8YSb/HjmafqXjJ0t/xzEDZ8R+LHxN/Ib7To+OH8+uGjENwtjQWKChFyt2oJZs tDMPJ4iSfmuGUEO8h/xlMXw== X-Received: by 2002:a50:9736:: with SMTP id c51mr3720185edb.160.1566994835460; Wed, 28 Aug 2019 05:20:35 -0700 (PDT) X-Google-Smtp-Source: APXvYqyWukKyNCUZbK7qPi7GwQzbR3867OkLKr3tvczz/FIb+NgO92UjwVMmzr/2PMX1gqD8Ev3xgg== X-Received: by 2002:a50:9736:: with SMTP id c51mr3720159edb.160.1566994835220; Wed, 28 Aug 2019 05:20:35 -0700 (PDT) Received: from shalem.localdomain (84-106-84-65.cable.dynamic.v4.ziggo.nl. [84.106.84.65]) by smtp.gmail.com with ESMTPSA id g20sm419835edp.92.2019.08.28.05.20.34 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 28 Aug 2019 05:20:34 -0700 (PDT) Subject: Re: [PATCH v2] gpiolib: acpi: Add gpiolib_acpi_run_edge_events_on_boot option and blacklist To: Andy Shevchenko Cc: Mika Westerberg , Bartosz Golaszewski , Linus Walleij , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, stable@vger.kernel.org, Daniel Drake , Ian W MORRISON References: <20190827202835.213456-1-hdegoede@redhat.com> <20190828113748.GK2680@smile.fi.intel.com> From: Hans de Goede Message-ID: <005b954d-46ad-5e45-6a9c-0b1efe020b92@redhat.com> Date: Wed, 28 Aug 2019 14:20:33 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.8.0 MIME-Version: 1.0 In-Reply-To: <20190828113748.GK2680@smile.fi.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-gpio-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-gpio@vger.kernel.org Hi, On 28-08-19 13:37, Andy Shevchenko wrote: > On Tue, Aug 27, 2019 at 10:28:35PM +0200, Hans de Goede wrote: >> 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. > > Thank you! > > Assuming it works for Ian, > Reviewed-by: Andy Shevchenko Note I have access to a Minix Neo Z83-4 myself now and I did test that this fixes it and that passing gpiolib_acpi.run_edge_events_on_boot=0 breaks HDMI again (so the option works). Regards, Hans > >> >> 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 >> --- >> Changes in v2: >> - Use a module_param instead of __setup >> - Do DMI check only once from a postcore_initcall >> --- >> drivers/gpio/gpiolib-acpi.c | 42 +++++++++++++++++++++++++++++++++---- >> 1 file changed, 38 insertions(+), 4 deletions(-) >> >> diff --git a/drivers/gpio/gpiolib-acpi.c b/drivers/gpio/gpiolib-acpi.c >> index 39f2f9035c11..bda28eb82c3f 100644 >> --- a/drivers/gpio/gpiolib-acpi.c >> +++ b/drivers/gpio/gpiolib-acpi.c >> @@ -7,6 +7,7 @@ >> * Mika Westerberg >> */ >> >> +#include >> #include >> #include >> #include >> @@ -19,6 +20,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 >> * >> @@ -170,10 +176,13 @@ static void acpi_gpiochip_request_irq(struct acpi_gpio_chip *acpi_gpio, >> 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) >> @@ -1283,3 +1292,28 @@ static int acpi_gpio_handle_deferred_request_irqs(void) >> } >> /* 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); >> -- >> 2.23.0 >> >