From patchwork Tue Sep 22 00:09:51 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791291 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 80DD2112E for ; Tue, 22 Sep 2020 00:10:05 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 65C6323A75 for ; Tue, 22 Sep 2020 00:10:05 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="iLTt1Smx" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728881AbgIVAKE (ORCPT ); Mon, 21 Sep 2020 20:10:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46394 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727390AbgIVAKD (ORCPT ); Mon, 21 Sep 2020 20:10:03 -0400 Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7415EC061755 for ; Mon, 21 Sep 2020 17:10:03 -0700 (PDT) Received: by mail-pf1-x442.google.com with SMTP id b124so10758512pfg.13 for ; Mon, 21 Sep 2020 17:10:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=pbzzrbDhZx0uwATrkyhoLM+A2nR9L970PZGfpM6TTB0=; b=iLTt1Smx7uFfhdTUhKzZxeN8wtr6uy46RYMNIjhtQ3bDtc68W1BwCuFibdvTkwEJug XF+5zdjbf18nXVXpu9A9qP3gf8apyvHwkjM57nGIjy49PCwvm3hwDuDfwNYxtL3t0Mmn izcEWc8TWIdeWjr1jnkAQklTnCsfbdP6F6lNYcoJhsAZZIQ4UahHpJkpQQGpe5AZJ4SL mv4Lp23DVrlkj/FSRxCqlbf6Nv8tKBW7jr8W/Mdf0GWxXaQQY/YlnEEJrSNW47Nt7729 w0oFej/PBzAi62lkTNiKF+r2njj1iIKwYcUSjrfQlX1LNQyw9aTnKGj29PZmZgYWN9xI 8r3g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=pbzzrbDhZx0uwATrkyhoLM+A2nR9L970PZGfpM6TTB0=; b=bOejWKYrrcZwMb9NNYnzdT5Z2qHhCFINKwp/etiQBiQ8ffGI1yPHrs0xvh56GxY7/I CxQEA2FlExh3PyqIksM2r5HFHP/zbYOYKvblZepD5S2uxder0t4+sd3kbdrnloEBoOZn B9HSwZM1cCeU5h+VO8c+hNx6cTHV6qdnDad+KO9+00dEn9TcHM/+koRgJ9Z0GKfuyeDZ fk18VXmpkn7u2mhD/Ym3ob/3J3VbCwCqRVfvn3ej7OSoDlwjbelNS5tOjs2H73M6DyY9 b36IJC0DHpTvNr26Hf1y/YX5eiNiLfAVDnGLrf4FjPGxrfhTQg7TR0mcVguEiHtDXiGV LH8A== X-Gm-Message-State: AOAM531/0W7FlrmBvYt+V7ykaprUHafyCSkhLhmBGK7OidW/qHdoEdU5 GYI8ipG9OR/1eYUptRE4kcZQk6AnizitoA== X-Google-Smtp-Source: ABdhPJwWRwcrPfvgvFCP11lvXOSs/9uM+0kqDcOin22KRsPJDvt+AWNRKrEPKCZDZ33UblhdqVG1wg== X-Received: by 2002:a62:fb1a:0:b029:142:2501:39f9 with SMTP id x26-20020a62fb1a0000b0290142250139f9mr1796480pfm.72.1600733403024; Mon, 21 Sep 2020 17:10:03 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.02 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:02 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 01/10] rpmsg: virtio: rename rpmsg_create_channel Date: Mon, 21 Sep 2020 18:09:51 -0600 Message-Id: <20200922001000.899956-2-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Arnaud Pouliquen Rename the internal function as it is internal, and as the name will be used in rpmsg_core. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/virtio_rpmsg_bus.c | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 7d7ed4e5cce7..e8d55c8b9cbf 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -395,8 +395,9 @@ static void virtio_rpmsg_release_device(struct device *dev) * this function will be used to create both static and dynamic * channels. */ -static struct rpmsg_device *rpmsg_create_channel(struct virtproc_info *vrp, - struct rpmsg_channel_info *chinfo) +static struct rpmsg_device * +__rpmsg_create_channel(struct virtproc_info *vrp, + struct rpmsg_channel_info *chinfo) { struct virtio_rpmsg_channel *vch; struct rpmsg_device *rpdev; @@ -869,7 +870,7 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, if (ret) dev_err(dev, "rpmsg_destroy_channel failed: %d\n", ret); } else { - newch = rpmsg_create_channel(vrp, &chinfo); + newch = __rpmsg_create_channel(vrp, &chinfo); if (!newch) dev_err(dev, "rpmsg_create_channel failed\n"); } From patchwork Tue Sep 22 00:09:52 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791295 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 1EC5A112C for ; Tue, 22 Sep 2020 00:10:12 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id F004823A74 for ; Tue, 22 Sep 2020 00:10:11 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="cTp/+Bcc" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729102AbgIVAKL (ORCPT ); Mon, 21 Sep 2020 20:10:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46398 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727390AbgIVAKE (ORCPT ); Mon, 21 Sep 2020 20:10:04 -0400 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 A4221C061755 for ; Mon, 21 Sep 2020 17:10:04 -0700 (PDT) Received: by mail-pj1-x1044.google.com with SMTP id md22so525823pjb.0 for ; Mon, 21 Sep 2020 17:10:04 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=p5nUSjWR/Mldt926WccD+ixHckUqZWbkV5NJAtOcn6E=; b=cTp/+Bcc9YipIXPEO6XZqsd/9WvRKr1y2j/W4LPFU28CM2WSQ/Ep7N1jSM1X6AVHKp SZakUDkRjaXctBfz3Q4IlRlupml4Sdfu2jyqr8Qsmcv5wawvLtL3hJKB8UTg3BhgPp27 5lTO32++TnYxQWUOwdWy5BODlro1iGLPyhbbpGvubse+rV5yfphlaBS4X2BdZDzghY0N yQiLOF+sFVnD18V3EwMUV+xchQ44Oyko9fDSGIeO5vwdgo9xUncbCa+iN9Dg4VanGnem mriRnDhGBSOjPbKvwxlikyha3I9qICggJ1H4nG4IugXCIff+Qw2tWHazX4M5LOUEKbCo bj0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=p5nUSjWR/Mldt926WccD+ixHckUqZWbkV5NJAtOcn6E=; b=uhbyQBODCMKIn90D2kB828J5n8RrEaC+tsRXJgU5jm+lPzDIjpaJ3GcXnmjeFk1qkG U8NCL7DqhWdYhB6k5LoaY5mjaBcaE8jHPYJPFz4r/ctvaD9YFRS8AHRQ5gKKV0k/iD8F qi6LJ7eqlDAt+W9DCyjcVty3HeTXs15aJ7Y8FBm0KXmVieD5A5wcQjz3j9Zr0lflSB44 Ddw3RUlz0Dm5d9n3sJCHlFBt1z9bP6VlwTSth5MUjf98C5yPOwOzZCs2NHYdkuvzWcgW XcfGUBj/A4oq3pI2Yl0NQ9yMSO0xfTUFFVuh3EbjRwjVy8XoED8FwFW6xQdO3vhBGVMU Zd0A== X-Gm-Message-State: AOAM533F9bGJjw1jd0WqG7iM8FdEbF8BO9ndHsU+n/N2J9j+EZdqMexQ tAsCPrLO/miFU9hUOjns2j31ZQ== X-Google-Smtp-Source: ABdhPJyU0YaxKBuB+bPZ/8ZbSIAV7XjWH8vR1OVs8fAL2OZoxEJii9k/0fXt8shgVKw4YMNuwkR1dg== X-Received: by 2002:a17:90a:54f:: with SMTP id h15mr1550832pjf.191.1600733404171; Mon, 21 Sep 2020 17:10:04 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:03 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 02/10] rpmsg: core: Add channel creation internal API Date: Mon, 21 Sep 2020 18:09:52 -0600 Message-Id: <20200922001000.899956-3-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Arnaud Pouliquen Add the channel creation API as a first step to be able to define the name service announcement as a rpmsg driver independent from the RPMsg virtio bus. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/rpmsg_core.c | 45 ++++++++++++++++++++++++++++++++++ drivers/rpmsg/rpmsg_internal.h | 12 +++++++++ 2 files changed, 57 insertions(+) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index 91de940896e3..50a835eaf1ba 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -20,6 +20,51 @@ #include "rpmsg_internal.h" +/** + * rpmsg_create_channel() - create a new rpmsg channel + * using its name and address info. + * @rpdev: rpmsg driver + * @chinfo: channel_info to bind + * + * Returns a pointer to the new rpmsg device on success, or NULL on error. + */ +struct rpmsg_device * + rpmsg_create_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo) +{ + if (WARN_ON(!rpdev)) + return NULL; + if (!rpdev->ops || !rpdev->ops->create_channel) { + dev_err(&rpdev->dev, "no create_channel ops found\n"); + return NULL; + } + + return rpdev->ops->create_channel(rpdev, chinfo); +} +EXPORT_SYMBOL(rpmsg_create_channel); + +/** + * rpmsg_release_channel() - release a rpmsg channel + * using its name and address info. + * @rpdev: rpmsg driver + * @chinfo: channel_info to bind + * + * Returns 0 on success or an appropriate error value. + */ +int rpmsg_release_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo) +{ + if (WARN_ON(!rpdev)) + return -EINVAL; + if (!rpdev->ops || !rpdev->ops->release_channel) { + dev_err(&rpdev->dev, "no release_channel ops found\n"); + return -EPERM; + } + + return rpdev->ops->release_channel(rpdev, chinfo); +} +EXPORT_SYMBOL(rpmsg_release_channel); + /** * rpmsg_create_ept() - create a new rpmsg_endpoint * @rpdev: rpmsg channel device diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 3fc83cd50e98..587f723757d4 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -20,6 +20,8 @@ /** * struct rpmsg_device_ops - indirection table for the rpmsg_device operations + * @create_channel: create backend-specific channel, optional + * @release_channel: release backend-specific channel, optional * @create_ept: create backend-specific endpoint, required * @announce_create: announce presence of new channel, optional * @announce_destroy: announce destruction of channel, optional @@ -29,6 +31,11 @@ * advertise new channels implicitly by creating the endpoints. */ struct rpmsg_device_ops { + struct rpmsg_device *(*create_channel)(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo); + int (*release_channel)(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo); + struct rpmsg_endpoint *(*create_ept)(struct rpmsg_device *rpdev, rpmsg_rx_cb_t cb, void *priv, struct rpmsg_channel_info chinfo); @@ -75,6 +82,11 @@ int rpmsg_unregister_device(struct device *parent, struct device *rpmsg_find_device(struct device *parent, struct rpmsg_channel_info *chinfo); +struct rpmsg_device * +rpmsg_create_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo); +int rpmsg_release_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo); /** * rpmsg_chrdev_register_device() - register chrdev device based on rpdev * @rpdev: prepared rpdev to be used for creating endpoints From patchwork Tue Sep 22 00:09:53 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791293 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 2B386112C for ; Tue, 22 Sep 2020 00:10:07 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0EAA923A74 for ; Tue, 22 Sep 2020 00:10:07 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="qLAPqGaH" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728813AbgIVAKG (ORCPT ); Mon, 21 Sep 2020 20:10:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46406 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729021AbgIVAKG (ORCPT ); Mon, 21 Sep 2020 20:10:06 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E634DC061755 for ; Mon, 21 Sep 2020 17:10:05 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id k133so5685421pgc.7 for ; Mon, 21 Sep 2020 17:10:05 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=DsTBzQVhNY369Insfr5rXAu0ypsKEebbLr2rslQaLzY=; b=qLAPqGaHTnCaB6cYxJdNHQJrH1Fc3RZ3EuL2TAqpYtuu4ulTy6Dgjy/8BLCYkaMHRv QYOIw9dtogpkvN9q+5t0WsMIGV/H5W/7qEft/xU8cs48tUiTzlEY7JnICqY/d8XZocrs kpbfzWtv44TKHxaRurzkZ53FrjpLo3llirw6COXZOm8kv6nXpq5Hr/YU7Z1KbFzZtFvL rsvpVuaflv8vR157l6TIL/dapxxb/msR2kVl5wu6tpMRofbZbiGQ1ODcNNoqYCwfD6+L wdX+FprrsbTddSMVdem6ahSWaySeDBeFCwwFJ8eYcc2jRBVJ/335leON/8WbsrAGwKUT RiVQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=DsTBzQVhNY369Insfr5rXAu0ypsKEebbLr2rslQaLzY=; b=rc+NQStX+sbe3uwgJ+ICId5rEQM2a12j4EZJ8NPYKND1oRWlGaCCq5qH72fYPBdkUn Mx1EdTkDoHLlNBkTu1Jn1RrDaUg2GaBO/gyGw/mjACwmCF9UqXR0l2TNNRG5TvC2qKhA cEFwqU+0/1FoaiJxybJv4pjXCeScflz9Zo/qOT6vw/0MYESLX5MBQ/YcznSu4yTxwrub lSoxcbRZPRIa+TCCW9rslbxf9D15S2Bry5cCGKuIDs2kiD7HD+qWBIDNPSQA0ZN43pNt A/vvD+d9ldGzGU1kIkf7McADQdEJTWvfIixABgTm6Ve/jayiaVIVvhula30e1pcaXzCO tGIw== X-Gm-Message-State: AOAM533t7KEQ8AI/Hq5ke6/+TJBRm4ygcoD1klYnpX2wZiODJz+gSeD4 b59pU0MTE4Ent7reyf9CEjWQxw== X-Google-Smtp-Source: ABdhPJzdo1jbYZQjvkyyMUAzyyQAOghwaAhDiinrD3Wg5fBfoOHKlKk1lPGC/VC2Y2hafTX2LSv5RA== X-Received: by 2002:a17:902:758b:b029:d2:29fc:c841 with SMTP id j11-20020a170902758bb02900d229fcc841mr2220526pll.39.1600733405481; Mon, 21 Sep 2020 17:10:05 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:04 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 03/10] rpmsg: virtio: Add rpmsg channel device ops Date: Mon, 21 Sep 2020 18:09:53 -0600 Message-Id: <20200922001000.899956-4-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Arnaud Pouliquen Implement the create and release of the RPMsg channel for the RPMsg virtio bus. Signed-off-by: Arnaud Pouliquen [Moved function declaration above struct virtio_rpmsg_ops] Signed-off-by: Mathieu Poirier --- drivers/rpmsg/virtio_rpmsg_bus.c | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index e8d55c8b9cbf..e87cf0b79542 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -181,6 +181,9 @@ static int virtio_rpmsg_trysendto(struct rpmsg_endpoint *ept, void *data, int len, u32 dst); static int virtio_rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, u32 dst, void *data, int len); +static struct rpmsg_device * +__rpmsg_create_channel(struct virtproc_info *vrp, + struct rpmsg_channel_info *chinfo); static const struct rpmsg_endpoint_ops virtio_endpoint_ops = { .destroy_ept = virtio_rpmsg_destroy_ept, @@ -285,6 +288,25 @@ static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp, return NULL; } +static struct rpmsg_device * +virtio_rpmsg_create_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo) +{ + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); + struct virtproc_info *vrp = vch->vrp; + + return __rpmsg_create_channel(vrp, chinfo); +} + +static int virtio_rpmsg_release_channel(struct rpmsg_device *rpdev, + struct rpmsg_channel_info *chinfo) +{ + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); + struct virtproc_info *vrp = vch->vrp; + + return rpmsg_unregister_device(&vrp->vdev->dev, chinfo); +} + static struct rpmsg_endpoint *virtio_rpmsg_create_ept(struct rpmsg_device *rpdev, rpmsg_rx_cb_t cb, void *priv, @@ -377,6 +399,8 @@ static int virtio_rpmsg_announce_destroy(struct rpmsg_device *rpdev) } static const struct rpmsg_device_ops virtio_rpmsg_ops = { + .create_channel = virtio_rpmsg_create_channel, + .release_channel = virtio_rpmsg_release_channel, .create_ept = virtio_rpmsg_create_ept, .announce_create = virtio_rpmsg_announce_create, .announce_destroy = virtio_rpmsg_announce_destroy, From patchwork Tue Sep 22 00:09:54 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791307 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 8CAF9112C for ; Tue, 22 Sep 2020 00:10:39 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 613AA207C4 for ; Tue, 22 Sep 2020 00:10:39 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="fqr3s0Zv" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729054AbgIVAKe (ORCPT ); Mon, 21 Sep 2020 20:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46414 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729037AbgIVAKH (ORCPT ); Mon, 21 Sep 2020 20:10:07 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2F4F7C0613CF for ; Mon, 21 Sep 2020 17:10:07 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id l191so10445742pgd.5 for ; Mon, 21 Sep 2020 17:10:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=XG8TQDPV2ru/6Wc4JTqjVwyN3Ijlpo554VX/iowfsas=; b=fqr3s0ZvcpZXFINf5fUuJPR9ADUP6lt0NB64XExgGfL26h9ZEPepzGNvYO7jvM+qd1 kj2mzYV7UYQ+R8CjM8ZtzSAdd6vgoIebeNxYllBWvEL2TMjMaPgTBZETtosFvJuMs7lz A19xZ0BLzuK+d/+Z+9yuslH4rpI/3hv9tHX71GbSx/o7bVjn2tPzvrE1DN4fy5q3OxYs xZf0EyoQVv6vWiBufIecJ6mi16ThHjImxRTJBh/xVBsl2tpCYT7e3keKSEgG12Uid10U hVn6BhL0rCe6IEg8G3UoVTsTrmnOz5W0cifvDhM5hpU0qJXOzLz62V25tX661uPiH6Ua +TVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=XG8TQDPV2ru/6Wc4JTqjVwyN3Ijlpo554VX/iowfsas=; b=U6cyVw3uyE1b5+OPdCMgc5T6JUZyhJQwVaMJR9ALzLNQPcnUHuyrfULZVRqSGvkXjk 7oF4HQKiIM6vMrXFgCqqUNgC61drh9ematr/BhL9e++FLJHPEf+yfFhsWtK5lFN7OHRP hafjtvnW/lLsVKgEBE/EKK2SGW9XVpvbfiHuQzxIpnREKo8op/mX79tHuF3R+ZSoiagI 7iRXfv5APkVcerkpMBYD+2sc2lajPd6frTvbm/ztkXosSWXnulvZ/AfBBl7Syv0+a1dW Ygb3V1R+njc9L3J6hIamr3c7mc/5PUX8+EuY+EIFdX3jRfSg1s7pflCkJ1E4sLC42FE4 AZtw== X-Gm-Message-State: AOAM532yYHTRHBreIQJ3eCM3n0wIXT+jZtoXxZ5wKX+/vwBxNLeQA1vS LUxf5YloEDR/93qUNAhqzQCrSHl/iNMuYg== X-Google-Smtp-Source: ABdhPJyfHrrtQ5W9ryImzXpTbubEXfXt9aOZuVs2NzhedZAq6tUUSdphmtp4/+Vyc3xlo9uaSKgrGg== X-Received: by 2002:a17:902:b413:b029:d1:f3d7:2674 with SMTP id x19-20020a170902b413b02900d1f3d72674mr2056772plr.53.1600733406614; Mon, 21 Sep 2020 17:10:06 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.05 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:06 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 04/10] rpmsg: Move common structures and defines to headers Date: Mon, 21 Sep 2020 18:09:54 -0600 Message-Id: <20200922001000.899956-5-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Guennadi Liakhovetski virtio_rpmsg_bus.c keeps RPMsg protocol structure declarations and common defines like the ones, needed for name-space announcements, internal. Move them to common headers instead. Signed-off-by: Guennadi Liakhovetski [Renamed header file from linux/rpmsg/rpmsg_virtio.h to linux/rpmsg_ns.h] Signed-off-by: Mathieu Poirier --- drivers/rpmsg/virtio_rpmsg_bus.c | 78 +----------------------------- include/linux/rpmsg_ns.h | 83 ++++++++++++++++++++++++++++++++ include/uapi/linux/rpmsg.h | 3 ++ 3 files changed, 88 insertions(+), 76 deletions(-) create mode 100644 include/linux/rpmsg_ns.h diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index e87cf0b79542..eaf3b2c012c8 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -19,6 +19,7 @@ #include #include #include +#include #include #include #include @@ -27,6 +28,7 @@ #include #include #include +#include #include "rpmsg_internal.h" @@ -70,58 +72,6 @@ struct virtproc_info { struct rpmsg_endpoint *ns_ept; }; -/* The feature bitmap for virtio rpmsg */ -#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ - -/** - * struct rpmsg_hdr - common header for all rpmsg messages - * @src: source address - * @dst: destination address - * @reserved: reserved for future use - * @len: length of payload (in bytes) - * @flags: message flags - * @data: @len bytes of message payload data - * - * Every message sent(/received) on the rpmsg bus begins with this header. - */ -struct rpmsg_hdr { - __virtio32 src; - __virtio32 dst; - __virtio32 reserved; - __virtio16 len; - __virtio16 flags; - u8 data[]; -} __packed; - -/** - * struct rpmsg_ns_msg - dynamic name service announcement message - * @name: name of remote service that is published - * @addr: address of remote service that is published - * @flags: indicates whether service is created or destroyed - * - * This message is sent across to publish a new service, or announce - * about its removal. When we receive these messages, an appropriate - * rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe() - * or ->remove() handler of the appropriate rpmsg driver will be invoked - * (if/as-soon-as one is registered). - */ -struct rpmsg_ns_msg { - char name[RPMSG_NAME_SIZE]; - __virtio32 addr; - __virtio32 flags; -} __packed; - -/** - * enum rpmsg_ns_flags - dynamic name service announcement flags - * - * @RPMSG_NS_CREATE: a new remote service was just created - * @RPMSG_NS_DESTROY: a known remote service was just destroyed - */ -enum rpmsg_ns_flags { - RPMSG_NS_CREATE = 0, - RPMSG_NS_DESTROY = 1, -}; - /** * struct virtio_rpmsg_channel - rpmsg channel descriptor * @rpdev: the rpmsg channel device @@ -139,27 +89,6 @@ struct virtio_rpmsg_channel { #define to_virtio_rpmsg_channel(_rpdev) \ container_of(_rpdev, struct virtio_rpmsg_channel, rpdev) -/* - * We're allocating buffers of 512 bytes each for communications. The - * number of buffers will be computed from the number of buffers supported - * by the vring, upto a maximum of 512 buffers (256 in each direction). - * - * Each buffer will have 16 bytes for the msg header and 496 bytes for - * the payload. - * - * This will utilize a maximum total space of 256KB for the buffers. - * - * We might also want to add support for user-provided buffers in time. - * This will allow bigger buffer size flexibility, and can also be used - * to achieve zero-copy messaging. - * - * Note that these numbers are purely a decision of this driver - we - * can change this without changing anything in the firmware of the remote - * processor. - */ -#define MAX_RPMSG_NUM_BUFS (512) -#define MAX_RPMSG_BUF_SIZE (512) - /* * Local addresses are dynamically allocated on-demand. * We do not dynamically assign addresses from the low 1024 range, @@ -167,9 +96,6 @@ struct virtio_rpmsg_channel { */ #define RPMSG_RESERVED_ADDRESSES (1024) -/* Address 53 is reserved for advertising remote services */ -#define RPMSG_NS_ADDR (53) - static void virtio_rpmsg_destroy_ept(struct rpmsg_endpoint *ept); static int virtio_rpmsg_send(struct rpmsg_endpoint *ept, void *data, int len); static int virtio_rpmsg_sendto(struct rpmsg_endpoint *ept, void *data, int len, diff --git a/include/linux/rpmsg_ns.h b/include/linux/rpmsg_ns.h new file mode 100644 index 000000000000..aabc6c3c0d6d --- /dev/null +++ b/include/linux/rpmsg_ns.h @@ -0,0 +1,83 @@ +/* SPDX-License-Identifier: GPL-2.0 */ + +#ifndef _LINUX_RPMSG_NS_H +#define _LINUX_RPMSG_NS_H + +#include +#include +#include + +/** + * struct rpmsg_hdr - common header for all rpmsg messages + * @src: source address + * @dst: destination address + * @reserved: reserved for future use + * @len: length of payload (in bytes) + * @flags: message flags + * @data: @len bytes of message payload data + * + * Every message sent(/received) on the rpmsg bus begins with this header. + */ +struct rpmsg_hdr { + __virtio32 src; + __virtio32 dst; + __virtio32 reserved; + __virtio16 len; + __virtio16 flags; + u8 data[]; +} __packed; + +/** + * struct rpmsg_ns_msg - dynamic name service announcement message + * @name: name of remote service that is published + * @addr: address of remote service that is published + * @flags: indicates whether service is created or destroyed + * + * This message is sent across to publish a new service, or announce + * about its removal. When we receive these messages, an appropriate + * rpmsg channel (i.e device) is created/destroyed. In turn, the ->probe() + * or ->remove() handler of the appropriate rpmsg driver will be invoked + * (if/as-soon-as one is registered). + */ +struct rpmsg_ns_msg { + char name[RPMSG_NAME_SIZE]; + __virtio32 addr; + __virtio32 flags; +} __packed; + +/** + * enum rpmsg_ns_flags - dynamic name service announcement flags + * + * @RPMSG_NS_CREATE: a new remote service was just created + * @RPMSG_NS_DESTROY: a known remote service was just destroyed + */ +enum rpmsg_ns_flags { + RPMSG_NS_CREATE = 0, + RPMSG_NS_DESTROY = 1, +}; + +/* + * We're allocating buffers of 512 bytes each for communications. The + * number of buffers will be computed from the number of buffers supported + * by the vring, upto a maximum of 512 buffers (256 in each direction). + * + * Each buffer will have 16 bytes for the msg header and 496 bytes for + * the payload. + * + * This will utilize a maximum total space of 256KB for the buffers. + * + * We might also want to add support for user-provided buffers in time. + * This will allow bigger buffer size flexibility, and can also be used + * to achieve zero-copy messaging. + * + * Note that these numbers are purely a decision of this driver - we + * can change this without changing anything in the firmware of the remote + * processor. + */ +#define MAX_RPMSG_NUM_BUFS 512 +#define MAX_RPMSG_BUF_SIZE 512 + +/* Address 53 is reserved for advertising remote services */ +#define RPMSG_NS_ADDR 53 + +#endif diff --git a/include/uapi/linux/rpmsg.h b/include/uapi/linux/rpmsg.h index e14c6dab4223..d669c04ef289 100644 --- a/include/uapi/linux/rpmsg.h +++ b/include/uapi/linux/rpmsg.h @@ -24,4 +24,7 @@ struct rpmsg_endpoint_info { #define RPMSG_CREATE_EPT_IOCTL _IOW(0xb5, 0x1, struct rpmsg_endpoint_info) #define RPMSG_DESTROY_EPT_IOCTL _IO(0xb5, 0x2) +/* The feature bitmap for virtio rpmsg */ +#define VIRTIO_RPMSG_F_NS 0 /* RP supports name service notifications */ + #endif From patchwork Tue Sep 22 00:09:55 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791309 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 96D10112E for ; Tue, 22 Sep 2020 00:10:40 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6D411206BE for ; Tue, 22 Sep 2020 00:10:40 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="ICRL5MYm" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729052AbgIVAKe (ORCPT ); Mon, 21 Sep 2020 20:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46420 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729045AbgIVAKI (ORCPT ); Mon, 21 Sep 2020 20:10:08 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 86478C0613D0 for ; Mon, 21 Sep 2020 17:10:08 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id l126so10785720pfd.5 for ; Mon, 21 Sep 2020 17:10:08 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=8TjdMDcbc9uuujVTzgzt/gRIi5BJNJaTzMCDIv50sag=; b=ICRL5MYmu74+cfY8vKQSwfsac6fFPuz8fe6td0/uK7tfUwfwsU6LDVhMcljILP10l3 aGvFga4rr8MmkMfITEC66pqXdT00pMhGkR7cfy0bUNuWi2Zbmvy6ln/TFF116aRVUypG kGWhE4Se/BAxOngQB80AhWjWq4Y3P2z9KlYHHX7KMnipScSfSoGVEvrib/ogbDeE4yqK xJxE08L5sWPM/alo7lYnm2/mpFm0xV4Ude9Vthwi4kj6HPWg8fiys9dFbUOpwjkeNCic wuZbzJleQnddUSBPw+aTRvG0uV57iShC/8c9F5To3BZUrorKdzrcaeETPmx8EYsxtSMa 6P7w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=8TjdMDcbc9uuujVTzgzt/gRIi5BJNJaTzMCDIv50sag=; b=Frwa2TUysAUerCx4NvSIJcKQdBfhu2DxPZYu2LmR7x4MOflKrAMbtVZ/umLmnVl8ST i42i5+HUlr4YgZxrFWLbCjRC4vBtD56+NID73FKr/X89qAiTzypBAIlF8hrsAy32UoLJ YhElmoeaIlOyHv+zjzG2nM5/s3rjeRdLZAnW6tH2LJCaIZRdURFELRunRJaB6PH9qZVY prgz3idmEv9Kre8suGxRSyGoZeElwToC2sE9JZLu5Xot0AXpHqyoRNMRqebXAhhJiRps zU85d2QzWKcIQHdfQUq3tr/eavDtAavajYwW1MlOwiyKTK5NvZrt4HLkKjsj37MU4Atb gYCQ== X-Gm-Message-State: AOAM533DfrTB47KuZL7DN1RhDIJeUxhUWgZz1Fpg8KCfLDpyWTkHwyZQ VYtdgtY+bPnfPfP25Y2pzSfn/A== X-Google-Smtp-Source: ABdhPJxhAtPEdLS9et/YYDneOQ1xmJ0ewoCXQ8oTCIlaBBcXcAWrb3nYWg73L9ojpLbqTYVJKNT9TA== X-Received: by 2002:a63:1449:: with SMTP id 9mr1564579pgu.260.1600733408014; Mon, 21 Sep 2020 17:10:08 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.06 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:07 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 05/10] rpmsg: virtio: Move virtio RPMSG structures to private header Date: Mon, 21 Sep 2020 18:09:55 -0600 Message-Id: <20200922001000.899956-6-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Move structure virtiproc_info and virtio_rpmsg_channel to rpmsg_internal.h so that they can be used by rpmsg_ns.c Signed-off-by: Mathieu Poirier --- drivers/rpmsg/rpmsg_internal.h | 62 ++++++++++++++++++++++++++++++++ drivers/rpmsg/virtio_rpmsg_bus.c | 57 ----------------------------- 2 files changed, 62 insertions(+), 57 deletions(-) diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 587f723757d4..3ea9cec26fc0 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -12,12 +12,74 @@ #ifndef __RPMSG_INTERNAL_H__ #define __RPMSG_INTERNAL_H__ +#include +#include #include +#include +#include +#include #include #define to_rpmsg_device(d) container_of(d, struct rpmsg_device, dev) #define to_rpmsg_driver(d) container_of(d, struct rpmsg_driver, drv) +/** + * struct virtproc_info - virtual remote processor state + * @vdev: the virtio device + * @rvq: rx virtqueue + * @svq: tx virtqueue + * @rbufs: kernel address of rx buffers + * @sbufs: kernel address of tx buffers + * @num_bufs: total number of buffers for rx and tx + * @buf_size: size of one rx or tx buffer + * @last_sbuf: index of last tx buffer used + * @bufs_dma: dma base addr of the buffers + * @tx_lock: protects svq, sbufs and sleepers, to allow concurrent senders. + * sending a message might require waking up a dozing remote + * processor, which involves sleeping, hence the mutex. + * @endpoints: idr of local endpoints, allows fast retrieval + * @endpoints_lock: lock of the endpoints set + * @sendq: wait queue of sending contexts waiting for a tx buffers + * @sleepers: number of senders that are waiting for a tx buffer + * @ns_ept: the bus's name service endpoint + * + * This structure stores the rpmsg state of a given virtio remote processor + * device (there might be several virtio proc devices for each physical + * remote processor). + */ +struct virtproc_info { + struct virtio_device *vdev; + struct virtqueue *rvq, *svq; + void *rbufs, *sbufs; + unsigned int num_bufs; + unsigned int buf_size; + int last_sbuf; + dma_addr_t bufs_dma; + struct mutex tx_lock; + struct idr endpoints; + struct mutex endpoints_lock; + wait_queue_head_t sendq; + atomic_t sleepers; + struct rpmsg_endpoint *ns_ept; +}; + +/** + * struct virtio_rpmsg_channel - rpmsg channel descriptor + * @rpdev: the rpmsg channel device + * @vrp: the virtio remote processor device this channel belongs to + * + * This structure stores the channel that links the rpmsg device to the virtio + * remote processor device. + */ +struct virtio_rpmsg_channel { + struct rpmsg_device rpdev; + + struct virtproc_info *vrp; +}; + +#define to_virtio_rpmsg_channel(_rpdev) \ + container_of(_rpdev, struct virtio_rpmsg_channel, rpdev) + /** * struct rpmsg_device_ops - indirection table for the rpmsg_device operations * @create_channel: create backend-specific channel, optional diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index eaf3b2c012c8..0635d86d490f 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -32,63 +32,6 @@ #include "rpmsg_internal.h" -/** - * struct virtproc_info - virtual remote processor state - * @vdev: the virtio device - * @rvq: rx virtqueue - * @svq: tx virtqueue - * @rbufs: kernel address of rx buffers - * @sbufs: kernel address of tx buffers - * @num_bufs: total number of buffers for rx and tx - * @buf_size: size of one rx or tx buffer - * @last_sbuf: index of last tx buffer used - * @bufs_dma: dma base addr of the buffers - * @tx_lock: protects svq, sbufs and sleepers, to allow concurrent senders. - * sending a message might require waking up a dozing remote - * processor, which involves sleeping, hence the mutex. - * @endpoints: idr of local endpoints, allows fast retrieval - * @endpoints_lock: lock of the endpoints set - * @sendq: wait queue of sending contexts waiting for a tx buffers - * @sleepers: number of senders that are waiting for a tx buffer - * @ns_ept: the bus's name service endpoint - * - * This structure stores the rpmsg state of a given virtio remote processor - * device (there might be several virtio proc devices for each physical - * remote processor). - */ -struct virtproc_info { - struct virtio_device *vdev; - struct virtqueue *rvq, *svq; - void *rbufs, *sbufs; - unsigned int num_bufs; - unsigned int buf_size; - int last_sbuf; - dma_addr_t bufs_dma; - struct mutex tx_lock; - struct idr endpoints; - struct mutex endpoints_lock; - wait_queue_head_t sendq; - atomic_t sleepers; - struct rpmsg_endpoint *ns_ept; -}; - -/** - * struct virtio_rpmsg_channel - rpmsg channel descriptor - * @rpdev: the rpmsg channel device - * @vrp: the virtio remote processor device this channel belongs to - * - * This structure stores the channel that links the rpmsg device to the virtio - * remote processor device. - */ -struct virtio_rpmsg_channel { - struct rpmsg_device rpdev; - - struct virtproc_info *vrp; -}; - -#define to_virtio_rpmsg_channel(_rpdev) \ - container_of(_rpdev, struct virtio_rpmsg_channel, rpdev) - /* * Local addresses are dynamically allocated on-demand. * We do not dynamically assign addresses from the low 1024 range, From patchwork Tue Sep 22 00:09:56 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791305 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 6EEDE112E for ; Tue, 22 Sep 2020 00:10:34 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4C513206BE for ; Tue, 22 Sep 2020 00:10:34 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="omzqSKVg" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728959AbgIVAKe (ORCPT ); Mon, 21 Sep 2020 20:10:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46428 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729011AbgIVAKJ (ORCPT ); Mon, 21 Sep 2020 20:10:09 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA92EC0613D2 for ; Mon, 21 Sep 2020 17:10:09 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id g29so10460326pgl.2 for ; Mon, 21 Sep 2020 17:10:09 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=hbk9zcYeD+9Uduv/zaUcY28B45xybgwqjUf1aBL4iW4=; b=omzqSKVgL//OalmQsfu68+UnR95J0iHwsG1YKjy+1hXLGT8aeWTuYLYUtcdnlO+Y2+ AzgR4PIsV7uX+tfRJZ7DwZOiGfJqrI+b1PxMLJN/lVVLRdLkPsbnKUGO3a+l0rIF6ZHR Gxm7o21DvmR1FEM1Mx5lQ5g4wleLI8RQALGhLGoOJIjTgY+pkQjHaEGpmLupFBw5mV6P /hxJfeFYPsCGLvZozZk8yI8SPlacQ3kVue51xMKkIM7UBVyS3o+JaJfPse0Ik9W8qOZ+ m+/1Ey/ZCbL5+GYGYcEpZW+B9TgGRFLhmwjxq0uDTiZUa/bjf1nifCAYK7wEPXagMjRC BZJA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=hbk9zcYeD+9Uduv/zaUcY28B45xybgwqjUf1aBL4iW4=; b=EIkl18xpuZbVHmUz8yBsPlJjmDOMK+eiNK5OqVHPkmiGL5c8pBI5AFOZ/1i6gT9jpj ecsY909/mIRjGujPJgl72Xk1n5Yr7Pa6GlF2lBrSPxvGuZMUsHsgPaDf/2thzyGyvi23 sbPf90kUJ6aDXqDG7M7L0XrBe2gNNO8+Zo1H2FfYrrG9Q4B7PcC2VLsAASLv1ioYQvrb 2QCgRK44SgZUuN1dnBCrRSqcPKo7r5tJ/qOtMiytIBQx0jv6KoqYj0X7XLnQF7UIAF9C X40xmXXQv1BbxMzESKe5MQ5r8QdMImJnzD8nr06TFn1Gzq5fVBws4w5shKsqeuK8xQTB 3txA== X-Gm-Message-State: AOAM5316KBaH7yO3EkxwVZ5Ko/hqqJRglJ+EFywtAt1332FGhCdunNqk BTvRsfAHvg8s3khOHIskExPriA== X-Google-Smtp-Source: ABdhPJwW6NGNxac4F0FNa4kgAuMkJrJECSn3W4isTYi8h5mYWDBZvAG2PV/Gl38+oKa7Ic9dmeuVfg== X-Received: by 2002:a17:902:8689:b029:d1:9bf7:230a with SMTP id g9-20020a1709028689b02900d19bf7230amr2276079plo.22.1600733409284; Mon, 21 Sep 2020 17:10:09 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.08 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:08 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 06/10] rpmsg: Turn name service into a stand alone driver Date: Mon, 21 Sep 2020 18:09:56 -0600 Message-Id: <20200922001000.899956-7-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Arnaud Pouliquen Make the RPMSG name service announcement a stand alone driver so that it can be reused by other subsystems. It is also the first step in making the functionatlity transport independent, i.e that is not tied to virtIO. Signed-off-by: Arnaud Pouliquen Signed-off-by: Mathieu Poirier Reported-by: kernel test robot --- drivers/rpmsg/Kconfig | 8 +++ drivers/rpmsg/Makefile | 1 + drivers/rpmsg/rpmsg_internal.h | 18 ++++++ drivers/rpmsg/rpmsg_ns.c | 110 +++++++++++++++++++++++++++++++++ 4 files changed, 137 insertions(+) create mode 100644 drivers/rpmsg/rpmsg_ns.c diff --git a/drivers/rpmsg/Kconfig b/drivers/rpmsg/Kconfig index f96716893c2a..c3fc75e6514b 100644 --- a/drivers/rpmsg/Kconfig +++ b/drivers/rpmsg/Kconfig @@ -15,6 +15,14 @@ config RPMSG_CHAR in /dev. They make it possible for user-space programs to send and receive rpmsg packets. +config RPMSG_NS + tristate "RPMSG name service announcement" + depends on RPMSG + help + Say Y here to enable the support of the name service announcement + channel that probes the associated RPMsg device on remote endpoint + service announcement. + config RPMSG_MTK_SCP tristate "MediaTek SCP" depends on MTK_SCP diff --git a/drivers/rpmsg/Makefile b/drivers/rpmsg/Makefile index ffe932ef6050..8d452656f0ee 100644 --- a/drivers/rpmsg/Makefile +++ b/drivers/rpmsg/Makefile @@ -1,6 +1,7 @@ # SPDX-License-Identifier: GPL-2.0 obj-$(CONFIG_RPMSG) += rpmsg_core.o obj-$(CONFIG_RPMSG_CHAR) += rpmsg_char.o +obj-$(CONFIG_RPMSG_NS) += rpmsg_ns.o obj-$(CONFIG_RPMSG_MTK_SCP) += mtk_rpmsg.o qcom_glink-objs := qcom_glink_native.o qcom_glink_ssr.o obj-$(CONFIG_RPMSG_QCOM_GLINK) += qcom_glink.o diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 3ea9cec26fc0..04e6cb287e18 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -15,6 +15,7 @@ #include #include #include +#include #include #include #include @@ -164,4 +165,21 @@ static inline int rpmsg_chrdev_register_device(struct rpmsg_device *rpdev) return rpmsg_register_device(rpdev); } +/** + * 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); +} + #endif diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c new file mode 100644 index 000000000000..b3318bf84433 --- /dev/null +++ b/drivers/rpmsg/rpmsg_ns.c @@ -0,0 +1,110 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (C) STMicroelectronics 2020 - All Rights Reserved + */ +#include +#include +#include +#include +#include +#include +#include +#include "rpmsg_internal.h" + +/* Invoked when a name service announcement arrives */ +static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, + void *priv, u32 src) +{ + struct rpmsg_ns_msg *msg = data; + struct rpmsg_device *newch; + struct rpmsg_channel_info chinfo; + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); + struct virtproc_info *vrp = vch->vrp; + struct device *dev = &vrp->vdev->dev; + int ret; + +#if defined(CONFIG_DYNAMIC_DEBUG) + dynamic_hex_dump("NS announcement: ", DUMP_PREFIX_NONE, 16, 1, + data, len, true); +#endif + + if (len != sizeof(*msg)) { + dev_err(dev, "malformed ns msg (%d)\n", len); + return -EINVAL; + } + + /* Don't trust the remote processor for null terminating the name */ + msg->name[RPMSG_NAME_SIZE - 1] = '\0'; + + strncpy(chinfo.name, msg->name, sizeof(chinfo.name)); + chinfo.src = RPMSG_ADDR_ANY; + chinfo.dst = virtio32_to_cpu(vrp->vdev, msg->addr); + + dev_info(dev, "%sing channel %s addr 0x%x\n", + virtio32_to_cpu(vrp->vdev, msg->flags) & RPMSG_NS_DESTROY ? + "destroy" : "creat", msg->name, chinfo.dst); + + if (virtio32_to_cpu(vrp->vdev, msg->flags) & RPMSG_NS_DESTROY) { + ret = rpmsg_release_channel(rpdev, &chinfo); + if (ret) + dev_err(dev, "rpmsg_destroy_channel failed: %d\n", ret); + } else { + newch = rpmsg_create_channel(rpdev, &chinfo); + if (!newch) + dev_err(dev, "rpmsg_create_channel failed\n"); + } + + return 0; +} + +static int rpmsg_ns_probe(struct rpmsg_device *rpdev) +{ + struct rpmsg_channel_info ns_chinfo; + struct rpmsg_endpoint *ns_ept; + + ns_chinfo.src = RPMSG_NS_ADDR; + ns_chinfo.dst = RPMSG_NS_ADDR; + strcpy(ns_chinfo.name, "name_service"); + + /* + * Create the NS announcement service endpoint associated to the RPMsg + * device. The endpoint will be automatically destroyed when the RPMsg + * device will be deleted. + */ + ns_ept = rpmsg_create_ept(rpdev, rpmsg_ns_cb, NULL, ns_chinfo); + if (!ns_ept) { + dev_err(&rpdev->dev, "failed to create the ns ept\n"); + return -ENOMEM; + } + rpdev->ept = ns_ept; + + return 0; +} + +static struct rpmsg_driver rpmsg_ns_driver = { + .drv.name = "rpmsg_ns", + .probe = rpmsg_ns_probe, +}; + +static int rpmsg_ns_init(void) +{ + int ret; + + ret = register_rpmsg_driver(&rpmsg_ns_driver); + if (ret < 0) + pr_err("%s: Failed to register rpmsg driver\n", __func__); + + return ret; +} +postcore_initcall(rpmsg_ns_init); + +static void rpmsg_ns_exit(void) +{ + unregister_rpmsg_driver(&rpmsg_ns_driver); +} +module_exit(rpmsg_ns_exit); + +MODULE_DESCRIPTION("Name service announcement rpmsg Driver"); +MODULE_AUTHOR("Arnaud Pouliquen "); +MODULE_ALIAS("rpmsg_ns"); +MODULE_LICENSE("GPL v2"); From patchwork Tue Sep 22 00:09:57 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791303 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 7FB86112E for ; Tue, 22 Sep 2020 00:10:33 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5EBC8206BE for ; Tue, 22 Sep 2020 00:10:33 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="TANCw2bP" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728497AbgIVAKc (ORCPT ); Mon, 21 Sep 2020 20:10:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46438 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729109AbgIVAKM (ORCPT ); Mon, 21 Sep 2020 20:10:12 -0400 Received: from mail-pg1-x542.google.com (mail-pg1-x542.google.com [IPv6:2607:f8b0:4864:20::542]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 01CF2C0613D4 for ; Mon, 21 Sep 2020 17:10:11 -0700 (PDT) Received: by mail-pg1-x542.google.com with SMTP id y1so10444606pgk.8 for ; Mon, 21 Sep 2020 17:10:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=tvjkMh1nVcvWbD/SxWJBLAgB6Awyphn/fwoUPXd6MgY=; b=TANCw2bP46+lHUHJ6IVsyt9iFSDzV5OjXuPP4mUnrBXHB4ToylojulONLPALSix5Tq /6UdjexfSznv3xXI3eVaqH2uhd4bryCOFNWEo+7aeOqKYAEGwG4S0NJotxLLuH8iumSf +aIlLZxLCZ1J7AcKXBnHK5uwVP782pH0YwU8dcU4ZAL7naUQioOtolm8ZNkQUHjlSTih wpW34ciGxJH7o7wXu5dlTrzwPFazP1vkO7wo4/SHvSTotZKiHbbCwaa2YA3RPAGnWrlQ VqAK/phE8cvxH+9tepGLqPEdn5zH4NGm7bDa2e9Y3/5WCrjqYijRznm7PatajNI4yZia e8rw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=tvjkMh1nVcvWbD/SxWJBLAgB6Awyphn/fwoUPXd6MgY=; b=R9kmaEmNe0Am0YNzswTRrkY+rDFEyuZNhvc/sZtusVjG8hi3lv5uzLqZ7oLqDfpcTk abGCK5AW72bpLGgEjjcK+58JMbnhP6JCn0dQGs7nPObdCkJacvjKpNNQXbBuFxsCcAs3 hcg/a1CoC9JW07CtcXsA8zBmQA12Svqo5Uirj1sK8laI3yG82HWJs90l0/3uT5r5z0XZ gkCuASLdu43vBlpfCTTaeboqCSDfx+FG9FxzzHlSYjD649ZysxmDz7KyqUHMuKz2Ei66 W06h8WS7UaEePzR8LZHmW5/jGmNOELWtSOT5WEPz+dW07PhfEFgyh+NX8Z3qHibXm7eM WiUw== X-Gm-Message-State: AOAM5303/vppt/cTmWIIbt8zWTjCYh3ZqxI/8BfYoDSd8+Y35jmmySTO pJ9jpTrVgU8JoqbNbTaKLYVC2A== X-Google-Smtp-Source: ABdhPJzpg0kLRIy6LCYG7ZS1FVExxH9YQYaq9/FWFF1DrAgrVp+Zho5vFy9B3UB9BvS1KgUszvBM7w== X-Received: by 2002:a17:902:fe85:b029:d1:e598:3ff7 with SMTP id x5-20020a170902fe85b02900d1e5983ff7mr2074081plm.49.1600733410518; Mon, 21 Sep 2020 17:10:10 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.09 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:10 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 07/10] rpmsg: virtio: use rpmsg ns device for the ns announcement Date: Mon, 21 Sep 2020 18:09:57 -0600 Message-Id: <20200922001000.899956-8-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org From: Arnaud Pouliquen As generic NS driver is available, rely on it for NS management instead of managing it in RPMsg virtio bus. Signed-off-by: Arnaud Pouliquen --- drivers/rpmsg/Kconfig | 1 + drivers/rpmsg/rpmsg_internal.h | 2 - drivers/rpmsg/virtio_rpmsg_bus.c | 84 ++++++++------------------------ 3 files changed, 21 insertions(+), 66 deletions(-) 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_internal.h b/drivers/rpmsg/rpmsg_internal.h index 04e6cb287e18..2e65386f191e 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -42,7 +42,6 @@ * @endpoints_lock: lock of the endpoints set * @sendq: wait queue of sending contexts waiting for a tx buffers * @sleepers: number of senders that are waiting for a tx buffer - * @ns_ept: the bus's name service endpoint * * This structure stores the rpmsg state of a given virtio remote processor * device (there might be several virtio proc devices for each physical @@ -61,7 +60,6 @@ struct virtproc_info { struct mutex endpoints_lock; wait_queue_head_t sendq; atomic_t sleepers; - struct rpmsg_endpoint *ns_ept; }; /** diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 0635d86d490f..1c0be0ee790c 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -715,68 +715,14 @@ static void rpmsg_xmit_done(struct virtqueue *svq) wake_up_interruptible(&vrp->sendq); } -/* invoked when a name service announcement arrives */ -static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, - void *priv, u32 src) -{ - struct rpmsg_ns_msg *msg = data; - struct rpmsg_device *newch; - struct rpmsg_channel_info chinfo; - struct virtproc_info *vrp = priv; - struct device *dev = &vrp->vdev->dev; - int ret; - -#if defined(CONFIG_DYNAMIC_DEBUG) - dynamic_hex_dump("NS announcement: ", DUMP_PREFIX_NONE, 16, 1, - data, len, true); -#endif - - if (len != sizeof(*msg)) { - dev_err(dev, "malformed ns msg (%d)\n", len); - return -EINVAL; - } - - /* - * the name service ept does _not_ belong to a real rpmsg channel, - * and is handled by the rpmsg bus itself. - * for sanity reasons, make sure a valid rpdev has _not_ sneaked - * in somehow. - */ - if (rpdev) { - dev_err(dev, "anomaly: ns ept has an rpdev handle\n"); - return -EINVAL; - } - - /* don't trust the remote processor for null terminating the name */ - msg->name[RPMSG_NAME_SIZE - 1] = '\0'; - - strncpy(chinfo.name, msg->name, sizeof(chinfo.name)); - chinfo.src = RPMSG_ADDR_ANY; - chinfo.dst = virtio32_to_cpu(vrp->vdev, msg->addr); - - dev_info(dev, "%sing channel %s addr 0x%x\n", - virtio32_to_cpu(vrp->vdev, msg->flags) & RPMSG_NS_DESTROY ? - "destroy" : "creat", msg->name, chinfo.dst); - - if (virtio32_to_cpu(vrp->vdev, msg->flags) & RPMSG_NS_DESTROY) { - ret = rpmsg_unregister_device(&vrp->vdev->dev, &chinfo); - if (ret) - dev_err(dev, "rpmsg_destroy_channel failed: %d\n", ret); - } else { - newch = __rpmsg_create_channel(vrp, &chinfo); - if (!newch) - dev_err(dev, "rpmsg_create_channel failed\n"); - } - - return 0; -} - static int rpmsg_probe(struct virtio_device *vdev) { vq_callback_t *vq_cbs[] = { rpmsg_recv_done, rpmsg_xmit_done }; static const char * const names[] = { "input", "output" }; struct virtqueue *vqs[2]; struct virtproc_info *vrp; + struct virtio_rpmsg_channel *vch; + struct rpmsg_device *rpdev_ns; void *bufs_va; int err = 0, i; size_t total_buf_space; @@ -852,14 +798,27 @@ static int rpmsg_probe(struct virtio_device *vdev) /* if supported by the remote processor, enable the name service */ if (virtio_has_feature(vdev, VIRTIO_RPMSG_F_NS)) { - /* a dedicated endpoint handles the name service msgs */ - vrp->ns_ept = __rpmsg_create_ept(vrp, NULL, rpmsg_ns_cb, - vrp, RPMSG_NS_ADDR); - if (!vrp->ns_ept) { - dev_err(&vdev->dev, "failed to create the ns ept\n"); + vch = kzalloc(sizeof(*vch), GFP_KERNEL); + if (!vch) { err = -ENOMEM; goto free_coherent; } + + /* Link the channel to our vrp */ + vch->vrp = vrp; + + /* Assign public information to the rpmsg_device */ + rpdev_ns = &vch->rpdev; + rpdev_ns->ops = &virtio_rpmsg_ops; + + rpdev_ns->dev.parent = &vrp->vdev->dev; + rpdev_ns->dev.release = virtio_rpmsg_release_device; + + err = rpmsg_ns_register_device(rpdev_ns); + if (err) { + kfree(vch); + goto free_coherent; + } } /* @@ -912,9 +871,6 @@ static void rpmsg_remove(struct virtio_device *vdev) if (ret) dev_warn(&vdev->dev, "can't remove rpmsg device: %d\n", ret); - if (vrp->ns_ept) - __rpmsg_destroy_ept(vrp, vrp->ns_ept); - idr_destroy(&vrp->endpoints); vdev->config->del_vqs(vrp->vdev); From patchwork Tue Sep 22 00:09:58 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791301 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id D2742112C for ; Tue, 22 Sep 2020 00:10:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B89F823A74 for ; Tue, 22 Sep 2020 00:10:26 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="AIUvhMEJ" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728938AbgIVAKN (ORCPT ); Mon, 21 Sep 2020 20:10:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46442 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729113AbgIVAKN (ORCPT ); Mon, 21 Sep 2020 20:10:13 -0400 Received: from mail-pf1-x444.google.com (mail-pf1-x444.google.com [IPv6:2607:f8b0:4864:20::444]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3B10CC0613D6 for ; Mon, 21 Sep 2020 17:10:12 -0700 (PDT) Received: by mail-pf1-x444.google.com with SMTP id k13so10269793pfg.1 for ; Mon, 21 Sep 2020 17:10:12 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=n1V7VaXNtFFXe8hlbSXGaT097In9oJAOqPbj32nqcpU=; b=AIUvhMEJFjOVuta1N6sc8KE/xp8ukyZ6sIWYmrGd7iBrO3I2DJuZHCdgPrzdozjFUT nvlAxDD3Ieu5ZfG2EIuJiwwmMiUlHqTX0A4KRL2XWWzCmgsPCnC3EzSSvWiY2J0KYJYf VHWcRtolWIh3vZkVH0m3NfFmqdhwrrl+t6aaQypqjWqogvHwV09camR9HFtpUWuNnyUj EfKwgtRht6A3plnwII76X3UJaO1Fmwjkr8fSB28zFZNHUlbyP3tsXzJcN0wRCGpJU9G0 qXlNMSrRjsj4UGa/Zkfzy6C35Wko9nnGZ3MySojdhRFrUFKJsDA61n5rUcLX6zAw+yrk 5Wqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=n1V7VaXNtFFXe8hlbSXGaT097In9oJAOqPbj32nqcpU=; b=D/FqYNepxPuzVx6XOlFt6vG/CqkhrT4hYcI02MsDs39D9GKuFd0daQjb2+AG7Ayrhn 5DEsGB4nS8M5aK3V24tFt+ciqULFAqn60dxw0An6pdQl2xOPX8+6+10rnDmXnro6nh9t JVF5nOCAlP6iWAfgW9tw6oKTNogYrpQa8br9/ZYkhQMN3XxS+RpvbIoPZMVYuA6SuFys j2U8YUwFJIcJZPvYnOpNeZg8l585wUNcYptNXETuit526Q4wfK1M4FjDArT5VagvS+aP qELw4Jx72iALqCOgoIQoEbWC5YWxVwtW6VBVQp6ivIB7KEW1p86/uC/9bTiBApGfysdm 3JmQ== X-Gm-Message-State: AOAM531Vs4OyKuxq+sKD4dN5U9GqCjFSz8gGltLKbE1yHLXWz5K1IE/f K0Ee2f1Y5EhaqGcxgJSbpYSIqg== X-Google-Smtp-Source: ABdhPJxe247RM3m9j5Pu5KP/uAEbO0zFKdsKId6FIMQNcersUYg4lHDF9IwODr0fP3JB1K6iEZWwZw== X-Received: by 2002:a63:7d5a:: with SMTP id m26mr1498809pgn.373.1600733411751; Mon, 21 Sep 2020 17:10:11 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:11 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 08/10] rpmsg: core: Add RPMSG byte conversion operations Date: Mon, 21 Sep 2020 18:09:58 -0600 Message-Id: <20200922001000.899956-9-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Add RPMSG device specific byte conversion operations as a first step to separate the RPMSG name space service from the virtIO transport layer. Signed-off-by: Mathieu Poirier Reported-by: kernel test robot Reported-by: Dan Carpenter --- drivers/rpmsg/rpmsg_core.c | 51 ++++++++++++++++++++++++++++++++++ drivers/rpmsg/rpmsg_internal.h | 12 ++++++++ 2 files changed, 63 insertions(+) diff --git a/drivers/rpmsg/rpmsg_core.c b/drivers/rpmsg/rpmsg_core.c index 50a835eaf1ba..66ad5b5f1e87 100644 --- a/drivers/rpmsg/rpmsg_core.c +++ b/drivers/rpmsg/rpmsg_core.c @@ -20,6 +20,57 @@ #include "rpmsg_internal.h" +/** + * rpmsg{16|32}_to_cpu() + * cpu_to_rpmsg[16|32}() - rpmsg device specific byte conversion functions to + * perform byte conversion between rpmsg device and the + * transport layer it is operating on. + */ + +u16 rpmsg16_to_cpu(struct rpmsg_device *rpdev, u16 val) +{ + if (WARN_ON(!rpdev)) + return -EINVAL; + if (!rpdev->ops || !rpdev->ops->transport16_to_cpu) + return -EPERM; + + return rpdev->ops->transport16_to_cpu(rpdev, val); +} +EXPORT_SYMBOL(rpmsg16_to_cpu); + +u16 cpu_to_rpmsg16(struct rpmsg_device *rpdev, u16 val) +{ + if (WARN_ON(!rpdev)) + return -EINVAL; + if (!rpdev->ops || !rpdev->ops->cpu_to_transport16) + return -EPERM; + + return rpdev->ops->cpu_to_transport16(rpdev, val); +} +EXPORT_SYMBOL(cpu_to_rpmsg16); + +u32 rpmsg32_to_cpu(struct rpmsg_device *rpdev, u32 val) +{ + if (WARN_ON(!rpdev)) + return -EINVAL; + if (!rpdev->ops || !rpdev->ops->transport32_to_cpu) + return -EPERM; + + return rpdev->ops->transport32_to_cpu(rpdev, val); +} +EXPORT_SYMBOL(rpmsg32_to_cpu); + +u32 cpu_to_rpmsg32(struct rpmsg_device *rpdev, u32 val) +{ + if (WARN_ON(!rpdev)) + return -EINVAL; + if (!rpdev->ops || !rpdev->ops->cpu_to_transport32) + return -EPERM; + + return rpdev->ops->cpu_to_transport32(rpdev, val); +} +EXPORT_SYMBOL(cpu_to_rpmsg32); + /** * rpmsg_create_channel() - create a new rpmsg channel * using its name and address info. diff --git a/drivers/rpmsg/rpmsg_internal.h b/drivers/rpmsg/rpmsg_internal.h index 2e65386f191e..2f0ad1a52698 100644 --- a/drivers/rpmsg/rpmsg_internal.h +++ b/drivers/rpmsg/rpmsg_internal.h @@ -81,6 +81,8 @@ struct virtio_rpmsg_channel { /** * struct rpmsg_device_ops - indirection table for the rpmsg_device operations + * @transport{16|32}_to_cpu: byte conversion from rpmsg device to transport layer + * @cpu_to_transport{16|32}: byte conversion from transport layer to rpmsg device * @create_channel: create backend-specific channel, optional * @release_channel: release backend-specific channel, optional * @create_ept: create backend-specific endpoint, required @@ -92,6 +94,10 @@ struct virtio_rpmsg_channel { * advertise new channels implicitly by creating the endpoints. */ struct rpmsg_device_ops { + u16 (*transport16_to_cpu)(struct rpmsg_device *rpdev, u16 val); + u16 (*cpu_to_transport16)(struct rpmsg_device *rpdev, u16 val); + u32 (*transport32_to_cpu)(struct rpmsg_device *rpdev, u32 val); + u32 (*cpu_to_transport32)(struct rpmsg_device *rpdev, u32 val); struct rpmsg_device *(*create_channel)(struct rpmsg_device *rpdev, struct rpmsg_channel_info *chinfo); int (*release_channel)(struct rpmsg_device *rpdev, @@ -148,6 +154,12 @@ rpmsg_create_channel(struct rpmsg_device *rpdev, struct rpmsg_channel_info *chinfo); int rpmsg_release_channel(struct rpmsg_device *rpdev, struct rpmsg_channel_info *chinfo); + +u16 rpmsg16_to_cpu(struct rpmsg_device *rpdev, u16 val); +u16 cpu_to_rpmsg16(struct rpmsg_device *rpdev, u16 val); +u32 rpmsg32_to_cpu(struct rpmsg_device *rpdev, u32 val); +u32 cpu_to_rpmsg32(struct rpmsg_device *rpdev, u32 val); + /** * rpmsg_chrdev_register_device() - register chrdev device based on rpdev * @rpdev: prepared rpdev to be used for creating endpoints From patchwork Tue Sep 22 00:09:59 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791299 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C1136112C for ; Tue, 22 Sep 2020 00:10:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A5CC923A77 for ; Tue, 22 Sep 2020 00:10:25 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="EjV9H6eR" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729156AbgIVAKW (ORCPT ); Mon, 21 Sep 2020 20:10:22 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729125AbgIVAKN (ORCPT ); Mon, 21 Sep 2020 20:10:13 -0400 Received: from mail-pg1-x543.google.com (mail-pg1-x543.google.com [IPv6:2607:f8b0:4864:20::543]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7D767C0613CF for ; Mon, 21 Sep 2020 17:10:13 -0700 (PDT) Received: by mail-pg1-x543.google.com with SMTP id k14so10434707pgi.9 for ; Mon, 21 Sep 2020 17:10:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=kjxi5jPY+5fiGib9aemaW9NnwRUiNwpEBOAwlpbjCi0=; b=EjV9H6eR89HJ++cASGIFensX72XSXg+IFP9M3mKjHvsMy3f146k9UUilXnSUfmEiVc 3B325WaWi9ZUSOzRSmL6PsQA0em7gIGb3Fja199BBBNTDoR796qUsfHPwZh1dpHoNwi0 jzxtxb8+6+kDkMhJzRys+ogIOrlyJXM2gbg2kCfWmY90L7kS7zxaSpTNdRBHv11cK/7V 9BksIdUFNr6OCaATgwFpSxGMHGSX1DLdWEzT4aliit/3g7qfid6p+xAnKudJJQs9nuCk EHO8IsyPDrKZ/J1cZrzTPqBHChS6dDjkPH7iFWmr2xPcVA4LfpVKXtc0qjXK7Dc1uuOC 3Z3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=kjxi5jPY+5fiGib9aemaW9NnwRUiNwpEBOAwlpbjCi0=; b=Ay+g7rsIk1N+EEB+ttIokq259mktVV7meGyMTbpm5iIe3gv9SYyRaU5yCsDKvIyxT3 953mL89v6GgUaDyhSgJUDi/0RRGkJvFNyTfcxFx9oOZ8lo0eUPtRK+i7/Xmi5DbyFbDL Tw85F9YlM2O+3u+ScjABYD3f6JcZ3dcsWOfOiE9bKEjwaPeOlOuAfm1ufL/bXuWwFCaJ fg+7u78UFSlTUcso7FA2Hrkqd/pAgZnCRUqM/e5HorTx5uepdpINsQjWuLGPlkMG75RY ZK06LSmIxb0aFrcCs+ovu9LCbEZkCFOq5L3L+Bf/4teCcmHkA9XrrWQ59GYPJ+zhNkyl rFKA== X-Gm-Message-State: AOAM530Z7odDV02pHILKnvAdnKgpGOlNNOf9+wIMuDJhp8+wwH28yrJc mWxADR6505AYSPda8kKTbdQALg== X-Google-Smtp-Source: ABdhPJxpCINuRSuKV4NEjLVkGeyuI4+z9LCyALw01vOZ954g/7R2EFYevIRMs05UPRRJxSJNJa/Orw== X-Received: by 2002:a63:384f:: with SMTP id h15mr1572345pgn.144.1600733413027; Mon, 21 Sep 2020 17:10:13 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:12 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 09/10] rpmsg: virtio: Make endianness conversion virtIO specific Date: Mon, 21 Sep 2020 18:09:59 -0600 Message-Id: <20200922001000.899956-10-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Introduce rpmsg operations to make byte conversion specific to the virtIO transport layer, therefore avoiding the protocol code from being aware of the virtIO transport specification. Signed-off-by: Mathieu Poirier Reported-by: kernel test robot --- drivers/rpmsg/virtio_rpmsg_bus.c | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 1c0be0ee790c..15cc383a85cc 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -157,6 +157,38 @@ static struct rpmsg_endpoint *__rpmsg_create_ept(struct virtproc_info *vrp, return NULL; } +static u16 virtio_rpmsg_transport16_to_cpu(struct rpmsg_device *rpdev, u16 val) +{ + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); + struct virtproc_info *vrp = vch->vrp; + + return virtio16_to_cpu(vrp->vdev, val); +} + +static u16 virtio_rpmsg_cpu_to_transport16(struct rpmsg_device *rpdev, u16 val) +{ + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); + struct virtproc_info *vrp = vch->vrp; + + return cpu_to_virtio16(vrp->vdev, val); +} + +static u32 virtio_rpmsg_transport32_to_cpu(struct rpmsg_device *rpdev, u32 val) +{ + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); + struct virtproc_info *vrp = vch->vrp; + + return virtio32_to_cpu(vrp->vdev, val); +} + +static u32 virtio_rpmsg_cpu_to_transport32(struct rpmsg_device *rpdev, u32 val) +{ + struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); + struct virtproc_info *vrp = vch->vrp; + + return cpu_to_virtio32(vrp->vdev, val); +} + static struct rpmsg_device * virtio_rpmsg_create_channel(struct rpmsg_device *rpdev, struct rpmsg_channel_info *chinfo) @@ -268,6 +300,10 @@ static int virtio_rpmsg_announce_destroy(struct rpmsg_device *rpdev) } static const struct rpmsg_device_ops virtio_rpmsg_ops = { + .transport16_to_cpu = virtio_rpmsg_transport16_to_cpu, + .cpu_to_transport16 = virtio_rpmsg_cpu_to_transport16, + .transport32_to_cpu = virtio_rpmsg_transport32_to_cpu, + .cpu_to_transport32 = virtio_rpmsg_cpu_to_transport32, .create_channel = virtio_rpmsg_create_channel, .release_channel = virtio_rpmsg_release_channel, .create_ept = virtio_rpmsg_create_ept, From patchwork Tue Sep 22 00:10:00 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Mathieu Poirier X-Patchwork-Id: 11791297 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id B159A112C for ; Tue, 22 Sep 2020 00:10:21 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9349F23A74 for ; Tue, 22 Sep 2020 00:10:21 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=linaro.org header.i=@linaro.org header.b="X9B7jt/P" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729143AbgIVAKS (ORCPT ); Mon, 21 Sep 2020 20:10:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:46458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729131AbgIVAKO (ORCPT ); Mon, 21 Sep 2020 20:10:14 -0400 Received: from mail-pg1-x544.google.com (mail-pg1-x544.google.com [IPv6:2607:f8b0:4864:20::544]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 94028C0613CF for ; Mon, 21 Sep 2020 17:10:14 -0700 (PDT) Received: by mail-pg1-x544.google.com with SMTP id k14so10434739pgi.9 for ; Mon, 21 Sep 2020 17:10:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=JYPr+7owzyzLplTCeGY50zAG7FlCrMEoUfNJS9GMOSU=; b=X9B7jt/PocCFkpDLXpWEOeyS6Aa35CKU0xIQNF03K3hk2yt4jXmf4G7/A4sudY4IhD gZ0F5XM+NKvO1ab/sBKJ/JGZH1yiV5WIG5lDEAv6P5Q0OjNL/w3iW7TO8l2DheRetixw 2FcT+LgUfCzP0tLE4PaOKkC0E1yG3GGHaNngv8PSpEEZlR/ptWg5ImH6GPMvzLTjXoOo FkjBNbm4ERXiJFndrCa4anX3GxCXf6US0IOSitxZiSyZ5uKcBHIOae8Mhu22wN6R2DbP eH3NqfysxwsnXf6ciepO+YAkXVxqL6Q8li/u+8ekfKTvwOJ80M0Z7vxGqAVTPmKw0WuT rY5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=JYPr+7owzyzLplTCeGY50zAG7FlCrMEoUfNJS9GMOSU=; b=tiQ7SeZTjXJQz6k2bwaVdJLIll2jl4eW5lxkqMuGdz1nyeYsjMneMVNQtkJRCGBdR9 1N8M/nx/5tZ3jev3KjG95wbTE2OnxRlyzhK6XkY4+DVvx2TVgEaM6yenHyqC3P0SN9w9 d/gML6ZM9VFKVBT+S79nI9NYddmdXM/upJTJrxdJpzTENO0kLD5RphNOP/PLmmaFmOrj dJapVEwNUUXVB++gKVGE1peYt0fdRasch384wMYWRg7lyKWScFpAIQKpM/+Vamx+YISC 1+1iucDmNgxlckRF/jI98JjW7T+yDhuVXXnzBmq4U8NExw1Xin2z7Eg9NGWUy873biHC 2EnA== X-Gm-Message-State: AOAM532Wws+G6FmHuf29jTwebzWxLeeDPd9fmmsjy/JGA8qL50r0Kme3 yv6gxHkRgQ5YRcFHddP1E11q4Q== X-Google-Smtp-Source: ABdhPJxLG4zVEFiTc0YFWJgvJVZU03YbD/HubJTEB7Pj5AzguknZki7gHWjxvQU3NiNWes3J4xnf3w== X-Received: by 2002:a63:d841:: with SMTP id k1mr1548724pgj.59.1600733414189; Mon, 21 Sep 2020 17:10:14 -0700 (PDT) Received: from xps15.cg.shawcable.net (S0106002369de4dac.cg.shawcable.net. [68.147.8.254]) by smtp.gmail.com with ESMTPSA id c9sm12807953pfn.78.2020.09.21.17.10.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 21 Sep 2020 17:10:13 -0700 (PDT) From: Mathieu Poirier To: ohad@wizery.com, bjorn.andersson@linaro.org, guennadi.liakhovetski@linux.intel.com Cc: loic.pallardy@st.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 10/10] rpmsg: ns: Make Name service module transport agnostic Date: Mon, 21 Sep 2020 18:10:00 -0600 Message-Id: <20200922001000.899956-11-mathieu.poirier@linaro.org> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20200922001000.899956-1-mathieu.poirier@linaro.org> References: <20200922001000.899956-1-mathieu.poirier@linaro.org> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org Make name service module transport agnostic by using the rpmsg device specific byte conversion routine. Signed-off-by: Mathieu Poirier Reported-by: kernel test robot --- drivers/rpmsg/rpmsg_ns.c | 10 ++++------ include/linux/rpmsg_ns.h | 4 ++-- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/drivers/rpmsg/rpmsg_ns.c b/drivers/rpmsg/rpmsg_ns.c index b3318bf84433..1df3aaadfe10 100644 --- a/drivers/rpmsg/rpmsg_ns.c +++ b/drivers/rpmsg/rpmsg_ns.c @@ -18,9 +18,7 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, struct rpmsg_ns_msg *msg = data; struct rpmsg_device *newch; struct rpmsg_channel_info chinfo; - struct virtio_rpmsg_channel *vch = to_virtio_rpmsg_channel(rpdev); - struct virtproc_info *vrp = vch->vrp; - struct device *dev = &vrp->vdev->dev; + struct device *dev = &rpdev->dev; int ret; #if defined(CONFIG_DYNAMIC_DEBUG) @@ -38,13 +36,13 @@ static int rpmsg_ns_cb(struct rpmsg_device *rpdev, void *data, int len, strncpy(chinfo.name, msg->name, sizeof(chinfo.name)); chinfo.src = RPMSG_ADDR_ANY; - chinfo.dst = virtio32_to_cpu(vrp->vdev, msg->addr); + chinfo.dst = rpmsg32_to_cpu(rpdev, msg->addr); dev_info(dev, "%sing channel %s addr 0x%x\n", - virtio32_to_cpu(vrp->vdev, msg->flags) & RPMSG_NS_DESTROY ? + rpmsg32_to_cpu(rpdev, msg->flags) & RPMSG_NS_DESTROY ? "destroy" : "creat", msg->name, chinfo.dst); - if (virtio32_to_cpu(vrp->vdev, msg->flags) & RPMSG_NS_DESTROY) { + if (rpmsg32_to_cpu(rpdev, msg->flags) & RPMSG_NS_DESTROY) { ret = rpmsg_release_channel(rpdev, &chinfo); if (ret) dev_err(dev, "rpmsg_destroy_channel failed: %d\n", ret); diff --git a/include/linux/rpmsg_ns.h b/include/linux/rpmsg_ns.h index aabc6c3c0d6d..9f3030b2145b 100644 --- a/include/linux/rpmsg_ns.h +++ b/include/linux/rpmsg_ns.h @@ -41,8 +41,8 @@ struct rpmsg_hdr { */ struct rpmsg_ns_msg { char name[RPMSG_NAME_SIZE]; - __virtio32 addr; - __virtio32 flags; + u32 addr; + u32 flags; } __packed; /**