From patchwork Thu Aug 30 17:20:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ezequiel Garcia X-Patchwork-Id: 10582397 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id C32D8920 for ; Thu, 30 Aug 2018 17:23:01 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A9452288B7 for ; Thu, 30 Aug 2018 17:23:01 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A68AC289EB; Thu, 30 Aug 2018 17:23:01 +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=-2.9 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,MAILING_LIST_MULTI,RCVD_IN_DNSWL_NONE,UNPARSEABLE_RELAY autolearn=ham version=3.3.1 Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.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 5176728E2F for ; Thu, 30 Aug 2018 17:23:01 +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:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Y5W+S2oXHRB/R623l3lqxaGYx+BNYPPFxaoUicgsvoU=; b=hylYTMJoBtbTifaSgHUCIisTZ5 5K2UJLg/8IbDylvGN7EvM7RvzVYUFye5Mhps6OtSCM7Xf1Qj7tOFhsZI0oH4Q80zGAs4pvIvhbH13 xHzaGx99sbLbPk++PAnOjRgUs6RUihfJGktDISZ7n6o1hCfmmrg34cncN5yFia/qGkvfZAIeyoCvo SVc70qzCE22f5EFEZNJYgmiy+9FFUfrnDZFQf9Ma+G2nd+iZTvyRqWasy8uBdFf8cW7NnBYhI4aIZ 4p6lwdnwu9UgknGzolKs7gC5S7d9WD+rsTIHwD37On+8zqpaPLKeAS8T8pM8K4RNtFOvl/heRU2Ul v/sO5oyA==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvQef-0007a8-PR; Thu, 30 Aug 2018 17:22:49 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvQdI-0006vn-11 for linux-arm-kernel@bombadil.infradead.org; Thu, 30 Aug 2018 17:21:24 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZjmPZWA2tcZh7gubEUApBpckBhPqN6I1iAS9wy9JUBE=; b=RSddwaz4mFQYJ4tx4c7tj9Dm7 bYumGR5HezMvueIb2BOqw70RIrZbja7D12PtY7gkyH1JYulAyZwIbZVuT/fHTchmHdEY9z8HnMEm6 qcDFQHqYHpc+syjNqUcxcpM6SwrOsxrNHgyLu8nQW/Q3Qhz5GaNTBy3Sr3DTSSOHZHTsITJHKmz9T 37Ij7KI3RR4wZRlhYwGnoLKYlJErh18qTm9rFyKxDBnWCSTcgb1vPaOgV2TXpFuLOnYgzgf0Ym9qs 3dN+BNvC3W0aBaM+8GQdCN4E/aG6RAIeI0DXC55Q/B1M+6ivBhnKtYi56p6QMjvkvlSGhqA3zd2cz uJANaQMug==; Received: from bhuna.collabora.co.uk ([46.235.227.227]) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fvQdE-00020m-Ve for linux-arm-kernel@lists.infradead.org; Thu, 30 Aug 2018 17:21:22 +0000 Received: from [127.0.0.1] (localhost [127.0.0.1]) (Authenticated sender: ezequiel) with ESMTPSA id BD5EB27D4B4 From: Ezequiel Garcia To: linux-media@vger.kernel.org, linux-usb@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC 1/3] HACK: ARM: dma-mapping: Get writeback memory for non-consistent mappings Date: Thu, 30 Aug 2018 14:20:28 -0300 Message-Id: <20180830172030.23344-2-ezequiel@collabora.com> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180830172030.23344-1-ezequiel@collabora.com> References: <20180830172030.23344-1-ezequiel@collabora.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180830_132121_118296_A4B8BCEF X-CRM114-Status: GOOD ( 10.28 ) 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: Tomasz Figa , "Matwey V . Kornilov" , Keiichi Watanabe , Alan Stern , Laurent Pinchart , kernel@collabora.com, Ezequiel Garcia MIME-Version: 1.0 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 This is obviously a hack. Signed-off-by: Ezequiel Garcia --- arch/arm/include/asm/pgtable.h | 3 +++ arch/arm/mm/dma-mapping.c | 9 ++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/arch/arm/include/asm/pgtable.h b/arch/arm/include/asm/pgtable.h index a757401129f9..37ddd0d73434 100644 --- a/arch/arm/include/asm/pgtable.h +++ b/arch/arm/include/asm/pgtable.h @@ -122,6 +122,9 @@ extern pgprot_t pgprot_s2_device; #define pgprot_writecombine(prot) \ __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_BUFFERABLE) +#define pgprot_writeback(prot) \ + __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_WRITEBACK) + #define pgprot_stronglyordered(prot) \ __pgprot_modify(prot, L_PTE_MT_MASK, L_PTE_MT_UNCACHED) diff --git a/arch/arm/mm/dma-mapping.c b/arch/arm/mm/dma-mapping.c index 66566472c153..11cca7bbb0a8 100644 --- a/arch/arm/mm/dma-mapping.c +++ b/arch/arm/mm/dma-mapping.c @@ -633,9 +633,12 @@ static void __free_from_contiguous(struct device *dev, struct page *page, static inline pgprot_t __get_dma_pgprot(unsigned long attrs, pgprot_t prot) { - prot = (attrs & DMA_ATTR_WRITE_COMBINE) ? - pgprot_writecombine(prot) : - pgprot_dmacoherent(prot); + if (attrs & DMA_ATTR_WRITE_COMBINE) + prot = pgprot_writecombine(prot); + else if (attrs & DMA_ATTR_NON_CONSISTENT) + prot = pgprot_writeback(prot); + else + prot = pgprot_dmacoherent(prot); return prot; }