From owner-freebsd-arm@freebsd.org Thu Oct 8 17:38:29 2020 Return-Path: Delivered-To: freebsd-arm@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id 8AFFE42CCCA for ; Thu, 8 Oct 2020 17:38:29 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [IPv6:2610:1c1:1:606c::24b:4]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "smtp.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4C6dj12pt1z4H3c for ; Thu, 8 Oct 2020 17:38:29 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: from mail-qv1-f46.google.com (mail-qv1-f46.google.com [209.85.219.46]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (Client CN "smtp.gmail.com", Issuer "GTS CA 1O1" (verified OK)) (Authenticated sender: kevans) by smtp.freebsd.org (Postfix) with ESMTPSA id 3FB8D222D2 for ; Thu, 8 Oct 2020 17:38:29 +0000 (UTC) (envelope-from kevans@freebsd.org) Received: by mail-qv1-f46.google.com with SMTP id j3so3461455qvi.7 for ; Thu, 08 Oct 2020 10:38:29 -0700 (PDT) X-Gm-Message-State: AOAM5301Du2t6k0a88F2ZjHXVHlAtvxl6t02vNgmgPtlY7hvzAE+qcd2 vAf92kSdcNvSqt+81JtB3rshkyxSDfeYfOwAexE= X-Received: by 2002:ad4:41c4:: with SMTP id a4mt9080744qvq.60.1602178708787; Thu, 08 Oct 2020 10:38:28 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Kyle Evans Date: Thu, 8 Oct 2020 12:38:15 -0500 X-Gmail-Original-Message-ID: Message-ID: Subject: Re: RPi4B: emmc2bus dma-range handling does not track the boot-time-FDT (u-boot based booting) Cc: Mark Millard , freebsd-arm Content-Type: text/plain; charset="UTF-8" X-BeenThere: freebsd-arm@freebsd.org X-Mailman-Version: 2.1.33 Precedence: list List-Id: "Porting FreeBSD to ARM processors." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 08 Oct 2020 17:38:29 -0000 On Thu, Oct 8, 2020 at 11:33 AM Kyle Evans wrote: > > On Thu, Oct 8, 2020 at 4:01 AM Mark Millard via freebsd-arm > wrote: > > > > sys/gnu/dts/arm/bcm2711.dtsi reports: > > > > /* > > * emmc2 has different DMA constraints based on SoC revisions. It was > > * moved into its own bus, so as for RPi4's firmware to update them. > > * The firmware will find whether the emmc2bus alias is defined, and if > > * so, it'll edit the dma-ranges property below accordingly. > > */ > > [... snip ...] > > I have no words for how annoying this is. > For a slightly more helpful response: We can fix this, and it ends up being much cleaner than my current hack. Basically, in bcm2835_vcbus.c, we should eradicate the busdma_lowaddr from bcm283x_memory_soc_cfg. bcm283x_dmabus_peripheral_lowaddr should instead take a device_t and grab the bus's dma-ranges. It /looks/ to be valid on all the DTS I see for the RPi boards we support, so we can just unconditionally use that and things will just work for the newer RPi4 models. >From my discussion (with an assist Ian on address interpretation) on IRC, so I don't forget: dma-ranges is three-value: We'll see 4 and 5 value variants of this because 64-bit addresses are described with pairs of 32-bit values. 4-value variant: dma_addr will be 32-bit, cpu_addr will be 64-bit 5-value variant: both are 64-bit Note that bcm283x_dmabus_peripheral_lowaddr() will be returning cpu_addr + (max_len - 1) This won't match perfectly with what we currently return, but it will be more accurate. Thanks, Kyle Evans