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 Received: from kanga.kvack.org (kanga.kvack.org [205.233.56.17]) by smtp.lore.kernel.org (Postfix) with ESMTP id 034B2C77B70 for ; Tue, 11 Apr 2023 13:11:50 +0000 (UTC) Received: by kanga.kvack.org (Postfix) id 87C036B0075; Tue, 11 Apr 2023 09:11:50 -0400 (EDT) Received: by kanga.kvack.org (Postfix, from userid 40) id 82B4A6B0078; Tue, 11 Apr 2023 09:11:50 -0400 (EDT) X-Delivered-To: int-list-linux-mm@kvack.org Received: by kanga.kvack.org (Postfix, from userid 63042) id 6F2CB900003; Tue, 11 Apr 2023 09:11:50 -0400 (EDT) X-Delivered-To: linux-mm@kvack.org Received: from relay.hostedemail.com (smtprelay0016.hostedemail.com [216.40.44.16]) by kanga.kvack.org (Postfix) with ESMTP id 5BD4E6B0075 for ; Tue, 11 Apr 2023 09:11:50 -0400 (EDT) Received: from smtpin06.hostedemail.com (a10.router.float.18 [10.200.18.1]) by unirelay07.hostedemail.com (Postfix) with ESMTP id 2CCD7160CF9 for ; Tue, 11 Apr 2023 13:11:50 +0000 (UTC) X-FDA: 80669147580.06.60C8AFD Received: from mail-vs1-f49.google.com (mail-vs1-f49.google.com [209.85.217.49]) by imf15.hostedemail.com (Postfix) with ESMTP id 51522A0018 for ; Tue, 11 Apr 2023 13:11:48 +0000 (UTC) Authentication-Results: imf15.hostedemail.com; dkim=pass header.d=bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=xcJRS2UH; spf=none (imf15.hostedemail.com: domain of brgl@bgdev.pl has no SPF policy when checking 209.85.217.49) smtp.mailfrom=brgl@bgdev.pl; dmarc=none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=hostedemail.com; s=arc-20220608; t=1681218708; h=from:from:sender:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references:dkim-signature; bh=GonC8IX0js+OVi94Wk4G2xkTnBOQ98tF+JQsSsp/P+Q=; b=iYmwL2bWGtTGpuI9e3s8jolv6TewoRnm3XsW1bqAo1TGxy6t1ZKtC1E5B4CuW03umyGD+z /iOzr6Obvf/LTMwAhrBjhiWtKIjWQdZr6F10sIunqSBxiF/IfiyXKauqa7Ndfcl85Ytfyn D/fTlvYx/mPUEtrylsl7hmzYyv4ps+I= ARC-Authentication-Results: i=1; imf15.hostedemail.com; dkim=pass header.d=bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=xcJRS2UH; spf=none (imf15.hostedemail.com: domain of brgl@bgdev.pl has no SPF policy when checking 209.85.217.49) smtp.mailfrom=brgl@bgdev.pl; dmarc=none ARC-Seal: i=1; s=arc-20220608; d=hostedemail.com; t=1681218708; a=rsa-sha256; cv=none; b=lBv//FjoSSYOdVxRSivCQvOK7MPW5CCKz0XI6RpVaLMnZbIL3yNikb1NCug/Dr6PuJuv81 zW6VeevIHi1NCfVpzKuHdvgH+BNp6Tq4A50dc5WdMpoOrtcCjX4iJrXfvr7fm2v56MOUs5 0sCk/+mAIzy8rrN9CaN1cQvRGe6of0U= Received: by mail-vs1-f49.google.com with SMTP id b26so7356492vsa.11 for ; Tue, 11 Apr 2023 06:11:47 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bgdev-pl.20210112.gappssmtp.com; s=20210112; t=1681218707; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=GonC8IX0js+OVi94Wk4G2xkTnBOQ98tF+JQsSsp/P+Q=; b=xcJRS2UHnJF4qMLv4zXTiL1wmsA2j57YKkXofoZoG/nncFZ9Dc1hTwLN9PxOK66kSn mz5KoPN9Le33iDewCg+LcdfbSvEsXPwZX+o6OB81EpOzNNkDtFiXuemIctsk56gBvpCC wDInekSq7XXxuRAZSFDN+SVTjC0FN04Oh7DdCusqwKQ8b4Fga6xT4XzMEc0v9bldQ9Ez dAgN26c61YqIQFVmFY94LfFbXWjGBpZmtDSFpAPxfM5ShpqBMCeOaneCk3slWVYcWVcA pTI/4tv2eM4KsYmeCwLjBPhsy9AF78MmkekST/L15qszuiH85CAGdjRrRpkonzJhc9h+ hwXQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; t=1681218707; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=GonC8IX0js+OVi94Wk4G2xkTnBOQ98tF+JQsSsp/P+Q=; b=OFJc/Tve2hGN9lpnRpc90i5QXeQwjSXPNnlSybGqhciC/yzcZf99ksJmYbw0u8K5r+ 4vCEejfDbC9loLt4l6RQhPZ/TpzEeiCSmQJ9e0G9D7hRg/0Ne44cZrR+tiqIcXB44wDm BCFGYEv5ReFkpLy1Pmr66NPFgRFsbay5KK54FQlF2IxGFpyTsV9irgS8/R3MX//7URVR rw0WrYRiCkY0Ql16YdGUuvwz7Db5yiJhK/AbEWKTBbHrxGN1JULiXn5mMPKhviMYc7R7 ciphCSDezAeP3r4LKt5cHNrEBIs9EBULH61NUhUEPoKjR13R9ti+rs5DGj+p2z4vw3dy iYIQ== X-Gm-Message-State: AAQBX9cZYeNZEdw2/rG5HzoR6+qQSFQvNX1IR8UdOWQxCyWtGZafLF/E 11V8EEfVVK9u8r3PDDTFae1DgGeU2jb01gdi6g5uOg== X-Google-Smtp-Source: AKy350YbgCCHeeQll+PtCuIJBiGVDqYrDGK7d5MCr7dW/WF0/1JpvIxP/7GIUb8Prhz1Fy5k/YBRj+Zy3NIQvBwzyTk= X-Received: by 2002:a67:ca81:0:b0:426:7730:1b89 with SMTP id a1-20020a67ca81000000b0042677301b89mr1904738vsl.0.1681218707036; Tue, 11 Apr 2023 06:11:47 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Bartosz Golaszewski Date: Tue, 11 Apr 2023 15:11:36 +0200 Message-ID: Subject: Re: selftests: gpio: crash on arm64 To: Linus Walleij Cc: Naresh Kamboju , Bartosz Golaszewski , "open list:GPIO SUBSYSTEM" , Andy Shevchenko , Anders Roxell , Linux-Next Mailing List , open list , lkft-triage@lists.linaro.org, "open list:KERNEL SELFTEST FRAMEWORK" , linux-mm , Arnd Bergmann , Shuah Khan , Andrew Morton , Pengfei Xu , yi1.lai@intel.com Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Rspamd-Server: rspam05 X-Rspamd-Queue-Id: 51522A0018 X-Stat-Signature: z5s8oc4kqomriux3w6rociffjnppo1ai X-Rspam-User: X-HE-Tag: 1681218708-218021 X-HE-Meta: U2FsdGVkX187j5+v0jFCQl4dsEjywrmuFeC2CHTUtfbLAVXNicXKT2mJ7j7T+OOTIUvXzqJLNh5DtBwpCIrsVHNIG/cW0ZffATzm2X3et1P/N7oGIN1N8yfEWaiG6qPDBZp/nOkY78TkW0oNV711Lir0R4Aw0nGDvrnu4ulzq3B0xrmZ0Oo/MALfLxXAO1aQeCItrCkRRigdPzpnm2CpralyjhJYnhgtdN3+AUR07w3heidpEELMLAcdo7uN00pVmJ9i3WnkOYryODUO9XcaG807Q+FdEvhejKadex4lCbFS3pY2BeDyEToDABB4HiZefB/AVEp3bwkTLp0ewFzZkbpNnkFnHUFbxzLFKpE4yIfNgttUEk3qbLk+gr2Rs5fNUj4vtl/zxAJ107XiDa1OYhH0VeMMANApKfY4nX2xVjY9doj0LWPXF6jNkHAU9HvXzIDYO8f8qf8vrEeeRLB4Acw21+FBztlYoRcqGDDumTp9/09a7BiQ4AtwxSH5R0KrZb8ut8kZjz2fRMAiUKCmUFQFAbTbBZBJs9LgSqYjqjkj5tuP5PA62JtaNWOD3RPZK0RnVWkkc6FiPdoTPG0Mm/93FLLYiHi6Nh6DaKnca3+yzUr2/3mG6gvvcu2qX/EWlc3Vyb9WYc8sT8rwuNuoc9DFvW5QdNHFSvhlHPTUK09wgF9b9vbhEOpm7m/LTU8tEFjP9Vqb3uu5ys19F0kAJ2xo4CZLGwpZqHM5NLOvZUp5iFyFBCK8ogNIXN5mOpCX/xBwyWmwSSjwSHmMKp7yRGaknZyysKT8yb/htLB73Tjl+uVzqXtCe2XLTF4hJTJefpgtJmkpvBZkIN/eB4gzjdxqTIg06g9HJkjVw1/O+ziOlv7TprAK0+u0ob7hb1UvHjTciUDntQXFY+uhRTHBPjmqLdZoP7Ffv9VsmexeeEB3xfHW7GlBGLV2YFS2QzNrFXsZMIScuRSlo+MESIO 05UcErwf HcpAI4/WFBKmJyjMdKk5rAE6d935I3ZnQiom+J4kzkz/bnPCi7TKYN8UxEfXe2Et6nGD7CgTDSWFRzxe2KW5eEa8vfjPgNjA/zZ3DYRPcn7awyKHGEVHYS2lnRcSfMIIUVUjyIkOOjMKx3vzP+E564pZ/t2gYtH7xVfDSQR4go/xeihX3oEsq5q/kR4NZX602r4SUaJcaQ9J6WAfU3TrGHvbzYQPDsKteYqJNbZTtUkQ7k7gi02/UzsJiS2LpcuWzsSuBY8hX7wYPqUIhtjTJZbjhNNNMcelHetGMOg1y/Cey0t86yHKZ/3qoLGSYSK0Qxsfe3NSpFV6LmWzWX7rp2jFz7qUuRqy8ZZT2 X-Bogosity: Ham, tests=bogofilter, spamicity=0.000000, version=1.2.4 Sender: owner-linux-mm@kvack.org Precedence: bulk X-Loop: owner-majordomo@kvack.org List-ID: On Tue, Apr 11, 2023 at 10:57=E2=80=AFAM Linus Walleij wrote: > > On Mon, Apr 10, 2023 at 11:16=E2=80=AFAM Naresh Kamboju > wrote: > (...) > > Anders performed bisection on this problem. > > The bisection have been poing to this commit log, > > first bad commit: [24c94060fc9b4e0f19e6e018869db46db21d6bc7] > > gpiolib: ensure that fwnode is properly set > > I don't think this is the real issue. > > (...) > > # 2. Module load error tests > > # 2.1 gpio overflow > (...) > > [ 88.900984] Freed in software_node_release+0xdc/0x108 age=3D34 cpu= =3D1 pid=3D683 > > [ 88.907899] __kmem_cache_free+0x2a4/0x2e0 > > [ 88.912024] kfree+0xc0/0x1a0 > > [ 88.915015] software_node_release+0xdc/0x108 > > [ 88.919402] kobject_put+0xb0/0x220 > > [ 88.922919] software_node_notify_remove+0x98/0xe8 > > [ 88.927741] device_del+0x184/0x380 > > [ 88.931259] platform_device_del.part.0+0x24/0xa8 > > [ 88.935995] platform_device_unregister+0x30/0x50 > > I think the refcount is wrong on the fwnode. > > The chip is allocated with devm_gpiochip_add_data() which will not call > gpiochip_remove() until all references are removed by calling > devm_gpio_chip_release(). > > Add a pr_info() devm_gpio_chip_release() in drivers/gpio/gpiolib-devres.c > and see if the callback is even called. I think this could be the > problem: if that isn't cleaned up, there will be dangling references. > > diff --git a/drivers/gpio/gpiolib-devres.c b/drivers/gpio/gpiolib-devres.= c > index fe9ce6b19f15..30a0622210d7 100644 > --- a/drivers/gpio/gpiolib-devres.c > +++ b/drivers/gpio/gpiolib-devres.c > @@ -394,6 +394,7 @@ static void devm_gpio_chip_release(void *data) > { > struct gpio_chip *gc =3D data; > > + pr_info("GPIOCHIP %s WAS REMOVED BY DEVRES\n", gc->label); > gpiochip_remove(gc); > } > > If this isn't working we need to figure out what is holding a reference t= o > the gpiochip. > > I don't know how the references to the gpiochip fwnode is supposed to > drop to zero though? I didn't work with mockup much ... > > What I could think of is that maybe the mockup driver need a .shutdown() > callback to forcibly call gpiochip_remove(), and in that case it should > be wrapped in a non-existining devm_gpiochip_remove() since devres > is used to register it. > > Bartosz will know better though! I am pretty sure he has this working > flawlessly so the tests must be doing something weird which is leaving > references around. > > Yours, > Linus Walleij Interestingly I'm not seeing this neither with gpio-sim selftests nor with any of the libgpiod tests which suggests it's the gpio-mockup module that's doing something wrong (or very right in which case it uncovers some otherwise hidden bug). Anyway, I'll try to spend some time on it and figure it out, although I'd like to be done with gpio-mockup altogether already. Bart