Received: by 10.192.165.148 with SMTP id m20csp414518imm; Fri, 20 Apr 2018 01:10:10 -0700 (PDT) X-Google-Smtp-Source: AIpwx4+aVPTk5RLRhYiBx89WLh332uH9qU96Q8awLIjbruWsVlEo3ek0eK63CS4dt44JGZiZ1/B7 X-Received: by 10.99.171.11 with SMTP id p11mr7506686pgf.176.1524211810562; Fri, 20 Apr 2018 01:10:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1524211810; cv=none; d=google.com; s=arc-20160816; b=c9u/lgx1MOXgJOTDmSH9274AAXr/ibYFTIqwpKX8RzVIajtu+tUxPs3UXIpbcjiRXO 87FNdyhjl1+6Tz/O7xpfOziBR7lGigoMsy+7HioYbmSxRmTHA7l3eC1rYttpYqhLSdgq MuvKbV6ILo6aBLxS+yS2cE+CVkGZFtvaddzYkQRCCSpC4eZC8PBfczAtLGMTGvdwwD07 i+H5tY8DApOqNl188+5GLnMC3O2wiF38FnO/1YnzOGCOhKAaKnWl/LElrZon5gQW5I/V hL/CMoG3Pzg7xLapwahnx8sL9KO+alqDrUMIimgLxai+KW45RX27d2OkHwdMZtX0L8Fq ch9g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:in-reply-to:message-id:date :subject:cc:from:dkim-signature:arc-authentication-results; bh=G7BoRD6XaPp/jaaG1XrkswLn5iHEsyoIjxVCSdpon0g=; b=xhFQ9RmgfMVZzFtUkcbk1fHOjn6XNMJ+y1kkPa/36HfNSJo+RKgTVU1LBS6yOQHagV JlVXXxwUUibduPE07eQFlWMzob+/BDiq8drOla9Jde6TD3SCrd8jit/5HwpCvk97wLon su05c2HZ1RkxHPyJiI1Iwd5SEYrzVrFOrKI378XJXrlb6H/5Of2Yfvm19gGdp+4EOZwJ St1gWbIDx34yTMjFPUKNORELP6Guim2wU9MTi4aRclhBE9a5U/jS10PM7awSOJhUUzB8 HhemyRvnt+Po5+gg2Xd1joN+J5rDJXH1LOxfDlTqqiQk7RlsfkKBJ+gz5dKmjHP7kicK PqUg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rbBT+t3i; 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 b3-v6si5144349plc.63.2018.04.20.01.09.55; Fri, 20 Apr 2018 01:10:10 -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=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=rbBT+t3i; 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 S1754510AbeDTIIi (ORCPT + 99 others); Fri, 20 Apr 2018 04:08:38 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:40676 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754307AbeDTIEt (ORCPT ); Fri, 20 Apr 2018 04:04:49 -0400 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=bombadil.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=G7BoRD6XaPp/jaaG1XrkswLn5iHEsyoIjxVCSdpon0g=; b=rbBT+t3ioyWFVj+wK5ernJgiY OYlgWakVlCZO0LWr98uVS9ipEESLDwxetJpCElgLG2YI/AHoDMs+TjdXoxU9QaFtAw8b5ms/eij/Y dBBpsb/v86Ax3tqV3eqGuvHl6KOUgVP1Srovu6ywQPx777ONYC9An1orJuWpt/gmI541dEYOSxHDs hpybtKA+eIaEjh4czBNQJa5W8n6sMAR53/1TaRYsBjktMqQo+gDNl4d2G/IqbxePhnFPBvHL9OWTb upkBLCb2Ijt1ipku0eGaIEhesyeQY4PPcjtERpkYuut+vcLKx4FVEQpw8g/LsNUHyoyowAQ28Vw6P boCq4sIrw==; Received: from static-242-42-24-46.ipcom.comunitel.net ([46.24.42.242] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1f9R1j-0007kw-Up; Fri, 20 Apr 2018 08:04:16 +0000 From: Christoph Hellwig Cc: linux-arch@vger.kernel.org, Michal Simek , Greentime Hu , Vincent Chen , linux-alpha@vger.kernel.org, linux-snps-arc@lists.infradead.org, linux-arm-kernel@lists.infradead.org, linux-c6x-dev@linux-c6x.org, linux-hexagon@vger.kernel.org, linux-m68k@lists.linux-m68k.org, nios2-dev@lists.rocketboards.org, openrisc@lists.librecores.org, linux-parisc@vger.kernel.org, linux-sh@vger.kernel.org, sparclinux@vger.kernel.org, linux-xtensa@linux-xtensa.org, linux-kernel@vger.kernel.org Subject: [PATCH 17/22] sh: introduce a sh_cacheop_vaddr helper Date: Fri, 20 Apr 2018 10:03:08 +0200 Message-Id: <20180420080313.18796-18-hch@lst.de> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20180420080313.18796-1-hch@lst.de> References: <20180420080313.18796-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org And use it in the maple bus code to avoid a dma API dependency. Signed-off-by: Christoph Hellwig --- arch/sh/include/asm/cacheflush.h | 7 +++++++ arch/sh/mm/consistent.c | 5 +---- drivers/sh/maple/maple.c | 7 ++++--- 3 files changed, 12 insertions(+), 7 deletions(-) diff --git a/arch/sh/include/asm/cacheflush.h b/arch/sh/include/asm/cacheflush.h index d103ab5a4e4b..b932e42ef028 100644 --- a/arch/sh/include/asm/cacheflush.h +++ b/arch/sh/include/asm/cacheflush.h @@ -101,5 +101,12 @@ void kunmap_coherent(void *kvaddr); void cpu_cache_init(void); +static inline void *sh_cacheop_vaddr(void *vaddr) +{ + if (__in_29bit_mode()) + vaddr = (void *)CAC_ADDR((unsigned long)vaddr); + return vaddr; +} + #endif /* __KERNEL__ */ #endif /* __ASM_SH_CACHEFLUSH_H */ diff --git a/arch/sh/mm/consistent.c b/arch/sh/mm/consistent.c index af2f28572119..516d481525e1 100644 --- a/arch/sh/mm/consistent.c +++ b/arch/sh/mm/consistent.c @@ -69,10 +69,7 @@ void dma_generic_free_coherent(struct device *dev, size_t size, void sh_sync_dma_for_device(void *vaddr, size_t size, enum dma_data_direction direction) { - void *addr; - - addr = __in_29bit_mode() ? - (void *)CAC_ADDR((unsigned long)vaddr) : vaddr; + void *addr = sh_cacheop_vaddr(vaddr); switch (direction) { case DMA_FROM_DEVICE: /* invalidate only */ diff --git a/drivers/sh/maple/maple.c b/drivers/sh/maple/maple.c index 7525039d812c..c9c354bd713a 100644 --- a/drivers/sh/maple/maple.c +++ b/drivers/sh/maple/maple.c @@ -300,8 +300,8 @@ static void maple_send(void) mutex_unlock(&maple_wlist_lock); if (maple_packets > 0) { for (i = 0; i < (1 << MAPLE_DMA_PAGES); i++) - sh_sync_dma_for_device(maple_sendbuf + i * PAGE_SIZE, - PAGE_SIZE, DMA_BIDIRECTIONAL); + __flush_purge_region(maple_sendbuf + i * PAGE_SIZE, + PAGE_SIZE); } finish: @@ -642,7 +642,8 @@ static void maple_dma_handler(struct work_struct *work) list_for_each_entry_safe(mq, nmq, &maple_sentq, list) { mdev = mq->dev; recvbuf = mq->recvbuf->buf; - sh_sync_dma_for_device(recvbuf, 0x400, DMA_FROM_DEVICE); + __flush_invalidate_region(sh_cacheop_vaddr(recvbuf), + 0x400); code = recvbuf[0]; kfree(mq->sendbuf); list_del_init(&mq->list); -- 2.17.0