Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp6792272imm; Tue, 24 Jul 2018 03:11:46 -0700 (PDT) X-Google-Smtp-Source: AAOMgpeadMHTk3zswg3gysbU++LBwyeOn9ZHJ3mssFTr4l28Bw6RP1ZMw3Hg9CqtBJPmdkhoa1Zg X-Received: by 2002:a17:902:708b:: with SMTP id z11-v6mr16095761plk.262.1532427106863; Tue, 24 Jul 2018 03:11:46 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1532427106; cv=none; d=google.com; s=arc-20160816; b=v1mqL5ueLAkTqebv/0pRokTnZjZ6ygLHSIDUVMC0facvSawloLThDAHEqmAWuHRxbv o0fizKZe7unuXc4rHMxyzt4Xe/alWi8vKh1HQAS1RwjWhkvGTmNmQ6r/y0OK1ovGoop1 9HytTG4yGSGHOYUaFX86N5wtNZ/NsHpQczBFE2ugg7qRhQkLAQRN7ZV6bMIjA7N72XVZ m7m5qsMFh6On5viVCgrXFPqmz4fqTDlZeFKX4vSM2FBT/XQd5XDV54GVNK2M47nDIKRz CR97fW8o6vkHdDqIbn1PsOEQd8tlOc0znsCBmlCw9izH/XeqRo7UuFmMlcbiNn7LTKSx vjIA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=CtkUO8SuBUmyFnc3276DWZxAlOnmSLecAmLu8BWJaD8=; b=ewv5EpFYg53q/rOCxcfZBLsQY0kEHIXOvvx1gTYH5ar+KmDqrMqTknNDv5TCM8hLcb XVxBS7RPo4VDOUAbMA+dAHnSQj9OUCmpTS2njjUIflGmqNPFfc9Jx0vdwp8CdJt/MxWi 5JhlO7yakSWXxDd0dRtAN3toOa5lJOon47v9+0mspj3rDCKaZwHI/hR8cMZ3kSiDIVD3 KqYlX2YUmJaw0kdNgPMLZYfKHxmSj0pJO1/s2eET/7BQ+Nbi58p8PqCs2KmN5b5jJK4Q l9XkMRVz7HX8y5zo1+avt92n2VKp5KQPMwjYrsq/2CDkyfE5ENIj74nWh/GjfhFMulA2 thFA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@synopsys.com header.s=mail header.b="Wda/JaLy"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id a95-v6si11082380pla.401.2018.07.24.03.11.32; Tue, 24 Jul 2018 03:11:46 -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; dkim=pass header.i=@synopsys.com header.s=mail header.b="Wda/JaLy"; 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; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=synopsys.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388502AbeGXLQZ (ORCPT + 99 others); Tue, 24 Jul 2018 07:16:25 -0400 Received: from us01smtprelay-2.synopsys.com ([198.182.60.111]:40133 "EHLO smtprelay.synopsys.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388251AbeGXLQZ (ORCPT ); Tue, 24 Jul 2018 07:16:25 -0400 Received: from mailhost.synopsys.com (mailhost3.synopsys.com [10.12.238.238]) by smtprelay.synopsys.com (Postfix) with ESMTP id 22B9A10C0D61; Tue, 24 Jul 2018 03:10:42 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=synopsys.com; s=mail; t=1532427042; bh=7JLQXvWOCbq90isblzh8XlINfMmrqevVjHleMR4MpU8=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Wda/JaLyGAAyh76u6lx/FKzfkA80S/nMK3P6nboj4k6JAINhphi9eNzEtAKqU5ryR OcbPjsMEtyWGqDc7YDsBGkV/TozyTNdgYvHYPXnuZatR3Ny9juIn612eknma/ctpU2 Wg/yEDCT/UDEYdIXbsv0FT91raNxmLKF1r/ZjDcVb9B5AZMuA9wOcprIp9k+DJGfP/ Q/J55vAFeTcbsuABT02Jb9SZLBhDPfhxIbhm1IPq4vKja6dOIeOj7p6GfaJgQ4cxSw ycPFkW/OHfPLWUJlJizWlZi+LME6QzCKMyOxmVF2Jn2AI/qBI77UX+hR/XOi5C3FRx LyG/epk4N2KRA== Received: from paltsev-e7480.internal.synopsys.com (unknown [10.121.8.86]) by mailhost.synopsys.com (Postfix) with ESMTP id 4DFA03364; Tue, 24 Jul 2018 03:10:40 -0700 (PDT) From: Eugeniy Paltsev To: linux-snps-arc@lists.infradead.org Cc: linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, Vineet Gupta , Alexey Brodkin , hch@lst.de, Eugeniy Paltsev Subject: [PATCH 3/4] ARC: refactor arch/arc/mm/dma.c Date: Tue, 24 Jul 2018 13:10:00 +0300 Message-Id: <20180724101001.31965-4-Eugeniy.Paltsev@synopsys.com> X-Mailer: git-send-email 2.14.4 In-Reply-To: <20180724101001.31965-1-Eugeniy.Paltsev@synopsys.com> References: <20180724101001.31965-1-Eugeniy.Paltsev@synopsys.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Refactoring, no functional change intended. Signed-off-by: Eugeniy Paltsev --- arch/arc/mm/dma.c | 28 ++++++++++------------------ 1 file changed, 10 insertions(+), 18 deletions(-) diff --git a/arch/arc/mm/dma.c b/arch/arc/mm/dma.c index b693818cd8e5..46584c7c2858 100644 --- a/arch/arc/mm/dma.c +++ b/arch/arc/mm/dma.c @@ -27,30 +27,24 @@ 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); 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 + * - A highmem page needs a virtual handle (hence MMU mapping) + * independent of cachability. + * kvaddr is kernel Virtual address (0x7000_0000 based) + */ + if (PageHighMem(page) || need_coh) { kvaddr = ioremap_nocache(paddr, size); if (kvaddr == NULL) { __free_pages(page, order); @@ -81,11 +75,9 @@ 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); + bool is_coh = !(attrs & DMA_ATTR_NON_CONSISTENT); - if (PageHighMem(page) || !is_non_coh) + if (PageHighMem(page) || is_coh) iounmap((void __force __iomem *)vaddr); __free_pages(page, get_order(size)); -- 2.14.4