Received: by 10.213.65.68 with SMTP id h4csp1707878imn; Mon, 19 Mar 2018 11:04:42 -0700 (PDT) X-Google-Smtp-Source: AG47ELufc1OBSsL/CHMaz30PX2mpZD7Afhvn6oYMsKpKxV+LCIgigNOMn1xABZ0BQxtaJkgWh8XO X-Received: by 2002:a17:902:700b:: with SMTP id y11-v6mr1967411plk.177.1521482682773; Mon, 19 Mar 2018 11:04:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1521482682; cv=none; d=google.com; s=arc-20160816; b=Dqg6cyacm3X89DCzBkmJqcYO2SoYh/w+a5c5w68Gw/YIxRcs1z8iRGymUWxLxWuUAS p1px1x1y6nC3WIgt2wFAE5ZQsvPt3D4C8I38WJYzbmfXzI1yRTC/i2vw7AyM30Lj5EqA zjW31SQBmQf9Tyc/+NwD7Qnj2dCtGbzmP5COTAOl3jsparM+u+Ne/XaRv+yFkz+5tNXJ 0AnXgTdOKSzpTPsbPPfjHbKfYrCKYLIW+lgpFJvl70y/1BjMSElOozayvjNxDx7J472f D+FJHkYGrc1WLgM7PEugBxZ+HfJzI3FJ+hfw3NydCMe+g6P5ZewrGh+YiCB8R09g3U98 VoUw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=xshHIaJYuHP+Gy3Yzh8/GD/Djw5I6blx0FJrI0zBgMU=; b=Kai99uNm4di9UaTMCr6rE82bXMCu2VJcgIYEb9LBYUCO7l5UelmsBKmYc7CO0X1LqL 3nbwcIgu75wm9+NTexsyLU/vvDXBuyeVDpKoo04GrSFMd8eO0axfIsKoq4bush+cxljz dpBhUyESur5oaxkJDskTfw5Rhk2vVC7SFRgwOEe8uCJuQpxVy1NM+a00nsvbxRPEw1gC 77TgfR09cgERt7bNhnjkUemViL11RJ+G/wsoSvjyMa9f5FeyXOi8lBPLBMw3d7jN8QfT OQTo/TQ6DuU8Pbl09punZasoc6Tq3VrQ1pu8Tpu6ivCRskIEChK7vPG4o7RENt9Tr5cN xf5g== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 65-v6si381565plb.573.2018.03.19.11.04.27; Mon, 19 Mar 2018 11:04:42 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S967806AbeCSSC5 (ORCPT + 99 others); Mon, 19 Mar 2018 14:02:57 -0400 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:56428 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1030369AbeCSSBq (ORCPT ); Mon, 19 Mar 2018 14:01:46 -0400 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 3165580D; Mon, 19 Mar 2018 11:01:46 -0700 (PDT) Received: from armageddon.cambridge.arm.com (armageddon.cambridge.arm.com [10.1.206.84]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id 40E6F3F25D; Mon, 19 Mar 2018 11:01:44 -0700 (PDT) Date: Mon, 19 Mar 2018 18:01:41 +0000 From: Catalin Marinas To: Christoph Hellwig Cc: Will Deacon , Robin Murphy , x86@kernel.org, Tom Lendacky , Konrad Rzeszutek Wilk , linux-kernel@vger.kernel.org, Muli Ben-Yehuda , iommu@lists.linux-foundation.org, David Woodhouse Subject: Re: [PATCH 12/14] dma-direct: handle the memory encryption bit in common code Message-ID: <20180319180141.w5o6lhknhd6q7ktq@armageddon.cambridge.arm.com> References: <20180319103826.12853-1-hch@lst.de> <20180319103826.12853-13-hch@lst.de> <20180319152442.GA27915@lst.de> <5316b479-7e75-d62f-6b17-b6bece55187c@arm.com> <20180319154832.GD14916@arm.com> <20180319160343.GA29002@lst.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20180319160343.GA29002@lst.de> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Mar 19, 2018 at 05:03:43PM +0100, Christoph Hellwig wrote: > On Mon, Mar 19, 2018 at 03:48:33PM +0000, Will Deacon wrote: > > Why can't we just resolve the conflict by adding the underscores? > > We can solve the conflict easily that way. But that's not the point. > > The point is that I've been fighting hard to consolidate dma code > given that the behavior really is common and not arch specific. And > this one is another case like that: the fact that the non-coherent > dma boundary is bigger than the exposed size is something that can > easily happen elsewhere, so there is no need to duplicate a lot > of code for that. I don't particularly like maintaining an arm64-specific dma-direct.h either but arm64 seems to be the only architecture that needs to potentially force a bounce when cache_line_size() > ARCH_DMA_MINALIGN and the device is non-coherent. Note that lib/swiotlb.c doesn't even deal with non-coherent DMA (e.g. map_sg doesn't have arch callbacks for cache maintenance), so not disrupting lib/swiotlb.c seems to be the least intrusive option. > Nevermind that the commit should at least be three different patches: > > (1) revert the broken original commit > (2) increase the dma min alignment Reverting the original commit could, on its own, break an SoC which expects ARCH_DMA_MINALIGN == 128. So these two should be a single commit (my patch only reverts the L1_CACHE_BYTES change rather than ARCH_DMA_MINALIGN, the latter being correct as 128). Anyway, it's queued already and we try not to rebase the branches we published. Fix-ups on top are fine though. > (3) put the swiotlb workaround in place As I said above, adding a check in swiotlb.c for !is_device_dma_coherent(dev) && (ARCH_DMA_MINALIGN < cache_line_size()) feels too architecture specific. Adding yet another hook like arch_dma_capable() doesn't feel right either since we already have the possibility to override dma_capable() by selecting ARCH_HAS_PHYS_TO_DMA. The "cleanest" I came up with for swiotlb.c was a new DMA_ATTR_FORCE_BOUNCE attribute. However, it required more changes to the arm64 dma-mapping.c than simply implementing an arch-specific dma_capable(). -- Catalin