Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp777696imp; Thu, 21 Feb 2019 10:59:37 -0800 (PST) X-Google-Smtp-Source: AHgI3IaefbPUHbNgrhVleBDBz1EFEoRZKHZAtAdSuf8BGO/44RUidy+5a9IY7MI2ctFuWt+Fwtza X-Received: by 2002:a63:6f09:: with SMTP id k9mr26246pgc.326.1550775577864; Thu, 21 Feb 2019 10:59:37 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550775577; cv=none; d=google.com; s=arc-20160816; b=BRQZpqDRXmzmj6j1dM8p7VrXXlzDhtk7wlikRGu/m+vAqQ2ISbctQ+8exvOILFUJaD WxDdUosDdZanQnuYNfxoqqPUxh6J+h+HkMmT6BAJTc0UDjMo5L1nvd2FnqNQ+rEd0uQl huFhiPIdwdPV50ZfdHk7jZCAnnQIfMW0/9GzmSSxtZdW6AAqHl4Bi0mksFiOhMkSpWdy tgnlR0NxmU3GIyZOoupEkvyb1cOLPOp5LDs3kc5SBCfiug0Hx6GxY2gzxX4cxlkXIsQd PF71A1/MzaXZ5V7RoLZLqQ6ilbdCxLxd9S3fyK2O7aCs9r8NtJFstRMCb5FNQ+CZINhn u0tw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=/fg/zRGOqEr6soWn4lYJNlKofJY1rut3rOP2dQ7jtbg=; b=0A9AMGbWPjE8IQcxTcj3sycpgd3YWPwLvfTTuZhMbmM+3Qg1d3M9sBdiiWrgaTNTum hnGO8oLc5pS4wmoMoBJ/nlhcG50tYGnmZU3KQUqoobCGHF1pL0Y7JdMhqfMH1u/g9uu0 57XXzOZAOZr3EZtx3DFrPlJIpGcXrbfj4IRic2serS0SBv06zpwxfdm4oKUC+oxbCo+3 plt3hgBuFtnhwBHegFjVny92iNhQdzEpD+0NOXj9EtlpnWh/XyzAk8l+aqZiyraTpt5W t3wROxH+EoUuVmcW0MtcxMChxqgbA96SLL9TIq9dQHKgWoAy5nYdspnPYZtg+LTokDtv vqgg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@google.com header.s=20161025 header.b="SxM8uB/E"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id j9si3570772pgb.49.2019.02.21.10.59.22; Thu, 21 Feb 2019 10:59:37 -0800 (PST) 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=@google.com header.s=20161025 header.b="SxM8uB/E"; 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=pass (p=REJECT sp=REJECT dis=NONE) header.from=google.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727146AbfBUS63 (ORCPT + 99 others); Thu, 21 Feb 2019 13:58:29 -0500 Received: from mail-io1-f68.google.com ([209.85.166.68]:46981 "EHLO mail-io1-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726400AbfBUS62 (ORCPT ); Thu, 21 Feb 2019 13:58:28 -0500 Received: by mail-io1-f68.google.com with SMTP id k21so3096512ior.13 for ; Thu, 21 Feb 2019 10:58:27 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=/fg/zRGOqEr6soWn4lYJNlKofJY1rut3rOP2dQ7jtbg=; b=SxM8uB/EhPIbquPtTx+TLO7T5riQ5OPLUZfupa6Zy44VtZyYwS5NwnmmeevrNXgqGj cW25YRZF7Z9QIVEy9o2viCI3xY3MOzitcKt0vyobIbUopELNc1CM+FdAVz8bXY7tCStK K/6+dfUwYkNdDOd38Gg1IT4IjA9DHqbtEU+nat+wCwscqWnMb25kY05osIlBVxZ1IqAy WpBni+wLqbhg7wWDd1vXj+ZzkV5h7VLVgffBUeDArnH0g8qsZQvdbges9IxV6a52Arqi rrsWayyQiaPc+ZZ6Bv36lbHRtUp2L5hxvMSNXXH5/86oIRI81hm5e71J5cksSVxOx43X o1sw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=/fg/zRGOqEr6soWn4lYJNlKofJY1rut3rOP2dQ7jtbg=; b=gNTpCXUGWdossBKR704yt/52Udcwc055yujguhthbubTPNcdZ/+5hNZX+G2GmOA9IS LyHYrF/pHvVRohuVxjLhm7iTrQGYCf2AdjfUarTknSD7bfqGCoyMU8rQYsnnlchlcNnE QN03ODYBgXJcmorUK21KL8VHmn5S6LFNJZlcIXUnS8ZC8tqKUDZSGY0jh72PR90svEyr RL0MJvH3EGLVufBGTz0Cg/Iad8JESrsIoWMXG31vbbuqhJvJ7HGXxRy/waIAUFsYnQxA B5leH0gwPlDaVoxf6DERBazcAEyE/9s1Z/fukfU82GlXTO3h5MAWH+5AeSlHPqQGJF9Y DQ0Q== X-Gm-Message-State: AHQUAubcFS+/7zztxRe9TOURS8kPEJ9kD7S/Oy9um4Gc717C9budIerD pdaEC7i7p1A8xsWiLVTlhvWMnZ/2LZ/jd3DlE1u9KA== X-Received: by 2002:a02:bb82:: with SMTP id g2mr35469jan.8.1550775507001; Thu, 21 Feb 2019 10:58:27 -0800 (PST) MIME-Version: 1.0 References: <20190207185917.167829-1-egranata@google.com> <20190211190112.209286-1-egranata@chromium.org> <20190220180538.GA42642@google.com> In-Reply-To: <20190220180538.GA42642@google.com> From: Enrico Granata Date: Thu, 21 Feb 2019 10:58:15 -0800 Message-ID: Subject: Re: [PATCH v2] driver: platform: Support parsing GpioInt 0 in platform_get_irq() To: Brian Norris Cc: Enrico Granata , Hans de Goede , Mika Westerberg , Dmitry Torokhov , Andy Shevchenko , "Rafael J. Wysocki" , Greg Kroah-Hartman , Enric Balletbo i Serra , Linux Kernel Mailing List , Gwendal Grignou , ACPI Devel Maling List , Andy Shevchenko Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Thanks for catching that and sorry for the delayed response, I was on vacation. I think your analysis makes sense. I would personally lean towards the former suggestion (keeping the change localized to the return value of platform_get_irq() which is the function that apparently has an informal contract about returning -ENXIO specifically). I am happy to post a PATCH v3 to that effect if this seems amenable. Thanks Enrico Granata | egranata@google.com | ChromeOS | MTV1600 On Wed, Feb 20, 2019 at 10:05 AM Brian Norris wrote: > > Hi, > > On Mon, Feb 11, 2019 at 11:01:12AM -0800, egranata@chromium.org wrote: > > From: Enrico Granata > > > > ACPI 5 added support for GpioInt resources as a way to provide > > information about interrupts mediated via a GPIO controller. > > > > Several device buses (e.g. SPI, I2C) have support for retrieving > > an IRQ specified via this type of resource, and providing it > > directly to the driver as an IRQ number. > > > > This is not currently done for the platform drivers, as platform_get_irq() > > does not try to parse GpioInt() resources. This requires drivers to > > either have to support only one possible IRQ resource, or to have code > > in place to try both as a failsafe. > > > > While there is a possibility of ambiguity for devices that exposes > > multiple IRQs, it is easy and feasible to support the common case > > of devices that only expose one IRQ which would be of either type > > depending on the underlying system's architecture. > > > > This commit adds support for parsing a GpioInt resource in order > > to fulfill a request for the index 0 IRQ for a platform device. > > > > Signed-off-by: Enrico Granata > > --- > > Changes in v2: > > - only support IRQ index 0 > > > > drivers/base/platform.c | 15 ++++++++++++++- > > 1 file changed, 14 insertions(+), 1 deletion(-) > > > > diff --git a/drivers/base/platform.c b/drivers/base/platform.c > > index 1c958eb33ef4d..0d3611cd1b3bc 100644 > > --- a/drivers/base/platform.c > > +++ b/drivers/base/platform.c > > @@ -127,7 +127,20 @@ int platform_get_irq(struct platform_device *dev, unsigned int num) > > irqd_set_trigger_type(irqd, r->flags & IORESOURCE_BITS); > > } > > > > - return r ? r->start : -ENXIO; > > + if (r) > > + return r->start; > > + > > + /* > > + * For the index 0 interrupt, allow falling back to GpioInt > > + * resources. While a device could have both Interrupt and GpioInt > > + * resources, making this fallback ambiguous, in many common cases > > + * the device will only expose one IRQ, and this fallback > > + * allows a common code path across either kind of resource. > > + */ > > + if (num == 0 && has_acpi_companion(&dev->dev)) > > + return acpi_dev_gpio_irq_get(ACPI_COMPANION(&dev->dev), num); > > For ACPI devices, this changes the return code for a missing interrupt > 0 from ENXIO to ENOENT, because acpi_dev_gpio_irq_get() uses ENOENT > instead of ENXIO. While ENXIO isn't exactly documented as the *specific* > error code for a missing interrupt in platform_get_irq(), there are > definitely drivers out there that are looking specifically for ENXIO > (grepping the tree finds several Rockchip platform drivers and a few > ethernet drivers at a minimum). And it also incidentally broke some > usage of the very driver you were trying to support > (drivers/platform/chrome/cros_ec_lpc.c). > > I suspect a good strategy here would be to check > acpi_dev_gpio_irq_get()'s return codes here with something like: > > if (ret > 0 || ret == -EPROBE_DEFER) > return ret; > return -ENXIO; > > Although, the gpiolib functions embedded in there also can return EIO, > so maybe something like this is better? > > if (ret == -ENOENT || ret == 0) > return -ENXIO; > return ret; > > I'm kinda unsure what to do with error codes besides PROBE_DEFER or > "missing", since most users don't really have it in their mind that > platform_get_irq() can fail with EIO or similar. > > Brian > > > + > > + return -ENXIO; > > #endif > > } > > EXPORT_SYMBOL_GPL(platform_get_irq); > > -- > > 2.20.1.791.gb4d0f1c61a-goog > >