Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp4259755pxb; Tue, 17 Nov 2020 16:09:41 -0800 (PST) X-Google-Smtp-Source: ABdhPJwOwfZQTHiPcf/X8d3fIKfS9u3Kv/v0lDPZ33tWYgnZfuHPovrBHxsIQvXkX4CMyFGY7Id2 X-Received: by 2002:aa7:d94c:: with SMTP id l12mr23806561eds.355.1605658181712; Tue, 17 Nov 2020 16:09:41 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605658181; cv=none; d=google.com; s=arc-20160816; b=p/4j4UDtm3w/XO20jGNrcAquuxBbvacJOeWTnWdAXTTydRtJRfo1vCobuxRCLY3XKJ +0PtDdA5f0QD/4eJaxvrL1RUGdV6z7ofA81czDqcdZxdBzfxcH6sMRwPbNqx0xSCDwln +W4WY9mqE37oKam6k2ZpxPapOBKXPxuD1Bp7Tzpmom4y1cm2R7i5Wzsn4yc/xBY8mIHJ 4g25cISlHFAMlNgd6ooNxqkOCO8afIm/jml/5InNjkQ+1ajud/xeyH+X82Va5sqb0C6X +SefwIoRj85dT032a1FlATwwawAIGKzTMunC2HaQ5bgE5VMJjMHm1glZNMnCFXXBlQyo iwsA== 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=LbHoYkDshsZNDnVClBGFOLqaI4R4jBMVshvMjXXS/SE=; b=ShQaTVlbmMijd+zJdyn7kfvw+mMRREbZvdbuwpJkYeAEVlF6j/J6RmqmDb/uSlBBpE zHJXu5TYeNPAad5hZo8k8zoieljehsaV4UaWsxuj/oxPD91lRwrsC7RIMrr5N4hPB2iN 1cofer71GvfDvNo7mwreGuLOqVE+Bnj8Z3UA0KU1uwYQOeDjMwUYlTON3q+U194iuywP /7DdgVn/NqYfUj5DFSRCo+dYSsILxLVBwU/llba/4WCZhfab7JbYD0YoTtObnMWUDCdA 2Mz914yCZU6KLMjnagQtuBfd+0UZ8HgNt7PCUWCKChilrQuNmjc2+eY4AdYTvo/7pv3g 9wlg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=sYKoNr7a; 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=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id ob22si2089276ejb.735.2020.11.17.16.09.18; Tue, 17 Nov 2020 16:09:41 -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=@linaro.org header.s=google header.b=sYKoNr7a; 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=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728385AbgKRAGu (ORCPT + 99 others); Tue, 17 Nov 2020 19:06:50 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726205AbgKRAGu (ORCPT ); Tue, 17 Nov 2020 19:06:50 -0500 Received: from mail-pj1-x1044.google.com (mail-pj1-x1044.google.com [IPv6:2607:f8b0:4864:20::1044]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5E3F0C0613CF for ; Tue, 17 Nov 2020 16:06:50 -0800 (PST) Received: by mail-pj1-x1044.google.com with SMTP id t12so90756pjq.5 for ; Tue, 17 Nov 2020 16:06:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=LbHoYkDshsZNDnVClBGFOLqaI4R4jBMVshvMjXXS/SE=; b=sYKoNr7a0tDbSEHIPgnmUJvh5wuPFq7BuhpbIsvk5MbdedI1K4AY1d5kJ0F0UzHH2u VoL7b0W+czcz8FNRWscvjogwdoa1xogZLEVWEW69P3QBHk7WrBM6zJ/oiT4PxA00rIxM R3Tre+W3SY8EFuaBEhrCiUXMtoSPk78bxz8BtTLOlNicEEhMYKbfs2Fbq9tq9Tg+ovOd 6NOporZbyLb99nkfRHlQYgQf/DzxcP9olswA868ClDX1GuXHm026eNKl6J6TWLMU63ci 42tPX9GNXr9a3ZxlcLFrCaIt6hibXFj5zsdMKzxOuwp+/rOB7oRkA8F/kK1A8YWoJZn3 hfkw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=LbHoYkDshsZNDnVClBGFOLqaI4R4jBMVshvMjXXS/SE=; b=NkpcjLGzHtWtCP1zH7sPnKu8gjiRKmgvt+FgsR1N/m4z//lDEljColyzjhb2gA9JCT 37VsqyUOmq9NhmsRetptcHHH4aCFTiK40rWFcK+XXJtq0jhD0D1afIxonoWq92u6h5sA BnV4HQGThaWm7+/oUmXvJJlOz23hhbaBX7L3j0lmpXIal5PXUF1gYYB3g2Gkmbf+Ber+ 2PjO3p2QZarMg8Xp4hM8PEMqbl2qv42udpAYGF4oQE/d6zM7Z0IT7ii7fwPOuqqhAQdO l86wtGg2GH3M9K+Jo8lLnFH85OStHProDYrV3vljt6lMCIaiStsAdL3SWLy+1J17VSEJ pH5A== X-Gm-Message-State: AOAM533sYYy6EnaPeMVoYiSC8AXb3x6HWrXkXiUpdDwAJevgUVnj/WLe 09kaO2FnRyhBvaHnceLlYm/Krw== X-Received: by 2002:a17:90a:c0f:: with SMTP id 15mr1457749pjs.148.1605658009680; Tue, 17 Nov 2020 16:06:49 -0800 (PST) Received: from xps15 (S0106889e681aac74.cg.shawcable.net. [68.147.0.187]) by smtp.gmail.com with ESMTPSA id l1sm1519511pgg.4.2020.11.17.16.06.48 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 17 Nov 2020 16:06:48 -0800 (PST) Date: Tue, 17 Nov 2020 17:06:47 -0700 From: Mathieu Poirier To: Arnaud POULIQUEN Cc: Guennadi Liakhovetski , "ohad@wizery.com" , "bjorn.andersson@linaro.org" , "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" Subject: Re: [PATCH v5 8/8] rpmsg: Turn name service into a stand alone driver Message-ID: <20201118000647.GA4113759@xps15> References: <20201112115115.GA11069@ubuntu> <945f377d-1975-552d-25b2-1dc25d3c3a46@st.com> <2d25d1aa-bd8a-f0db-7888-9f72edc9f687@st.com> <20201116151028.GA1519@ubuntu> <20201116224003.GC3892875@xps15> <50549519-d9ff-9048-a3d8-dab02bfda096@st.com> <20201117160330.GA15538@ubuntu> 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 Tue, Nov 17, 2020 at 05:44:05PM +0100, Arnaud POULIQUEN wrote: > > > On 11/17/20 5:03 PM, Guennadi Liakhovetski wrote: > > On Tue, Nov 17, 2020 at 12:42:30PM +0100, Arnaud POULIQUEN wrote: > > > > [snip] > > > >> diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c > >> index 5bda7cb44618..80c2cc23bada 100644 > >> --- a/drivers/rpmsg/rpmsg_ns.c > >> +++ b/drivers/rpmsg/rpmsg_ns.c > >> @@ -55,6 +55,39 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void > >> *data, int len, > >> return 0; > >> } > >> > >> +/** > >> + * rpmsg_ns_register_device() - register name service device based on rpdev > >> + * @rpdev: prepared rpdev to be used for creating endpoints > >> + * > >> + * This function wraps rpmsg_register_device() preparing the rpdev for use as > >> + * basis for the rpmsg name service device. > >> + */ > >> +int rpmsg_ns_register_device(struct rpmsg_device *rpdev) > >> +{ > >> +#ifdef MODULES > >> + int ret; > >> + struct module *rpmsg_ns; > >> + > >> + mutex_lock(&module_mutex); > >> + rpmsg_ns = find_module(KBUILD_MODNAME); > >> + mutex_unlock(&module_mutex); > >> + > >> + if (!rpmsg_ns) { > >> + ret = request_module(KBUILD_MODNAME); > > > > Is this code requesting the module in which it is located?.. I must be missing > > something... > > Right this is stupid...Thanks to highlight this! > > That being said, your remark is very interesting: we need to load the module to > access to this function. This means that calling this function ensures that the > module is loaded. In this case no need to add the piece of code to find > module... here is the call stack associated (associated patch is available below): > > > (rpmsg_ns_probe+0x5c/0xe0 [rpmsg_ns]) > [ 11.858748] [] (rpmsg_ns_probe [rpmsg_ns]) from [] > (rpmsg_dev_probe+0x14c/0x1b0 [rpmsg_core]) > [ 11.869047] [] (rpmsg_dev_probe [rpmsg_core]) from [] > (really_probe+0x208/0x4f0) > [ 11.878117] [] (really_probe) from [] > (driver_probe_device+0x78/0x16c) > [ 11.886404] [] (driver_probe_device) from [] > (bus_for_each_drv+0x84/0xd0) > [ 11.894887] [] (bus_for_each_drv) from [] > (__device_attach+0xf0/0x188) > [ 11.903142] [] (__device_attach) from [] > (bus_probe_device+0x84/0x8c) > [ 11.911314] [] (bus_probe_device) from [] > (device_add+0x3b0/0x7b0) > [ 11.919227] [] (device_add) from [] > (rpmsg_register_device+0x54/0x88 [rpmsg_core]) > [ 11.928541] [] (rpmsg_register_device [rpmsg_core]) from > [] (rpmsg_probe+0x298/0x3c8 [virtio_rpmsg_bus]) > [ 11.939748] [] (rpmsg_probe [virtio_rpmsg_bus]) from [] > (virtio_dev_probe+0x1f4/0x2c4) > [ 11.949377] [] (virtio_dev_probe) from [] > (really_probe+0x208/0x4f0) > [ 11.957454] [] (really_probe) from [] > (driver_probe_device+0x78/0x16c) > [ 11.965710] [] (driver_probe_device) from [] > (device_driver_attach+0x58/0x60) > [ 11.974574] [] (device_driver_attach) from [] > (__driver_attach+0xb4/0x154) > [ 11.983177] [] (__driver_attach) from [] > (bus_for_each_dev+0x78/0xc0) > [ 11.991344] [] (bus_for_each_dev) from [] > (bus_add_driver+0x170/0x20c) > [ 11.999600] [] (bus_add_driver) from [] > (driver_register+0x74/0x108) > [ 12.007693] [] (driver_register) from [] > (rpmsg_init+0x10/0x1000 [virtio_rpmsg_bus]) > [ 12.017168] [] (rpmsg_init [virtio_rpmsg_bus]) from [] > (do_one_initcall+0x58/0x2bc) > [ > > This would make the patch very simple. I tested following patch on my platform, > applying it, i do not reproduce the initial issue. > > > diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig > index c3fc75e6514b..1394114782d2 100644 > --- a/drivers/rpmsg/Kconfig > +++ b/drivers/rpmsg/Kconfig > @@ -71,5 +71,6 @@ config RPMSG_VIRTIO > depends on HAS_DMA > select RPMSG > select VIRTIO > + select RPMSG_NS > > endmenu > diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c > index 5bda7cb44618..5867281188de 100644 > --- a/drivers/rpmsg/rpmsg_ns.c > +++ b/drivers/rpmsg/rpmsg_ns.c > @@ -55,6 +55,24 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void > *data, int len, > return 0; > } > > +/** > + * rpmsg_ns_register_device() - register name service device based on rpdev > + * @rpdev: prepared rpdev to be used for creating endpoints > + * > + * This function wraps rpmsg_register_device() preparing the rpdev for use as > + * basis for the rpmsg name service device. > + */ > +int rpmsg_ns_register_device(struct rpmsg_device *rpdev) > +{ > + strcpy(rpdev->id.name, KBUILD_MODNAME); > + rpdev->driver_override = KBUILD_MODNAME; > + rpdev->src = RPMSG_NS_ADDR; > + rpdev->dst = RPMSG_NS_ADDR; > + > + return rpmsg_register_device(rpdev); > +} > +EXPORT_SYMBOL(rpmsg_ns_register_device); > + > static int rpmsg_ns_probe(struct rpmsg_device *rpdev) > { > struct rpmsg_endpoint *ns_ept; > @@ -80,7 +98,7 @@ static int rpmsg_ns_probe(struct rpmsg_device *rpdev) > } > > static struct rpmsg_driver rpmsg_ns_driver = { > - .drv.name = "rpmsg_ns", > + .drv.name = KBUILD_MODNAME, > .probe = rpmsg_ns_probe, > }; > > @@ -104,5 +122,5 @@ module_exit(rpmsg_ns_exit); > > MODULE_DESCRIPTION("Name service announcement rpmsg Driver"); > MODULE_AUTHOR("Arnaud Pouliquen "); > -MODULE_ALIAS("rpmsg_ns"); > +MODULE_ALIAS("rpmsg:" KBUILD_MODNAME); > MODULE_LICENSE("GPL v2"); > diff --git a/include/linux/rpmsg/ns.h b/include/linux/rpmsg/ns.h > index bdc1ea278814..68eac2b42075 100644 > --- a/include/linux/rpmsg/ns.h > +++ b/include/linux/rpmsg/ns.h > @@ -41,21 +41,6 @@ enum rpmsg_ns_flags { > /* Address 53 is reserved for advertising remote services */ > #define RPMSG_NS_ADDR (53) > > -/** > - * rpmsg_ns_register_device() - register name service device based on rpdev > - * @rpdev: prepared rpdev to be used for creating endpoints > - * > - * This function wraps rpmsg_register_device() preparing the rpdev for use as > - * basis for the rpmsg name service device. > - */ > -static inline int rpmsg_ns_register_device(struct rpmsg_device *rpdev) > -{ > - strcpy(rpdev->id.name, "rpmsg_ns"); > - rpdev->driver_override = "rpmsg_ns"; > - rpdev->src = RPMSG_NS_ADDR; > - rpdev->dst = RPMSG_NS_ADDR; > - > - return rpmsg_register_device(rpdev); > -} > +int rpmsg_ns_register_device(struct rpmsg_device *rpdev); I confirm that all this is working as expected - I will send a new revision of this set tomorrow afternoon. Guennadi, can I add a Co-developed-by and Signed-off-by with your name on the patch? > > #endif > > Thanks, > Arnaud > > > > > Thanks > > Guennadi > >