Message ID | 20221022234024.87475-1-mw@semihalf.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:4242:0:0:0:0:0 with SMTP id s2csp1398063wrr; Sat, 22 Oct 2022 17:03:10 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5dWw7eezIB9hf36WWw/s/Pt9la3UR09x+okuk8wNGMzgrDSfUxa2Ltc8MiKz3/cIv68q5Z X-Received: by 2002:a17:907:2bd5:b0:76f:591c:466b with SMTP id gv21-20020a1709072bd500b0076f591c466bmr20599674ejc.504.1666483390544; Sat, 22 Oct 2022 17:03:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1666483390; cv=none; d=google.com; s=arc-20160816; b=DRiRm8Q1MaqqKSCQpnJzB8X23yJdNqJv8FOL4EW0+N6C/vEF0vdLqAGeU0ylvLjm2b s82QybKUYNBp78SGSoRofbTpaLDL01ckMsTa1aSGLx0LPewqAfCn6nrVjnqVaFU52VkD lzzEgdYkUMyMkrRT3ufGsmh/OT6359YHsYAdV68wJjzkPJkTKkKBbdjTmjNdaljBNLi6 YFjllceDPJ49+7GHoCsuqddouSQd5rrlibii1eAUY98veDlUKDzhcbsigiHewHcG1kFB Iy+zH91bFXH++GCKifChJbWjsO4bVOHyULfZyNvhJ9skhLOtc+5zrZOMMVkGV9XkoOTo oudQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=C6At1H3szjViJnkV3q1VRKzRG4v2Bj/cByCEwQ1bgyM=; b=To8xYxF+qgIOtg0qyN/f8OYb150rSrJ3ZRihT5MBi8ER39aUfb4hJpYazJokRbVhuA dCQ7Ev+CWFnAY38SWgonja+fyO/jOqxyA27ZeoJ/QN3jMpU/SkgPasdHVvdqnwvX0uPr Nu1CU+vtVfIt3rNBlMCz2r7jslUHxW2iSHWkSx+z+9CYrNb7ji1EWHiJ08Lkhipxr8aA KQTbFlyVrWMCOAx64SpGGfqxguGPUML/6GzVPBm16QNzz8ZOQmmB6j8p5CMlpWG+x+me ZP9D7R0UCbRRCK3b2i3sYhrk+zBzXVIYoo9DQQ6Fo5LEFPg7r1MuiQZDv+JmYTlFl1Z2 7qEQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=VQ7mbzj5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id g16-20020a1709065d1000b007a6384d506csi7862ejt.643.2022.10.22.17.02.26; Sat, 22 Oct 2022 17:03:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@semihalf.com header.s=google header.b=VQ7mbzj5; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=semihalf.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229799AbiJVXkh (ORCPT <rfc822;pwkd43@gmail.com> + 99 others); Sat, 22 Oct 2022 19:40:37 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:51754 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229519AbiJVXkf (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Sat, 22 Oct 2022 19:40:35 -0400 Received: from mail-lj1-x22c.google.com (mail-lj1-x22c.google.com [IPv6:2a00:1450:4864:20::22c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8D2A4785A1 for <linux-kernel@vger.kernel.org>; Sat, 22 Oct 2022 16:40:33 -0700 (PDT) Received: by mail-lj1-x22c.google.com with SMTP id by36so8439306ljb.4 for <linux-kernel@vger.kernel.org>; Sat, 22 Oct 2022 16:40:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=semihalf.com; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=C6At1H3szjViJnkV3q1VRKzRG4v2Bj/cByCEwQ1bgyM=; b=VQ7mbzj5hN8t52IfZwXU2t2B95RRp7vmkiDpjZTVDaEI1x0VBP/iysdDlLGUa6wPji U26MuG7nEDCxDQwr4XjJqN2lglZacSeRqq0UYk1GLdQiE8y1BqYHPFtR5DstYTRl6Zjh +thhymXHeveBJ8g4OBx7law2Q8osxes7zx8rA+3QoT4iY/4Ux44zYQgZTL7W443zyKjc LLxHO2qd4Zw84SYawq25Tc0tkXK+FwPfaqh36GjAT0tuNpnq9aK3APIr7L0fojratQIo iMpsILAzdk6v4zHxdclu/LFOTEJDXWydP7zQ7IsyTdt9g2m6OxUSFM8qh4pzevB2ThQV 82iQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=C6At1H3szjViJnkV3q1VRKzRG4v2Bj/cByCEwQ1bgyM=; b=w346s00S02L+24t/bWj1FMjJJNfskDL8hMZSwdx4iP4wRYZdnBQFv6uWQ5EJgK1UZ+ I4fBu0VLZVajpG3cD+ssjo+Fi/Qmm2jSV7ezpEoPBDiRsA8nLfD6nRIQDEReEPlrVyrX HaXhbayMGi3tkS+H8WuPPbMgInd1wqx6iT7UAQ2C1Y0x8iwRr+VMMG500YugxpeflC/o uDcnsBLhERv3BqIO7FA5vETdhllRszEX7UUpOKQTshUsL0xHqJLhmP6d9WsDawrN1zeB 3UDwztmMPyFHS2Pi4/278wZuVrA9lzby3t1WwpIgarURxtTnR7ooK2mdtAoACElpx+3X Uc/g== X-Gm-Message-State: ACrzQf2mDvMEVXjo9ZwVKQ9bdOCAtcAOsO6vyw0xJ/RHSQxOjmhww9JN o9PP9dVRTo1FEl+VPO8Mt3r3Nw== X-Received: by 2002:a2e:97d7:0:b0:277:4c7:c938 with SMTP id m23-20020a2e97d7000000b0027704c7c938mr571272ljj.294.1666482031813; Sat, 22 Oct 2022 16:40:31 -0700 (PDT) Received: from gilgamesh.lab.semihalf.net ([83.142.187.85]) by smtp.gmail.com with ESMTPSA id e10-20020a05651236ca00b004949f7cbb6esm3752602lfs.79.2022.10.22.16.40.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 22 Oct 2022 16:40:31 -0700 (PDT) From: Marcin Wojtas <mw@semihalf.com> To: linux-arm-kernel@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: andrew@lunn.ch, gregory.clement@bootlin.com, sebastian.hesselbarth@gmail.com, robh+dt@kernel.org, krzysztof.kozlowski+dt@linaro.org, hch@lst.de, kabel@kernel.org, jaz@semihalf.com, Marcin Wojtas <mw@semihalf.com> Subject: [PATCH] ARM: dts: armada-38x: Mark devices as dma-coherent Date: Sun, 23 Oct 2022 01:40:24 +0200 Message-Id: <20221022234024.87475-1-mw@semihalf.com> X-Mailer: git-send-email 2.29.0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1747434487737706417?= X-GMAIL-MSGID: =?utf-8?q?1747434487737706417?= |
Series |
ARM: dts: armada-38x: Mark devices as dma-coherent
|
|
Commit Message
Marcin Wojtas
Oct. 22, 2022, 11:40 p.m. UTC
Armada 38x platforms marks all devices as coherent via
mvebu_hwcc_notifier(), whereas the standard way to determine
this is by of_dma_is_coherent(). Reflect the hardware
capabilities by adding 'dma-coherent' properties to the device tree.
Signed-off-by: Marcin Wojtas <mw@semihalf.com>
---
arch/arm/boot/dts/armada-380.dtsi | 1 +
arch/arm/boot/dts/armada-385.dtsi | 1 +
arch/arm/boot/dts/armada-38x.dtsi | 1 +
3 files changed, 3 insertions(+)
Comments
On Sun, Oct 23, 2022 at 01:40:24AM +0200, Marcin Wojtas wrote: > Armada 38x platforms marks all devices as coherent via > mvebu_hwcc_notifier(), whereas the standard way to determine > this is by of_dma_is_coherent(). Reflect the hardware > capabilities by adding 'dma-coherent' properties to the device tree. Hi Marcin Does this need to go to -rc for 6.0? The DMA issues being reported? If so, please add a Fixed: tag. Andrew
On Sun, Oct 23, 2022 at 05:04:01PM +0200, Andrew Lunn wrote: > On Sun, Oct 23, 2022 at 01:40:24AM +0200, Marcin Wojtas wrote: > > Armada 38x platforms marks all devices as coherent via > > mvebu_hwcc_notifier(), whereas the standard way to determine > > this is by of_dma_is_coherent(). Reflect the hardware > > capabilities by adding 'dma-coherent' properties to the device tree. > > Hi Marcin > > Does this need to go to -rc for 6.0? The DMA issues being reported? > If so, please add a Fixed: tag. Are we absolutely sure this makes sense? Looking at atch/arm/mach-mvebu/coherency.c, there are dependencies on stuff such as whether the kernel is in SMP mode or not (because the page tables need to be appropriately marked as shared for coherency with IO to work). We only enable the shared bit if we're in SMP mode because (a) its difficult to do at runtime due to TLB conflicts (requires switching the MMU off, rewriting the page tables and switching the MMU back on), and (b) setting the shared bit for CPUs that don't need it _can_ result in the CPUs basically bypassing their caches and thus kill system performance. So, if we have Armada 38x platforms that are operated in uniprocessor mode, this patch can cause havoc on such a setup. I would suggest utmost caution with this approach.
niedz., 23 paź 2022 o 18:21 Russell King (Oracle) <linux@armlinux.org.uk> napisał(a): > > On Sun, Oct 23, 2022 at 05:04:01PM +0200, Andrew Lunn wrote: > > On Sun, Oct 23, 2022 at 01:40:24AM +0200, Marcin Wojtas wrote: > > > Armada 38x platforms marks all devices as coherent via > > > mvebu_hwcc_notifier(), whereas the standard way to determine > > > this is by of_dma_is_coherent(). Reflect the hardware > > > capabilities by adding 'dma-coherent' properties to the device tree. > > > > Hi Marcin > > > > Does this need to go to -rc for 6.0? The DMA issues being reported? > > If so, please add a Fixed: tag. > > Are we absolutely sure this makes sense? > > Looking at atch/arm/mach-mvebu/coherency.c, there are dependencies > on stuff such as whether the kernel is in SMP mode or not (because > the page tables need to be appropriately marked as shared for > coherency with IO to work). We only enable the shared bit if we're > in SMP mode because (a) its difficult to do at runtime due to TLB > conflicts (requires switching the MMU off, rewriting the page tables > and switching the MMU back on), and (b) setting the shared bit for > CPUs that don't need it _can_ result in the CPUs basically bypassing > their caches and thus kill system performance. > > So, if we have Armada 38x platforms that are operated in uniprocessor > mode, this patch can cause havoc on such a setup. > > I would suggest utmost caution with this approach. > Sure. In such a case the description of 380 variant (single core) should remain untouched. We need to decide what to do with dual-CPU, i.e. Armada 385/388. How about: - Don't change current behavior, i.e. perform a necessary kernel configuration in "arm,pl310-cache" driver, arch/arm/mach-mvebu/coherency.c + &coherencyfab:node in DT - Satisfy of_dma_is_coherent() by adding `dma-coherent;` in armada-385.dtsi only (IMO this would describe HW properly) ? Best regards, Marcin
On Sun, 23 Oct 2022 23:30:34 +0200 Marcin Wojtas <mw@semihalf.com> wrote: > niedz., 23 paź 2022 o 18:21 Russell King (Oracle) > <linux@armlinux.org.uk> napisał(a): > > > > On Sun, Oct 23, 2022 at 05:04:01PM +0200, Andrew Lunn wrote: > > > On Sun, Oct 23, 2022 at 01:40:24AM +0200, Marcin Wojtas wrote: > > > > Armada 38x platforms marks all devices as coherent via > > > > mvebu_hwcc_notifier(), whereas the standard way to determine > > > > this is by of_dma_is_coherent(). Reflect the hardware > > > > capabilities by adding 'dma-coherent' properties to the device tree. > > > > > > Hi Marcin > > > > > > Does this need to go to -rc for 6.0? The DMA issues being reported? > > > If so, please add a Fixed: tag. > > > > Are we absolutely sure this makes sense? > > > > Looking at atch/arm/mach-mvebu/coherency.c, there are dependencies > > on stuff such as whether the kernel is in SMP mode or not (because > > the page tables need to be appropriately marked as shared for > > coherency with IO to work). We only enable the shared bit if we're > > in SMP mode because (a) its difficult to do at runtime due to TLB > > conflicts (requires switching the MMU off, rewriting the page tables > > and switching the MMU back on), and (b) setting the shared bit for > > CPUs that don't need it _can_ result in the CPUs basically bypassing > > their caches and thus kill system performance. > > > > So, if we have Armada 38x platforms that are operated in uniprocessor > > mode, this patch can cause havoc on such a setup. > > > > I would suggest utmost caution with this approach. > > > > Sure. In such a case the description of 380 variant (single core) > should remain untouched. > > We need to decide what to do with dual-CPU, i.e. Armada 385/388. How about: > - Don't change current behavior, i.e. perform a necessary kernel > configuration in "arm,pl310-cache" driver, > arch/arm/mach-mvebu/coherency.c + &coherencyfab:node in DT > - Satisfy of_dma_is_coherent() by adding `dma-coherent;` in > armada-385.dtsi only (IMO this would describe HW properly) > ? It will describe HW properly, but someone running older kernel compiled with no SMP support will see a performance drop. I wonder how many people do that. Marek
On Mon, Oct 24, 2022 at 08:51:02AM +0200, Marek Behún wrote: > > Sure. In such a case the description of 380 variant (single core) > > should remain untouched. > > > > We need to decide what to do with dual-CPU, i.e. Armada 385/388. How about: > > - Don't change current behavior, i.e. perform a necessary kernel > > configuration in "arm,pl310-cache" driver, > > arch/arm/mach-mvebu/coherency.c + &coherencyfab:node in DT > > - Satisfy of_dma_is_coherent() by adding `dma-coherent;` in > > armada-385.dtsi only (IMO this would describe HW properly) > > ? > > It will describe HW properly, but someone running older kernel compiled > with no SMP support will see a performance drop. I wonder how many > people do that. If the kernel is built without SMP support, the page table entries will not have the shared bit set, and the system will _not_ be DMA-coherent. Having DT mark devices as "dma-coherent" in this case will lead to data corruption, because the DMA API will believe them to be DMA-coherent when the page tables are not setup for that to work.
pon., 24 paź 2022 o 09:51 Russell King (Oracle) <linux@armlinux.org.uk> napisał(a): > > On Mon, Oct 24, 2022 at 08:51:02AM +0200, Marek Behún wrote: > > > Sure. In such a case the description of 380 variant (single core) > > > should remain untouched. > > > > > > We need to decide what to do with dual-CPU, i.e. Armada 385/388. How about: > > > - Don't change current behavior, i.e. perform a necessary kernel > > > configuration in "arm,pl310-cache" driver, > > > arch/arm/mach-mvebu/coherency.c + &coherencyfab:node in DT > > > - Satisfy of_dma_is_coherent() by adding `dma-coherent;` in > > > armada-385.dtsi only (IMO this would describe HW properly) > > > ? > > > > It will describe HW properly, but someone running older kernel compiled > > with no SMP support will see a performance drop. I wonder how many > > people do that. > > If the kernel is built without SMP support, the page table entries will > not have the shared bit set, and the system will _not_ be DMA-coherent. > Having DT mark devices as "dma-coherent" in this case will lead to data > corruption, because the DMA API will believe them to be DMA-coherent > when the page tables are not setup for that to work. > Thanks, for the explanation. Since we're heavily dependent on what happens in the kernel we boot, it will be easier to just drop this patch and keep using the DT as-is. Best regards, Marcin
diff --git a/arch/arm/boot/dts/armada-380.dtsi b/arch/arm/boot/dts/armada-380.dtsi index ce1dddb2269b..25d17550e2fc 100644 --- a/arch/arm/boot/dts/armada-380.dtsi +++ b/arch/arm/boot/dts/armada-380.dtsi @@ -38,6 +38,7 @@ pcie { compatible = "marvell,armada-370-pcie"; status = "disabled"; device_type = "pci"; + dma-coherent; #address-cells = <3>; #size-cells = <2>; diff --git a/arch/arm/boot/dts/armada-385.dtsi b/arch/arm/boot/dts/armada-385.dtsi index 83392b92dae2..6fb8c254cbdc 100644 --- a/arch/arm/boot/dts/armada-385.dtsi +++ b/arch/arm/boot/dts/armada-385.dtsi @@ -37,6 +37,7 @@ pciec: pcie { compatible = "marvell,armada-370-pcie"; status = "disabled"; device_type = "pci"; + dma-coherent; #address-cells = <3>; #size-cells = <2>; diff --git a/arch/arm/boot/dts/armada-38x.dtsi b/arch/arm/boot/dts/armada-38x.dtsi index 446861b6b17b..5801873dfcbe 100644 --- a/arch/arm/boot/dts/armada-38x.dtsi +++ b/arch/arm/boot/dts/armada-38x.dtsi @@ -102,6 +102,7 @@ internal-regs { #address-cells = <1>; #size-cells = <1>; ranges = <0 MBUS_ID(0xf0, 0x01) 0 0x100000>; + dma-coherent; sdramc: sdramc@1400 { compatible = "marvell,armada-xp-sdram-controller";