Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp1853248pxb; Fri, 5 Mar 2021 00:57:03 -0800 (PST) X-Google-Smtp-Source: ABdhPJwnPNiELICVlEebH38QbgQvxVGu38iGAZP93vTPVAVgRJwqPCrJiDcr9js04Ae+QVYVnLi4 X-Received: by 2002:a5d:93cc:: with SMTP id j12mr7283457ioo.15.1614934623237; Fri, 05 Mar 2021 00:57:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614934623; cv=none; d=google.com; s=arc-20160816; b=ZyOTcjrSraJlEvvwp7JaVCR1xcs8n5OIi6NE3NnYlPw+gyh7sOOZL2hmsjZDDJ32xa 6Z59EaFO1Rp6HYXRIuBjog/ih1vetjz+SzmiwB+8RLiQgsis0eEvxtshLFg7lSaddXnX l9141uYXl7Lrd9QcIdx+xBLOQ/bvpHvbircQhskv6yKLN7vB6ykNM/jPH6x8Kun+16RJ hr93480WI47LHyLU2OnvGa/FSEw69D/dK+QVAuwW7CLToRMpdD+PRd+b44pxbi7JLot5 5SlieirXxQPDABaCmxS1m62txZblj2CdNDyP2GkK/Ub6eb8o2vELsRqTDHtzvtjmz6an TF7w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=+oGdTg3Bg46MzYDlMYUSWvaZjU5cTg9BUOJ8sNBiu90=; b=mRY8ocQPylDITUppUXQ9HL4lTCxbGGt/EQmtPmd5xe6ZULMSuhYoz3JS5m8cc6YGDj O4N3bjPE9ZbQFfIiFVZ809QFLREj3cvHRSvTBEGOFHC4ZnWKfgQxvesrW5Ic0nUvI9ve 6Ggq3WaXRS33mCFSgyRKUXj8TKhheCJ2kHv2aKzVY2Y6jxWFHBEkkcOJbOrszHHBfjH5 LY6OMtmekJ7/JETE1StlgEWwurI3F0alEKd39W8OFDyZ1kEK4Dijr+/HGLv6u/CA1wR0 On4FyUIn0jBoH/ggpBvYZSpP/JD6BPJdqm4SEgJihQ3QH/wG+MYRZn9IstX53FfLyRyO Ieow== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jizmpC8c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id c13si1817996ilm.5.2021.03.05.00.56.49; Fri, 05 Mar 2021 00:57:03 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=jizmpC8c; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229670AbhCEIz4 (ORCPT + 99 others); Fri, 5 Mar 2021 03:55:56 -0500 Received: from mail.kernel.org ([198.145.29.99]:54832 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229651AbhCEIzo (ORCPT ); Fri, 5 Mar 2021 03:55:44 -0500 Received: by mail.kernel.org (Postfix) with ESMTPSA id 30DCC64FD4; Fri, 5 Mar 2021 08:55:43 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1614934543; bh=7xbUILjhJbNDQagScChcv4Gaofvy+5qY7cqgJdMS1mI=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=jizmpC8cyf2p86fDg7151oG6UzybEffAZy9DKN8JV38FNsckr24YhRLRN+OyshZOQ 0lnF6AMWjnwz3GHnAUOLnUOKPDxr3NsKOdEeEvfPpzXn1V03kq9wd2TV4OLrwAefTv RXbmBa0kPTCtb+0M0rZox32M05LUMPDe/rtC3w6k= Date: Fri, 5 Mar 2021 09:55:41 +0100 From: Greg KH To: Bartosz Golaszewski Cc: Geert Uytterhoeven , Joel Becker , Christoph Hellwig , Shuah Khan , Linus Walleij , Andy Shevchenko , Uwe =?iso-8859-1?Q?Kleine-K=F6nig?= , Kent Gibson , Jonathan Corbet , "open list:GPIO SUBSYSTEM" , Linux Kernel Mailing List , "open list:DOCUMENTATION" , Bartosz Golaszewski Subject: Re: [PATCH v2 08/12] drivers: export device_is_bound() Message-ID: References: <20210304102452.21726-1-brgl@bgdev.pl> <20210304102452.21726-9-brgl@bgdev.pl> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Mar 05, 2021 at 09:45:41AM +0100, Bartosz Golaszewski wrote: > On Fri, Mar 5, 2021 at 9:34 AM Greg KH wrote: > > > > On Fri, Mar 05, 2021 at 09:18:30AM +0100, Geert Uytterhoeven wrote: > > > CC Greg > > > > > > On Thu, Mar 4, 2021 at 11:30 AM Bartosz Golaszewski wrote: > > > > > > > > From: Bartosz Golaszewski > > > > > > > > Export the symbol for device_is_bound() so that we can use it in gpio-sim > > > > to check if the simulated GPIO chip is bound before fetching its driver > > > > data from configfs callbacks in order to retrieve the name of the GPIO > > > > chip device. > > > > > > > > Signed-off-by: Bartosz Golaszewski > > > > --- > > > > drivers/base/dd.c | 1 + > > > > 1 file changed, 1 insertion(+) > > > > > > > > diff --git a/drivers/base/dd.c b/drivers/base/dd.c > > > > index 9179825ff646..c62c02e3490a 100644 > > > > --- a/drivers/base/dd.c > > > > +++ b/drivers/base/dd.c > > > > @@ -353,6 +353,7 @@ bool device_is_bound(struct device *dev) > > > > { > > > > return dev->p && klist_node_attached(&dev->p->knode_driver); > > > > } > > > > +EXPORT_SYMBOL_GPL(device_is_bound); > > > > No. Please no. Why is this needed? Feels like someone is doing > > something really wrong... > > > > NACK. > > > > I should have Cc'ed you the entire series, my bad. > > This is the patch that uses this change - it's a new, improved testing > module for GPIO using configfs & sysfs as you (I think) suggested a > while ago: > > https://lkml.org/lkml/2021/3/4/355 > > The story goes like this: committing the configfs item registers a > platform device. Ick, no, stop there, that's not a "real" device, please do not abuse platform devices like that, you all know I hate this :( Use the virtbus code instead perhaps? > As far as I understand - there's no guarantee that > the device will be bound to a driver before the commit callback (or > more specifically platform_device_register_full() in this case) > returns so the user may try to retrieve the name of the device > immediately (normally user-space should wait for the associated uevent > but nobody can force that) by doing: > > mv /sys/kernel/config/gpio-sim/pending/foo /sys/kernel/config/gpio-sim/live/ > cat /sys/kernel/config/gpio-sim/live/foo/dev_name > > If the device is not bound at this point, we'll have a crash in the > kernel as opposed to just returning -ENODEV. How will the kernel crash? What has created the dev_name sysfs file before it is possible to be read from? That feels like the root problem. > Please advise on how to handle it without device_is_bound(). Please do not create sysfs files before they can be read from :) thanks, greg k-h