Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp3997673pxb; Tue, 17 Nov 2020 08:46:12 -0800 (PST) X-Google-Smtp-Source: ABdhPJx4qs+gezeuI+OXYV5OffvdRqnWzR3/Xme/uDC8MY/MfN+72IQgku0ipAhE1yiS3orb0elP X-Received: by 2002:a17:906:bce6:: with SMTP id op6mr19839945ejb.2.1605631572340; Tue, 17 Nov 2020 08:46:12 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605631572; cv=none; d=google.com; s=arc-20160816; b=lnKH5iRwS4B2sJB9pHzTcpSz1cf04fM8EsGLmzgLzx7g5fbUwr2kv6hcgBPiIYYCTy IxXzfMBbMNKKLxtshHznijgfQ11XQfZpliXJi0ZYWiMMZ781xgWeEpxlRJgMqd+ts3tL 7xTVRp6yoPuQdPE//WycQ4Fuy4j/JJaBguuBalYAQY0tOlsQl+u351qIwqrs8WxWhCsy d4Waq8fBPzmdslesoWznoituQeGcGUeyK7EyPlm5ZEiDddNZKN7MvRpsoRxlOzUdNboA GpITEcfcSJffnZlCkRViTbZGZ81EjYIBBV9fwx2btAconLL6UeuzxupS3v/UPM39Z+1z pLjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature; bh=gOq8PtsLPl8YcQWlI24WYrhhhkl3V8mDV43l6Fi6+4A=; b=XZHsK9FHz3Lt9U5nwPLdRQBZmr7Jhh0/csYo0v04wgbYvmkLdkXiGfFZbj5xqwF79h sBHISQjI1IyySWqGSdsxsHXAzkX7kypIGcy/jB3hMbKKqC+vVvJbF8Ltiv0G/icUK9pG vqPJNZlR0SHWL31KV0BysHoJ5ofh9eQKIxBxmVQBerHg/m6/NXXvUYeu7PaEFYLdnqgs nPaBmQVISHlc1XHlL2qx9joy+EpyQWOCLj4RgGWz5Uuk1oCcUzxHAXUAq+BMMuiCmyh2 6Omo+clQMHb9Xk4OQlVun7DRwNQfcJq5bVPJQRXgcu/lBKhT97YqE+cLc7sSTa6fC2H5 xEPw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b="txKTnx/g"; 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=st.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id y16si1479662edm.321.2020.11.17.08.45.48; Tue, 17 Nov 2020 08:46:12 -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=@st.com header.s=STMicroelectronics header.b="txKTnx/g"; 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=st.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727439AbgKQQoN (ORCPT + 99 others); Tue, 17 Nov 2020 11:44:13 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:57112 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1727010AbgKQQoN (ORCPT ); Tue, 17 Nov 2020 11:44:13 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.42/8.16.0.42) with SMTP id 0AHGLdbS011324; Tue, 17 Nov 2020 17:44:07 +0100 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=st.com; h=subject : to : cc : references : from : message-id : date : mime-version : in-reply-to : content-type : content-transfer-encoding; s=STMicroelectronics; bh=gOq8PtsLPl8YcQWlI24WYrhhhkl3V8mDV43l6Fi6+4A=; b=txKTnx/gC3wOu0FfqhLo0//opUonK0mem30dBKDvihXJ1+Khhs56A0GlEIthIFSTxt4F JDhrNmNOJdcHBV9ibpbUu5iEvAr0yaGkHPjsBVUb+KyGFje3Ar6nlTcUJfmCVyKgVIqA 4W2LRQ8a/vvbyUOWSHApoaDqmvOnzpk2dKjuJDR/BoiCH/tDUc+KVZPaSzr2vg/pPQNF LudocrTE6IG75W9fOUJvwphi+hTox6l7Vl312ccEgrbVTBD3p86ty5vEFyikrFgqlecD KyJFxFMs1Mp0X1RA62Aj9GvDZ8mwwPukRL6yLPAvINODIIE8WapNQAkwSD6jHXnQNNrU QQ== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-00178001.pphosted.com with ESMTP id 34t70gjndt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Tue, 17 Nov 2020 17:44:07 +0100 Received: from euls16034.sgp.st.com (euls16034.sgp.st.com [10.75.44.20]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id EBFBB100034; Tue, 17 Nov 2020 17:44:06 +0100 (CET) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by euls16034.sgp.st.com (STMicroelectronics) with ESMTP id D97A8215D13; Tue, 17 Nov 2020 17:44:06 +0100 (CET) Received: from lmecxl0889.lme.st.com (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1473.3; Tue, 17 Nov 2020 17:44:05 +0100 Subject: Re: [PATCH v5 8/8] rpmsg: Turn name service into a stand alone driver To: Guennadi Liakhovetski CC: Mathieu Poirier , "ohad@wizery.com" , "bjorn.andersson@linaro.org" , "linux-remoteproc@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20201111144942.GA6403@ubuntu> <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> From: Arnaud POULIQUEN Message-ID: Date: Tue, 17 Nov 2020 17:44:05 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: <20201117160330.GA15538@ubuntu> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 7bit X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG3NODE1.st.com (10.75.127.7) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:6.0.312,18.0.737 definitions=2020-11-17_06:2020-11-17,2020-11-17 signatures=0 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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); #endif Thanks, Arnaud > > Thanks > Guennadi >