Received: by 2002:a05:6358:1087:b0:cb:c9d3:cd90 with SMTP id j7csp996094rwi; Thu, 27 Oct 2022 09:53:29 -0700 (PDT) X-Google-Smtp-Source: AMsMyM6dLMCtGRBE6Op0zD5RbI0ZTRfcMTMzPexizOI8jbi/VKIuH7WTsmqj98/TAtApeP3w7Asa X-Received: by 2002:a05:6402:5191:b0:462:a5f1:4599 with SMTP id q17-20020a056402519100b00462a5f14599mr2620610edd.35.1666889609769; Thu, 27 Oct 2022 09:53:29 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666889609; cv=none; d=google.com; s=arc-20160816; b=wCUU49gTmsIvigiLUm+gkP+9dS1m37lKwwCTe6U4qRgXIkPAdgSTicdscbQX4FKmxG 0MLmCcFajV568n9WLs5gim1U1n9vlTSSBNs+e3AlNWkQaP43y1euWMH6M54sA12hirNl 6qXCWllyuGcQcoqXBVb3zDohC9zBvuFPvgFsoj3MrzSxSxGQEcq8mP7IQAOjRUivyviQ 2xGhtM3wO9ugDm86CT9/XibAxwH1hNItzLd9MwsPa83dtox3d/T3jrUbnyk0fiZ7mIFR 7GFeTTeRHC4Laotlw5ooJrelMTp+jRWtSk6B2Z7xSdNrPWMPWfzNq7R94tSMXVwazeIb V8Cw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:date:cc:to:from:subject :message-id:dkim-signature:dkim-signature; bh=Kxz9+oecIDUzEW8MxjtD3nJA+i4Plx4+UwXBtItquao=; b=eCPL+6cKFWhJFp/WGWg9bmm1wmI4Rs27nov9LFfyzu4cXkoTgdJrfs9yqg3l3A/6q2 GDapCJU6zofYb3YX4ZCGESCoSmSuL+eSZFUEr6hajb26ajCy5SJVUG6iO9r4DWFGrzs8 j5fj+Hkv7IqUqtWk1OCN3cDy3nFLTS/G1RT+jGQ5yTz9hxPDP2XhnxCpPXH4Yry7PARv aHtKaT1aheofy8RLodCebs7FFpotZs24tEkamjiiTJZsW+NZdnlv9s5rmVLmYmcHexpC +9ZBiufFdDAzu2Mtz+rgWx8opu04dv0fgztNKWhjqwTTOA9XGUGC6hT+M5+csRU2bPEo Rrdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@tq-group.com header.s=key1 header.b=aApm2BeQ; dkim=pass header.i=@tq-group.com header.s=key1 header.b=G7fqgSCQ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id hb33-20020a170907162100b0078dcc87b1c4si2025367ejc.923.2022.10.27.09.53.14; Thu, 27 Oct 2022 09:53:29 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-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=@tq-group.com header.s=key1 header.b=aApm2BeQ; dkim=pass header.i=@tq-group.com header.s=key1 header.b=G7fqgSCQ; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=tq-group.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236613AbiJ0Qdl (ORCPT + 65 others); Thu, 27 Oct 2022 12:33:41 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40606 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S234812AbiJ0Qdk (ORCPT ); Thu, 27 Oct 2022 12:33:40 -0400 Received: from mx1.tq-group.com (mx1.tq-group.com [93.104.207.81]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1C80BAB80F; Thu, 27 Oct 2022 09:33:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1666888418; x=1698424418; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=Kxz9+oecIDUzEW8MxjtD3nJA+i4Plx4+UwXBtItquao=; b=aApm2BeQrV0vCY5aAxCim9zu3/A12myoXypEywsAu+yiEih7rlrCdW9r CCWPjxJvUcG746AaYzcuUu0Ey1OvlUeNrzMburinKI51gQ39qfQKsboex tJr+C0KM52ZIB/rD9xV3/U52ciGIvVSh2sCTuv0D/LwIbdNa+T4Xwf6HY kp/fUN3DbXn26gl1CBbdMQpzA2+CEEUf42g+IjTxjFq0CVSPEzkyqxs6j mZEGxq/2TevHqcRPmB109wupcDOy3rCBpOMCDr3WYjKt+rhrKFUM507VO Voh4HrRy+hU8IVhFxJpgAdOWcsyg9M2ooWN0hAqvfjoZGImR6EV91Rm3M A==; X-IronPort-AV: E=Sophos;i="5.95,218,1661810400"; d="scan'208";a="27019743" Received: from unknown (HELO tq-pgp-pr1.tq-net.de) ([192.168.6.15]) by mx1-pgp.tq-group.com with ESMTP; 27 Oct 2022 18:33:36 +0200 Received: from mx1.tq-group.com ([192.168.6.7]) by tq-pgp-pr1.tq-net.de (PGP Universal service); Thu, 27 Oct 2022 18:33:36 +0200 X-PGP-Universal: processed; by tq-pgp-pr1.tq-net.de on Thu, 27 Oct 2022 18:33:36 +0200 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=tq-group.com; i=@tq-group.com; q=dns/txt; s=key1; t=1666888416; x=1698424416; h=message-id:subject:from:to:cc:date:in-reply-to: references:mime-version:content-transfer-encoding; bh=Kxz9+oecIDUzEW8MxjtD3nJA+i4Plx4+UwXBtItquao=; b=G7fqgSCQ4LBe0RUEM5MDckqDb5Y35BVUvrdTdJNQMi0tilvpaKJ6wpOY Yldo4MzaTyx8VYqPFynHIQ2qzu9Nuj4+nPi9I3P7p+XsQo1GJuQAC8cSV RphK9S/IqJWwKd8vPvF4QXLTYdsQxVtAlkEZsbQ2F2n5K/09RQGbMW5j+ KtEkRsY8+ZPoF5NKFsVQb3rvrnm+25B6i6jjm9Btqrv4jXFgTPSnbjqRS EpDYr2L5OQWCXQVJvHyAYEVXIYz2xkZPKbwcDNjt95J/a8LP36QbgxdYY 88/6nA3ByG9ZvdA19QVYISSM4u+3ZnbQPcTs5QXIMa67kzdTlT1cqE1Re A==; X-IronPort-AV: E=Sophos;i="5.95,218,1661810400"; d="scan'208";a="27019742" Received: from vtuxmail01.tq-net.de ([10.115.0.20]) by mx1.tq-group.com with ESMTP; 27 Oct 2022 18:33:36 +0200 Received: from schifferm-ubuntu (unknown [192.168.66.106]) by vtuxmail01.tq-net.de (Postfix) with ESMTPA id BB624280056; Thu, 27 Oct 2022 18:33:35 +0200 (CEST) X-CheckPoint: {635AB2DD-2-C1A14347-CAD711DE} X-MAIL-CPID: 2A0551D518828FB9A5B2DD3E1D5C90C0_1 X-Control-Analysis: str=0001.0A782F26.635AB2E0.001D,ss=1,re=0.000,recu=0.000,reip=0.000,cl=1,cld=1,fgs=0 Message-ID: Subject: Re: [RFC 1/5] misc: introduce notify-device driver From: Matthias Schiffer To: Greg Kroah-Hartman Cc: Arnd Bergmann , linux-kernel@vger.kernel.org, linux-bluetooth@vger.kernel.org, linux-wireless@vger.kernel.org, netdev@vger.kernel.org, devicetree@vger.kernel.org, linux@ew.tq-group.com Date: Thu, 27 Oct 2022 18:33:33 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" User-Agent: Evolution 3.36.5-0ubuntu1 MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,SPF_HELO_NONE,SPF_PASS autolearn=ham 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-wireless@vger.kernel.org On Wed, 2022-10-26 at 16:37 +0200, Greg Kroah-Hartman wrote: > On Wed, Oct 26, 2022 at 03:15:30PM +0200, Matthias Schiffer wrote: > > A notify-device is a synchronization facility that allows to query > > "readiness" across drivers, without creating a direct dependency between > > the driver modules. The notify-device can also be used to trigger deferred > > probes. > > > > Signed-off-by: Matthias Schiffer > > --- > > drivers/misc/Kconfig | 4 ++ > > drivers/misc/Makefile | 1 + > > drivers/misc/notify-device.c | 109 ++++++++++++++++++++++++++++++++++ > > include/linux/notify-device.h | 33 ++++++++++ > > 4 files changed, 147 insertions(+) > > create mode 100644 drivers/misc/notify-device.c > > create mode 100644 include/linux/notify-device.h > > > > diff --git a/drivers/misc/Kconfig b/drivers/misc/Kconfig > > index 358ad56f6524..63559e9f854c 100644 > > --- a/drivers/misc/Kconfig > > +++ b/drivers/misc/Kconfig > > @@ -496,6 +496,10 @@ config VCPU_STALL_DETECTOR > > > > If you do not intend to run this kernel as a guest, say N. > > > > +config NOTIFY_DEVICE > > + tristate "Notify device" > > + depends on OF > > + > > source "drivers/misc/c2port/Kconfig" > > source "drivers/misc/eeprom/Kconfig" > > source "drivers/misc/cb710/Kconfig" > > diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile > > index ac9b3e757ba1..1e8012112b43 100644 > > --- a/drivers/misc/Makefile > > +++ b/drivers/misc/Makefile > > @@ -62,3 +62,4 @@ obj-$(CONFIG_HI6421V600_IRQ) += hi6421v600-irq.o > > obj-$(CONFIG_OPEN_DICE) += open-dice.o > > obj-$(CONFIG_GP_PCI1XXXX) += mchp_pci1xxxx/ > > obj-$(CONFIG_VCPU_STALL_DETECTOR) += vcpu_stall_detector.o > > +obj-$(CONFIG_NOTIFY_DEVICE) += notify-device.o > > diff --git a/drivers/misc/notify-device.c b/drivers/misc/notify-device.c > > new file mode 100644 > > index 000000000000..42e0980394ea > > --- /dev/null > > +++ b/drivers/misc/notify-device.c > > @@ -0,0 +1,109 @@ > > +// SPDX-License-Identifier: GPL-2.0-or-later > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +static void notify_device_release(struct device *dev) > > +{ > > + of_node_put(dev->of_node); > > + kfree(dev); > > +} > > + > > +static struct class notify_device_class = { > > + .name = "notify-device", > > + .owner = THIS_MODULE, > > + .dev_release = notify_device_release, > > +}; > > + > > +static struct platform_driver notify_device_driver = { [Pruning the CC list a bit, to avoid clogging people's inboxes] > > Ick, wait, this is NOT a platform device, nor driver, so it shouldn't be > either here. Worst case, it's a virtual device on the virtual bus. This part of the code is inspired by mac80211_hwsim, which uses a platform driver in a similar way, for a plain struct device. Should this rather use a plain struct device_driver? Also, what's the virtual bus? Grepping the Linux code and documentation didn't turn up anything. > > But why is this a class at all? Classes are a representation of a type > of device that userspace can see, how is this anything that userspace > cares about? Makes sense, I will remove the class. > > Doesn't the device link stuff handle all of this type of "when this > device is done being probed, now I can" problems? Why is a whole new > thing needed? The issue here is that (as I understand it) the device link and deferred probing infrastructore only cares about whether the supplier device has been probed successfully. This is insuffient in the case of the dependency between mwifiex and hci_uart/hci_mrvl that I want to express: mwifiex loads its firmware asynchronously, so finishing the mwifiex probe is too early to retry probing the Bluetooth driver. While mwifiex does create a few devices (ieee80211, netdevice) when the firmware has loaded, none of these bind to a driver, so they don't trigger the deferred probes. Using their existence as a condition for allowing the Bluetooth driver to probe also seems ugly too me (ieee80211 currently can't be looked up by OF node, and netdevices can be created and deleted dynamically). Because of this, I came to the conclusion that creating and binding a device specifically for this purpose is a good solution, as it solves two problems at once: - The driver bind triggers deferred probes - The driver allows to look up the device by OF node Integrating this with device links might make sense as well, but I haven't looked much into that yet. Thanks, Matthias > > thanks, > > greg k-h