From patchwork Wed Feb 1 15:07:12 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Pallardy X-Patchwork-Id: 93043 Delivered-To: patch@linaro.org Received: by 10.140.20.99 with SMTP id 90csp2459264qgi; Wed, 1 Feb 2017 07:07:32 -0800 (PST) X-Received: by 10.84.209.172 with SMTP id y41mr5083899plh.96.1485961652013; Wed, 01 Feb 2017 07:07:32 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id b189si14628150pga.105.2017.02.01.07.07.31; Wed, 01 Feb 2017 07:07:31 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752508AbdBAPHa (ORCPT + 25 others); Wed, 1 Feb 2017 10:07:30 -0500 Received: from mx07-00178001.pphosted.com ([62.209.51.94]:49099 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752471AbdBAPH2 (ORCPT ); Wed, 1 Feb 2017 10:07:28 -0500 Received: from pps.filterd (m0046668.ppops.net [127.0.0.1]) by mx07-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id v11F2KwA025329; Wed, 1 Feb 2017 16:07:26 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx07-.pphosted.com with ESMTP id 288hn1va6y-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 01 Feb 2017 16:07:26 +0100 Received: from zeta.dmz-eu.st.com (zeta.dmz-eu.st.com [164.129.230.9]) by beta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 2CB0731; Wed, 1 Feb 2017 15:07:25 +0000 (GMT) Received: from Webmail-eu.st.com (safex1hubcas4.st.com [10.75.90.69]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 0E1BD2ADF; Wed, 1 Feb 2017 15:07:25 +0000 (GMT) Received: from localhost (10.201.23.23) by webmail-eu.st.com (10.75.90.13) with Microsoft SMTP Server (TLS) id 8.3.444.0; Wed, 1 Feb 2017 16:07:24 +0100 From: Loic Pallardy To: , , CC: , , , , , , Subject: [PATCH v3 6/6] rpmsg: virtio_rpmsg: set buffer configuration to virtio Date: Wed, 1 Feb 2017 16:07:12 +0100 Message-ID: <1485961632-21980-7-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1485961632-21980-1-git-send-email-loic.pallardy@st.com> References: <1485961632-21980-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-02-01_08:, , signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rpmsg is allocating buffer one dedicated communication link with some specificity like number of buffers, size of one buffer... These characteristics should be shared with remote coprocessor to guarantee communication link coherency. Proposal is to update rpmsg configuration fields in coprocessor firmware resource table if it exists. This is possible thanks to virtio set interface which allows to update cfg fields of struct fw_rsc_vdev. Signed-off-by: Loic Pallardy --- Changes since V1: - Set virtio_cfg.da to -1 (any address) by default - Add comment about IOMMU support No change since v2. --- drivers/rpmsg/virtio_rpmsg_bus.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) -- 1.9.1 diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index b347e34..d9af556 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -923,6 +923,27 @@ static int virtio_rpmsg_get_config(struct virtio_device *vdev) return ret; } +static void virtio_rpmsg_set_config(struct virtio_device *vdev) +{ + struct virtio_rpmsg_cfg virtio_cfg; + struct virtproc_info *vrp = vdev->priv; + + /* fill virtio_cfg struct */ + memset(&virtio_cfg, 0, sizeof(virtio_cfg)); + virtio_cfg.id = VIRTIO_ID_RPMSG; + /* + * IOMMU not managed at the time being, set device address to (-1) + * meaning any address value. + */ + virtio_cfg.da = -1; + virtio_cfg.pa = vrp->bufs_dma; + virtio_cfg.len = vrp->num_bufs * vrp->buf_size; + virtio_cfg.buf_size = vrp->buf_size; + + vdev->config->set(vdev, RPMSG_CONFIG_OFFSET, &virtio_cfg, + sizeof(virtio_cfg)); +} + static int rpmsg_probe(struct virtio_device *vdev) { vq_callback_t *vq_cbs[] = { rpmsg_recv_done, rpmsg_xmit_done }; @@ -933,6 +954,7 @@ static int rpmsg_probe(struct virtio_device *vdev) int err = 0, i; size_t total_buf_space = 0; bool notify; + bool has_cfg = false; vrp = kzalloc(sizeof(*vrp), GFP_KERNEL); if (!vrp) @@ -972,6 +994,9 @@ static int rpmsg_probe(struct virtio_device *vdev) if (err < 0) goto free_vrp; + if (err) + has_cfg = true; + /* Allocate buffer if none provided by low level platform driver */ if (!vrp->ext_buffer) { total_buf_space = vrp->num_bufs * vrp->buf_size; @@ -993,6 +1018,10 @@ static int rpmsg_probe(struct virtio_device *vdev) /* and half is dedicated for TX */ vrp->sbufs = bufs_va + total_buf_space / 2; + + /* Notify configuration to coprocessor */ + if (has_cfg) + virtio_rpmsg_set_config(vdev); } /* set up the receive buffers */