From patchwork Thu Dec 8 06:59:12 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jiaying Liang X-Patchwork-Id: 9465893 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 EB0C860231 for ; Thu, 8 Dec 2016 07:07:12 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id C971428425 for ; Thu, 8 Dec 2016 07:07:12 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BD2E4284D3; Thu, 8 Dec 2016 07:07:12 +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 26E2728425 for ; Thu, 8 Dec 2016 07:07:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752145AbcLHHHL (ORCPT ); Thu, 8 Dec 2016 02:07:11 -0500 Received: from mail-cys01nam02on0050.outbound.protection.outlook.com ([104.47.37.50]:23231 "EHLO NAM02-CY1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1751392AbcLHHHK (ORCPT ); Thu, 8 Dec 2016 02:07:10 -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=sLHnY5AlZr2rOJhziaU80L0v8Xj+/pLp0ksFDMl+plM=; b=4f7FVEPDnPCMcZMJU4orGG62tfKh02AGUeEVXKLDGjcurDD5sDArYGIFToNpLRmgFdhNVmFa70xijqWKY3w7gx5muR9h8CMk7CL/bBZ0iG9zJhBOuRPlAESo8UHTBS1GAeIKxhGipiwwdBwTr4WDt4xJKUi+DAGdrAX5+AzKcBw= Received: from BY2PR02CA0034.namprd02.prod.outlook.com (10.141.216.24) by DM2PR0201MB0911.namprd02.prod.outlook.com (10.160.215.27) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.761.9; Thu, 8 Dec 2016 07:06:35 +0000 Received: from CY1NAM02FT030.eop-nam02.prod.protection.outlook.com (2a01:111:f400:7e45::207) by BY2PR02CA0034.outlook.office365.com (2a01:111:e400:2c40::24) 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:06:34 +0000 Authentication-Results: spf=pass (sender IP is 149.199.60.83) 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.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 CY1NAM02FT030.mail.protection.outlook.com (10.152.75.163) 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:06:33 +0000 X-IncomingTopHeaderMarker: OriginalChecksum:; UpperCasedChecksum:; SizeAsReceived:1360; Count:15 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 1cEsmn-0004b7-4i; Wed, 07 Dec 2016 23:06:33 -0800 Received: from [127.0.0.1] (helo=localhost) by xsj-pvapsmtp01 with smtp (Exim 4.63) (envelope-from ) id 1cEsmn-0005xi-1L; Wed, 07 Dec 2016 23:06:33 -0800 Received: from [172.19.74.38] (helo=xsjjliang50.xlnx.xilinx.com) by xsj-pvapsmtp01 with esmtp (Exim 4.63) (envelope-from ) id 1cEsmh-0005kc-UK; Wed, 07 Dec 2016 23:06:27 -0800 From: Wendy Liang To: , , , , , CC: Wendy Liang Subject: [PATCH 1/2] virtio_ring: Do not call dma_map_page if sg is already mapped. Date: Wed, 7 Dec 2016 22:59:12 -0800 Message-ID: <1481180353-11139-2-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.83; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39410400002)(39840400002)(39850400002)(39450400003)(39860400002)(2980300002)(438002)(189002)(199003)(5001770100001)(4001430100002)(106466001)(8936002)(50226002)(77096006)(107886002)(38730400001)(189998001)(2906002)(50986999)(5660300001)(4326007)(2950100002)(76176999)(6666003)(626004)(36756003)(8676002)(48376002)(50466002)(81166006)(81156014)(63266004)(9786002)(2201001)(7846002)(356003)(47776003)(33646002)(5003940100001)(305945005)(92566002)(36386004)(107986001); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR0201MB0911; H:xsj-pvapsmtpgw01; FPR:; SPF:Pass; PTR:unknown-60-83.xilinx.com; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; CY1NAM02FT030; 1:80n78COiEVuVsz7uj8OgqqJQD2CYfoeRdeQUK9ePyY5plORJoCbibCx3hH7qSkyJF5u9p3rrN8yfX8PAsILElxxgi4/ToGsJlQlHaFMTS6VKnCTBLKmaDiXFbJ3vs1t7kgb2vpHoO5KNA5/4qRHebeCcSmghYagW8YkfoywVKoOipHAFnUWBy2eTbdJRmlqFSaB+4MzfL3lxBolp3vOkFU4cB8gEEDWGT7r3ftbAExf1Enbm3+shHkqv3O1niHSn36CLDMST6ONKw/OW3JkFDAl7SzrqeGkKgW+QIISuSz74D7taxapaAfUT4cVWDfMSeAAHSZ9MsdUloq7FVic0vd1/5Jef7KObTW9R4gbYTV3wnCoqbb+lo1tCzSLARKFlConWCH9so0sx9QIfgvC9E2eHAGGtUfOjs9+GGlR78q5JqeoUA+KunvFrBwMEkI0mPB7wpuhqPKWMw0BP63Ot5sHaZKTwCa8/imkL/UNn4FsJEywANDy24f5wQI5kRJoIAFZHxV+H+raCnxhHzxnla52OON7ur5MX7QnW1kDzs5HiOrTHFmGEspfk1Ajrww/UkIhDubJCN0J046eL+iCAFw== MIME-Version: 1.0 X-MS-Office365-Filtering-Correlation-Id: 393d2cbe-ed5a-4053-13c0-08d41f38be9b X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002); SRVR:DM2PR0201MB0911; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0201MB0911; 3:UxVUuTxQGw0joh4Ghb/7DLx+HkZoorTReeUbUetdnAGFbQMC4Mq+3+JW9yTt478ylbs9zl4W3SLWpEOHqwsCEHv7yoQ+RTyD5aYaz2riPoZ6UTRR6/KP/jTKUK2hNVQ2yTyaFrvW22BsEKZ2VN0T4cohlsQKNLl2YL2QBOIEhC5UuN6thoz8/TyV1wA24iL9udrl0e8PZ0W6997W8zjLbXpm22YCkZjVHBfvbUrcLeU0pkmu4iFCsmnLKSFdAbVyYpLHJA4IwingpqD+g2GO+LScpsLJsfQIKFcBrHF7y8SB5HdrVieE9gzi/z8PNn9okRTWDUM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FXo8jSrAvFIExI2a2V5APxxumJCiD89kothx63eIPsTuS3cVxPHj7lMVPQo3ruVT/eWUtp5a4e7UiG1l7i6EVsoS4yTa5mAE3m9r7qKnjpJRJLLfVWqFyRJbs4yUgDPsa3s4ijyxtEOb8a3Ft7xNWi8yFUwadItQfGw==; 20:vOhZfDUZZelrFW4XRkJ+mFNqGsFSium0OiIh7CnCGmSY5umetJTsFds4R3cMv78wP6lCf8hcK8OCRnGsKJc15Me1hmXEnUYo7fnkzW92EqlD21+KQUq7xzzHpA5C/VT9SUlBOfvek6no7aSiU2nd3KkVX/N9jdbV+wIR5b6/BDWe7NzdFAx1i0vsBD68FjeXlF+msdr+s1e6zLfT9BYJ2K4Fpbs6SSXTF0giUti00wLcpZ/zKkBYUlfnanqGZ1iiM1fYxc2Z5r4JNzcyhPooYoKIGQNtlasT5u1poHluw7N3lfmnYDqoBidWiAfFlYlv7m2KkEVoWNeC2RWzvcWOkH4TBE7wuDePTAfMDggUjVePImQo5OKghu3dHGCU8na3TdunRsuPJp+Hg0solKKMjrhQI/x842Qv5MYvrPU8OZWG+YIDTT4ss40UpiYj3MZfzAgVUnVqwxM3lwGb6dbj4hBwFud1UWH+8ElETCBEgvgI40wGcXHSZsPRxTNOsok1 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)(13023025)(13015025)(13017025)(13024025)(13018025)(5005006)(8121501046)(3002001)(10201501046)(6055026)(6041248)(20161123555025)(20161123560025)(20161123562025)(20161123564025)(6072148); SRVR:DM2PR0201MB0911; BCL:0; PCL:0; RULEID:; SRVR:DM2PR0201MB0911; X-Microsoft-Exchange-Diagnostics: 1; DM2PR0201MB0911; 4:aHewzN04SeFJ2WezgpMO5q2Q6z3DtsfudcTxnGHSHmzfyzXFQD9FV+VK69WQueAxDxx7xF1cpULMoWAK9o3qvClP6eUgoycWU/oNIDB72Mer42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sSwQfnSWf3NzFupizlladJ0Gth8Dmbk8RuPR/ZMRHORTQ6skqfWPcNrFdO5RBoXe2malBfqrJsAvpNPG2gE6he8Nl+ufZcTaDsIAMkPXmK7FC5alP1e8yKf+LUGHJGC3jGBOYYHpjrg/q7bvm83BEJSlpNH4MlsEHKKgu6booFxnQc3QC2YzO4xULluXocKxsHrWWVYgcYTElo1yX20xRaJehWcbGjt1EQ6Xzu3912Tl6Z01gk8iaig== X-OriginatorOrg: xilinx.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Dec 2016 07:06:33.8327 (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: DM2PR0201MB0911 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 If sg is already dma mapped, do not call dma_map_page() in vring_map_one_sg(). In case of rpmsg, rpmsg uses dma_alloc_coherent() to allocate memory to share with the remote. There is no pages setup in dma_alloc_coherent(). In this case, we cannot convert the virtual address back to the physical address. In this case, we can setup the sg_dma_addr to store the DMA address, and also mark the sg is already mapped. In the vring, we can detect if the address is already mapped by checking the sg_dma_addr. If yes, do not call dma_map_page(). Signed-off-by: Wendy Liang --- drivers/virtio/virtio_ring.c | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index 489bfc6..9793e1f 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -180,6 +180,12 @@ static dma_addr_t vring_map_one_sg(const struct vring_virtqueue *vq, if (!vring_use_dma_api(vq->vq.vdev)) return (dma_addr_t)sg_phys(sg); + /* If the sg is already mapped, return the DMA address */ + if (sg_dma_address(sg)) { + sg->length = sg_dma_len(sg); + return sg_dma_address(sg); + } + /* * We can't use dma_map_sg, because we don't use scatterlists in * the way it expects (we don't guarantee that the scatterlist