Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp701082yba; Thu, 9 May 2019 04:48:39 -0700 (PDT) X-Google-Smtp-Source: APXvYqxuPRDyl0ly0sXIpuH5lecVCpXdV+gSAUXE2MPOOdDyj0NDVtkil00bCB4cHA8A4r/vmAzh X-Received: by 2002:a17:902:b695:: with SMTP id c21mr4535603pls.160.1557402519111; Thu, 09 May 2019 04:48:39 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557402519; cv=none; d=google.com; s=arc-20160816; b=Kq4XSL2PD90/H1U5r5TbykOz8dqjBp6WnSOfIHPlUX8wL06LEcLFR+dWkf/2LlKb5I tOMfqYmVh62SyVIrOTPfVBje9CoEQvyRqruP752Q7+fPoQwQ/xH7/SVgZxdqNVtRghge cv/9Ms7PzYHdoOAxVEyJwKhmNMuEAD+SvPG02chYxste02O5E23eIcLzs+jzP8LRMmcU ckxWi3j8S76AvqdTOa1ecjP8d6FBjzaBZS2W7br0A1pDKOgvcXlQ1Fsiozs+BbpUvGvY RlM2l1/CGzFfn4Rypmo78dx6i+tUBAa/xNCjSR4fvvRF7JBbKYw6rGuF2ZWW1E+gyB9w 2mrw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:openpgp:from:references:cc:to:subject :dkim-signature; bh=6f9n5M3hgXa5sWjQwp0pZ+4Oumgu+9zo8X5s+G/bSds=; b=YRdDWC4jwgfXZK4jrIM6+pKX63TzXFvdss+gTWUDPzPyga/H07LbomFOp4E1AJzup9 c7Gzgg9EJ8GflnULuy4Gohi9+A51guW7ECdae2yCFkIVLC8WDyabxvaaIh+2e1Q87+aG gBthrm3kIBVKQ35Px3q84LBmOQED32ISeZ7RSqcMHo9p5lpyi0MOuuoYZodwx26tGPGo fyj77v4TTjuVtfAMVo5D3gKjb63bbhUan/sRATlwino2mi4fz46vrXT1nL9lZ2Xr+e23 GtILKuUokmtcenVZsBJDX5AwkWbrfNGWKE1o8Wpvp4L9JFrHM8/xZgKAvM0VG4o3htie xh7g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=wMBxhHE7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id d186si2652343pgc.311.2019.05.09.04.48.22; Thu, 09 May 2019 04:48:39 -0700 (PDT) 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; dkim=pass header.i=@st.com header.s=STMicroelectronics header.b=wMBxhHE7; 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 S1726573AbfEILrP (ORCPT + 99 others); Thu, 9 May 2019 07:47:15 -0400 Received: from mx08-00178001.pphosted.com ([91.207.212.93]:36744 "EHLO mx07-00178001.pphosted.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1725961AbfEILrO (ORCPT ); Thu, 9 May 2019 07:47:14 -0400 Received: from pps.filterd (m0046661.ppops.net [127.0.0.1]) by mx08-00178001.pphosted.com (8.16.0.27/8.16.0.27) with SMTP id x49BfN8T016214; Thu, 9 May 2019 13:47:10 +0200 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=6f9n5M3hgXa5sWjQwp0pZ+4Oumgu+9zo8X5s+G/bSds=; b=wMBxhHE788QdtHRReSVElVb6OBU4F/7Bm6nQ1EknlUEzKnl+lNmF9Uioywxh0hkzUBmv zfTGXLmXouSJR6sHlPdHAj1O5PRXGOL5lysXIx6BogjoXZWOz/ALOXwZGEJWqgTrNCPa 8/KSy1fp+Ru33uEBdRum73nbeDpV/o1vROalM4LfxXiQvkZPmxXgyFQEg0KnPps77vzQ Q+5ZKG+Cy7xcm+Rt4ZEXIJdG21NSVE5O5pDF+Uz3O6NyB92LOljvUjDqbDuL74ngddrj IpXKfGx0usMYS+C2pbA10qFcyYUIvvyXa2dEtY56aR1t3wsX19cOim63G8YS0fbN2xRA og== Received: from beta.dmz-eu.st.com (beta.dmz-eu.st.com [164.129.1.35]) by mx08-00178001.pphosted.com with ESMTP id 2scfv2hg1c-1 (version=TLSv1 cipher=ECDHE-RSA-AES256-SHA bits=256 verify=NOT); Thu, 09 May 2019 13:47:10 +0200 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 2F1FE38; Thu, 9 May 2019 11:47:09 +0000 (GMT) Received: from Webmail-eu.st.com (sfhdag3node1.st.com [10.75.127.7]) by zeta.dmz-eu.st.com (STMicroelectronics) with ESMTP id 077942488; Thu, 9 May 2019 11:47:09 +0000 (GMT) Received: from [10.48.0.131] (10.75.127.47) by SFHDAG3NODE1.st.com (10.75.127.7) with Microsoft SMTP Server (TLS) id 15.0.1347.2; Thu, 9 May 2019 13:47:07 +0200 Subject: Re: [PATCH 1/3] rpmsg: virtio_rpmsg_bus: allow the different vring size for send/recv To: Xiang Xiao , , , , , CC: Xiang Xiao References: <1548949280-31794-1-git-send-email-xiaoxiang@xiaomi.com> <1548949280-31794-2-git-send-email-xiaoxiang@xiaomi.com> From: Arnaud Pouliquen Openpgp: preference=signencrypt Autocrypt: addr=arnaud.pouliquen@st.com; prefer-encrypt=mutual; keydata= xsFNBFZu+HIBEAC/bt4pnj18oKkUw40q1IXSPeDFOuuznWgFbjFS6Mrb8axwtnxeYicv0WAL rW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rzw2zjgr1e2zCZ1gHBTOyJZiDwAR AQABwsFlBBgBAgAPBQJWbvhyAhsMBQkJZgGAAAoJEP0ZQ+DAfqbfs5AQAJKIr2+j+U3JaMs3 px9bbxcuxRLtVP5gR3FiPR0onalO0QEOLKkXb1DeJaeHHxDdJnVV7rCJX/Fz5CzkymUJ7GIO gpUGstSpJETi2sxvYvxfmTvE78D76rM5duvnGy8lob6wR2W3IqIRwmd4X0Cy1Gtgo+i2plh2 ttVOM3OoigkCPY3AGD0ts+FbTn1LBVeivaOorezSGpKXy3cTKrEY9H5PC+DRJ1j3nbodC3o6 peWAlfCXVtErSQ17QzNydFDOysL1GIVn0+XY7X4Bq+KpVmhQOloEX5/At4FlhOpsv9AQ30rZ 3F5lo6FG1EqLIvg4FnMJldDmszZRv0bR0RM9Ag71J9bgwHEn8uS2vafuL1hOazZ0eAo7Oyup 2VNRC7Inbc+irY1qXSjmq3ZrD3SSZVa+LhYfijFYuEgKjs4s+Dvk/xVL0JYWbKkpGWRz5M82 Pj7co6u8pTEReGBYSVUBHx7GF1e3L/IMZZMquggEsixD8CYMOzahCEZ7UUwD5LKxRfmBWBgK 36tfTyducLyZtGB3mbJYfWeI7aiFgYsd5ehov6OIBlOz5iOshd97+wbbmziYEp6jWMIMX+Em zqSvS5ETZydayO5JBbw7fFBd1nGVYk1WL6Ll72g+iEnqgIckMtxey1TgfT7GhPkR7hl54ZAe 8mOik8I/F6EW8XyQAA2P Message-ID: <6d069d84-a01b-42f7-0e09-464477a7b1ee@st.com> Date: Thu, 9 May 2019 13:47:07 +0200 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:60.0) Gecko/20100101 Thunderbird/60.6.1 MIME-Version: 1.0 In-Reply-To: <1548949280-31794-2-git-send-email-xiaoxiang@xiaomi.com> Content-Type: text/plain; charset="utf-8" Content-Language: en-US Content-Transfer-Encoding: 8bit X-Originating-IP: [10.75.127.47] X-ClientProxiedBy: SFHDAG6NODE2.st.com (10.75.127.17) To SFHDAG3NODE1.st.com (10.75.127.7) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10434:,, definitions=2019-05-09_02:,, signatures=0 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hello Xiang, I tested your patch on stm32 platform, no issue. No remark on you code. Acked-by:Arnaud POULIQUEN Thanks, Arnaud On 1/31/19 4:41 PM, Xiang Xiao wrote: > it's useful if the communication throughput is different from each side > > Signed-off-by: Xiang Xiao > --- > drivers/rpmsg/virtio_rpmsg_bus.c | 47 ++++++++++++++++++++-------------------- > 1 file changed, 24 insertions(+), 23 deletions(-) > > diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c > index 664f957..fb0d2eb 100644 > --- a/drivers/rpmsg/virtio_rpmsg_bus.c > +++ b/drivers/rpmsg/virtio_rpmsg_bus.c > @@ -36,8 +36,9 @@ > * @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 > + * @num_rbufs: total number of buffers for rx > + * @num_sbufs: total number of buffers for 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. > @@ -57,7 +58,8 @@ struct virtproc_info { > struct virtio_device *vdev; > struct virtqueue *rvq, *svq; > void *rbufs, *sbufs; > - unsigned int num_bufs; > + unsigned int num_rbufs; > + unsigned int num_sbufs; > unsigned int buf_size; > int last_sbuf; > dma_addr_t bufs_dma; > @@ -136,7 +138,7 @@ struct virtio_rpmsg_channel { > /* > * 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). > + * by the vring, up to a maximum of 256 in each direction. > * > * Each buffer will have 16 bytes for the msg header and 496 bytes for > * the payload. > @@ -151,7 +153,7 @@ struct virtio_rpmsg_channel { > * can change this without changing anything in the firmware of the remote > * processor. > */ > -#define MAX_RPMSG_NUM_BUFS (512) > +#define MAX_RPMSG_NUM_BUFS (256) > #define MAX_RPMSG_BUF_SIZE (512) > > /* > @@ -446,11 +448,8 @@ static void *get_a_tx_buf(struct virtproc_info *vrp) > /* support multiple concurrent senders */ > mutex_lock(&vrp->tx_lock); > > - /* > - * either pick the next unused tx buffer > - * (half of our buffers are used for sending messages) > - */ > - if (vrp->last_sbuf < vrp->num_bufs / 2) > + /* either pick the next unused tx buffer */ > + if (vrp->last_sbuf < vrp->num_sbufs) > ret = vrp->sbufs + vrp->buf_size * vrp->last_sbuf++; > /* or recycle a used one */ > else > @@ -897,19 +896,20 @@ static int rpmsg_probe(struct virtio_device *vdev) > vrp->rvq = vqs[0]; > vrp->svq = vqs[1]; > > - /* we expect symmetric tx/rx vrings */ > - WARN_ON(virtqueue_get_vring_size(vrp->rvq) != > - virtqueue_get_vring_size(vrp->svq)); > - > /* we need less buffers if vrings are small */ > - if (virtqueue_get_vring_size(vrp->rvq) < MAX_RPMSG_NUM_BUFS / 2) > - vrp->num_bufs = virtqueue_get_vring_size(vrp->rvq) * 2; > + if (virtqueue_get_vring_size(vrp->rvq) < MAX_RPMSG_NUM_BUFS) > + vrp->num_rbufs = virtqueue_get_vring_size(vrp->rvq); > + else > + vrp->num_rbufs = MAX_RPMSG_NUM_BUFS; > + > + if (virtqueue_get_vring_size(vrp->svq) < MAX_RPMSG_NUM_BUFS) > + vrp->num_sbufs = virtqueue_get_vring_size(vrp->svq); > else > - vrp->num_bufs = MAX_RPMSG_NUM_BUFS; > + vrp->num_sbufs = MAX_RPMSG_NUM_BUFS; > > vrp->buf_size = MAX_RPMSG_BUF_SIZE; > > - total_buf_space = vrp->num_bufs * vrp->buf_size; > + total_buf_space = (vrp->num_rbufs + vrp->num_sbufs) * vrp->buf_size; > > /* allocate coherent memory for the buffers */ > bufs_va = dma_alloc_coherent(vdev->dev.parent->parent, > @@ -923,14 +923,14 @@ static int rpmsg_probe(struct virtio_device *vdev) > dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n", > bufs_va, &vrp->bufs_dma); > > - /* half of the buffers is dedicated for RX */ > + /* first part of the buffers is dedicated for RX */ > vrp->rbufs = bufs_va; > > - /* and half is dedicated for TX */ > - vrp->sbufs = bufs_va + total_buf_space / 2; > + /* and second part is dedicated for TX */ > + vrp->sbufs = bufs_va + vrp->num_rbufs * vrp->buf_size; > > /* set up the receive buffers */ > - for (i = 0; i < vrp->num_bufs / 2; i++) { > + for (i = 0; i < vrp->num_rbufs; i++) { > struct scatterlist sg; > void *cpu_addr = vrp->rbufs + i * vrp->buf_size; > > @@ -999,7 +999,8 @@ static int rpmsg_remove_device(struct device *dev, void *data) > static void rpmsg_remove(struct virtio_device *vdev) > { > struct virtproc_info *vrp = vdev->priv; > - size_t total_buf_space = vrp->num_bufs * vrp->buf_size; > + unsigned int num_bufs = vrp->num_rbufs + vrp->num_sbufs; > + size_t total_buf_space = num_bufs * vrp->buf_size; > int ret; > > vdev->config->reset(vdev); >