Received: by 2002:a25:ab43:0:0:0:0:0 with SMTP id u61csp6898818ybi; Wed, 29 May 2019 15:17:27 -0700 (PDT) X-Google-Smtp-Source: APXvYqxV67RFPIqz/Wbx/YHWOlHh2eu2xlhGvc8TQraTHxsm+GJ8z4Ml43sPea9v7fAkTBnmlVnM X-Received: by 2002:aa7:9217:: with SMTP id 23mr53238514pfo.80.1559168247214; Wed, 29 May 2019 15:17:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1559168247; cv=none; d=google.com; s=arc-20160816; b=TLlgabNcp4aPeSAd57kyXcZ/MsOTA14netYe8GmJs8ObTIRiDSSWQQHAUQd1U1nPlB raJqI2Lu/G3KxvD2vM4uYpI/JFohXrg8f0tSixmpbQy/Yr4ICdLkEAnB4TMvC9SZslkB mCXLpOOXQ3x5F0hN2OT2NvOZnI/1RPR5+D4gE68efqxF6UwFBQRWLrR833W5t7Zwi0rN WzF6LRJHBEOJZ7vjJk2eZG3q4KaejEQik3wovPMyPTgoJdnI5bxzukBtTZ8ENOocjleo B/ToHnKIQ6CYxIeNBxtrw+LNevLD5soQ+tRjBdjEqPTMVBhdfgtgKnMILVBfsg2J0MTo qXaQ== 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; bh=KSFF4bDXPHpLrA6n50RMJhRFJYg/glW80Pouz4KvDb0=; b=TBKj2zK6EurzqH0SlXOF8RPKF8wQTkCh+apO20hpIRplMjqJ4yAC3mdmxEwzqId5Xx s66UTseA7y4UoyDd8P/Il+rvmHma3I4KDdE44R+UF/SjSj0OefuCiVaL29xPwDshcJnq f4xcYxv4h8ce7tUrDtEzVBy7fq9fba47T/xvx/UIRt3DGDh51AFVv35pUkirbTHQZq3c PpG8D0yndWm2vAYVwNHurVLwXaWLBFJX1xPQYC9PDHfLPmT+Ry5oy1SMvrzvxwMzrwqc FoimAWerVG1W2hkpvMjpJGFzYJYrU69v0UHTV9tuna5XRdMHWYfLqJw5Nb5c5XHo+Gh3 dRiA== 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=nxp.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m9si966985pls.31.2019.05.29.15.17.10; Wed, 29 May 2019 15:17:27 -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=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbfE2WPT (ORCPT + 99 others); Wed, 29 May 2019 18:15:19 -0400 Received: from mail-ot1-f66.google.com ([209.85.210.66]:40273 "EHLO mail-ot1-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726054AbfE2WPT (ORCPT ); Wed, 29 May 2019 18:15:19 -0400 Received: by mail-ot1-f66.google.com with SMTP id u11so3665242otq.7; Wed, 29 May 2019 15:15:18 -0700 (PDT) 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=KSFF4bDXPHpLrA6n50RMJhRFJYg/glW80Pouz4KvDb0=; b=IEMl1JGnDtgMbFifwyt+n3RoZCpqnF0MNkZcfSyOGUu1w/+TML/K7HiMRd3TSAnRAL ZuqQDsEbRhnCWSAQIjgz6VbQul60A0HhsNT7GMyxUDKEuIRCMnxWitJp9+KVO+5iSJqo S/qcC31/FZ3nnKUF+fSljw0UG7fmu3+vjItB25xpCU1y7NkHpkF7Vstg5JpAYC+U8qsm neHTiQBLeJXV4btS5aMuc/DMPtqo03oNMM837UiS9w25RjGFgf7PQ0jQuVYdhDeXRC3H 78qDOYIn+BMFdc+yOuGwpneB3q0DNIhRYzG7TzSwwW0A6VobOzuIwptdc1P4xtM3TDvz S4sQ== X-Gm-Message-State: APjAAAVX+ZMtywgTCQG4/41Adnsncs05rE2yh08s3ldEEINZ+O1vjqa+ qW+E0ogJzkO2rBOzM9cCeHzLqPJlxKg= X-Received: by 2002:a9d:7d9a:: with SMTP id j26mr105618otn.102.1559168118123; Wed, 29 May 2019 15:15:18 -0700 (PDT) Received: from mail-oi1-f173.google.com (mail-oi1-f173.google.com. [209.85.167.173]) by smtp.gmail.com with ESMTPSA id r14sm335550otk.72.2019.05.29.15.15.15 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 29 May 2019 15:15:15 -0700 (PDT) Received: by mail-oi1-f173.google.com with SMTP id w144so3380984oie.12; Wed, 29 May 2019 15:15:15 -0700 (PDT) X-Received: by 2002:aca:ea05:: with SMTP id i5mr374591oih.51.1559168115228; Wed, 29 May 2019 15:15:15 -0700 (PDT) MIME-Version: 1.0 References: <20190529083254.39581-1-chuanhua.han@nxp.com> <20190529083254.39581-2-chuanhua.han@nxp.com> In-Reply-To: <20190529083254.39581-2-chuanhua.han@nxp.com> From: Li Yang Date: Wed, 29 May 2019 17:15:03 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: [PATCH 2/3] gpio: mpc8xxx: Use IRQF_SHARED mode to request IRQ To: Chuanhua Han Cc: Shawn Guo , Rob Herring , Mark Rutland , Linus Walleij , bgolaszewski@baylibre.com, "moderated list:ARM/FREESCALE IMX / MXC ARM ARCHITECTURE" , "open list:OPEN FIRMWARE AND FLATTENED DEVICE TREE BINDINGS" , lkml , linux-gpio@vger.kernel.org, Zhang Ying-22455 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 On Wed, May 29, 2019 at 3:33 AM Chuanhua Han wrote: > > GPIO3 and GPIO4 controllers share one irq number on Layerscape > platform. In the current implementation, only one GPIO controller > can register successfully. > > This patch is to allow two controllers to share a single interrupt > number. This patch definitely did more than setting the IRQF_SHARED flag for interrupt. If the driver do need some cleanup please separate the cleanup into another patch. > > Signed-off-by: Zhang Ying-22455 > Signed-off-by: Chuanhua Han > --- > drivers/gpio/gpio-mpc8xxx.c | 43 ++++++++++++++++++++++++++----------- > 1 file changed, 30 insertions(+), 13 deletions(-) > > diff --git a/drivers/gpio/gpio-mpc8xxx.c b/drivers/gpio/gpio-mpc8xxx.c > index 555e0e7957d9..63c8586fe5c8 100644 > --- a/drivers/gpio/gpio-mpc8xxx.c > +++ b/drivers/gpio/gpio-mpc8xxx.c > @@ -11,6 +11,7 @@ > > #include > #include > +#include > #include > #include > #include > @@ -105,10 +106,9 @@ static int mpc8xxx_gpio_to_irq(struct gpio_chip *gc, unsigned offset) > return -ENXIO; > } > > -static void mpc8xxx_gpio_irq_cascade(struct irq_desc *desc) > +static irqreturn_t mpc8xxx_gpio_irq_cascade(int irq, void *dev_id) > { > - struct mpc8xxx_gpio_chip *mpc8xxx_gc = irq_desc_get_handler_data(desc); > - struct irq_chip *chip = irq_desc_get_chip(desc); > + struct mpc8xxx_gpio_chip *mpc8xxx_gc = dev_id; > struct gpio_chip *gc = &mpc8xxx_gc->gc; > unsigned int mask; > > @@ -117,8 +117,7 @@ static void mpc8xxx_gpio_irq_cascade(struct irq_desc *desc) > if (mask) > generic_handle_irq(irq_linear_revmap(mpc8xxx_gc->irq, > 32 - ffs(mask))); > - if (chip->irq_eoi) > - chip->irq_eoi(&desc->irq_data); > + return IRQ_HANDLED; > } > > static void mpc8xxx_irq_unmask(struct irq_data *d) > @@ -129,6 +128,9 @@ static void mpc8xxx_irq_unmask(struct irq_data *d) > > raw_spin_lock_irqsave(&mpc8xxx_gc->lock, flags); > > + gc->write_reg(mpc8xxx_gc->regs + GPIO_IER, > + gc->pin2mask(gc, irqd_to_hwirq(d))); This API has been removed for a while, are you sure you compiled and tested the change on latest kernel? commit 24efd94bc38290dc1d9775a1e767ed4685d8a79b Author: Linus Walleij Date: Fri Oct 20 16:31:27 2017 +0200 gpio: mmio: Make pin2mask() a private business The vtable call pin2mask() was introducing a vtable function call in every gpiochip callback for a generic MMIO GPIO chip. This was not exactly efficient. (Maybe link-time optimization could get rid of it, I don't know.) After removing all external calls into this API we can make it a boolean flag in the struct gpio_chip call and sink the function into the gpio-mmio driver yielding encapsulation and potential speedups. Cc: Anton Vorontsov Signed-off-by: Linus Walleij > + > gc->write_reg(mpc8xxx_gc->regs + GPIO_IMR, > gc->read_reg(mpc8xxx_gc->regs + GPIO_IMR) > | mpc_pin2mask(irqd_to_hwirq(d))); > @@ -302,21 +304,31 @@ static int mpc8xxx_probe(struct platform_device *pdev) > struct gpio_chip *gc; > const struct mpc8xxx_gpio_devtype *devtype = > of_device_get_match_data(&pdev->dev); > - int ret; > + int ret, irq; > > mpc8xxx_gc = devm_kzalloc(&pdev->dev, sizeof(*mpc8xxx_gc), GFP_KERNEL); > if (!mpc8xxx_gc) > return -ENOMEM; > > - platform_set_drvdata(pdev, mpc8xxx_gc); > - > - raw_spin_lock_init(&mpc8xxx_gc->lock); > - > mpc8xxx_gc->regs = of_iomap(np, 0); > if (!mpc8xxx_gc->regs) > return -ENOMEM; > > gc = &mpc8xxx_gc->gc; > + irq = platform_get_irq(pdev, 0); > + if (irq < 0) { > + dev_err(&pdev->dev, "can't get irq number\n"); > + return irq; > + } > + > + mpc8xxx_gc->gc.label = pdev->name; > + mpc8xxx_gc->gc.owner = THIS_MODULE; > + mpc8xxx_gc->gc.base = -1; > + mpc8xxx_gc->gc.ngpio = MPC8XXX_GPIO_PINS; > + > + platform_set_drvdata(pdev, mpc8xxx_gc); > + > + raw_spin_lock_init(&mpc8xxx_gc->lock); > > if (of_property_read_bool(np, "little-endian")) { > ret = bgpio_init(gc, &pdev->dev, 4, > @@ -364,7 +376,7 @@ static int mpc8xxx_probe(struct platform_device *pdev) > goto err; > } > > - mpc8xxx_gc->irqn = irq_of_parse_and_map(np, 0); > + mpc8xxx_gc->irqn = platform_get_irq(pdev, 0); > if (!mpc8xxx_gc->irqn) > return 0; > > @@ -378,8 +390,13 @@ static int mpc8xxx_probe(struct platform_device *pdev) > gc->write_reg(mpc8xxx_gc->regs + GPIO_IMR, 0xffffffff); > gc->write_reg(mpc8xxx_gc->regs + GPIO_ICR2, 0xffffffff); > > - irq_set_chained_handler_and_data(mpc8xxx_gc->irqn, > - mpc8xxx_gpio_irq_cascade, mpc8xxx_gc); > + /* Request IRQ */ > + ret = devm_request_irq(&pdev->dev, irq, mpc8xxx_gpio_irq_cascade, > + IRQF_SHARED, pdev->name, mpc8xxx_gc); > + if (ret) { > + dev_err(&pdev->dev, "can't claim irq %d\n", mpc8xxx_gc->irqn); > + goto err; > + } > return 0; > err: > iounmap(mpc8xxx_gc->regs); > -- > 2.17.1 >