Received: by 2002:a05:6a10:1d13:0:0:0:0 with SMTP id pp19csp1230103pxb; Tue, 17 Aug 2021 06:57:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJz7aQFTDnGMLi70FN4k8SBm0l8ekHyjTqcZ7jkqHV4HOvs6bfWOy4cEuluI++GrOBPaTk03 X-Received: by 2002:a17:906:4f03:: with SMTP id t3mr4215316eju.369.1629208631991; Tue, 17 Aug 2021 06:57:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1629208631; cv=none; d=google.com; s=arc-20160816; b=R7cs/UgyaBTJac31TvjN2qqf895uYfp2YHzgEtzv6hb8YiD2K3SFE6U7WoGI5pX725 iaPpo7HycmppccctW2GWkqevS3yu/gBI0Mj8fBbNQts1wbGJgG8dMiG5dmVxoTkm3xqK WB7Zs6GBXfwL79ihbVsGV+WY7ajcvTpIDTCLf/bsbr/u6AWlla+J1+ytXb16KodvobsP zJLerAlkTi4mPnrLj7VGPbXk0Z/08VfKtynej16PdLbg7LFgKntiRiSpKmflqp9wKO+f QuL27wwcfyUM5h9Hi+oEWE/KfdLnHBeKIzJk8nxTdfSaOV8RkOP2RhbipYjDV7rhotRb 6PaA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:reply-to:message-id:subject:cc:to:from:date :dkim-signature; bh=lwXa7hLga92j3DTdVK260CMxgGblSnsuINtwLzVAD6Q=; b=eTuscZNY8jXMwH6zFfYHSakaDGRnCMD8XtElEgD6pvVc1Q1Tv6tWII4gRpjLJ8ykbN vyEFn23MwzR1Q2bfmtODUOy945boPXqv4DPlYJKwxN5DuwI6M674NfyTBNuW5jgJZZlh D4TSHISRptUjUTmAUTcMT/1JhtTiJr7/0BBT6vIqRbExlk2ibeXetNd5c4IlJa0tgwJy p9/boTD0Y0XuAl1OO8Nlq3wUjs5iAejmAgRi1YK5Fmr0ZXBKINB8/vdkLAFBmo4DGwTH jYMIJ7NbAUgpvNlzWa+KxANnpab0W//2+mAim+jpg9XwTn5s6jYVdRRMdLYq4qNA/fWI KFaA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RgLq2wmV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id lg8si2570520ejb.102.2021.08.17.06.56.46; Tue, 17 Aug 2021 06:57:11 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=RgLq2wmV; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S234741AbhHQNxl (ORCPT + 99 others); Tue, 17 Aug 2021 09:53:41 -0400 Received: from mail.kernel.org ([198.145.29.99]:35692 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231786AbhHQNxl (ORCPT ); Tue, 17 Aug 2021 09:53:41 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 5145660F58; Tue, 17 Aug 2021 13:53:08 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1629208388; bh=HkQR3v2tgZqoqXvfcCaaGF1O5WkRs2MFBLBTe+MuExc=; h=Date:From:To:Cc:Subject:Reply-To:References:In-Reply-To:From; b=RgLq2wmV4YUESnEWz5lx7o1zsVDsCgDWWS4Lozq9znawa7mDcO3K1kVbFLVeKyUPE dgO4sVGWa8HXqZhTFglDyfcZ1wvQ7g88IUsEOmFf2VEp45BqkSJT8W7l3FEbnLeR8s 7POrckDNE0brjbgiVd/xBz5iA1jec0ypCpR7NVf7vUtWEWLUyoGjFkyPm8IuWXkH/y yR4OjfgZ49xTZxuPaJVmJNrLvKzV7huFoCqFvK3OPry7CRyIzqKIxhPfh57x73+dVs 9cS+v0hWNYTIrqY05aC4nJn0ZpjigRS3ZLhJB1D3qQ+p9HJxaTJqCh9HqYUrCPTomA 1VvYdYRYuuACg== Received: by paulmck-ThinkPad-P17-Gen-1.home (Postfix, from userid 1000) id 20EF05C0F2E; Tue, 17 Aug 2021 06:53:08 -0700 (PDT) Date: Tue, 17 Aug 2021 06:53:08 -0700 From: "Paul E. McKenney" To: Will Deacon Cc: Alan Stern , Marco Elver , Boqun Feng , Andrea Parri , Mark Rutland , Dmitry Vyukov , kasan-dev@googlegroups.com, linux-kernel@vger.kernel.org Subject: Re: LKMM: Read dependencies of writes ordered by dma_wmb()? Message-ID: <20210817135308.GO4126399@paulmck-ThinkPad-P17-Gen-1> Reply-To: paulmck@kernel.org References: <20210816145945.GB121345@rowland.harvard.edu> <20210816192109.GC121345@rowland.harvard.edu> <20210816205057.GN4126399@paulmck-ThinkPad-P17-Gen-1> <20210817122816.GA12746@willie-the-truck> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20210817122816.GA12746@willie-the-truck> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Aug 17, 2021 at 01:28:16PM +0100, Will Deacon wrote: > Just on this bit... > > On Mon, Aug 16, 2021 at 01:50:57PM -0700, Paul E. McKenney wrote: > > 5. The dma_mb(), dma_rmb(), and dma_wmb() appear to be specific > > to ARMv8. > > These are useful on other architectures too! IIRC, they were added by x86 in > the first place. They're designed to be used with dma_alloc_coherent() > allocations where you're sharing something like a ring buffer with a device > and they guarantee accesses won't be reordered before they become visible > to the device. They _also_ provide the same ordering to other CPUs. > > I gave a talk at LPC about some of this, which might help (or might make > things worse...): > > https://www.youtube.com/watch?v=i6DayghhA8Q The slides are here, correct? Nice summary and examples! https://elinux.org/images/a/a8/Uh-oh-Its-IO-Ordering-Will-Deacon-Arm.pdf And this is all I see for dma_mb(): arch/arm64/include/asm/barrier.h:#define dma_mb() dmb(osh) arch/arm64/include/asm/io.h:#define __iomb() dma_mb() And then for __iomb(): arch/arm64/include/asm/io.h:#define __iomb() dma_mb() drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c: __iomb(); But yes, dma_rmb() and dma_wmb() do look to have a few hundred uses between them, and not just within ARMv8. I gave up too soon, so thank you! > Ignore the bits about mmiowb() as we got rid of that. Should the leftovers in current mainline be replaced by wmb()? Or are patches to that effect on their way in somewhere? $ git grep 'mmiowb()' arch/ia64/include/asm/mmiowb.h:#define mmiowb() ia64_mfa() arch/ia64/include/asm/spinlock.h: mmiowb(); arch/mips/include/asm/mmiowb.h:#define mmiowb() iobarrier_w() arch/mips/include/asm/spinlock.h: mmiowb(); arch/mips/kernel/gpio_txx9.c: mmiowb(); arch/mips/kernel/gpio_txx9.c: mmiowb(); arch/mips/kernel/gpio_txx9.c: mmiowb(); arch/mips/kernel/irq_txx9.c: mmiowb(); arch/mips/loongson2ef/common/bonito-irq.c: mmiowb(); arch/mips/loongson2ef/common/bonito-irq.c: mmiowb(); arch/mips/loongson2ef/common/mem.c: mmiowb(); arch/mips/loongson2ef/common/pm.c: mmiowb(); arch/mips/loongson2ef/lemote-2f/reset.c: mmiowb(); arch/mips/loongson2ef/lemote-2f/reset.c: mmiowb(); arch/mips/loongson2ef/lemote-2f/reset.c: mmiowb(); arch/mips/loongson2ef/lemote-2f/reset.c: mmiowb(); arch/mips/loongson2ef/lemote-2f/reset.c: mmiowb(); arch/mips/pci/ops-bonito64.c: mmiowb(); arch/mips/pci/ops-loongson2.c: mmiowb(); arch/mips/txx9/generic/irq_tx4939.c: mmiowb(); arch/mips/txx9/generic/setup.c: mmiowb(); arch/mips/txx9/rbtx4927/irq.c: mmiowb(); arch/mips/txx9/rbtx4938/irq.c: mmiowb(); arch/mips/txx9/rbtx4938/irq.c: mmiowb(); arch/mips/txx9/rbtx4938/setup.c: mmiowb(); arch/mips/txx9/rbtx4939/irq.c: mmiowb(); arch/powerpc/include/asm/mmiowb.h:#define mmiowb() mb() arch/riscv/include/asm/mmiowb.h:#define mmiowb() __asm__ __volatile__ ("fence o,w" : : : "memory"); arch/s390/include/asm/io.h:#define mmiowb() zpci_barrier() arch/sh/include/asm/mmiowb.h:#define mmiowb() wmb() arch/sh/include/asm/spinlock-llsc.h: mmiowb(); include/asm-generic/mmiowb.h: * Generic implementation of mmiowb() tracking for spinlocks. include/asm-generic/mmiowb.h: * 1. Implement mmiowb() (and arch_mmiowb_state() if you're fancy) include/asm-generic/mmiowb.h: mmiowb(); Thanx, Paul