From: Niklas Cassel <cassel@kernel.org>
To: Kunihiko Hayashi <hayashi.kunihiko@socionext.com>
Cc: "Manivannan Sadhasivam" <manivannan.sadhasivam@linaro.org>,
"Krzysztof Wilczyński" <kw@linux.com>,
"Kishon Vijay Abraham I" <kishon@kernel.org>,
"Arnd Bergmann" <arnd@arndb.de>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Lorenzo Pieralisi" <lpieralisi@kernel.org>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH 2/2] misc: pci_endpoint_test: Set reserved BARs for each SoCs
Date: Thu, 19 Dec 2024 14:08:01 +0100 [thread overview]
Message-ID: <Z2QasXs0c9jQY8RL@x1-carbon> (raw)
In-Reply-To: <56f1a6cf-40ad-4452-bce1-274eb3d124a9@socionext.com>
On Thu, Dec 19, 2024 at 08:17:50PM +0900, Kunihiko Hayashi wrote:
> On 2024/12/17 17:19, Niklas Cassel wrote:
>
> > If you simply add code that disables all BARs by default in am654, you
> > should be able to remove these ugly is_am654_pci_dev() checks in the host
> > driver, and the host driver should not be able to write to these reserved
> > BARs, as they will never get enabled by pci-epf-test.c.
>
> However, dw_pcie_ep_reset_bar() only clears BAR registers to 0x0. BAR
> doesn't have any "disabled" field, so I think that it means "32-bit, memory,
> non-prefetchable".
From the DWC databook, 4.60a, section "6.1.2 BAR Details",
heading "Disabling a BAR".
"To disable a BAR (in any of the three schemes), your application can
write ‘0’ to the LSB of the BAR mask register."
dw_pcie_ep_reset_bar() calls __dw_pcie_ep_reset_bar(), which will
write a zero to the LSB of the BAR mask register:
https://github.com/torvalds/linux/blob/v6.13-rc3/drivers/pci/controller/dwc/pcie-designware-ep.c#L50
>
>
> https://github.com/torvalds/linux/blob/v6.13-rc3/drivers/pci/controller/dwc/pcie-designware-ep.c#L47-L52
>
> And even if each endpoint driver marks "BAR_RESERVED" to the features, it is
> only referred to as excluded BARs when searching for free BARs. So the host
> will recognize this "reserved" BAR.
A BAR that has been disabled on the EP side, will not have a size/
be visible on host side.
Like I said, rk3588 calls dw_pcie_ep_reset_bar() on all BARs in EP init,
like most DWC based EPC drivers, and marks BAR4 as reserved.
This is how it looks on the host side during enumeration:
[ 25.496645] pci 0000:01:00.0: [1d87:3588] type 00 class 0xff0000 PCIe Endpoint
[ 25.497322] pci 0000:01:00.0: BAR 0 [mem 0x00000000-0x000fffff]
[ 25.497863] pci 0000:01:00.0: BAR 1 [mem 0x00000000-0x000fffff]
[ 25.498400] pci 0000:01:00.0: BAR 2 [mem 0x00000000-0x000fffff]
[ 25.498937] pci 0000:01:00.0: BAR 3 [mem 0x00000000-0x000fffff]
[ 25.499498] pci 0000:01:00.0: BAR 5 [mem 0x00000000-0x000fffff]
[ 25.500036] pci 0000:01:00.0: ROM [mem 0x00000000-0x0000ffff pref]
[ 25.500861] pci 0000:01:00.0: supports D1 D2
[ 25.501240] pci 0000:01:00.0: PME# supported from D0 D1 D3hot
Likewise the looping in pci_endpoint_test.c will skip disabled BARs, e.g.:
https://github.com/torvalds/linux/blob/v6.13-rc3/drivers/misc/pci_endpoint_test.c#L940-L943
Since test->bar[bar] will be NULL for BARs that are disabled.
Kind regards,
Niklas
next prev parent reply other threads:[~2024-12-19 13:08 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-12-16 7:39 [PATCH 1/2] misc: pci_endpoint_test: Fix irq_type to convey the correct type Kunihiko Hayashi
2024-12-16 7:39 ` [PATCH 2/2] misc: pci_endpoint_test: Set reserved BARs for each SoCs Kunihiko Hayashi
2024-12-17 8:19 ` Niklas Cassel
2024-12-19 11:17 ` Kunihiko Hayashi
2024-12-19 13:08 ` Niklas Cassel [this message]
2024-12-23 11:51 ` Kunihiko Hayashi
2024-12-23 12:05 ` Niklas Cassel
2024-12-24 11:39 ` Kunihiko Hayashi
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=Z2QasXs0c9jQY8RL@x1-carbon \
--to=cassel@kernel.org \
--cc=arnd@arndb.de \
--cc=gregkh@linuxfoundation.org \
--cc=hayashi.kunihiko@socionext.com \
--cc=kishon@kernel.org \
--cc=kw@linux.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=lpieralisi@kernel.org \
--cc=manivannan.sadhasivam@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.