From patchwork Tue Apr 11 12:43:28 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julien Grall X-Patchwork-Id: 9675271 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 4DE27600CB for ; Tue, 11 Apr 2017 12:43:56 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3C84A2843F for ; Tue, 11 Apr 2017 12:43:56 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 2FB3628548; Tue, 11 Apr 2017 12:43:56 +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=-1.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [65.50.211.133]) (using TLSv1.2 with cipher AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id B121E2843F for ; Tue, 11 Apr 2017 12:43:55 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:Cc:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date: Message-ID:From:References:To:Subject:Reply-To:Content-ID:Content-Description :Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=abDdR2ntNlOj4NKnsRH2CiOJb0bWKfvy1bYcxgQs3R0=; b=mBtsOfsdmu1lbv zs6Wwo7apadMi04BrZqA00MOeu4sQhcl39tnPkg/nipOGbVbZB988cqEMee3xYF+dk0Bk5to3H4X5 4nMXY/rEwyUykPFcrBQdVZJS7EqinvJhemcRFSKTrcDfGVTzdXUskGO2VRsJgyB+Fp2D30z1ebxRy lKHDpSLgKlSV4k6KQRyMd6/HIO6wnvzliQuCBgyUqTxqBgABzrDKPwila+HUkvB3ibrQ70nOK5y07 cd2y0VevPlTvvuIJQr3DvsEJ3UwDtN73mW6DwnmyIss3bzPRLt4Kj9K9o90a6uQF8C6Gb1/6To9xz 5zPjZ0aRNaDQ0O9P33mw==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cxv9H-0000Ij-DI; Tue, 11 Apr 2017 12:43:55 +0000 Received: from foss.arm.com ([217.140.101.70]) by bombadil.infradead.org with esmtp (Exim 4.87 #1 (Red Hat Linux)) id 1cxv9E-0000FJ-2k for linux-arm-kernel@lists.infradead.org; Tue, 11 Apr 2017 12:43:53 +0000 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id A7D971688; Tue, 11 Apr 2017 05:43:31 -0700 (PDT) Received: from [10.1.206.53] (e108454-lin.cambridge.arm.com [10.1.206.53]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A70903F23B; Tue, 11 Apr 2017 05:43:29 -0700 (PDT) Subject: Re: "Consolidate get_dma_ops" breaks Xen on ARM To: Bart Van Assche , Stefano Stabellini References: From: Julien Grall Message-ID: Date: Tue, 11 Apr 2017 13:43:28 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:45.0) Gecko/20100101 Thunderbird/45.8.0 MIME-Version: 1.0 In-Reply-To: X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20170411_054352_131356_3FA4F748 X-CRM114-Status: GOOD ( 14.97 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: "jgross@suse.com" , "linux-arch@vger.kernel.org" , "benh@kernel.crashing.org" , "x86@kernel.org" , "linux@armlinux.org.uk" , "linux-kernel@vger.kernel.org" , "mingo@redhat.com" , "hpa@zytor.com" , "boris.ostrovsky@oracle.com" , "dwmw2@infradead.org" , linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org X-Virus-Scanned: ClamAV using ClamSMTP Hi Bart, On 11/04/17 02:14, Bart Van Assche wrote: > On 04/10/17 17:31, Stefano Stabellini wrote: >> I think the reason is that, as you can see, if (dev && dev->dma_ops), >> dev->dma_ops is returned, while before this changes, xen_dma_ops was >> returned on Xen on ARM. >> >> Unfortunately DMA cannot work properly without using the appropriate >> xen_dma_ops. See drivers/xen/swiotlb-xen.c and arch/arm/xen/mm.c for >> more details. (The problem is easy to spot, but I wasn't CC'ed on the >> patch.) >> >> I don't know how to solve this problem without introducing some sort of >> if (xen()) in include/linux/dma-mapping.h. > > Sorry but I don't have access to an ARM development system. Does your > comment apply to dev == NULL only, dev != NULL only or perhaps to both? > If your comment applies to dev != NULL only, can you check whether > adding something like set_dma_ops(dev, get_arch_dma_ops(NULL)) to the > appropriate ARM arch_setup_dma_ops() function is sufficient? If I understand correctly, set_dma_ops will replace dev->dma_ops with Xen DMA ops. However, Xen DMA ops will need in some places to call the device specific DMA ops (see __generic_dma_ops(...)). So I think replacing dev->dma_ops is not a solution here. The hackish patch below is fixing the problem for both ARM64 and ARM32. It is not nice as this is common code, but I can't find a better solution so far. Any opinions? Cheers, diff --git a/include/linux/dma-mapping.h b/include/linux/dma-mapping.h index 0977317c6835..43a73ddeec7a 100644 --- a/include/linux/dma-mapping.h +++ b/include/linux/dma-mapping.h @@ -174,6 +174,8 @@ int dma_mmap_from_coherent(struct device *dev, struct vm_area_struct *vma, #include static inline const struct dma_map_ops *get_dma_ops(struct device *dev) { + if (xen_initial_domain()) + return xen_dma_ops; if (dev && dev->dma_ops) return dev->dma_ops; return get_arch_dma_ops(dev ? dev->bus : NULL);