Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4847847pxj; Tue, 25 May 2021 18:47:12 -0700 (PDT) X-Google-Smtp-Source: ABdhPJytEzN5gk/XdL/k6qlKBYtQssXWp4Q3Ozpgt4y6d7o5gLenSuHy9x3ESXEtROYCjjXinqXW X-Received: by 2002:a05:6e02:d:: with SMTP id h13mr22531333ilr.112.1621993632283; Tue, 25 May 2021 18:47:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621993632; cv=none; d=google.com; s=arc-20160816; b=Gk373aaWHdR7YatBKxmQGNh1acoyUQpuDBahtLQcyAjI4NiwivWsEpNsjxMQSA/V6Q VBycEpQlS7Qm+tF/2z6yK1O8LtTRiqh8TjNlhEFB5xe6dcs/y2L6I2pvuK1kk+k5rH5M T6niO9Cvdlo5RRWqRYZ6C0RnrBNsHPOak0dSJsxoTdU2W+94J31ZcdAiwzw/NR41/g56 dNooQUVtQQc/w4kCjZFooVYhIMlJmm0NHefwIFwEvCWp8EkowWjEaMAKy08ksTdHrkAi EtKOX9Yp9UbJiUGkBJfeVoowEd1/dxPKdiYZwzArvtSKaF/FTkdCCvZsfQkRQlmoYurF G1Ig== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:message-id:in-reply-to :date:references:subject:cc:to:from:dkim-signature; bh=wn3EG8k3M8Vjrn0xAqTbjN7lE2HqWDMtOWHhAlz2oY0=; b=g7rfelohz2yDBLPXjA1IL0AoTCrDSFzVNhGQ/wD90TUQiGAgZxZ7RaPbR7dvIX/wWS Y0xBJdUO/XZYquwE1gr8ZRtc7STWkIDmuxnePt/XG3VpLW4abD+PSmDyojTFtoyOQ1Pz Xs3QpcAqO9QedJPI8ioJ5abnMhOS89gKGoWlemFHs/L8o5afUMPdKCysdAdo6PCw97yN QSSTeyQbkqCS6knKK5xuzKTIdiDyZV+6rczjpANml/DIiN4YfalBPBNrbJox3msbrQnP 0sMe3IZVMxcxazM/eSTCHlKAjpnRBR+fT7EUue+uMMaMij3MdQsKGQ6HFDSaS3y1j0pg 54xQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=YUOtOr1A; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id h6si19442327ili.157.2021.05.25.18.46.57; Tue, 25 May 2021 18:47:12 -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=@gmail.com header.s=20161025 header.b=YUOtOr1A; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231364AbhEYWh6 (ORCPT + 99 others); Tue, 25 May 2021 18:37:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:44666 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230075AbhEYWh5 (ORCPT ); Tue, 25 May 2021 18:37:57 -0400 Received: from mail-pg1-x530.google.com (mail-pg1-x530.google.com [IPv6:2607:f8b0:4864:20::530]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9923BC061574; Tue, 25 May 2021 15:36:25 -0700 (PDT) Received: by mail-pg1-x530.google.com with SMTP id 29so12814925pgu.11; Tue, 25 May 2021 15:36:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:references:date:in-reply-to:message-id :user-agent:mime-version; bh=wn3EG8k3M8Vjrn0xAqTbjN7lE2HqWDMtOWHhAlz2oY0=; b=YUOtOr1AVPer3RmRfek2VbOYVLoUuADSgpiS6RErYIwnz5sVKtwCflo6KEXtRSUEes obeWF2Rq6vwPsTXrlQYdl+MKtwmhAXQYukJrtn4q+pXNJNoQWVFbs+W4Wasvvus2hky5 yCZtIxsv6D2xJhTvoX7A4beRiJaYjppiWk0WMQ67un7TyOe8mNelkSi8Wb9poYAEKqeh ejyyGZUJxVPcbNPSQALlx8LXEGQeY5YVNDXubq2ZKSdYThHUMY3VJBz4gSfAYEo0bHFs YzhSL4xNlpZPL2nLyBhzBJ7hccukBgi0xgygdtylVKLZkC2AHm5TmMbFNaLWUDcCPU01 K5kw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:references:date:in-reply-to :message-id:user-agent:mime-version; bh=wn3EG8k3M8Vjrn0xAqTbjN7lE2HqWDMtOWHhAlz2oY0=; b=lM8PFSZ/Or3pBBnJ8ej/E234czJ1PR5WvSDgh7Qx+ajbqUOvv9RkAvEccJdZRcuZSF B3hl2WkGGuYiby8YgAvTno0Z6tUMWu20HxzQ0UniemMB160UpL72lKgLZjIlzWnd8rM3 rUgnMq+dElGi6fjvcHxzUKxd0piBuVltJynSaPk7LFkgK7o62f9xEGqMpoz1khJDh0tu ER4ie7s3H5BLXGDN3D7lFde6wiOaLokr/qofHD8MU0HRdbHOWATqJAAQeEyTFtV94Jzi 0AKnGfQzbIt1YfwnGnrjQyCIZp7Fk3fPGXzv9T6brF8i1lQ1URVYpIbPicuznmozZ8pL VIxA== X-Gm-Message-State: AOAM531Jy5eGecK+hKnbhBPkLXcgxtGNIuH0OchQG5Z4v4hOweb1OFkF gDzpF116DGCFxURz5G7AhzE= X-Received: by 2002:a63:aa48:: with SMTP id x8mr21127327pgo.359.1621982184997; Tue, 25 May 2021 15:36:24 -0700 (PDT) Received: from localhost (122x211x248x161.ap122.ftth.ucom.ne.jp. [122.211.248.161]) by smtp.gmail.com with ESMTPSA id o186sm14260694pfg.170.2021.05.25.15.36.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 25 May 2021 15:36:24 -0700 (PDT) From: Punit Agrawal To: Ard Biesheuvel Cc: Robin Murphy , Alexandru Elisei , Linux Kernel Mailing List , linux-rockchip@lists.infradead.org, arm-mail-list , Heiko Stuebner , leobras.c@gmail.com, Rob Herring , PCI Subject: Re: [BUG] rockpro64: PCI BAR reassignment broken by commit 9d57e61bf723 ("of/pci: Add IORESOURCE_MEM_64 to resource flags for 64-bit memory addresses") References: <7a1e2ebc-f7d8-8431-d844-41a9c36a8911@arm.com> <01efd004-1c50-25ca-05e4-7e4ef96232e2@arm.com> <87eedxbtkn.fsf@stealth> <877djnaq11.fsf@stealth> Date: Wed, 26 May 2021 07:36:21 +0900 In-Reply-To: (Ard Biesheuvel's message of "Tue, 25 May 2021 15:54:30 +0200") Message-ID: <871r9ubfve.fsf@stealth> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/27.1 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Ard Biesheuvel writes: > On Tue, 25 May 2021 at 15:42, Punit Agrawal wrote: >> >> Hi Ard, >> >> Ard Biesheuvel writes: >> >> > On Sun, 23 May 2021 at 13:06, Punit Agrawal wrote: >> >> >> >> Robin Murphy writes: >> >> >> >> > [ +linux-pci for visibility ] >> >> > >> >> > On 2021-05-18 10:09, Alexandru Elisei wrote: >> >> >> After doing a git bisect I was able to trace the following error when booting my >> >> >> rockpro64 v2 (rk3399 SoC) with a PCIE NVME expansion card: >> >> >> [..] >> >> >> [ 0.305183] rockchip-pcie f8000000.pcie: host bridge /pcie@f8000000 ranges: >> >> >> [ 0.305248] rockchip-pcie f8000000.pcie: MEM 0x00fa000000..0x00fbdfffff -> >> >> >> 0x00fa000000 >> >> >> [ 0.305285] rockchip-pcie f8000000.pcie: IO 0x00fbe00000..0x00fbefffff -> >> >> >> 0x00fbe00000 >> >> >> [ 0.306201] rockchip-pcie f8000000.pcie: supply vpcie1v8 not found, using dummy >> >> >> regulator >> >> >> [ 0.306334] rockchip-pcie f8000000.pcie: supply vpcie0v9 not found, using dummy >> >> >> regulator >> >> >> [ 0.373705] rockchip-pcie f8000000.pcie: PCI host bridge to bus 0000:00 >> >> >> [ 0.373730] pci_bus 0000:00: root bus resource [bus 00-1f] >> >> >> [ 0.373751] pci_bus 0000:00: root bus resource [mem 0xfa000000-0xfbdfffff 64bit] >> >> >> [ 0.373777] pci_bus 0000:00: root bus resource [io 0x0000-0xfffff] (bus >> >> >> address [0xfbe00000-0xfbefffff]) >> >> >> [ 0.373839] pci 0000:00:00.0: [1d87:0100] type 01 class 0x060400 >> >> >> [ 0.373973] pci 0000:00:00.0: supports D1 >> >> >> [ 0.373992] pci 0000:00:00.0: PME# supported from D0 D1 D3hot >> >> >> [ 0.378518] pci 0000:00:00.0: bridge configuration invalid ([bus 00-00]), >> >> >> reconfiguring >> >> >> [ 0.378765] pci 0000:01:00.0: [144d:a808] type 00 class 0x010802 >> >> >> [ 0.378869] pci 0000:01:00.0: reg 0x10: [mem 0x00000000-0x00003fff 64bit] >> >> >> [ 0.379051] pci 0000:01:00.0: Max Payload Size set to 256 (was 128, max 256) >> >> >> [ 0.379661] pci 0000:01:00.0: 8.000 Gb/s available PCIe bandwidth, limited by >> >> >> 2.5 GT/s PCIe x4 link at 0000:00:00.0 (capable of 31.504 Gb/s with 8.0 GT/s PCIe >> >> >> x4 link) >> >> >> [ 0.393269] pci_bus 0000:01: busn_res: [bus 01-1f] end is updated to 01 >> >> >> [ 0.393311] pci 0000:00:00.0: BAR 14: no space for [mem size 0x00100000] >> >> >> [ 0.393333] pci 0000:00:00.0: BAR 14: failed to assign [mem size 0x00100000] >> >> >> [ 0.393356] pci 0000:01:00.0: BAR 0: no space for [mem size 0x00004000 64bit] >> >> >> [ 0.393375] pci 0000:01:00.0: BAR 0: failed to assign [mem size 0x00004000 64bit] >> >> >> [ 0.393397] pci 0000:00:00.0: PCI bridge to [bus 01] >> >> >> [ 0.393839] pcieport 0000:00:00.0: PME: Signaling with IRQ 78 >> >> >> [ 0.394165] pcieport 0000:00:00.0: AER: enabled with IRQ 78 >> >> >> [..] >> >> >> to the commit 9d57e61bf723 ("of/pci: Add IORESOURCE_MEM_64 to >> >> >> resource flags for >> >> >> 64-bit memory addresses"). >> >> > >> >> > FWFW, my hunch is that the host bridge advertising no 32-bit memory >> >> > resource, only only a single 64-bit non-prefetchable one (even though >> >> > it's entirely below 4GB) might be a bit weird and tripping something >> >> > up in the resource assignment code. It certainly seems like the thing >> >> > most directly related to the offending commit. >> >> > >> >> > I'd be tempted to try fiddling with that in the DT (i.e. changing >> >> > 0x83000000 to 0x82000000 in the PCIe node's "ranges" property) to see >> >> > if it makes any difference. Note that even if it helps, though, I >> >> > don't know whether that's the correct fix or just a bodge around a >> >> > corner-case bug somewhere in the resource code. >> >> >> >> From digging into this further the failure seems to be due to a mismatch >> >> of flags when allocating resources in pci_bus_alloc_from_region() - >> >> >> >> if ((res->flags ^ r->flags) & type_mask) >> >> continue; >> >> >> >> Though I am also not sure why the failure is only being reported on >> >> RK3399 - does a single 64-bit window have anything to do with it? >> >> >> > >> > The NVMe in the example exposes a single 64-bit non-prefetchable BAR. >> > Such BARs can not be allocated in a prefetchable host bridge window >> > (unlike the converse, i.e., allocating a prefetchable BAR in a >> > non-prefetchable host bridge window is fine) >> > >> > 64-bit non-prefetchable host bridge windows cannot be forwarded by PCI >> > to PCI bridges, they simply lack the BAR registers to describe them. >> > Therefore, non-prefetchable endpoint BARs (even 64-bit ones) need to >> > be carved out of a host bridge's non-prefetchable 32-bit window if >> > they need to pass through a bridge. >> >> Thank you for the explanation. I also looked at the PCI-to-PCI Bridge >> spec to understand where some of the limitations are coming from. >> >> > So the error seems to be here that the host bridge's 32-bit >> > non-prefetchable window has the 64-bit attribute set, even though it >> > resides below 4 GB entirely. I suppose that the resource allocation >> > could be made more forgiving (and it was in the past, before commit >> > 9d57e61bf723 was applied). However, I would strongly recommend not >> > deviating from common practice, and just describe the 32-bit >> > addressable non-prefetchable resource window as such. >> >> IIUC, the host bridge's configuration (64-bit on non-prefetchable >> window) is based on what the hardware advertises. >> > > What do you mean by 'what the hardware advertises'? The host bridge is > apparently configured to decode a 32-bit addressable window as MMIO, > and the question is why this window has the 64-bit attribute set in > the DT description. Right - I completely missed the fact that the ranges property is also encoding the window attributes. Thanks for setting me straight. git archaeology doesn't provide any explanation - I am wondering if it is just an oversight. >> Can you elaborate on what you have in mind to correct the >> non-prefetchable resource window? Are you thinking of adding a quirk >> somewhere to address this? >> > > No. Just fix the DT. After updating the DT to mark the non-prefetchable window as 32-bit things work as expected. Let me send a patch to update the DT - I'll include previous authors who've touched that DT fragment. Hopefully somebody will jump in to explain the reason it was done that way. Thanks, Punit [...]