From patchwork Thu Dec 8 06:59:13 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaying Liang X-Patchwork-Id: 9465895 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 A28AA60231 for ; Thu, 8 Dec 2016 07:07:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7ECD428442 for ; Thu, 8 Dec 2016 07:07:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 704AE284D0; Thu, 8 Dec 2016 07:07:59 +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.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID 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 BFC3D28442 for ; Thu, 8 Dec 2016 07:07:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbcLHHH6 (ORCPT ); Thu, 8 Dec 2016 02:07:58 -0500 Received: from mail-sn1nam01on0085.outbound.protection.outlook.com ([104.47.32.85]:40457 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750822AbcLHHH5 (ORCPT ); Thu, 8 Dec 2016 02:07:57 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=xilinx.onmicrosoft.com; s=selector1-xilinx-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=2pHZoFwl/zDoPEeINWsdEn/JU+dubM/Ajs6MoVdcnxo=; b=GmFHBWjOPPzbanT2JpPD20CB3ndHTTgq8tVBVAURb6Sqvn+OznP/iARItcpCQoqQQRA/gV4gJo/Qal0DpThdJRAuxT8vGq78fkJY0MewBuwE19Wv7DNGt6P1jDyxv1Lca86dDEKfOftCZ6MksohQwKpP/E4Z6vzgl6h5SoDweyU= Received: from BLUPR02CA029.namprd02.prod.outlook.com (10.160.23.147) by DM2PR0201MB0896.namprd02.prod.outlook.com (10.160.215.142) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.8; Thu, 8 Dec 2016 07:07:24 +0000 Received: from BL2NAM02FT064.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e46::200) by BLUPR02CA029.outlook.office365.com (2a01:111:e400:8ad::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.734.8 via Frontend Transport; Thu, 8 Dec 2016 07:07:24 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.100) smtp.mailfrom=xilinx.com; redhat.com; dkim=none (message not signed) header.d=none;redhat.com; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.100 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.100; helo=xsj-pvapsmtpgw02; Received: from xsj-pvapsmtpgw02 (149.199.60.100) by BL2NAM02FT064.mail.protection.outlook.com (10.152.77.119) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.761.6 via Frontend Transport; Thu, 8 Dec 2016 07:07:23 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:1390; Count:15 Received: from unknown-38-66.xilinx.com ([149.199.38.66]:41319 helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw02 with esmtp (Exim 4.63) (envelope-from ) id 1cEsnb-0007pP-Al; Wed, 07 Dec 2016 23:07:23 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1cEsnb-00069s-7U; Wed, 07 Dec 2016 23:07:23 -0800 Received: from [172.19.74.38] (helo=xsjjliang50.xlnx.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1cEsnW-0005kc-LO; Wed, 07 Dec 2016 23:07:18 -0800 From: Wendy Liang To: , , , , , CC: "Edgar E. Iglesias" , Wendy Liang Subject: [PATCH 2/2] rpmsg: DMA map sgs passed to virtio Date: Wed, 7 Dec 2016 22:59:13 -0800 Message-ID: <1481180353-11139-3-git-send-email-jliang@xilinx.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1481180353-11139-1-git-send-email-jliang@xilinx.com> References: <1481180353-11139-1-git-send-email-jliang@xilinx.com> X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22746.005 X-TM-AS-User-Approved-Sender: Yes;Yes X-IncomingHeaderCount: 15 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.100; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39410400002)(39840400002)(39860400002)(39450400003)(39850400002)(2980300002)(438002)(199003)(189002)(7846002)(106466001)(5001770100001)(356003)(8676002)(8936002)(38730400001)(36386004)(63266004)(6666003)(2950100002)(77096006)(50986999)(81156014)(5660300001)(626004)(36756003)(47776003)(81166006)(4001430100002)(76176999)(305945005)(48376002)(92566002)(189998001)(50466002)(2201001)(50226002)(9786002)(107886002)(2906002)(575784001)(33646002)(4326007)(5003940100001)(107986001)(5001870100001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0201MB0896; H:xsj-pvapsmtpgw02; FPR:; SPF:Pass; PTR:unknown-60-100.xilinx.com,xapps1.xilinx.com; A:1; MX:1; LANG:en; X-Microsoft-Ex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PB0iudHqryIIyHEW5c9pr5H30TqDj9v+2wgmMWLazrJtPhMtrP6qARn7JkONH6RggTfm3Eg3M+ZvCZ5pn68wpuPQ= X-MS-Office365-Filtering-Correlation-Id: 27f28497-c966-4a68-cfa6-08d41f38dc5a X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002); SRVR:DM2PR0201MB0896; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0201MB0896; 25:XK1Q7/gpCfL6Qcge+nGYcMWKMf9hB79as0neMx6dROWNfUfBbCWm8B5y0NcHT+0j/T8uP5bvlzyDVozFQFWaCOL0KuFr4ymfvhlOaGdRVzrXnNTkeMdlhSAS0db4gsnpXzh3Sq1YORrEIOmrNy5FUMyKE23YGLenNsW9JtvOiJGWCaVUlP7WRhlb1e/DhU7BFTkTk4Ik4/6QnvBp+r5v5ZxmG1DcZ2Citd9EPbPOo4yOhps6qcXcimY9f0/MGbIjvdRIMLXx7kkF4eFeDGG9CFiW+nShwSeHM8GguqL7syb7eAwRAZcDHo7buVvkqyfr0B7Ufm3SAmBjYoapYVu1ZiX7nIVAFVtkcCvjGlNZwOixA0Kt/7S1YlJJo5LQ95EaHr8OEfiSj+keTjrjXMeO2GV2Fzm7j8clPv2Sm3TuMAPe3V9qsJtbi2hklOqpc6Groqp4wES+EOpqst7S0nvrWK8q1DUHQMzHCilw4+8sDUlOh5HqNs42vINt864CXC4k35NjiOeNW/a+SxgvRWxu/1t0l4av52xanQ/56bo5pGbGiGOV3Z5b8pzLkkqK3o/MRp+IM5sYu2LlJ9d/xvHN8QoZYoCU6/xH7j4LgaYtmZYkFbPY2qcEk+rv7JO2+9OZqAWcH/kWhlSjN9xIqOM75ZlEyuCP/6EJxoTIY9EWrNaSudAQuVjp6Mtfpvf/j5iZOjP5DVXG0VFXoaqPlPqBPuNk8Fs2yvAQsYf8vfDMU2aAPqMkA3rFJD2aD1WVWSd3pUFwEOjVjRhP13scSlwoTeRLuVuS0D0s80Jdn5OeieV1PKiXzXjA2h531jVMOLvi X-Microsoft-Exchange-Diagnostics: 1; DM2PR0201MB0896; 31:0bHliJlc7xgWxeyQ8CDONY3C4ofmUDCFWBvBPFERId8JL2nC9FhqU0EmGvAkFWWnYEGM4VVoOLMadNmWWaMsMrn1LK9syMhUQ1heLQsQulk0NmvRymfu/r/i79VDqwmYHLRM6Oyy6ie5jbhy8gSwM2/1C/bID8iW6m/5zEz0t/KizEL7LwNwijkAq9Zn+zU/oO1BzDHH4KDUFEa3/e87PMoRpUi8ZYCsupTqV6evrHQGqZHttLyXsJ5GH6kk0iS/TKG7ktsu20J5+ndUicT/IVowbkq+3i9KkpA30FLGnnU=; 20:OfdsRj/XBEHCfZ2H75Q+X4O/xrJis/Tt07yHLeuh2Blhxm+3ZTP2PLLsWEiwroIqiBfROCwQboJ7EZVH/EsgjdcfdAKqwH/ycJ7ks0KdKZWl910ndUK1mc5IMCcHaFo0Hrvnehc2qHTJbYRx5emexpWqzjYomstECLt2375UcZQxlslFsNRPHzu/cDv0/3LZlPbVOD1Zlian+Ykhk5LnQeu3kRr/9Je8y8/dMqizDipBAYf0KvIrP5tT3eVpCOLXJbhhLRw3623lPM2hB5iWG7yKKICLCAAgsS85zzHUX7b7TUmzIFcsUswxbeb3lCJUqw4pvr8jQBMojEwxJXSHkyB6lH/NFxkkay6HMPhIHoLXQw8WhINdmi0WouqAMMEgLIoo8t/d/B/B9HDd08w3UzFlSfu/EYa7X7xG1URKKXHlxrJi1xJXCBpGhgyAcipOgfmpqV5apgCdgqzj30FEwbH3HVBvpsjeJ0Cw8ffOYn9I1BH0dujAjWAhdoE3XQmG X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(192813158149592); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(13015025)(13017025)(13023025)(13024025)(13018025)(10201501046)(3002001)(6055026)(6041248)(20161123555025)(20161123564025)(20161123558021)(20161123560025)(20161123562025)(6072148); SRVR:DM2PR0201MB0896; BCL:0; PCL:0; RULEID:; SRVR:DM2PR0201MB0896; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0201MB0896; 4:EszQ5/Ni5IcbwCMAAD+g5mq+oDbKMFXJA/X8QZU0XNzNdJJgGZzFiAJcJ7meoWlt9jMXV48+a2xdbQfyWvdMJqQiGOP2IOk4CUeb9Obi01R7YtvMSpjIx3hI6A/dlBvF3KLe2pZiLpSc4dIyqT1/cC2WJc9dYhAtoxKf0hEZQBrlN5dwf8MOZPum2X6pPrh5EJce60r4UdT8vO//Zp5ek5VfIe/Tz0RdaCawClSNGAUZdB/WcOFOukduqkwoIjW6tNU34s0BQHrSY2Hmd3MqNDH3tOqRB17Z+YGm9ot2HQuZ92fXZi6g78er43aYb4sSz8nTRoryJToD5ywe6sg/lZoXk+7pBoWBcR3Y0Tw+PQ485rlioh64a40bpYa2tXXLbjZa0IaSfkkvoHUbxk3t/mOMOldQcKQVRmFYpvUPN3+yHnfobUGuA8V2mwEsKPX3ExYDGgZ2qqL/zaK4GYHxKegu2XFuM2ORQUpnSkKjSdNkyM0SFcQt88ZdEV/Tqwc+elaMb0cF27J+xGhbqYjUSiIBIlrC+jUnVqCHPHzEBR/tbDzoR3RWQi/3wQGWi3R2zgAfg5EmrxdlPj+soE5D7OjWOtU3yR27asFnHZfLF74oakoZOQYoiirmldTMR3eZsGwiFWLTV36esUDLdH2Thv7OBu8XKlL1ppf5LRJMXj9VlcICJhOAhmyUEvwpmjFEFzi9UFTSEcwurNhEBckNX4sdi9XWEOnCL8z6j/dmxz4m999hpqZ625bFWXbS2BPEMYEfH1EffIgp8DEImHaqbw== X-Forefront-PRVS: 0150F3F97D X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; DM2PR0201MB0896; 23:dbyrlfxc6tl9Xz7XkewZJexToFgImB9/tQn58t5?= =?us-ascii?Q?rzGp8tW6b84e08SaEvQKCQ/XeEII8/ffL/sz8X/6FDmKIuxs8q75g4/SaH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AUQLnoE0hdiC/PNINrBYNBDK?= =?us-ascii?Q?e6Z0Pp4IKnaWqHzmkQDPo9ijqnrKZmHJ/IcNYNYvcb97xmPqsYaBqCco3vqW?= =?us-ascii?Q?Xh3Nlzltog+nhlk/lmJj8ZN0O8jgnkaGubBPDaxCJX/IUgX/CurGXDna5nFE?= =?us-ascii?Q?HKnYIJE8REE9S8f4U/pyzMupaaWGAjTKLineJOt8ktI0jQ3PTjlsX3qSOEzQ?= =?us-ascii?Q?zHzwkEDYs7ZnVaysVVyVEpU1yAuVUs0d166Wp?= X-Microsoft-Exchange-Diagnostics: 1; DM2PR0201MB0896; 6:o3AUWG6WkbQp9542A2OLeWzFoP31JPv/PinPY+V7pRUPWsWW8e7pNiG0qUDGaRJPyofJI+8jO6ivRqOWafWqDQoQgLwFQann0RJSAw7zqqbbAB05fA/EIaaacfKsraLfdKTq9lbtih2zNRcsALXCTEiO5iohGPlj6dsSRoFalzvHfbcVTcCl7gQ9U6RWn1pJKPdA3zJkeeC42I86i6j2B8o8B48jYmaYg8wtvVzXN0Se2F3033mKqkL8rmbqGGgyvkPcBQgS2vn9Ia6wCaZgY2zBOjDx35Q91a569y6xC4S1k1nS7dsejHDaKCH7o/53YOBQUFqH/JeN1t/QzcdOaaSP6uPSUUPc4ADpRpCIlyoKa3OQJWRcnGFmpRkWQYZX; 5:+PeADnr1tiq/5GUajoUCOrgVbZQiiT4x6hogkX2WdxlXc2baVaUDZSRGDxNSNhGp+G8/cdXoF7bnRw65ptsGtwZJDbkmyd7/6r0cUfI60cuc3mTa0DZhWdLnT1S9LwsGse0Xp1bTAPlYHVE5rAI7lg==; 24:IDYxruxgbW/cY1PigzASViaK7XGPdREsuvvPV6zLRKDLqDvo4e+UCxlWQVDdg9lj1ip16+YbobHcn9zG0tJ66uPaXZ5PjZ/pU5d3L1Nv4/8= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR0201MB0896; 7:823UobcNnOZc2H0AOrW50kBUmrKzuSiNkwLX4sU34nHMdyDk01DqLCupO6iFKPpmfE53KA4PyWJ6qz42BMG3gNDzkY9QNhDRDSl2JmZPEv321Q8UlszaQXbiMZQPvIHbfeSU3E0eOCZ3nG3lSDgXV9b4CmPBoXKekZTLYBBKMi7Ye5QGb47kfnYDll45ZNk3McrjrZKxcHiiRS1HJhkcPOnDG78IqKj0pI7Hyk/0BjvJa9vvADPdUwcMqlXFLwvyj7iMuIrCOy4bwOAetaLzelfcwczNwVyR/fkVKu1vvioZyj72pMrV9HKgjQSrQXrj+YAf+bV2pUyYSS+dXFCiuG7RIfwclrgIpY3GojOjT1A= X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2016 07:07:23.9776 (UTC) X-MS-Exchange-CrossTenant-Id: 657af505-d5df-48d0-8300-c31994686c5c X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=657af505-d5df-48d0-8300-c31994686c5c; Ip=[149.199.60.100]; Helo=[xsj-pvapsmtpgw02] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR0201MB0896 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 From: "Edgar E. Iglesias" As rpmsg uses dma_alloc_coherent() to allocate memory to shared with the remote. Virtio ring requires the shared buffers to be passed as sg struct. As the memory has already been mapped, and we cannot convert the virtual address got from dma_alloc_coherent() back to the physical address. We set the sg_dma_addr to store the DMA address before we pass it to virtio. Signed-off-by: Edgar E. Iglesias Signed-off-by: Wendy Liang --- drivers/rpmsg/virtio_rpmsg_bus.c | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/drivers/rpmsg/virtio_rpmsg_bus.c b/drivers/rpmsg/virtio_rpmsg_bus.c index 3090b0d..af76187 100644 --- a/drivers/rpmsg/virtio_rpmsg_bus.c +++ b/drivers/rpmsg/virtio_rpmsg_bus.c @@ -192,6 +192,22 @@ static int virtio_rpmsg_trysend_offchannel(struct rpmsg_endpoint *ept, u32 src, .trysend_offchannel = virtio_rpmsg_trysend_offchannel, }; +static inline dma_addr_t msg_dma_address(struct virtproc_info *vrp, void *msg) +{ + unsigned long offset = msg - vrp->rbufs; + + return vrp->bufs_dma + offset; +} + +static inline void rpmsg_msg_sg_init(struct virtproc_info *vrp, + struct scatterlist *sg, + void *msg, unsigned int len) +{ + sg_init_table(sg, 1); + sg_dma_address(sg) = msg_dma_address(vrp, msg); + sg_dma_len(sg) = len; +} + /** * __ept_release() - deallocate an rpmsg endpoint * @kref: the ept's reference count @@ -604,7 +620,7 @@ static int rpmsg_send_offchannel_raw(struct rpmsg_device *rpdev, msg, sizeof(*msg) + msg->len, true); #endif - sg_init_one(&sg, msg, sizeof(*msg) + len); + rpmsg_msg_sg_init(vrp, &sg, msg, sizeof(*msg) + len); mutex_lock(&vrp->tx_lock); @@ -729,7 +745,7 @@ static int rpmsg_recv_single(struct virtproc_info *vrp, struct device *dev, dev_warn(dev, "msg received with no recipient\n"); /* publish the real size of the buffer */ - sg_init_one(&sg, msg, RPMSG_BUF_SIZE); + rpmsg_msg_sg_init(vrp, &sg, msg, RPMSG_BUF_SIZE); /* add the buffer back to the remote processor's virtqueue */ err = virtqueue_add_inbuf(vrp->rvq, &sg, 1, msg, GFP_KERNEL); @@ -911,7 +927,7 @@ static int rpmsg_probe(struct virtio_device *vdev) struct scatterlist sg; void *cpu_addr = vrp->rbufs + i * RPMSG_BUF_SIZE; - sg_init_one(&sg, cpu_addr, RPMSG_BUF_SIZE); + rpmsg_msg_sg_init(vrp, &sg, cpu_addr, RPMSG_BUF_SIZE); err = virtqueue_add_inbuf(vrp->rvq, &sg, 1, cpu_addr, GFP_KERNEL);