From patchwork Thu Jan 12 19:06:59 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Bart Van Assche X-Patchwork-Id: 9514061 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 0C1B9601E7 for ; Thu, 12 Jan 2017 19:13:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F1C05284C3 for ; Thu, 12 Jan 2017 19:13:10 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E682A286D9; Thu, 12 Jan 2017 19:13:10 +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 88B12284C3 for ; Thu, 12 Jan 2017 19:13:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751110AbdALTNF (ORCPT ); Thu, 12 Jan 2017 14:13:05 -0500 Received: from mail-sn1nam01on0042.outbound.protection.outlook.com ([104.47.32.42]:63616 "EHLO NAM01-SN1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1750842AbdALTIJ (ORCPT ); Thu, 12 Jan 2017 14:08:09 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=sandiskcorp.onmicrosoft.com; s=selector1-sandisk-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=uxD7ijN6YfDbd+lW0zyD7UFzL9frKk0s+R9oEXazW8o=; b=Aal/uIsX0uJOBVeEbYTI0TWnCuBrtY9eHEyuKDNfOx5PexQ2Nvm8VhfX/ZLM50BLmAanB12VYlPVCRqHIDAldmDNiaepK0QYGoPaXdGCSBwuVFZNmUQgjaXyAuUv9sDezk0w7JcPZX1YbQscFgD4LnVHpixRIqOcGYhvrLBa67Y= Received: from CY1PR0201CA0007.namprd02.prod.outlook.com (10.163.30.145) by DM2PR02MB1420.namprd02.prod.outlook.com (10.161.143.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12; Thu, 12 Jan 2017 19:08:07 +0000 Received: from BL2FFO11OLC002.protection.gbl (2a01:111:f400:7c09::181) by CY1PR0201CA0007.outlook.office365.com (2a01:111:e400:58b9::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.845.12 via Frontend Transport; Thu, 12 Jan 2017 19:08:06 +0000 Authentication-Results: spf=pass (sender IP is 63.163.107.21) smtp.mailfrom=sandisk.com; linuxfoundation.org; dkim=none (message not signed) header.d=none; linuxfoundation.org; dmarc=bestguesspass action=none header.from=sandisk.com; Received-SPF: Pass (protection.outlook.com: domain of sandisk.com designates 63.163.107.21 as permitted sender) receiver=protection.outlook.com; client-ip=63.163.107.21; helo=milsmgep15.sandisk.com; Received: from milsmgep15.sandisk.com (63.163.107.21) by BL2FFO11OLC002.mail.protection.outlook.com (10.173.161.186) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P384) id 15.1.803.8 via Frontend Transport; Thu, 12 Jan 2017 19:08:02 +0000 Received: from MILHUBIP04.sdcorp.global.sandisk.com (Unknown_Domain [10.201.67.162]) (using TLS with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client did not present a certificate) by (Symantec Messaging Gateway) with SMTP id 7E.90.65426.861D7785; Thu, 12 Jan 2017 10:56:40 -0800 (PST) Received: from milsmgip12.sandisk.com (10.177.9.6) by MILHUBIP04.sdcorp.global.sandisk.com (10.177.9.97) with Microsoft SMTP Server id 14.3.319.2; Thu, 12 Jan 2017 11:07:58 -0800 X-AuditID: 0ac94369-b62949800001ff92-e4-5877d16841fe Received: from exp-402881.sdcorp.global.sandisk.com ( [10.177.9.6]) by (Symantec Messaging Gateway) with SMTP id C8.DF.09762.E04D7785; Thu, 12 Jan 2017 11:07:58 -0800 (PST) From: Bart Van Assche To: Doug Ledford CC: , , "Greg Kroah-Hartman" , Bart Van Assche , Christian Borntraeger , Joerg Roedel , Andy Lutomirski , "Michael S . Tsirkin" Subject: [PATCH v2 07/26] lib/dma-virt: Add dma_virt_ops Date: Thu, 12 Jan 2017 11:06:59 -0800 Message-ID: <20170112190718.6728-8-bart.vanassche@sandisk.com> X-Mailer: git-send-email 2.11.0 In-Reply-To: <20170112190718.6728-1-bart.vanassche@sandisk.com> References: <20170112190718.6728-1-bart.vanassche@sandisk.com> X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFvrKLMWRmVeSWpSXmKPExsXCddJ5kW7GxfIIg3kHRC2mr9jOYvHy/AdW i+bF69ksJp+ay2RxedccNotnh3pZLM7vWstq8f/XK1YHDo+Djw6xeWxa1cnmsX/uGnaP9/uu snlsPl3t8XmTXABbFJdNSmpOZllqkb5dAldG182NjAXdchU9uy+wNTAukOhi5OSQEDCR+Prj BHMXIxeHkMBSJolZ12cwQTjbGCV6uk4zwlTdWryaHSKxkVHi4aMFTCAJNgEjiW/vZ7KA2CIC ahKbXi0CK2IWOMQkcfzmBXaQhLCAhcTUHRfYQGwWAVWJLxMWgsV5Bewk9q59CbVBXmJX20VW EJtTwF7i2/9LYHEhoJpdB/6zgAyVEFjFKvF+yS6oZkGJkzOfgG1mFpCQOPjiBTNEg7rEySXz mSYwCs1CUjYLSdkCRqZVjGK5mTnFuempBYamesWJeSmZxdl6yfm5mxghkZG5g/HuE+9DjAIc jEo8vDtsyiKEWBPLiitzDzFKcDArifDOOl8eIcSbklhZlVqUH19UmpNafIhRmoNFSZzX7d6X MCGB9MSS1OzU1ILUIpgsEwenVAPjdqmo5Y4pH1/YLhZu6L+k974/acYHI+Unv+X/82wtOnj7 YEvCcS3V99JXVRaEix0s3y0yhfvXTSF9p59x6y7+udCYsSRMs05LauaJN0KnbbTZazUk0uWs Xpg8+LJnX829jF+B0z/OE+Bc+cgwyvakbu+k+sJmjasq54LnLYj9IVhQ4lAUt7hTiaU4I9FQ i7moOBEAMRjHaYgCAAA= X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFjrMJMWRmVeSWpSXmKPExsXCtZGTTZfvSnmEwYbJYhYHf7YxWkxfsZ3F 4uX5D6wWzYvXs1lMPjWXyeLyrjlsFs8O9bJYnN+1ltXi/69XrA6cHgcfHWLz2LSqk81j/9w1 7B7v911l85i25jyTx+bT1R6fN8kFsEdx2aSk5mSWpRbp2yVwZXTd3MhY0C1X0bP7AlsD4wKJ LkZODgkBE4lbi1ezg9hCAusZJZZ15YHYbAJGEt/ez2QBsUUE1CQ2vVoEVMPFwSxwhEniwI/l YAlhAQuJqTsusIHYLAKqEl8mLAQbxCtgJ/Fh1yZmiAXyErvaLrKC2JwC9hLf/l9ihFhmJ7Hr wH+WCYzcCxgZVjGK5WbmFOemZxYYGukVJ+alZBZn6yXn525ihART1A7G6xPNDzEycXBKNTBm 3g83cO+pEKu2ep+iLK9dkvsq6IXS9gcc1sJGHmp91e5nst2+PD4tf+dJnixjU71ArMy9wOzI 05W/Wp6oBO95PtnmzG+plM/Bb7fF9WnW3Jyj/658xpTA3Z4pF3ge7+bbxb3r3OGfnTXLu5WU lgsrtJlLrpjsk6sgLvF7TZ+g943i7syLYUosxRmJhlrMRcWJADdqFgHWAQAA MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-Office365-Filtering-HT: Tenant X-Forefront-Antispam-Report: CIP:63.163.107.21; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(7916002)(39860400002)(39850400002)(39450400003)(39840400002)(39410400002)(2980300002)(438002)(189002)(199003)(8676002)(189998001)(92566002)(77096006)(81166006)(81156014)(5660300001)(86362001)(2906002)(106466001)(69596002)(5003940100001)(97736004)(356003)(305945005)(4326007)(6916009)(1076002)(2270400002)(76176999)(50986999)(33646002)(110136003)(2950100002)(68736007)(38730400001)(47776003)(50466002)(36756003)(50226002)(54906002)(626004)(48376002)(8936002); DIR:OUT; SFP:1101; SCL:1; SRVR:DM2PR02MB1420; H:milsmgep15.sandisk.com; FPR:; SPF:Pass; PTR:InfoDomainNonexistent; MX:1; A:1; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BL2FFO11OLC002; 1:2nhdsY3mRFUtuFO36XofXf5SqhySIrF5eS89aU0wNxDrGa7HAv/eAKGhsFMh/DLjqThFgRW7yhjDqap7ZkdYPw9BHfQy+d0+YzkbQG0Zr8AvozPO28BLz2OqQAq9bzTZ78Sv1MmqX+Vn4NE0wV7qybuD6oaqwMm3gknUTbEZHJdnX6WRoUiFzEnOM1KtOyTOfpBWJEBZ5dEYLRWCSFQa4gmcMZPxV/JIjykRKLtI3pYGlMZoEcV2P9L+ObOA04VBRZ8X9+rzlKepeKZelB3LD2s6lHN+FAzTpDK0Qc7PV8X0Gk7AoDmby9QnFkT7/Wmm02t5ndzNW8XbiyLKXzCvZ9joTVdY5LL8V8Vu4cwRqNo4GrsVaR1z8enz+XfEeQ06aQBFNETjr2OtJ0Jzu0B24Gj7xKYQ/xRBytjGFLHv50zotGBG/cZ7sC3LzR7yv87Exr6VsM1z7MA/RfPdq6K2iWZbIjkz2uFUXey2qgAP1EBY98pwsPD/1rozzERjcUq0 X-MS-Office365-Filtering-Correlation-Id: 6673fae5-a937-4643-b9ca-08d43b1e55b9 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(8251501002); SRVR:DM2PR02MB1420; X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB1420; 3:Z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RRKOmZAned3uSNxjPaithUo6STrVL6lceHdPJ5yXv4AK4vt2FSLWpRQHwLHK0eHIyaUwFYuiVVw5afFyG0KFmujt66THijdq9j8vx7Vvm/BGp7xYyGiw==; 20:ARQVVP2/XrRdL0aYRw+IErbB9PczztHevNn6w/bMDUfX9avvOaOODm1ngkQWNjN5atSIgFYicNvjurVXRZpMilTDnlpZ0r8zWyUs92HQqSJ3haE6vf4rRxXCAPUWwGzSSM2dA3k9oq8TZqjiQAvGlqctBX3FgE82oFMsGF7TPQwn6uMQ6pp5o5dpIpJ0QKXLCtMSNHZas37Sj13JbiOHPV/+BtrWuEM5Zpw6uPmJYM5tSDrTh/RDu5LmohvmV/77JBvbf9YHxVht+SveYXbscu4NzdKGiHXWGPeymXsfCuPd5RmQzioXH+15uE0twm3yGLnu3/vePsBlsImnPym9GsSKIgrER/k9Ul4ozwDdhsIK6q17HpBK8rEuNRLlDaa1ICrfFU6hqUgvPWCgQyFPpWoll0TCaDx5Qrji+tRCw0bqAHJVvcouO6VzH9os37po2q07GrIISKSzpJ7TtI4UAFSBhzbCzc/7QdDItSxOwP1kzsF4cpp+wMG3WGsC3e8a X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(190383065149520)(104084551191319)(42932892334569); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6040375)(601004)(2401047)(5005006)(8121501046)(13016025)(13018025)(10201501046)(3002001)(6055026)(6041248)(20161123562025)(20161123564025)(20161123555025)(20161123560025)(20161123558021)(6072148); SRVR:DM2PR02MB1420; BCL:0; PCL:0; RULEID:; SRVR:DM2PR02MB1420; X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB1420; 4:yEFb3xr3xJYRiJqeVZvLWtIbXSE2G/sVVp/JlTkNV3Mc5aLj8Nonn9Bq9dh3fuuHSgKshxlrDGPcMFSxDzpTCU0F4PieWtA3kHORwsyMhNJlD4l0xDfVvoe/MHabtlglJQEARWpsXuq1f8PNF/4EUQ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MB1420; 6:b6UL/DgKu3j+U/HyTR9I8NqG/U26bxpaFVhhKgAC6UL3El2WTx2Mdr0NTxBiolyWgyygDus4eY/8FXWDmnEsWlEy4dFHrFobvPWuoJNmUT9cZXMIAmv5FXl2FPj33S6QnDsYL1PEr/n4w12tG0o0odXQhrikGj4wxA7878KIHoeC1+D26WF2M2yNxlmLzRDjnIamz8qDu0vefC4cXrZtbeyIh6pcaZHLpK6lv/LDvCI95F1XNg/DAhcEYaCeODVczvOWTk9wP6PEqc0x58c8jp8fVLVWwHWNodpHTAm1aI/k6708ZPTo6tDz1xNk58ll405xPD6+fRSZ1Hkio+L30bATwj1cHOOxpII11TrGKKws5TTfpvmRGUVZQygclpR48CgLnPBM0YYUZunS52KGQ8sOOP7HYtJuuxUso5J6CCp52jIGUS9AVuy/QtvL3iu3XVI0IoklWXtgsjDJUasp+A==; 5:u2WUQm55x+HGW62cCb6e1Xxw3dcTtN1sUU8rzWWRMaH/HZDtxmOdUhdAJwcMHUAlmbpc54zqYDBHLdI7caXAEwMY2fNg3dtPO/9cSbYzI/J/oGanIv1LyHrfumOmPd6XOK9rhmaNV/Y399X8M9kcoQ==; 24:pkENU1i1aEPto+itX9aaFm8Z6OZlu4P43HHmjGMYqeis7XeUOZmRHdr3ZYyo6D0TGleVSag/buP8x9zoOLAV9Fj7pwHJFAV7MDmbHUx7mFk= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; DM2PR02MB1420; 7:/wqBMCQ+QwN9nJbAMwX3fWHhZxP+Ee1smJczqn1NCWk2t+dZwToCUakGn9JMv53kUn8i79rMpbeP4HR2CiKh3B20llvBggCvetGu8XoDD6JA8fbR763ilIUexTzydyZrqPRPvruBYXtkH/EITbAGhFL0yOPX2XjcHqEQqFW2eHAarV9GvUGI4kUSJMWw/aPKdtEV/nDt1dMLchRXFzsw4mpHVqUvR/QcU9ncbj4zHu8S86itgcU+RNdFjfQBMc8B4eL9G+DkbJLJ7tJAdXilMOeabzz41qcV0mqsYw7hlliYDtKH8GroRRDjoKaDdgskX+EHk2LyLeUBqmXkemlLjaKwrjVSA9mxYnxxLQ1KcJCY1jE3ycoG1HZqaemjIa/F7DcpltG5pV+W3RwtRc5MeCuBar49CMQZ0x7qa+Unoj6uTVdhb5qDM13jNzDhEUm14aqayyFlodHfNuJzPuaLcA== X-OriginatorOrg: sandisk.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 12 Jan 2017 19:08:02.6115 (UTC) X-MS-Exchange-CrossTenant-Id: fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=fcd9ea9c-ae8c-460c-ab3c-3db42d7ac64d; Ip=[63.163.107.21]; Helo=[milsmgep15.sandisk.com] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM2PR02MB1420 Sender: linux-rdma-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-rdma@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Several RDMA drivers need to provide a DMA mapping API but use the CPU to transfer data. Provide DMA mapping operations that are suitable for these drivers. Signed-off-by: Bart Van Assche Cc: Christian Borntraeger Cc: Joerg Roedel Cc: Andy Lutomirski Cc: Michael S. Tsirkin --- include/linux/dma-mapping.h | 1 + lib/Kconfig | 5 ++++ lib/Makefile | 1 + lib/dma-virt.c | 73 +++++++++++++++++++++++++++++++++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 lib/dma-virt.c diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index ab8710888ddf..426c43d4fdbf 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -128,6 +128,7 @@ struct dma_map_ops { }; extern const struct dma_map_ops dma_noop_ops; +extern const struct dma_map_ops dma_virt_ops; #define DMA_BIT_MASK(n) (((n) == 64) ? ~0ULL : ((1ULL<<(n))-1)) diff --git a/lib/Kconfig b/lib/Kconfig index b6baf0609e8b..97af23b26f33 100644 --- a/lib/Kconfig +++ b/lib/Kconfig @@ -400,6 +400,11 @@ config DMA_NOOP_OPS depends on HAS_DMA && (!64BIT || ARCH_DMA_ADDR_T_64BIT) default n +config DMA_VIRT_OPS + bool + depends on HAS_DMA && (!64BIT || ARCH_DMA_ADDR_T_64BIT) + default n + config CHECK_SIGNATURE bool diff --git a/lib/Makefile b/lib/Makefile index ada06d5652e8..b97e9a814854 100644 --- a/lib/Makefile +++ b/lib/Makefile @@ -27,6 +27,7 @@ lib-y := ctype.o string.o vsprintf.o cmdline.o \ lib-$(CONFIG_MMU) += ioremap.o lib-$(CONFIG_SMP) += cpumask.o lib-$(CONFIG_DMA_NOOP_OPS) += dma-noop.o +lib-$(CONFIG_DMA_VIRT_OPS) += dma-virt.o lib-y += kobject.o klist.o obj-y += lockref.o diff --git a/lib/dma-virt.c b/lib/dma-virt.c new file mode 100644 index 000000000000..b3573b6ad5b1 --- /dev/null +++ b/lib/dma-virt.c @@ -0,0 +1,73 @@ +/* + * lib/dma-virt.c + * + * DMA operations that map to virtual addresses without flushing memory. + */ +#include +#include +#include +#include + +static void *dma_virt_alloc(struct device *dev, size_t size, + dma_addr_t *dma_handle, gfp_t gfp, + unsigned long attrs) +{ + void *ret; + + ret = (void *)__get_free_pages(gfp, get_order(size)); + if (ret) + *dma_handle = (uintptr_t)ret; + return ret; +} + +static void dma_virt_free(struct device *dev, size_t size, + void *cpu_addr, dma_addr_t dma_addr, + unsigned long attrs) +{ + free_pages((unsigned long)cpu_addr, get_order(size)); +} + +static dma_addr_t dma_virt_map_page(struct device *dev, struct page *page, + unsigned long offset, size_t size, + enum dma_data_direction dir, + unsigned long attrs) +{ + return (uintptr_t)(page_address(page) + offset); +} + +static int dma_virt_map_sg(struct device *dev, struct scatterlist *sgl, int nents, + enum dma_data_direction dir, + unsigned long attrs) +{ + int i; + struct scatterlist *sg; + + for_each_sg(sgl, sg, nents, i) { + BUG_ON(!sg_page(sg)); + sg_dma_address(sg) = (uintptr_t)sg_virt(sg); + sg_dma_len(sg) = sg->length; + } + + return nents; +} + +static int dma_virt_mapping_error(struct device *dev, dma_addr_t dma_addr) +{ + return false; +} + +static int dma_virt_supported(struct device *dev, u64 mask) +{ + return true; +} + +const struct dma_map_ops dma_virt_ops = { + .alloc = dma_virt_alloc, + .free = dma_virt_free, + .map_page = dma_virt_map_page, + .map_sg = dma_virt_map_sg, + .mapping_error = dma_virt_mapping_error, + .dma_supported = dma_virt_supported, +}; + +EXPORT_SYMBOL(dma_virt_ops);