From patchwork Mon Jul 30 16:26:36 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eugeniy Paltsev X-Patchwork-Id: 951140 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=synopsys.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="LLbt4tq4"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="kULv8Vwl"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=synopsys.com header.i=@synopsys.com header.b="AaHMGxkV"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41fQ2T0Tn6z9ryt for ; Tue, 31 Jul 2018 02:27:13 +1000 (AEST) 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=Dc+XyFa5KFv0fZUFQggM6l7dJ18+xWAkLu/tyuACsr0=; b=LLbt4tq4nHJ7bx2xD7gj9xAuPB LVECEpj3OKlesNt/oYO+5f+KQ5Cc8/p4DG+HAesUaaVO3PVmJPVkfvH+OvYiKwIUNz15qNaGeQuBV bJOtdi6Bc8f4xaD/DhV/+qEFwrJ3EpJAcV6IsC+6xRRhZ7IWAWtWwMxs01oHXJH14vV2e4IpkttGd eSJd6r1BKdffiVCsIKHCmPyZeMh43YMIdyg+ZtsDmmf4BJgAfmW6wB8vWV+kA2Owyf09oTQHGHJMY m7y/iAd0yt89H21WhsR0P1UEVW32Ji7TD89BeNNq8Wv6diT70jzE6lVNajVTqNOiyJzuZkDyHuAmL 9hW6YBwA==; 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 1fkB0o-0002K2-MX; Mon, 30 Jul 2018 16:27:10 +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 1fkB0m-00027W-Pe for linux-snps-arc@bombadil.infradead.org; Mon, 30 Jul 2018 16:27:08 +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=MgtPiNyun+fhfaHuF7CqoqzYA6i7duvUAx8C0la5mCk=; b=kULv8VwlUG5ipRzPJV6nJKnhh yjQbPcsBdYd5kUf5kx20YDEz/MPVRC4PJzDVTMXRb0D10RYq/7NRnppDr52ax5yfyGgftG+lH9HSB GM+LBEvjP8/IYDKrwuyJblvMmufBrEtoojvPpebGLmg+hsUJI7fJtv0dRYrOBzQ6WUlT8Ajwow2af ZDnVQaM66a3Eu4Qd6ggavSFNsKOUJFnFXgpbyhwRLTQytT84IjvlG3iKUU6+ErwCbDh1qiVpQmrFo amSaYMEcfDcDg4jOsfgewH7dDxHUBVw7C5a2vui8t9Iih99oqk5sa1aOlC7BUbhn5qWUGgHbhNeep ZYFJ2V4XA==; Received: from smtprelay2.synopsys.com ([198.182.60.111] helo=smtprelay.synopsys.com) by merlin.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fkB0j-0007ba-Ke for linux-snps-arc@lists.infradead.org; Mon, 30 Jul 2018 16:27:06 +0000 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 2DCA410C05D8; Mon, 30 Jul 2018 09:26:50 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1532968010; bh=EN6mNSpaRkYlyEL2gxhw9tIreBpXQzuMLKFgvRF6IAk=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=AaHMGxkVccjcbQC34ngaxcpErVyk5CuuVD+SQ6sID6YUWSOE/VcqpGruKY5zXIyus Ci0cYuJjDpfX38pX63NQCKB9emrZ32qKckXzmCN/5cCD5PhAoSXUVUtwYjf4cCzlBl vk57PPTQd4JsjmeQaogcuD7Jmb4ynoflZLyhY1XJnDazTIQpk2HbmM7J9CmwNfsx7U esYdPoxm580RI3UwzWJu9P8fxc5Xv0tftw2NU42UVq8qbbdy/lqdy8SDXowEvWJUyA IqTfvfjIouYKidKEgbQzV7yfu/ribj1XWjCnGTMo6gKh2nHXuqSUiits0IImnHCNkN MLPzu9X1jm94w== Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.86]) by mailhost.synopsys.com (Postfix) with ESMTP id 68EB23FCB; Mon, 30 Jul 2018 09:26:48 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Subject: [PATCH v2 4/4] ARC: don't check for HIGHMEM pages in arch_dma_alloc Date: Mon, 30 Jul 2018 19:26:36 +0300 Message-Id: <20180730162636.3556-5-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180730162636.3556-1-Eugeniy.Paltsev@synopsys.com> References: <20180730162636.3556-1-Eugeniy.Paltsev@synopsys.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180730_122705_759368_059BA947 X-CRM114-Status: GOOD ( 11.59 ) X-Spam-Score: -0.1 (/) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (-0.1 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at http://www.dnswl.org/, no trust [198.182.60.111 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid X-BeenThere: linux-snps-arc@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux on Synopsys ARC Processors List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-arch@vger.kernel.org, Vineet Gupta , Alexey Brodkin , linux-kernel@vger.kernel.org, Eugeniy Paltsev , hch@lst.de MIME-Version: 1.0 Sender: "linux-snps-arc" Errors-To: linux-snps-arc-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org __GFP_HIGHMEM flag is cleared by upper layer functions (in include/linux/dma-mapping.h) so we'll never get a __GFP_HIGHMEM flag in arch_dma_alloc gfp argument. That's why alloc_pages will never return highmem page here. Get rid of highmem pages handling and cleanup arch_dma_alloc and arch_dma_free functions. Signed-off-by: Eugeniy Paltsev Reviewed-by: Christoph Hellwig --- Changes v1->v2 (Thanks to Christoph): * Remove check for HIGHMEM pages from arch_dma_{alloc, free} arch/arc/mm/dma.c | 32 ++++++++++++++------------------ 1 file changed, 14 insertions(+), 18 deletions(-) diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c index 4d1466905e48..46129d7a298d 100644 --- a/arch/arc/mm/dma.c +++ b/arch/arc/mm/dma.c @@ -27,30 +27,29 @@ void *arch_dma_alloc(struct device *dev, size_t size, dma_addr_t *dma_handle, struct page *page; phys_addr_t paddr; void *kvaddr; - int need_coh = 1, need_kvaddr = 0; + bool need_coh = !(attrs & DMA_ATTR_NON_CONSISTENT); + + /* + * __GFP_HIGHMEM flag is cleared by upper layer functions + * (in include/linux/dma-mapping.h) so we should never get a + * __GFP_HIGHMEM here. + */ + BUG_ON(gfp & __GFP_HIGHMEM); page = alloc_pages(gfp, order); if (!page) return NULL; - if (attrs & DMA_ATTR_NON_CONSISTENT) - need_coh = 0; - - /* - * - A coherent buffer needs MMU mapping to enforce non-cachability - * - A highmem page needs a virtual handle (hence MMU mapping) - * independent of cachability - */ - if (PageHighMem(page) || need_coh) - need_kvaddr = 1; - /* This is linear addr (0x8000_0000 based) */ paddr = page_to_phys(page); *dma_handle = paddr; - /* This is kernel Virtual address (0x7000_0000 based) */ - if (need_kvaddr) { + /* + * A coherent buffer needs MMU mapping to enforce non-cachability. + * kvaddr is kernel Virtual address (0x7000_0000 based). + */ + if (need_coh) { kvaddr = ioremap_nocache(paddr, size); if (kvaddr == NULL) { __free_pages(page, order); @@ -81,11 +80,8 @@ void arch_dma_free(struct device *dev, size_t size, void *vaddr, { phys_addr_t paddr = dma_handle; struct page *page = virt_to_page(paddr); - int is_non_coh = 1; - - is_non_coh = (attrs & DMA_ATTR_NON_CONSISTENT); - if (PageHighMem(page) || !is_non_coh) + if (!(attrs & DMA_ATTR_NON_CONSISTENT)) iounmap((void __force __iomem *)vaddr); __free_pages(page, get_order(size));