From patchwork Tue Dec 6 18:08:49 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaying Liang X-Patchwork-Id: 9463055 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 C0F3F6022E for ; Tue, 6 Dec 2016 18:15:42 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B7C782849E for ; Tue, 6 Dec 2016 18:15:42 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AB171284A0; Tue, 6 Dec 2016 18:15:42 +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 C18BD2849E for ; Tue, 6 Dec 2016 18:15:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1753285AbcLFSPl (ORCPT ); Tue, 6 Dec 2016 13:15:41 -0500 Received: from mail-sn1nam01on0076.outbound.protection.outlook.com ([104.47.32.76]:2112 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1753167AbcLFSPj (ORCPT ); Tue, 6 Dec 2016 13:15:39 -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=Hxfuc0JgsMDeZRAmTV9+mYN3e9/YNDRdiwyK1/15EiFOXi5RFIS1MIsKwQFNl+qjvs5V2p747ya9OPVg4ZAHbMsqC1WSYoQgDo4fbEC+0ze7W93PTzn6gD78pYXSWLIN+SG2Vnh4asU2mkTO7U13fY65KtfAwBDZuANvPoNRbWA= Received: from BN6PR02CA0068.namprd02.prod.outlook.com (10.175.94.158) by CY1PR0201MB0907.namprd02.prod.outlook.com (10.160.164.151) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.747.13; Tue, 6 Dec 2016 18:15:37 +0000 Received: from SN1NAM02FT017.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e44::202) by BN6PR02CA0068.outlook.office365.com (2603:10b6:404:f9::30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9 via Frontend Transport; Tue, 6 Dec 2016 18:15:37 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) smtp.mailfrom=xilinx.com; lists.linux-foundation.org; dkim=none (message not signed) header.d=none; lists.linux-foundation.org; dmarc=bestguesspass action=none header.from=xilinx.com; Received-SPF: Pass (protection.outlook.com: domain of xilinx.com designates 149.199.60.83 as permitted sender) receiver=protection.outlook.com; client-ip=149.199.60.83; helo=xsj-pvapsmtpgw01; Received: from xsj-pvapsmtpgw01 (149.199.60.83) by SN1NAM02FT017.mail.protection.outlook.com (10.152.72.115) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.761.6 via Frontend Transport; Tue, 6 Dec 2016 18:15:34 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:1605; Count:17 Received: from unknown-38-66.xilinx.com ([149.199.38.66] helo=xsj-pvapsmtp01) by xsj-pvapsmtpgw01 with esmtp (Exim 4.63) (envelope-from ) id 1cEKH7-0006Gj-GX; Tue, 06 Dec 2016 10:15:33 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1cEKH7-00018k-Ag; Tue, 06 Dec 2016 10:15:33 -0800 Received: from xsj-pvapsmtp01 (smtp2.xilinx.com [149.199.38.66]) by xsj-smtp-dlp2.xlnx.xilinx.com (8.13.8/8.13.1) with ESMTP id uB6IFTV3030830; Tue, 6 Dec 2016 10:15:29 -0800 Received: from [172.19.74.38] (helo=xsjjliang50.xlnx.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1cEKH3-000152-MB; Tue, 06 Dec 2016 10:15:29 -0800 From: Wendy Liang To: , , , , , CC: "Edgar E. Iglesias" , Wendy Liang Subject: [RFC LINUX PATCH 2/2] rpmsg: DMA map sgs passed to virtio Date: Tue, 6 Dec 2016 10:08:49 -0800 Message-ID: <1481047729-518-3-git-send-email-jliang@xilinx.com> X-Mailer: git-send-email 1.9.1 In-Reply-To: <1481047729-518-1-git-send-email-jliang@xilinx.com> References: <1481047729-518-1-git-send-email-jliang@xilinx.com> X-RCIS-Action: ALLOW X-TM-AS-Product-Ver: IMSS-7.1.0.1224-8.0.0.1202-22744.004 X-TM-AS-User-Approved-Sender: Yes;Yes X-IncomingHeaderCount: 17 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:149.199.60.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(2980300002)(438002)(189002)(199003)(7846002)(81166006)(38730400001)(5001770100001)(36386004)(92566002)(6666003)(189998001)(107886002)(4326007)(5003940100001)(8936002)(2201001)(2906002)(81156014)(2950100002)(9786002)(50226002)(39410400001)(4001430100002)(39850400001)(77096006)(575784001)(8676002)(39450400002)(106466001)(305945005)(48376002)(5660300001)(50466002)(47776003)(33646002)(63266004)(50986999)(626004)(356003)(39860400001)(36756003)(39840400001)(76176999)(107986001)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0201MB0907; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; PTR:unknown-60-83.xilinx.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; SN1NAM02FT017; 1:kJrhN4WH0LaHsBr20r4uTrvTQPbx3a0gKPb8OlpW4ejk/fxVu8otSLNZV7uFmWkiDRT9oh2sTYptNrdYKDeHiGyp82DL7Xb4nhQMrlLs+jA8ygyj/rHraDrTtzFU66gT73NOVOUK5QqRvys2JgbMIP+tu3dNjdeL+aZdJuahUxu4xKOlr5wxdagehzYPU5y1BtGlozsNKTWfb4YLmpZxEvLQ++lAynYmSM0ccG8dF6YoW2rG/h3rJYesRaw4gNQjw4Y3ZP9DC+nxn5IRWMvSv+s4VqZ87oJb8PUJkvgC2PhkHPpcx1kRxmNaedyfQTcfVUfOVwdTgvd4frFfvVHgtLZhB80BoOp1i0LyqYs03A5uCofsY0Hx5Gluc02I0+7J26cYbC0qiGpzoa3lAhM9PZbbxYBCpwKb/uEmcOAWb2/r0z59m9gRTBfikGkERsT8j3MhXEo9LsI5eujGDqqlJp39kRi8PZ6wuCyEGXrpowdX07hMrddQ3TkyZt35okMeYKQAfpu+3ll7pyel5rhlITtgR3QVpS2fz7rZ/p6NJ2WpFt1611shXzoM+oRqxlbZ9hGajV2lHB2k7WzruJLnCdBLnS2OeNAtQEe14seQSgU= MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 866b9dc8-564a-4ae9-6f5b-08d41e03df33 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002); SRVR:CY1PR0201MB0907; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB0907; 3:JL1Gl+4ce1WTbm7kPieOnIkn9/b3hlMjhpOrrE62TR0PlK5enTCLeM7z+O/1WnTTfyjCFchU4m+rvMf73pLYBh1KpQCX9yOwLeOTMf3zcMCrypLNc4/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QQjRx2GcJow8iD8regRlciQ=; 20:I7qmN7eyDmCcarsd9/tKNndNJOSVQSBU5dhN0adhc49C6uWIFGZuNjeCkfJ//ffIlURUkWNvkpoeg7hPUwyNx9rwcYUhHiEpEK9vcTHJ7syCKDtWMxTJ7K06uxSCh/w+IUzni17DncgobupcLrZcByfFl3VwGHje4C6glgug2OEa1lmcM4dWSEbEI5OGfIB732UNeTVajbgqCAEiMPESj4IMogVy6FcYti7b0DHZqKGTOb/RX4DmM8OOmptR484lQFp6fL9lKaUoKm2BrFhyTIKFWaGqsWiqXvsaYSTDz6jP71syCi2P4WaN9hKGhUjX1WgajHIJXDF48+K4td2CqXek6DhFdaDKhp6vJ/tTc/zxzzpENjEr2HN0jutBJ6sxkmdBylYrWghxRyXpzjbqRQgvFm2lhwDwBju9Kn5RnS1koMMbIn/1rEmNEEdqkB63/sdBZ4PrbUPzQv/httn/mBgTP88nmCMHi8r12sloJZ38nm6n0JrR84cZA6ePiNYC 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)(8121501046)(5005006)(13017025)(13015025)(13023025)(13024025)(13018025)(3002001)(10201501046)(6055026)(6041248)(20161123560025)(20161123562025)(20161123564025)(20161123555025)(6072148); SRVR:CY1PR0201MB0907; BCL:0; PCL:0; RULEID:; SRVR:CY1PR0201MB0907; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB0907; 4:ZFpCoJQL1kI7VIo/KwnO+guuDtguvUursgDdMVSfm1rHKmFqXfrkJ+gkFGJfRejHaZl32yvpA9EKbSM1BM+CAZj+98hUG+waPL3diwl8pI+cYjPZKZm+21qOLvC9mGl2djeKqK0jtniFNTj5CKqpL9/pRdS1V6yKZDwoJqFwjLv+kSSj+oEG0G0pDX7ixzgqbLtQQ9JNJUo+jaCRC4c1x/jAJSuMkbb1u0ZSVan/02B+Wz4jPcJielZBKUHbHNOk7LKIt0uoZTnrgDiVa2j3/q5sezqx9GJIlGw5juGw1Pjsn4C4maFpuPUPzmbgX1jnBMNt9WR2zaGUfpzx2K26I8SaAVEGUkAA4gyUjy6uFS8shRT960LESs3rlr7qUQ4DBSkNZ2L0psmBt4xe9JC/VvRmwlG8pCgEJarGnKcvpkJ6p4YFT4uH90mxUgcz7ImeOQN7pPybpdgScxlwexB3jDtsz62WNPSLYhPBPoCVBxedMmVPNM5TpCm93xLO/gj6KTEgCmsl3RefWWu+Fl7QFKFI3/DtgDbnWJrVVrbdrUu3/EDB3feBXrtqzEtsFdtAfKHSS4UdfkewrcDrlpFvXYYAd1YwJtREH78iYFLkluRRDnK8yUNn+//riE/17HqjmwM4hkzR6dN3FfcBIpqt15+eyirjg8sF1SIBaZsndcNSjwjyVtC5cKxI2J3T9aptrOyO+UbDozkENeB8Pc8tC0bU+EDa9tsc0P2oTDPHKkA= X-Forefront-PRVS: 01480965DA X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0201MB0907; 23:9GtGZdyIu0DxwUc4MJZ2oUnarMsiDoMvonXmqyi?= =?us-ascii?Q?uaqnfG7w5FQtpBMBO9923xa+3E5czS+H05IM+JmUgUPvCaT9xG0dNH4Icsce?= =?us-ascii?Q?WagUQxYtmA9cw5RQFYSIprgj5/DppxG7/dj5a3/nqvUPcu3yH/IcV2NApDNV?= =?us-ascii?Q?w+ZFIGQpzMn77pcQdJ3rQKxmxGfySG/YD4wwCqOEtGXO77jFWntazJPXQK+i?= =?us-ascii?Q?OnTFJSaVW33wr0OsiNfGQ71yaicGO7jlkASgV/HwSkC/4gFSF7Vh5qyb6oFG?= =?us-ascii?Q?LSthVi1BS261xRHpa3yvsafU6OvynJY4hRMCXdHQVoTVZFBYpAgdo5HmvlSa?= =?us-ascii?Q?lmBo+0xxWBxo21sbQt/fQpJv/BwzJ2+8P3mScxqxpy8xoswU2BSL3ITDTPo9?= =?us-ascii?Q?Zq+lvXVKOvaFmTunrBes+38PxVst9lDlbjpV+UbM53gZUKSpvVF+pVDDF53q?= =?us-ascii?Q?ZpLWYkwlraW87yT1l+2xPwMzPW1llRoDUBehPFehcimQVcUtAELNKi71B2sr?= =?us-ascii?Q?LmgmS/fFJxrvUPi8kSesDQv2Z9JKKbFY1QLUh2y8NkRr4IIxGbUhuejZQa/w?= =?us-ascii?Q?NyQKNwlYhCi/qm0icEan7qV1zyiS68UvxXrUCHLCJMox3NE8OVhzV4CjDTSF?= =?us-ascii?Q?ni70kfTtzrch4MTufzBvBih7OWgkA21OwD5xgmFDQs96sdTWPCciB3+vhPcd?= =?us-ascii?Q?tV8D9kTImkbEFTaP4P9D7IGFakqIQWyntcSahw4I+yP+gspmxuFsCxM4AehT?= =?us-ascii?Q?zBbcDasCGy+p7Xl+D/bXL6wq2LSl/Ygi4GEdDOVWZ5NllPWFTfiE61E3BnKh?= =?us-ascii?Q?mHMhLx/tU2B7i+f6n9UF2sbteYc1iH8MGoDDFDtqi527n4JOijAnLJFMkidk?= =?us-ascii?Q?Sx2AJCxYriqHP5Dvz/7Vslm0XtsnPfmY3v8MdZZvwNW6zZi9zr2hAItmRKYd?= =?us-ascii?Q?srh+w68tiaP+LxPRdhUo3DQ/kc3ADjfOvp8MZ0LNqv6O/F6JWjWVMRrwmx6I?= =?us-ascii?Q?gaMHfI1a32bwGPVvLA2179hwm29dTbrnWTQepEBQJHAunKRdPRhlbLXC4uJJ?= =?us-ascii?Q?uGpaS7irB6zMa7EnKg6MDxWH6JnLKnvKlK3rdKQrrnSNt02FrhJJyJuDmhp5?= =?us-ascii?Q?0U8B3EBLPUsCB1jLBR5rQE4zzZoTvHzuAjiHEGczIdWyBaDJ2OpYHdeTuM81?= =?us-ascii?Q?O+6phmrnu71x5U8NiPzlA76r9XZELmH4yKALM?= X-Microsoft-Exchange-Diagnostics: 1; CY1PR0201MB0907; 6:EpWfsdUcE2vwgMGT7JLZ8dZTZzl+YinOt/q6nYC+5oh/E0WQVyCC9KO8A1gNBy0tBq21V5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ZpSJqmvqZAGjLRj0kiBEuSnHv0v0RPDIVOYRbZgyQ2BxTKZmUo83g4cWXos0X3KgYtsnsulOm6P1i5SUVZeiFHYICkymc9RnX3DGdz5QT7Bg/bRe6aGKhNXBsSFDf6ixaZ2EQbrqMLr85JCF+xBMs6hrN1c7bm2zK7pKdurYAFZvppJA== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 06 Dec 2016 18:15:34.1695 (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.83]; Helo=[xsj-pvapsmtpgw01] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0201MB0907 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);