Received: by 2002:ac0:a5a7:0:0:0:0:0 with SMTP id m36-v6csp5407461imm; Tue, 31 Jul 2018 10:22:04 -0700 (PDT) X-Google-Smtp-Source: AAOMgpcPkfI494TlD8xQb8tDzBwkwRL1xzmYainS8+setz/KNOIp+V9b7vtw5Q1TIsjMCCN92ppK X-Received: by 2002:a63:1d3:: with SMTP id 202-v6mr21079709pgb.136.1533057724807; Tue, 31 Jul 2018 10:22:04 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1533057724; cv=none; d=google.com; s=arc-20160816; b=spkECxFth7djprRfq2u4hrrfGs3z9kJNaDmsYngMweonXaGaUbor1okvyBxfdOaKfw MoNDhEg+c/ZXaivjsG6kQwTUmmYtlMLQ2zWMPfSaV8TcZjzmTH/rWH/sKVT658R8uROq pWoeevkQESpdCI8Jf5hA2QZW+dM1iRqo12wP1pOsTTBvnCl52gwI4Pb7wxwcE2d/HuV/ zV2YQD/uWgjBq2o703rrlyQqvxAVTZDHJ5U1tGeXqXqDcaKWwDYdMOVSbZxiSKTbz9vV y+T6W3jR0TtBEnDW0mEaSeKzz3kpu3ux2Q+pPQizMUcCBhnDOVHVd7KJYk75fJKVOFsc NP1g== 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=/J/HGUgyOH5vfRsukQGVXjDLuxynaYtDJFq081fABsQ=; b=ikG5nbPhN7zAfUxN3AOYL0S0c/Rts8/+bSgOeZmhEy3+RbYyyZFXXM2h3eOQV+rCov Fwq7KRTssIzvVwGNeQnq6A5r8b4xlSnX3N5D+UrMxpCtx3xs9LYhQ8fJJrN6gxbrDfc3 0QiNCJNWYLTJ8CLLuoq0JoAvIQXFtjwUeQGcd8AcuEkrcQir9tWUvd5YOqFV7X3qSYKr JoExovEf7pOqfzCJ8nFNjDpAwIPsd7OYfsMxjU7+AbWa9mkJWCgiLi/S0wlrqufvShYK +YfC2Zfv9/5PqqSI8BeE526l9YyT9XW1LBAJ/fTXgi8DpVUn5Em5FQnq9DS2WSw5G69d 7E3A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@infradead.org header.s=bombadil.20170209 header.b=pZxeBAq1; 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 d11-v6si13743864pla.442.2018.07.31.10.21.50; Tue, 31 Jul 2018 10:22:04 -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=pZxeBAq1; 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 S1731383AbeGaTB7 (ORCPT + 99 others); Tue, 31 Jul 2018 15:01:59 -0400 Received: from bombadil.infradead.org ([198.137.202.133]:46356 "EHLO bombadil.infradead.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728968AbeGaTB7 (ORCPT ); Tue, 31 Jul 2018 15:01:59 -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=/J/HGUgyOH5vfRsukQGVXjDLuxynaYtDJFq081fABsQ=; b=pZxeBAq199lcK2J9QmFHBlklv LUmSOWLDGCAbUMsvxHNZytNfMLcIDxeZGzC+0k7Nk4Tmqm2xpAKTnE5o6I5p+xjZoXV9HjqV0pSxG OrtVH5nRjEv1jB+tOKE/vaWBtAkaU8gESPqQMgbAorjKzyy0KlW6dgeQsAccriWt5RDsByR1cdiYm 8xiDjReUyLbWlVxEsrjJTkpJFVzEDkQUP9KsjG/4Wcu/qIaXb0HQb0Wq3Dp2InlKtqzBwjNMnwDyL XYqhZaTaze91GkP+M9f39Or0bJP7cLVpK5aXfR7715qtjwaXNSZxuqfnPf/Kjpd9vmDFtN2ORaoyk IQ1ELFdnw==; Received: from 089144203113.atnat0012.highway.a1.net ([89.144.203.113] helo=localhost) by bombadil.infradead.org with esmtpsa (Exim 4.90_1 #2 (Red Hat Linux)) id 1fkYK6-0002IF-7g; Tue, 31 Jul 2018 17:20:38 +0000 From: Christoph Hellwig To: Tony Luck , Fenghua Yu Cc: Sinan Kaya , Arnd Bergmann , linux-ia64@vger.kernel.org, linux-arch@vger.kernel.org, linux-kernel@vger.kernel.org, iommu@lists.linux-foundation.org Subject: [PATCH] ia64: fix barrier placement for write* / dma mapping Date: Tue, 31 Jul 2018 19:20:31 +0200 Message-Id: <20180731172031.4447-2-hch@lst.de> X-Mailer: git-send-email 2.18.0 In-Reply-To: <20180731172031.4447-1-hch@lst.de> References: <20180731172031.4447-1-hch@lst.de> X-SRS-Rewrite: SMTP reverse-path rewritten from by bombadil.infradead.org. See http://www.infradead.org/rpr.html Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org memory-barriers.txt has been updated with the following requirement. "When using writel(), a prior wmb() is not needed to guarantee that the cache coherent memory writes have completed before writing to the MMIO region." The current writeX() and iowriteX() implementations on ia64 are not satisfying this requirement as the barrier is after the register write. This adds the missing memory barriers, and instead drops them from the dma sync routine where they are misplaced (and were missing in the more important map/unmap cases anyway). All this doesn't affect the SN2 platform, which already has barrier in the I/O accessors, and none in dma mapping (but then again swiotlb doesn't have any either). Signed-off-by: Christoph Hellwig --- arch/ia64/hp/common/sba_iommu.c | 4 ---- arch/ia64/include/asm/dma-mapping.h | 5 ----- arch/ia64/include/asm/io.h | 5 +++++ arch/ia64/kernel/machvec.c | 16 ---------------- arch/ia64/kernel/pci-dma.c | 5 ----- 5 files changed, 5 insertions(+), 30 deletions(-) diff --git a/arch/ia64/hp/common/sba_iommu.c b/arch/ia64/hp/common/sba_iommu.c index ee5b652d320a..e8da6503ed2f 100644 --- a/arch/ia64/hp/common/sba_iommu.c +++ b/arch/ia64/hp/common/sba_iommu.c @@ -2207,10 +2207,6 @@ const struct dma_map_ops sba_dma_ops = { .unmap_page = sba_unmap_page, .map_sg = sba_map_sg_attrs, .unmap_sg = sba_unmap_sg_attrs, - .sync_single_for_cpu = machvec_dma_sync_single, - .sync_sg_for_cpu = machvec_dma_sync_sg, - .sync_single_for_device = machvec_dma_sync_single, - .sync_sg_for_device = machvec_dma_sync_sg, .dma_supported = sba_dma_supported, .mapping_error = sba_dma_mapping_error, }; diff --git a/arch/ia64/include/asm/dma-mapping.h b/arch/ia64/include/asm/dma-mapping.h index 76e4d6632d68..2b8cd4a6d958 100644 --- a/arch/ia64/include/asm/dma-mapping.h +++ b/arch/ia64/include/asm/dma-mapping.h @@ -16,11 +16,6 @@ extern const struct dma_map_ops *dma_ops; extern struct ia64_machine_vector ia64_mv; extern void set_iommu_machvec(void); -extern void machvec_dma_sync_single(struct device *, dma_addr_t, size_t, - enum dma_data_direction); -extern void machvec_dma_sync_sg(struct device *, struct scatterlist *, int, - enum dma_data_direction); - static inline const struct dma_map_ops *get_arch_dma_ops(struct bus_type *bus) { return platform_dma_get_ops(NULL); diff --git a/arch/ia64/include/asm/io.h b/arch/ia64/include/asm/io.h index fb0651961e2c..ba5523b67eaf 100644 --- a/arch/ia64/include/asm/io.h +++ b/arch/ia64/include/asm/io.h @@ -22,6 +22,7 @@ #include #include +#include /* We don't use IO slowdowns on the ia64, but.. */ #define __SLOW_DOWN_IO do { } while (0) @@ -345,24 +346,28 @@ ___ia64_readq (const volatile void __iomem *addr) static inline void __writeb (unsigned char val, volatile void __iomem *addr) { + mb(); *(volatile unsigned char __force *) addr = val; } static inline void __writew (unsigned short val, volatile void __iomem *addr) { + mb(); *(volatile unsigned short __force *) addr = val; } static inline void __writel (unsigned int val, volatile void __iomem *addr) { + mb(); *(volatile unsigned int __force *) addr = val; } static inline void __writeq (unsigned long val, volatile void __iomem *addr) { + mb(); *(volatile unsigned long __force *) addr = val; } diff --git a/arch/ia64/kernel/machvec.c b/arch/ia64/kernel/machvec.c index 7bfe98859911..1b604d02250b 100644 --- a/arch/ia64/kernel/machvec.c +++ b/arch/ia64/kernel/machvec.c @@ -73,19 +73,3 @@ machvec_timer_interrupt (int irq, void *dev_id) { } EXPORT_SYMBOL(machvec_timer_interrupt); - -void -machvec_dma_sync_single(struct device *hwdev, dma_addr_t dma_handle, size_t size, - enum dma_data_direction dir) -{ - mb(); -} -EXPORT_SYMBOL(machvec_dma_sync_single); - -void -machvec_dma_sync_sg(struct device *hwdev, struct scatterlist *sg, int n, - enum dma_data_direction dir) -{ - mb(); -} -EXPORT_SYMBOL(machvec_dma_sync_sg); diff --git a/arch/ia64/kernel/pci-dma.c b/arch/ia64/kernel/pci-dma.c index 3c2884bef3d4..2512aa3029f5 100644 --- a/arch/ia64/kernel/pci-dma.c +++ b/arch/ia64/kernel/pci-dma.c @@ -55,11 +55,6 @@ void __init pci_iommu_alloc(void) { dma_ops = &intel_dma_ops; - intel_dma_ops.sync_single_for_cpu = machvec_dma_sync_single; - intel_dma_ops.sync_sg_for_cpu = machvec_dma_sync_sg; - intel_dma_ops.sync_single_for_device = machvec_dma_sync_single; - intel_dma_ops.sync_sg_for_device = machvec_dma_sync_sg; - /* * The order of these functions is important for * fall-back/fail-over reasons -- 2.18.0