From patchwork Wed Dec 7 20:35:41 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic PALLARDY X-Patchwork-Id: 9465213 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 280F260512 for ; Wed, 7 Dec 2016 20:37:07 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2A8A8212D8 for ; Wed, 7 Dec 2016 20:37:07 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1F4CF2855E; Wed, 7 Dec 2016 20:37:07 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-6.9 required=2.0 tests=BAYES_00,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id E82E4212D8 for ; Wed, 7 Dec 2016 20:37:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S932561AbcLGUhF (ORCPT ); Wed, 7 Dec 2016 15:37:05 -0500 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:52331 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S932119AbcLGUhF (ORCPT ); Wed, 7 Dec 2016 15:37:05 -0500 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.11/8.16.0.11) with SMTP id uB7KZqnM026889; Wed, 7 Dec 2016 21:37:03 +0100 Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-.pphosted.com with ESMTP id 2756tnbucf-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Wed, 07 Dec 2016 21:37:03 +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 B73A331; Wed, 7 Dec 2016 20:37:02 +0000 (GMT) Received: from Webmail-eu.st.com (Safex1hubcas21.st.com [10.75.90.44]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 9CF384EB5; Wed, 7 Dec 2016 20:37:02 +0000 (GMT) Received: from localhost (10.129.5.76) by Webmail-ga.st.com (10.75.90.48) with Microsoft SMTP Server (TLS) id 14.3.294.0; Wed, 7 Dec 2016 21:37:02 +0100 From: Loic Pallardy To: , , , CC: , , Subject: [PATCH v1 6/6] rpmsg: virtio_rpmsg: set buffer configuration to virtio Date: Wed, 7 Dec 2016 21:35:41 +0100 Message-ID: <1481142941-15616-7-git-send-email-loic.pallardy@st.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1481142941-15616-1-git-send-email-loic.pallardy@st.com> References: <1481142941-15616-1-git-send-email-loic.pallardy@st.com> MIME-Version: 1.0 X-Originating-IP: [10.129.5.76] X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-12-07_06:, , signatures=0 Sender: linux-remoteproc-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-remoteproc@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP 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 --- drivers/rpmsg/virtio_rpmsg_bus.c | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index b12fe2a..5527b65 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -924,6 +924,23 @@ static int virtio_rpmsg_get_config(struct virtio_device *vdev) } +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; + virtio_cfg.da = vrp->bufs_dma; + 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 }; @@ -934,6 +951,7 @@ static int rpmsg_probe(struct virtio_device *vdev) int err = 0, i; size_t total_buf_space; bool notify; + bool has_cfg = false; vrp = kzalloc(sizeof(*vrp), GFP_KERNEL); if (!vrp) @@ -973,6 +991,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 +1014,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 */