Received: by 2002:a25:4158:0:0:0:0:0 with SMTP id o85csp761860yba; Thu, 9 May 2019 05:39:25 -0700 (PDT) X-Google-Smtp-Source: APXvYqwCzALogW6wvXcWXxSy77foXHbYQUw/j5pFGe+X9+WcVVoYSOzW0xw/muN8mV28wJUZeI7S X-Received: by 2002:a17:902:112b:: with SMTP id d40mr4786701pla.31.1557405564904; Thu, 09 May 2019 05:39:24 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1557405564; cv=none; d=google.com; s=arc-20160816; b=ejYBIbb9AcxHfp6RxqRKW5zRDsY2eX9oKjYvUVxREnp2eIS9+QCj8rbLh0mCCgXdje vDQYCCcVUCZTsPfpodKeOTDrA0ls6M0Au1NoK6NNQM7IpcAyzB3rRGdYCK/6dt/cs3X3 55Z4gmlc60ZpEGZ6y/pz7URBW+h/ogrHL0+bzsZtYr6R+MvWCCcPXJzoTsAhyLvgi31y YFwO0fFf5MLvSvXRjNNBxlSpprHMEkQLOqjqcy9rqweXO4mDJHubbDWw9Yz51sgbfO25 ig04FQO+l1A1Tx99mHjDsoSf+Mz91yPVs2z4npQECxkJIIKSBo75vETYOtO0fmDG0KjY O4Jg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=gff3GQLBjvfEeXb3DPqNhomCkoH+ZNgB7C2kigM/kGQ=; b=V/dNCKeEKItEuyet6oo7jGltDFgY+NBQRTG6+jpdwAnU4ARMqSm36oekNKcNLE8YOT 3VV7ZGT3LcPXJkDENdfFthAlUaJNkxo+OYvqNveWTOSVJtYUkdo5TCt864xdBqs5AgOy yu5e01CCx7199cxlUlCbeIaUImpoPBA5tYyDhFORxFYjdbrJcRbBxNq9xrLtqqGRq6hn rIiU0RN9qHt+MRrFTlUyz1UBk2OPb08JfDFI7LEtUkwyizLBxSMkD4z4rCIu9+9b9fdn 98fD2F2wlSUXRNHR/3dItNLBCooD/6wHa1ElHJ0l/8UhBiPwNsxN6y8XVALrKEkmAT4O jrvg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=cMXPoWHN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l12si2751164pgq.329.2019.05.09.05.39.08; Thu, 09 May 2019 05:39:24 -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=@gmail.com header.s=20161025 header.b=cMXPoWHN; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726604AbfEIMht (ORCPT + 99 others); Thu, 9 May 2019 08:37:49 -0400 Received: from mail-qt1-f194.google.com ([209.85.160.194]:32939 "EHLO mail-qt1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726426AbfEIMht (ORCPT ); Thu, 9 May 2019 08:37:49 -0400 Received: by mail-qt1-f194.google.com with SMTP id m32so407316qtf.0; Thu, 09 May 2019 05:37:48 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=gff3GQLBjvfEeXb3DPqNhomCkoH+ZNgB7C2kigM/kGQ=; b=cMXPoWHNwNprH03rOZRpE7hDOwDFRpiRDWA1RQYN/COX3mgDBSvSbMGl8+eayLDIwi Wkbu0omPnEtJLSQrcuYr9H44e4PuJ2h+Vb5Fduh7ZzQDpx0s/1CZ9y5qGT5Km/qlQfNQ WJXqWu1iWNsjJcGxWLos1H24KMpLxzn7PSnhNOJ1Ot6IS6Gv3PkHLTUysPc0kgUHWc0F 7pDiMu28+vNjVLsDFhwkefVkaMpPtfiz5Ad3VManfUmtxeplvvLS1EKlws+3thdMuy8m eAziH0zvlkdFnyo+tT1CsaJFDcHD3mzE7VlHbodzA81xnCb3RjJwbVSmAKWRrh0uqyWH 1fuw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=gff3GQLBjvfEeXb3DPqNhomCkoH+ZNgB7C2kigM/kGQ=; b=ZBwfX57KBlKfQptpV90FhuN+wDTM9gh+fVqn1+Hhg9QFLEhSMNH9xgN3R6zXhOMrs3 kGJmbOHfN3brZeL2wlzKPQDTlnKh9AL0IuIAkVZwhMlVTsJJpISGlCLyD0iy57Kk69c1 zDOtvwQtQEiVaj6MFtDKLrSCulbBCRX28tyqRKM4JcrZL8xr4Zx+xMP5QNMb167FcTTw 4sC213r53/4GCDWHAXdBF8GQHgMqP3ysCiGpr/fIDxIUjkN6w5z0RogymKS03AYKn5j/ bCo1e847n54WGmsvl7PIWWbZ08bTwHkK7u9WZnTiv01VtoR3lBPGpJSzX4UVQj3WXgpN QBIw== X-Gm-Message-State: APjAAAXu9glS8dkCOq6GSOOb0dt5vk9uTfFrtEzbL62xLmEl9EblUypd KO6aafP5cMyI4aYjlL7dbR6mtahiesAWYLZlkVA= X-Received: by 2002:a0c:ee29:: with SMTP id l9mr3225465qvs.151.1557405467891; Thu, 09 May 2019 05:37:47 -0700 (PDT) MIME-Version: 1.0 References: <1548949280-31794-1-git-send-email-xiaoxiang@xiaomi.com> <1548949280-31794-3-git-send-email-xiaoxiang@xiaomi.com> <01b88b99-ebc1-a5a3-2ff9-39fe476847be@st.com> In-Reply-To: <01b88b99-ebc1-a5a3-2ff9-39fe476847be@st.com> From: xiang xiao Date: Thu, 9 May 2019 20:37:36 +0800 Message-ID: Subject: Re: [PATCH 2/3] rpmsg: virtio_rpmsg_bus: allocate rx/tx buffer separately To: Arnaud Pouliquen Cc: Ohad Ben Cohen , Bjorn Andersson , wendy.liang@xilinx.com, linux-remoteproc@vger.kernel.org, linux-kernel@vger.kernel.org, Xiang Xiao Content-Type: multipart/mixed; boundary="000000000000af8326058873b743" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --000000000000af8326058873b743 Content-Type: text/plain; charset="UTF-8" On Thu, May 9, 2019 at 8:02 PM Arnaud Pouliquen wrote: > > Hello Xiang, > > This patch has the opposite effect on my platform as DMA allocation is > aligned on 4k page. > For instance i declared: > - in RX 6 buffers (of 512 bytes) > - in TX 4 buffers ( of 512 bytes) > Yes, dma_init_coherent_memory always allocate memory by 4KB unit, but this limitation is too waste memory for remoteproc/rpmsg. The attached patch fix this problem by adding a new device tree option to customize the unit size. > The result is (kernel trace) > [ 41.915896] virtio_rpmsg_bus virtio0: rx buffers: va ebb5f5ca, dma > 0x0x10042000 > [ 41.915922] virtio_rpmsg_bus virtio0: tx buffers: va a7865153, dma > 0x0x10043000 > > The TX buffer memory is allocated on next 4k page... > > Anyway separate the RX and TX allocation makes sense. This could also > allow to allocate buffers in 2 different memories. > For time being, issue is that only one memory area can be attached to > the virtio device for DMA allocation... and PA/DA translations are missing. > This means that we probably need (in a first step) a new remoteproc API > for memory allocation. > These memories should be declared and mmaped in rproc platform drivers > (memory region) or in resource table (carveout). > This is partially done in the API for the platform driver > (rproc_mem_entry_init) but not available for rproc clients. > > Regards > Arnaud > > > On 1/31/19 4:41 PM, Xiang Xiao wrote: > > many dma allocator align the returned address with buffer size, > > so two small allocation could reduce the alignment requirement > > and save the the memory space wasted by the potential alignment. > > > > Signed-off-by: Xiang Xiao > > --- > > drivers/rpmsg/virtio_rpmsg_bus.c | 58 +++++++++++++++++++++++----------------- > > 1 file changed, 34 insertions(+), 24 deletions(-) > > > > diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c > > index fb0d2eb..59c4554 100644 > > --- a/drivers/rpmsg/virtio_rpmsg_bus.c > > +++ b/drivers/rpmsg/virtio_rpmsg_bus.c > > @@ -40,7 +40,8 @@ > > * @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 > > + * @rbufs_dma: dma base addr of rx buffers > > + * @sbufs_dma: dma base addr of tx 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. > > @@ -62,7 +63,8 @@ struct virtproc_info { > > unsigned int num_sbufs; > > unsigned int buf_size; > > int last_sbuf; > > - dma_addr_t bufs_dma; > > + dma_addr_t rbufs_dma; > > + dma_addr_t sbufs_dma; > > struct mutex tx_lock; > > struct idr endpoints; > > struct mutex endpoints_lock; > > @@ -872,9 +874,7 @@ static int rpmsg_probe(struct virtio_device *vdev) > > static const char * const names[] = { "input", "output" }; > > struct virtqueue *vqs[2]; > > struct virtproc_info *vrp; > > - void *bufs_va; > > int err = 0, i; > > - size_t total_buf_space; > > bool notify; > > > > vrp = kzalloc(sizeof(*vrp), GFP_KERNEL); > > @@ -909,25 +909,28 @@ static int rpmsg_probe(struct virtio_device *vdev) > > > > vrp->buf_size = MAX_RPMSG_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, > > - total_buf_space, &vrp->bufs_dma, > > - GFP_KERNEL); > > - if (!bufs_va) { > > + vrp->rbufs = dma_alloc_coherent(vdev->dev.parent->parent, > > + vrp->num_rbufs * vrp->buf_size, > > + &vrp->rbufs_dma, GFP_KERNEL); > > + if (!vrp->rbufs) { > > err = -ENOMEM; > > goto vqs_del; > > } > > > > - dev_dbg(&vdev->dev, "buffers: va %p, dma %pad\n", > > - bufs_va, &vrp->bufs_dma); > > + dev_dbg(&vdev->dev, "rx buffers: va %p, dma 0x%pad\n", > > + vrp->rbufs, &vrp->rbufs_dma); > > > > - /* first part of the buffers is dedicated for RX */ > > - vrp->rbufs = bufs_va; > > + vrp->sbufs = dma_alloc_coherent(vdev->dev.parent->parent, > > + vrp->num_sbufs * vrp->buf_size, > > + &vrp->sbufs_dma, GFP_KERNEL); > > + if (!vrp->sbufs) { > > + err = -ENOMEM; > > + goto free_rbufs; > > + } > > > > - /* and second part is dedicated for TX */ > > - vrp->sbufs = bufs_va + vrp->num_rbufs * vrp->buf_size; > > + dev_dbg(&vdev->dev, "tx buffers: va %p, dma 0x%pad\n", > > + vrp->sbufs, &vrp->sbufs_dma); > > > > /* set up the receive buffers */ > > for (i = 0; i < vrp->num_rbufs; i++) { > > @@ -954,7 +957,7 @@ static int rpmsg_probe(struct virtio_device *vdev) > > if (!vrp->ns_ept) { > > dev_err(&vdev->dev, "failed to create the ns ept\n"); > > err = -ENOMEM; > > - goto free_coherent; > > + goto free_sbufs; > > } > > } > > > > @@ -979,9 +982,14 @@ static int rpmsg_probe(struct virtio_device *vdev) > > > > return 0; > > > > -free_coherent: > > - dma_free_coherent(vdev->dev.parent->parent, total_buf_space, > > - bufs_va, vrp->bufs_dma); > > +free_sbufs: > > + dma_free_coherent(vdev->dev.parent->parent, > > + vrp->num_sbufs * vrp->buf_size, > > + vrp->sbufs, vrp->sbufs_dma); > > +free_rbufs: > > + dma_free_coherent(vdev->dev.parent->parent, > > + vrp->num_rbufs * vrp->buf_size, > > + vrp->rbufs, vrp->rbufs_dma); > > vqs_del: > > vdev->config->del_vqs(vrp->vdev); > > free_vrp: > > @@ -999,8 +1007,6 @@ static int rpmsg_remove_device(struct device *dev, void *data) > > static void rpmsg_remove(struct virtio_device *vdev) > > { > > struct virtproc_info *vrp = vdev->priv; > > - 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); > > @@ -1016,8 +1022,12 @@ static void rpmsg_remove(struct virtio_device *vdev) > > > > vdev->config->del_vqs(vrp->vdev); > > > > - dma_free_coherent(vdev->dev.parent->parent, total_buf_space, > > - vrp->rbufs, vrp->bufs_dma); > > + dma_free_coherent(vdev->dev.parent->parent, > > + vrp->num_sbufs * vrp->buf_size, > > + vrp->sbufs, vrp->sbufs_dma); > > + dma_free_coherent(vdev->dev.parent->parent, > > + vrp->num_rbufs * vrp->buf_size, > > + vrp->rbufs, vrp->rbufs_dma); > > > > kfree(vrp); > > } > > --000000000000af8326058873b743 Content-Type: application/octet-stream; name="0001-dma-coherent-support-the-alignment-smaller-than-PAGE.patch" Content-Disposition: attachment; filename="0001-dma-coherent-support-the-alignment-smaller-than-PAGE.patch" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jvgmyvwr0 RnJvbSA2MjY3MmUxZGY3OWM5ZmZjY2IwNjJmNWFhMGRjYjE4ZTkzOGNlZDBjIE1vbiBTZXAgMTcg MDA6MDA6MDAgMjAwMQpGcm9tOiBYaWFuZyBYaWFvIDx4aWFveGlhbmdAeGlhb21pLmNvbT4KRGF0 ZTogVGh1LCAyMiBKdW4gMjAxNyAxNDozMDo1MCArMDgwMApTdWJqZWN0OiBbUEFUQ0hdIGRtYS1j b2hlcmVudDogc3VwcG9ydCB0aGUgYWxpZ25tZW50IHNtYWxsZXIgdGhhbiBQQUdFX1NJWkUKCmFu ZCByZWFkIHRoZSBhbGlnbm1lbnQoZGVmYXVsdCBQQUdFX1NJWkUpIGZyb20gZGV2aWNlIHRyZWUK CkNoYW5nZS1JZDogSTUxMjEyODg1OWIwYWFjMmUyNWJlMDljYThlMDk2ODE5MDA1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