Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp5642403ybl; Tue, 27 Aug 2019 07:42:29 -0700 (PDT) X-Google-Smtp-Source: APXvYqw26Lb/sBAf59O1cVYIYepYyncdDE/y0nLr17H15LcpT6VDgQGzkTEJJMu+BrjhxhgJjUh9 X-Received: by 2002:a17:90a:1916:: with SMTP id 22mr26093270pjg.62.1566916949021; Tue, 27 Aug 2019 07:42:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1566916949; cv=none; d=google.com; s=arc-20160816; b=wpp124ACF78AHITOqAeVZ7kvBgI6ZmehTbBxxS20yKpSPfQlRppY429snjpWxCYdO+ hjHGJWvaRAWDx5zurR5rFz4mul3f/KyJqZDhMtCBA7Cwj7Wy1kazTj3I8bhafZ5asBPG tfeJlVoAP+c4Kf1fNH/9GOqSpBSzl90Dez/J1U/Kuf8Xjz234k8n/E53yw9FNm7DubJI sh7XA4oK8Km7lsKYaAptblZ8Q8dgC97QNEaHROhaFzY1Hr8W+N7CO7v7bmndgokt82u0 7vzfKveT93UJAFPn5zD2d2DN+6Y7FHnL0JGS1TIOL7C5wFHi9uDhgNyMdiITj8vTw4xa m+wA== 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 :content-language:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject; bh=gtdqTXHgEELwWUsXLxRHC6cx9mr0AwttNY4k7nCwF+k=; b=GOpfno0sxkC/VluLVLt/09N3w/2/BX0APW+AKgMcDANdm0zy3gZFvVdreOHkjIbyAE DpfRJ+/F6RcyYQlh3AJm2FR7qUvq6qb9qAZ4Wmecho6E3EwAwFXeGgS3JUlGW9/G+tZn tI4tIXrGckbESTcqEyfsXDCAYYEIkYdlA37332myqH4n1XIN22wHDQRcGg1pfxnYemit yKPVuJWYzzkc/G97rk1Xa5mTBk4u/KXxpS6yeza8ouwd4UFZbniSIRyfwLS/mfY0zHy/ EraA2QBlk8lEHP7JdHc3ialFzuDD1RAl+UajiM5pGp6JF6SvEVkaD/z8t3pUMLMSR69a cFtQ== ARC-Authentication-Results: i=1; mx.google.com; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 4si2763120pjo.48.2019.08.27.07.42.13; Tue, 27 Aug 2019 07:42:29 -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; 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=redhat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729797AbfH0OlP (ORCPT + 99 others); Tue, 27 Aug 2019 10:41:15 -0400 Received: from mx1.redhat.com ([209.132.183.28]:60642 "EHLO mx1.redhat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726871AbfH0OlO (ORCPT ); Tue, 27 Aug 2019 10:41:14 -0400 Received: from mail-ed1-f70.google.com (mail-ed1-f70.google.com [209.85.208.70]) (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 A372C5AFF8 for ; Tue, 27 Aug 2019 14:41:13 +0000 (UTC) Received: by mail-ed1-f70.google.com with SMTP id w15so11766867edv.17 for ; Tue, 27 Aug 2019 07:41:13 -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=gtdqTXHgEELwWUsXLxRHC6cx9mr0AwttNY4k7nCwF+k=; b=WI4JVV0pkRoHHfXAjsVB2R0bjP2p0rnW+/zeAB0qkDFgQTA6odNIJCuvV/zcVFe09i qoYIPbV5Yq16mhO9MMkIizIg7i9xt8ZkgsArIWjGOMYZRM3qgcWAtlLETi44o6kui9GS vv9uNZ4AmW3ovVBQbxbWfO9m84W379mYZsuUn8Zs1wvmWAkFFJWFcAH4K4DfcCwoXaw9 9uSiit3C6H2dKfUWr36QHFHd7/Os2sBErv/MN1ryJdVR1cPDw8f4Fmtu2jMybQoPsNZh GwOe4/5nm+M9OPi5a7UsGxYpHiiDPFuDeRKEB7CBMa6LrovtUVAlcWeFrznSjuEkkHa/ 1GbA== X-Gm-Message-State: APjAAAVLReNlPtbTuE5oIMqn9yiM3GARbISZzdGS8fsqWQzE9lbDvnFv UchDJ4wvqifWnCIkmJNhvNuHRgjkmhuQaRImn7ZSuIohcbMfb+XjQ2ofziNMSsXh1tlCRzGlT0Y l4/ThOkXsvhRwiXk83HcKY3sH X-Received: by 2002:a17:906:340e:: with SMTP id c14mr22089091ejb.170.1566916872397; Tue, 27 Aug 2019 07:41:12 -0700 (PDT) X-Received: by 2002:a17:906:340e:: with SMTP id c14mr22089062ejb.170.1566916872122; Tue, 27 Aug 2019 07:41:12 -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 bq19sm3651230ejb.33.2019.08.27.07.41.10 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Tue, 27 Aug 2019 07:41:11 -0700 (PDT) Subject: Re: [PATCH] gpiolib: acpi: Add gpiolib_acpi_run_edge_events_on_boot option and blacklist To: Andy Shevchenko Cc: Mika Westerberg , Linus Walleij , Bartosz Golaszewski , Benjamin Tissoires , linux-gpio@vger.kernel.org, linux-acpi@vger.kernel.org, linux-kernel@vger.kernel.org, stable@vger.kernel.org, Daniel Drake , Ian W MORRISON References: <20190823215255.7631-1-hdegoede@redhat.com> <20190826091110.GY30120@smile.fi.intel.com> From: Hans de Goede Message-ID: Date: Tue, 27 Aug 2019 16:41:10 +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: <20190826091110.GY30120@smile.fi.intel.com> Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Andy, On 26-08-19 11:11, Andy Shevchenko wrote: > On Fri, Aug 23, 2019 at 11:52:55PM +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 >> can be "on", "off", or "auto" (default). >> >> In auto mode the default is on and a DMI based blacklist is used, >> the initial version of this blacklist contains the Minix Neo Z83-4 >> fixing the HDMI being broken on this device. > >> +static int gpiolib_acpi_run_edge_events_on_boot = -1; >> + >> +static int __init gpiolib_acpi_run_edge_events_on_boot_setup(char *arg) >> +{ > >> + if (!strcmp(arg, "on")) >> + gpiolib_acpi_run_edge_events_on_boot = 1; >> + else if (!strcmp(arg, "off")) >> + gpiolib_acpi_run_edge_events_on_boot = 0; > > kstrtobool() ? > >> + else if (!strcmp(arg, "auto")) >> + gpiolib_acpi_run_edge_events_on_boot = -1; >> + >> + return 1; >> +} > >> + >> +__setup("gpiolib_acpi_run_edge_events_on_boot=", >> + gpiolib_acpi_run_edge_events_on_boot_setup); > > Can't we use module_param() ? > The resulting option would be 'gpiolib_acpi.foo=...' I was expecting that would not work, since gpiolib is a bool not a tristate, but it seems that if there is no module-name to use as prefix for module-parameters the kernel simply uses the .c file name, so this works and yes, this is better then using __setup, will fix for v2. >> +{ > >> + if (gpiolib_acpi_run_edge_events_on_boot == -1) { >> + if (dmi_check_system(run_edge_events_on_boot_blacklist)) >> + gpiolib_acpi_run_edge_events_on_boot = 0; >> + else >> + gpiolib_acpi_run_edge_events_on_boot = 1; >> + } > > Can we run this at an initcall once and use variable instead of calling a > method below? I was a bit worried about init ordering, but I've checked and dmi_setup() is done as a core_initcall, so we can do this once as a postcore_initcall which should be early enough, will fix for v2. > >> + return gpiolib_acpi_run_edge_events_on_boot; >> +} >> + >> static void acpi_gpiochip_request_irq(struct acpi_gpio_chip *acpi_gpio, >> struct acpi_gpio_event *event) >> { >> @@ -170,10 +211,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 (acpi_gpiochip_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); >> + } > Regards, Hans