Received: by 2002:a05:6358:11c7:b0:104:8066:f915 with SMTP id i7csp5483908rwl; Tue, 11 Apr 2023 06:13:03 -0700 (PDT) X-Google-Smtp-Source: AKy350YNUwnWh1o81hzkJWb3tIDAWRw/H/mkGQnKMpA+pb1ealTQYLCCHHub28aYVUNuN4p9Vfnu X-Received: by 2002:aa7:c413:0:b0:504:b5ca:7481 with SMTP id j19-20020aa7c413000000b00504b5ca7481mr3713561edq.3.1681218783377; Tue, 11 Apr 2023 06:13:03 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1681218783; cv=none; d=google.com; s=arc-20160816; b=BoCZbwELYjBeZgP6ZWGucZ5E9bzDGQgJj5VpGMo8OCs3n8EM/6EIlypRaWUAkpDNev TphHPAGLTtzKJGmqQzJhz2ri/P1VxZ2QIb2wQaKjp7wEbUJ+OO3ljjNKZjrGV3kZM/G4 +AScanrm4AB/a9MH9jkqNuH0K7OdJZBF9ZNpjPbIGpmA6IwfyGuy6oaDH9HyxASISCof 8CEdgGsjNtJ9lzmgFKtw16BgUqdinpHhmO18D+9FZ5TKc0mdh5iS7zep0P+YelDYOsIQ HiiVgrzMI+5D7/eAryAVqsZf1LMdsX876t1Kyd4hqJtfGPv8W/H5XpjifCwKovYYTf0b 93Eg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=GonC8IX0js+OVi94Wk4G2xkTnBOQ98tF+JQsSsp/P+Q=; b=neLU4C3qUSINV/45aA/83vH3m15Zn4Rg1kmXwz0r+ndlcSXxFq5uJrx8KDHndGx933 zN4bk0gwhSJmOEIK7laSmahBLCYbGRakdLn1sA/0EKat+T8aI+tnwZ/e+tib1FiwacDO snFRXXaeScO04/zne32afm0VBdthHhsZyFNxNbnOtvPg9QbUqq6rPkX17jdxeG15zFQ3 A9T1t29Pj2aFvqWz7ias0wZ9vTwWzWNYWPqb8yEbkgmaIA9te1IX1tLhD5WmmKSLxzmB IAlMHVDyj2hmyon2WFFSUivJvjCSYuQMzM2nefbqRoZY3kZx/2mZKETKRUdTFC/Ip8lp /7/g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=xcJRS2UH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 10-20020a170906100a00b009300aeecec0si2344822ejm.723.2023.04.11.06.12.37; Tue, 11 Apr 2023 06:13:03 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@bgdev-pl.20210112.gappssmtp.com header.s=20210112 header.b=xcJRS2UH; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230196AbjDKNLv (ORCPT + 99 others); Tue, 11 Apr 2023 09:11:51 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48066 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230047AbjDKNLt (ORCPT ); Tue, 11 Apr 2023 09:11:49 -0400 Received: from mail-vs1-xe31.google.com (mail-vs1-xe31.google.com [IPv6:2607:f8b0:4864:20::e31]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 413643AB6 for ; Tue, 11 Apr 2023 06:11:48 -0700 (PDT) Received: by mail-vs1-xe31.google.com with SMTP id dg15so33685911vsb.13 for ; Tue, 11 Apr 2023 06:11:48 -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=Wr19DsH58+Wi94s4c9IuaJYZqcIuuDrEjCewjsMaKAGaQr/vyQJiXaW3FQYhG0evz6 8nETkv98Gn34JJPhWXPyzDhC6ri/yVDrwLuSlPRepCJ9Ac+4l3Jqc9r/f94lHQZBf5io gFWluSLzrXks4Io2b45dmXtJnNlpkkOxwy5VAmQHi/XSubxEvGdV768KL0unds46ToD0 GBSK8lWk7s7vpaIdA663rg8eohfEyTXP8ldkv/6HyH6XCJjT/6ldLGIVz2km532zaGlW DaJCo26JkUSdGI9X275IHVXRsPFMbqQLgxp7pqkU4bDftLhnsLXMZ0f9Gvn8LVIzTH3K mUoA== X-Gm-Message-State: AAQBX9dO5xRrjJteFMXPiv21EeIpL8MktJnryDgJ5RgeHfOnbWRfBzgs 2Xw9rxfaMYyQRq2Lqct95bc+eia06EjyZibzciUw2Q== 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-Spam-Status: No, score=0.0 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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