From patchwork Tue Jan 31 18:30:25 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Anisov X-Patchwork-Id: 9548003 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 4702560415 for ; Tue, 31 Jan 2017 18:33:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 39CB2280F4 for ; Tue, 31 Jan 2017 18:33:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2EB3328384; Tue, 31 Jan 2017 18:33:05 +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=-3.6 required=2.0 tests=BAYES_00, DKIM_ADSP_CUSTOM_MED, DKIM_SIGNED, FREEMAIL_FROM, RCVD_IN_DNSWL_MED, RCVD_IN_SORBS_SPAM, T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id ACBAB282E8 for ; Tue, 31 Jan 2017 18:33:03 +0000 (UTC) Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYdCL-0004wR-Jw; Tue, 31 Jan 2017 18:30:33 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cYdCJ-0004vx-OC for xen-devel@lists.xenproject.org; Tue, 31 Jan 2017 18:30:31 +0000 Received: from [193.109.254.147] by server-2.bemta-6.messagelabs.com id CA/93-22326-7C7D0985; Tue, 31 Jan 2017 18:30:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrDIsWRWlGSWpSXmKPExsVyMfTSYd1j1yd EGJydqmTxfctkJgdGj8MfrrAEMEaxZuYl5VcksGZ0z25mLPgvWLFq+nWWBsbH/F2MXBxCAjMY JZ5tOsLaxcjJwSLwkkViSm8FiC0h0M8q0fFMAcKOkTgzuYcNwq6RaPz1hh3EFhJQk9h36DoLx KC5TBIXHnUzgSTYBHQlrr96AGaLCChJ3Fs1mQmkiFmgi1Hi9erdYAlhAR+JtQ3bGSE2q0qsnH MZLM4r4Cax7/1dRohtchI3z3Uyg9icAu4S59c8hNrsJvHl1wmWCYwCCxgZVjFqFKcWlaUW6Ro a6CUVZaZnlOQmZuYAeWZ6uanFxYnpqTmJScV6yfm5mxiBocUABDsY7y0LOMQoycGkJMqb3jEh QogvKT+lMiOxOCO+qDQntfgQowwHh5IE76TLQDnBotT01Iq0zBxgkMOkJTh4lER4Z4GkeYsLE nOLM9MhUqcYLTl6uk6/ZOI4dQNE7tl1+SWTEEtefl6qlDhvPUiDAEhDRmke3DhYJF5ilJUS5m UEOlCIpyC1KDezBFX+FaM4B6OSMG8hyBSezLwSuK2vgA5iAjrI/VUfyEEliQgpqQZGz7Bt69t E2Fft+tO8SuX6mrfyPwSUsra9uilxY4XjJXs+TYHdDQ+8n4rPeddVKJIxddEHRrUe7UMcarnN U+IkU9juvGv/tvTDa0Y3rrya8sny1nMSKr6f4lvwW86we+cK/ZwjJ3yTXHYsTjzFffGmortO0 sVzE0y0tNukgt+/PrtWodnaYuNkJZbijERDLeai4kQAYUOohr8CAAA= X-Env-Sender: andrii.anisov@gmail.com X-Msg-Ref: server-7.tower-27.messagelabs.com!1485887430!80104923!1 X-Originating-IP: [209.85.210.195] X-SpamReason: No, hits=0.0 required=7.0 tests= X-StarScan-Received: X-StarScan-Version: 9.1.1; banners=-,-,- X-VirusChecked: Checked Received: (qmail 41602 invoked from network); 31 Jan 2017 18:30:30 -0000 Received: from mail-wj0-f195.google.com (HELO mail-wj0-f195.google.com) (209.85.210.195) by server-7.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 31 Jan 2017 18:30:30 -0000 Received: by mail-wj0-f195.google.com with SMTP id le4so2345469wjb.0 for ; Tue, 31 Jan 2017 10:30:30 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=xdR4lez3miWEwi6uVhKFtN2t1360KSdZWERj2U/Z+oI=; b=AJHybXXkVVguUWN8sh5ry9WubKnoPEM0oUEbSylMTslz0ZnSB1mve2qQiSBcFcIR9C Nt4d9EdlnNatJiTMYI88zd7vx7ZwLSyIj3BbqYNVKWgRlySK4moZlmbHT6SXmv5uJmys Waul4pWzSuOBoPA18yydGV5BWlp7tn5PutpmSi991hkwefKl7O6tzc/QO3LhOLoa/oC5 ImsRnWyAOQcfmz6glsxDl2KYdg/Gb88GtiF/bJ8s9MJWYVPFux7tOpYYxIEauCHPHpQv IGRF/M891gDb3GL2q9jpV05iIFgvE2p6a+f/wNVyRcvAuLJRtdcQfNDea9NtP/874UgL uA5Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=xdR4lez3miWEwi6uVhKFtN2t1360KSdZWERj2U/Z+oI=; b=KjR0NV5h7o4ZLYBYH4LPo0tnyiRdU4qdTOGyYY31lW0ETOJjKES56gJo90dB7kvaKo UhOR2/rqcFZHGvbuOak2flFuGphO4U9nOJkB6c/wCLoVEtu6gUbe7CHijHsIgWPQvm5I RYU6v7ZpwBAzTinOAZb+uFmD4u7g61AmIE3d66qXVk/LqaVy48+foW1IGmWwtz3PdMiN pJhinAD5KP57tvfXLs7XOeFP4ICPmIlJoh4GL8nDAhEmoDrMOVHbL3SbAvoNiAaY+fRf tTZanWvau1GWI673OYuRL93ZZ1Fq1bNeHP3MgtYKq7inHwDSZXav5oBk7+0kjhSu3ZS7 19dA== X-Gm-Message-State: AIkVDXJQWGGF4J6jJTJIZLzH7bBdARPqUvyPzAEp5ELpwglWcE1VYNjIB7j4svVpCiKwSA== X-Received: by 10.223.150.183 with SMTP id u52mr24415669wrb.180.1485887430162; Tue, 31 Jan 2017 10:30:30 -0800 (PST) Received: from aanisov-work.kyiv.epam.com (ll-54.209.223.85.sovam.net.ua. [85.223.209.54]) by smtp.gmail.com with ESMTPSA id m84sm25205011wmf.10.2017.01.31.10.30.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 31 Jan 2017 10:30:29 -0800 (PST) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Tue, 31 Jan 2017 20:30:25 +0200 Message-Id: <1485887426-9016-2-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1485887426-9016-1-git-send-email-andrii.anisov@gmail.com> References: <1485887426-9016-1-git-send-email-andrii.anisov@gmail.com> Cc: julien.grall@arm.com, sstabellini@kernel.org, andrii_anisov@epam.com, oleksandr.dmytryshyn@globallogic.com Subject: [Xen-devel] [PATCH v3 1/2] swiotlb-xen: implement xen_swiotlb_dma_mmap callback X-BeenThere: xen-devel@lists.xen.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: xen-devel-bounces@lists.xen.org Sender: "Xen-devel" X-Virus-Scanned: ClamAV using ClamSMTP From: Stefano Stabellini This function creates userspace mapping for the DMA-coherent memory. Signed-off-by: Stefano Stabellini Signed-off-by: Oleksandr Dmytryshyn Signed-off-by: Andrii Anisov --- arch/arm/xen/mm.c | 1 + drivers/xen/swiotlb-xen.c | 18 ++++++++++++++++++ include/xen/swiotlb-xen.h | 5 +++++ 3 files changed, 24 insertions(+) diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c index bd62d94..cd1684e 100644 --- a/arch/arm/xen/mm.c +++ b/arch/arm/xen/mm.c @@ -198,6 +198,7 @@ static struct dma_map_ops xen_swiotlb_dma_ops = { .unmap_page = xen_swiotlb_unmap_page, .dma_supported = xen_swiotlb_dma_supported, .set_dma_mask = xen_swiotlb_set_dma_mask, + .mmap = xen_swiotlb_dma_mmap, }; int __init xen_mm_init(void) diff --git a/drivers/xen/swiotlb-xen.c b/drivers/xen/swiotlb-xen.c index f8afc6d..8ac36b4 100644 --- a/drivers/xen/swiotlb-xen.c +++ b/drivers/xen/swiotlb-xen.c @@ -681,3 +681,21 @@ xen_swiotlb_set_dma_mask(struct device *dev, u64 dma_mask) return 0; } EXPORT_SYMBOL_GPL(xen_swiotlb_set_dma_mask); + +/* + * Create userspace mapping for the DMA-coherent memory. + * Following function should be called with the local pages only. + */ +int +xen_swiotlb_dma_mmap(struct device *dev, struct vm_area_struct *vma, + void *cpu_addr, dma_addr_t dma_addr, size_t size, + unsigned long attrs) +{ +#if defined(CONFIG_ARM) || defined(CONFIG_ARM64) + if (__generic_dma_ops(dev)->mmap) + return __generic_dma_ops(dev)->mmap(dev, vma, cpu_addr, + dma_addr, size, attrs); +#endif + return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size); +} +EXPORT_SYMBOL_GPL(xen_swiotlb_dma_mmap); diff --git a/include/xen/swiotlb-xen.h b/include/xen/swiotlb-xen.h index a0083be..5c8f4c8 100644 --- a/include/xen/swiotlb-xen.h +++ b/include/xen/swiotlb-xen.h @@ -55,4 +55,9 @@ xen_swiotlb_dma_supported(struct device *hwdev, u64 mask); extern int xen_swiotlb_set_dma_mask(struct device *dev, u64 dma_mask); + +extern int +xen_swiotlb_dma_mmap(struct device *dev, struct vm_area_struct *vma, + void *cpu_addr, dma_addr_t dma_addr, size_t size, + unsigned long attrs); #endif /* __LINUX_SWIOTLB_XEN_H */