From patchwork Tue Jan 10 16:44:26 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andrii Anisov X-Patchwork-Id: 9508151 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 EB697601E9 for ; Tue, 10 Jan 2017 16:49:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DBCD728542 for ; Tue, 10 Jan 2017 16:49:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF30528548; Tue, 10 Jan 2017 16:49:52 +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 5811428542 for ; Tue, 10 Jan 2017 16:49:52 +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 1cQzaP-0008Fu-Gz; Tue, 10 Jan 2017 16:47:49 +0000 Received: from mail6.bemta6.messagelabs.com ([193.109.254.103]) by lists.xenproject.org with esmtp (Exim 4.84_2) (envelope-from ) id 1cQzXF-00086O-Fz for xen-devel@lists.xenproject.org; Tue, 10 Jan 2017 16:44:33 +0000 Received: from [193.109.254.147] by server-5.bemta-6.messagelabs.com id 12/56-11476-F6F05785; Tue, 10 Jan 2017 16:44:31 +0000 X-Brightmail-Tracker: H4sIAAAAAAAAA+NgFlrJIsWRWlGSWpSXmKPExsVyMfTSYd08/tI Ig++LjS2+b5nM5MDocfjDFZYAxijWzLyk/IoE1ownkzoZC05zV/xbV9bA2M3VxcjJISQwg1Gi 9wJbFyMXB4vASxaJ7atfsII4EgL9rBKd/Y1MXYwcQE6MxK+HliANEgLVEovXH2GFaFaT2HfoO gtIvZDAbCaJY/1vmEASbAK6EtdfPQCzRQSUJO6tmswEUsQscIBRouF1JztIQljAXeLr+lXMIA tYBFQlFp1QAQnzAoWXfl3FBLFMTuLmuU5mEJtTwENi65zjbCDlQkA1OxeYTWAUWMDIsIpRozi 1qCy1SNfISC+pKDM9oyQ3MTNH19DATC83tbg4MT01JzGpWC85P3cTIzCoGIBgB+Oa+YGHGCU5 mJREeZd9LokQ4kvKT6nMSCzOiC8qzUktPsQow8GhJMF7mq80QkiwKDU9tSItMwcY3jBpCQ4eJ RHeS7xAad7igsTc4sx0iNQpRkuOY7MWP2XimPYMRO7qXPOUSYglLz8vVUqc9zzIPAGQhozSPL hxsBi8xCgrJczLCHSgEE9BalFuZgmq/CtGcQ5GJWFecZApPJl5JXBbXwEdxAR0UKRdMchBJYk IKakGRu6EKOu2jZ66E1UfN/26uXKH9tzl9bN3r3etZUmZfW/9m/i/s7VbDn76d0EhZt+Tk3f9 ghZUSJgfsHJ+Ge/jWj+9iFF6x16bDqPSg/tVGwPT//v8DI6eJJU6gUPO36CO7evTObpyzO+6j 3xUZdgvXJRf9GjKZ/ETgRapfJd0bFLiJYP6xSMNlFiKMxINtZiLihMB1LPaUbwCAAA= X-Env-Sender: andrii.anisov@gmail.com X-Msg-Ref: server-3.tower-27.messagelabs.com!1484066670!80923822!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 24482 invoked from network); 10 Jan 2017 16:44:30 -0000 Received: from mail-wj0-f195.google.com (HELO mail-wj0-f195.google.com) (209.85.210.195) by server-3.tower-27.messagelabs.com with AES128-GCM-SHA256 encrypted SMTP; 10 Jan 2017 16:44:30 -0000 Received: by mail-wj0-f195.google.com with SMTP id dh1so7786403wjb.3 for ; Tue, 10 Jan 2017 08:44: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=0sfjJbmp5WK9/stqFukbfevGa//NV/qIHPRPSgidVYM=; b=gsGNHadqVp5Cn7dLTX951SYkFrxPSMJpI1f3iNq02Na+BC7PIMNgPXqPfbmBlZQh6q ZxYyihKZ8toKFtyhejFzfQ91vAbUMcUlzNKNeNDupP/A0CCBvC+JVSOhdKLpZgKUk5xE va0NHNUbdOP4jBo4gYfrMR3aGhhYAejl8sdC9URx48XHKIRA47ovJ0qNcH5S0Itzmlbp AZnJsnciKGzvhJhipCwt0iJw5bqBPg7G0aNRmuAXv2ber+ZTDBuXmMgGM9AF5iXqQVmf 68SM/5WhjW3MicBiPvnUCtZAd23FNXoNsBnsm5Uw6fc9gXrz44XLTsC2M+8oDbOcUd6M 9ozQ== 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=0sfjJbmp5WK9/stqFukbfevGa//NV/qIHPRPSgidVYM=; b=cgrPKCfU6dwNfj9GurQT7vQlA9qP6+5wPbkf9GEoG2ca12bTfSnkjIDwDtq9TIIHj0 sfF1LWA3N+rUIyL+LcoaFh8Usw2K+DbR34J/aV/iZpeccWTwUed618zU1IJvCw7VyW9D /loHPa+B02czmrXu2N+GjKJe1eSRPZFYEmrHt6Jxl2qMWyqGeJoacPvLlUdLeseJ3xWV 0SvAkCaKvQjZs+5FH5BORi0z23T6Hyg/OICzRxwgIcVqzKpg+0I0/8XHuNsIzzx3LuvU qAvkUbsl9MEU0syPidZamJd2F+ArX/HzxlsuTI33Lu9DRbHObwX3MMYsBXjd4Jmc9mnd zQ4g== X-Gm-Message-State: AIkVDXI1qwYgFKuVT3kyDka1U/0nZRth7+Lu/xh3Nqg3A0AI2CZL4Aw5eEUwrpXYJw5oCA== X-Received: by 10.194.163.42 with SMTP id yf10mr2323102wjb.109.1484066670420; Tue, 10 Jan 2017 08:44:30 -0800 (PST) Received: from aanisov-work.kyiv.epam.com (ll-51.209.223.85.sovam.net.ua. [85.223.209.51]) by smtp.gmail.com with ESMTPSA id a8sm4099711wjq.44.2017.01.10.08.44.29 (version=TLS1_2 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Tue, 10 Jan 2017 08:44:30 -0800 (PST) From: Andrii Anisov To: xen-devel@lists.xenproject.org Date: Tue, 10 Jan 2017 18:44:26 +0200 Message-Id: <1484066667-12160-2-git-send-email-andrii.anisov@gmail.com> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1484066667-12160-1-git-send-email-andrii.anisov@gmail.com> References: <1484066667-12160-1-git-send-email-andrii.anisov@gmail.com> X-Mailman-Approved-At: Tue, 10 Jan 2017 16:47:47 +0000 Cc: julien.grall@arm.com, sstabellini@kernel.org, andrii_anisov@epam.com, Oleksandr Dmytryshyn , Stefano Stabellini Subject: [Xen-devel] [RFC 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 | 14 ++++++++++++++ 1 file changed, 14 insertions(+) diff --git a/arch/arm/xen/mm.c b/arch/arm/xen/mm.c index c5f9a9e..050cf34 100644 --- a/arch/arm/xen/mm.c +++ b/arch/arm/xen/mm.c @@ -163,6 +163,19 @@ bool xen_arch_need_swiotlb(struct device *dev, !is_device_dma_coherent(dev)); } +/* + * Create userspace mapping for the DMA-coherent memory. + */ +static int xen_swiotlb_dma_mmap(struct device *dev, struct vm_area_struct *vma, + void *cpu_addr, dma_addr_t dma_addr, size_t size, + struct dma_attrs *attrs) +{ + if (__generic_dma_ops(dev)->mmap) + return __generic_dma_ops(dev)->mmap(dev, vma, cpu_addr, dma_addr, size, attrs); + + return dma_common_mmap(dev, vma, cpu_addr, dma_addr, size); +} + int xen_create_contiguous_region(phys_addr_t pstart, unsigned int order, unsigned int address_bits, dma_addr_t *dma_handle) @@ -199,6 +212,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)