Received: by 2002:a25:ad19:0:0:0:0:0 with SMTP id y25csp9005888ybi; Wed, 10 Jul 2019 03:08:09 -0700 (PDT) X-Google-Smtp-Source: APXvYqyXs3UXW++Rr/oWqAt/gxOiG816n40nxljPEUYWijC8xMySrBndsnoUwOKZB3e+n19SZqHJ X-Received: by 2002:a17:90a:e397:: with SMTP id b23mr5968572pjz.117.1562753289793; Wed, 10 Jul 2019 03:08:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1562753289; cv=none; d=google.com; s=arc-20160816; b=EbkwgyIWRJtzHb+zZ7qZmePItmwQybpO8cs0VLDhs2++PxCBnrMq2R2Fc8BwsdpXGh 1DUccWury1I1UFvEncrPBmm0XKLAANReRJql0ricRtqh7MOk60SKey7RUb7CfnRG/PE5 1mYKnTAGLFFmG7K0IjKq8GEqFmIjqKT4IPIvnH7CRoZ5tYU8/4C+uKSGcGo0uEDz6ES5 yY+/8GIUwg4vbp3oyFqyyGs2KCW7QvokDksb1Vwj1+IM6BAus99X8N4w5Th2rErtMBIy O3NwJoXBHJKJKF8Ep1LWVbS9d8vD2kXqL8Ki1pOp1tW8EdV9+wGG7HW6cuTBwO+iiozj If+g== 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:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=bzV97ZdiERZ42rZWsWCb0hOAee1RiY7/NGaFmcVPNbo=; b=j5+IjYJbIr8QaHJ6g8PJDWGz6DI7Mi/njh8YKKT3J3ilQDpEE0fUNALikWPhlm7wmu FVPOKOPZ8KQzcRxkGjSthOcMfM1j+pxvZ2k3WKVbgdGRdiEvonfWe2iN/UaOZxDklG39 YfqnreUHNckV4b4KlqKAa6OwRrS9O247PNsMKxyskCWn1swRKhsb7NH0MMDzmDCPSWrk rHp033YhL7dkxMHofDW99ESeWdeVUduz58p1ZXEkrKYGlXGmgnWhDISXNOZqY6yiLlh+ VrTlGrm6/3YgTWC/4XOj+qy/IZf6Fcvrddk93L++jdxbhQ5NKoQVZUC9FGoK8+2tR6V4 VeKQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=mstsLCtH; 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 v45si1854034pgn.10.2019.07.10.03.07.48; Wed, 10 Jul 2019 03:08:09 -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=@baylibre-com.20150623.gappssmtp.com header.s=20150623 header.b=mstsLCtH; 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 S1727282AbfGJJrb (ORCPT + 99 others); Wed, 10 Jul 2019 05:47:31 -0400 Received: from mail-oi1-f195.google.com ([209.85.167.195]:34845 "EHLO mail-oi1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727213AbfGJJra (ORCPT ); Wed, 10 Jul 2019 05:47:30 -0400 Received: by mail-oi1-f195.google.com with SMTP id a127so1141909oii.2 for ; Wed, 10 Jul 2019 02:47:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=baylibre-com.20150623.gappssmtp.com; s=20150623; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc:content-transfer-encoding; bh=bzV97ZdiERZ42rZWsWCb0hOAee1RiY7/NGaFmcVPNbo=; b=mstsLCtHadyks31Z9lCGNHdmPIycOBkJOxqQ5UkKwFgG9lMmu0w9BPn9D0HPMZ3pm2 mOjKgMR7/aBkKvMue+fDtVvZYHlidhvGfkYHFnNv8JbHIDL5t29vnLkw/TU63aMhrzXq z4SWpOhnjBibihvBajL0LC4cl0UnpJ5h+2c8nvhq48ZSb/yalpK5eo6iE0iX/P/LRfPg aDPSZMxdnHc9KgzwPR8tGtKJG6JpPAodrmvGicGP2c6tdC37mwqj4OYZZN5WarddV1RO Hi6yP3DlQFxeF/y6paTYMsVxwo0f32bmcDJ+vTDTBth1O8khr/viW7UXy21EXlknraqO jbcA== 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:content-transfer-encoding; bh=bzV97ZdiERZ42rZWsWCb0hOAee1RiY7/NGaFmcVPNbo=; b=BuKI1J5plVXFKryE3p1p3XoNrGqw2UhSq9/gfNG+BtyWBhbTmZhNWMkAfPf5eJ9FQG oYZMMuTnBQanG06HWOFPInCt7Vkt5PxsJx+QqPREBQFhVosHFaVsroNawIv6hGbANzxF d0kgsUXM6dWKJ5XJZ7xoFQ4Ibw+IT/W9XrlHb6z+rTQmzJ0M+1QPh/pu6yePxAwgXv1/ FM075V5MtFX1IXDEoihj5TPt2VYlVElxRyaFlA4ALmtdXUTfYrMknDSWUcf0N/n/lBWP J5OsvVaz2KM/B328z6veF4+mjOF7YI2E2iJQGWRliJQSsy/xdv/F41BlF4jL1d4aowN2 7lqg== X-Gm-Message-State: APjAAAXuP2Mw0HMsVuh0dmq28R8Q0YZTRV1qBbPfEs/SjH2B0c+v/dHR cI8xnfd1dEom2/aVOb/gMW64w2WBJxj6erFvZYIVBQ== X-Received: by 2002:aca:b06:: with SMTP id 6mr2926203oil.175.1562752049415; Wed, 10 Jul 2019 02:47:29 -0700 (PDT) MIME-Version: 1.0 References: <20190710090852.9239-1-brgl@bgdev.pl> <510f14c9-fc3b-734c-53ff-cbf4a7579e32@electromag.com.au> In-Reply-To: <510f14c9-fc3b-734c-53ff-cbf4a7579e32@electromag.com.au> From: Bartosz Golaszewski Date: Wed, 10 Jul 2019 11:47:18 +0200 Message-ID: Subject: Re: [PATCH 1/2] gpio: em: remove the gpiochip before removing the irq domain To: Phil Reid Cc: Bartosz Golaszewski , Linus Walleij , Geert Uytterhoeven , linux-gpio , LKML , "Stable # 4 . 20+" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org =C5=9Br., 10 lip 2019 o 11:37 Phil Reid napisa=C5= =82(a): > > G'day Bartosz, > > One comment below > > On 10/07/2019 17:08, Bartosz Golaszewski wrote: > > From: Bartosz Golaszewski > > > > In commit 8764c4ca5049 ("gpio: em: use the managed version of > > gpiochip_add_data()") we implicitly altered the ordering of resource > > freeing: since gpiochip_remove() calls gpiochip_irqchip_remove() > > internally, we now can potentially use the irq_domain after it was > > destroyed in the remove() callback (as devm resources are freed after > > remove() has returned). > > > > Use devm_add_action() to keep the ordering right and entirely kill > > the remove() callback in the driver. > > > > Reported-by: Geert Uytterhoeven > > Fixes: 8764c4ca5049 ("gpio: em: use the managed version of gpiochip_add= _data()") > > Cc: stable@vger.kernel.org > > Signed-off-by: Bartosz Golaszewski > > --- > > drivers/gpio/gpio-em.c | 35 +++++++++++++++++------------------ > > 1 file changed, 17 insertions(+), 18 deletions(-) > > > > diff --git a/drivers/gpio/gpio-em.c b/drivers/gpio/gpio-em.c > > index b6af705a4e5f..c88028ac66f2 100644 > > --- a/drivers/gpio/gpio-em.c > > +++ b/drivers/gpio/gpio-em.c > > @@ -259,6 +259,13 @@ static const struct irq_domain_ops em_gio_irq_doma= in_ops =3D { > > .xlate =3D irq_domain_xlate_twocell, > > }; > > > > +static void em_gio_irq_domain_remove(void *data) > > +{ > > + struct irq_domain *domain =3D data; > > + > > + irq_domain_remove(domain); > > +} > > + > > static int em_gio_probe(struct platform_device *pdev) > > { > > struct em_gio_priv *p; > > @@ -333,39 +340,32 @@ static int em_gio_probe(struct platform_device *p= dev) > > return -ENXIO; > > } > > > > + ret =3D devm_add_action(&pdev->dev, > > + em_gio_irq_domain_remove, p->irq_domain); > > Could devm_add_action_or_reset be used? > Of course it could and it should. :) I'll resend tomorrow to not spam the mailing list. Thanks, Bart > > + if (ret) { > > + irq_domain_remove(p->irq_domain); > > + return ret; > > + } > > + > > if (devm_request_irq(&pdev->dev, irq[0]->start, > > em_gio_irq_handler, 0, name, p)) { > > dev_err(&pdev->dev, "failed to request low IRQ\n"); > > - ret =3D -ENOENT; > > - goto err1; > > + return -ENOENT; > > } > > > > if (devm_request_irq(&pdev->dev, irq[1]->start, > > em_gio_irq_handler, 0, name, p)) { > > dev_err(&pdev->dev, "failed to request high IRQ\n"); > > - ret =3D -ENOENT; > > - goto err1; > > + return -ENOENT; > > } > > > > ret =3D devm_gpiochip_add_data(&pdev->dev, gpio_chip, p); > > if (ret) { > > dev_err(&pdev->dev, "failed to add GPIO controller\n"); > > - goto err1; > > + return ret; > > } > > > > return 0; > > - > > -err1: > > - irq_domain_remove(p->irq_domain); > > - return ret; > > -} > > - > > -static int em_gio_remove(struct platform_device *pdev) > > -{ > > - struct em_gio_priv *p =3D platform_get_drvdata(pdev); > > - > > - irq_domain_remove(p->irq_domain); > > - return 0; > > } > > > > static const struct of_device_id em_gio_dt_ids[] =3D { > > @@ -376,7 +376,6 @@ MODULE_DEVICE_TABLE(of, em_gio_dt_ids); > > > > static struct platform_driver em_gio_device_driver =3D { > > .probe =3D em_gio_probe, > > - .remove =3D em_gio_remove, > > .driver =3D { > > .name =3D "em_gio", > > .of_match_table =3D em_gio_dt_ids, > > > > > -- > Regards > Phil Reid >