cmd: pci: Add command to set MPS of all PCIe devices
PATCH v2 3/3 test: Add test for new command pci_mps
In reply to [email protected]From: Stephen Carlson <[email protected]>
Adds a test for the new pci_mps command to ensure that it can set the Maximum Payload Size (MPS) of all devices to 256 bytes in the sandbox environment. Enables the pci_mps command in the sandbox environment so that this test can be run.
--- MAINTAINERS | 6 ++++++ configs/sandbox_defconfig | 1 + include/test/suites.h | 2 ++ test/cmd/Makefile | 3 +++ test/cmd/pci_mps.c | 42 +++++++++++++++++++++++++++++++++++++++ test/cmd_ut.c | 6 ++++++ 6 files changed, 60 insertions(+) create mode 100644 test/cmd/pci_mps.c
MAINTAINERS +6 -0
@@ -1242,6 +1242,12 @@ M: Heiko Schocher <[email protected]> S: Maintained F: drivers/pci/pci_mpc85xx.c +PCI MPS +M: Stephen Carlson <[email protected]> +S: Maintained +F: cmd/pci_mps.c +F: test/cmd/pci_mps.c + POWER M: Jaehoon Chung <[email protected]> S: Maintained
configs/sandbox_defconfig +1 -0
@@ -77,6 +77,7 @@ CONFIG_CMD_MMC=y CONFIG_CMD_MUX=y CONFIG_CMD_OSD=y CONFIG_CMD_PCI=y +CONFIG_CMD_PCI_MPS=y CONFIG_CMD_READ=y CONFIG_CMD_REMOTEPROC=y CONFIG_CMD_SPI=y
include/test/suites.h +2 -0
@@ -48,6 +48,8 @@ int do_ut_mem(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[]);int do_ut_optee (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);int do_ut_overlay (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]); +int do_ut_pci_mps (struct cmd_tbl *cmdtp,int flag,int argc, +char *const argv[]);int do_ut_print (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);int do_ut_setexpr (struct cmd_tbl *cmdtp,int flag,int argc,char *const argv[]);
test/cmd/Makefile +3 -0
@@ -14,6 +14,9 @@ obj-$(CONFIG_CMD_FDT) += fdt.o obj-$(CONFIG_CONSOLE_TRUETYPE) += font.o obj-$(CONFIG_CMD_LOADM) += loadm.o obj-$(CONFIG_CMD_MEM_SEARCH) += mem_search.o +ifdef CONFIG_CMD_PCI +obj-$(CONFIG_CMD_PCI_MPS) += pci_mps.o +endif obj-$(CONFIG_CMD_PINMUX) += pinmux.o obj-$(CONFIG_CMD_PWM) += pwm.o ifdef CONFIG_SANDBOX
test/cmd/pci_mps.c new file +42 -0
42 lines not on this page · raw message
test/cmd_ut.c +6 -0
@@ -110,6 +110,9 @@ static struct cmd_tbl cmd_ut_sub[] = {#ifdef CONFIG_CMD_LOADM U_BOOT_CMD_MKENT(loadm, CONFIG_SYS_MAXARGS, 1, do_ut_loadm, "", ""),#endif +#ifdef CONFIG_CMD_PCI_MPS + U_BOOT_CMD_MKENT(pci_mps, CONFIG_SYS_MAXARGS, 1, do_ut_pci_mps, "", ""), +#endif }; static int do_ut_all(struct cmd_tbl *cmdtp, int flag, int argc,
@@ -206,6 +209,9 @@ static char ut_help_text[] =#endif #ifdef CONFIG_UT_OVERLAY "\noverlay - device tree overlays" +#endif +#ifdef CONFIG_CMD_PCI_MPS + "\npci_mps - PCI Express Maximum Payload Size"#endif "\nprint - printing things to the console" "\nsetexpr - setexpr command"
Signature · 1 line
2.25.1
PATCH v2 1/3 cmd: pci: Add command to set MPS of all PCIe devices
From: Stephen Carlson <[email protected]>
Enable tuning of the PCI Express MPS (Maximum Payload Size) of each device. The Maximum Read Request Size is not altered.
The SAFE method uses the largest MPS value supported by all devices in the system for each device. This method is the same algorithm as used by Linux pci=pcie_bus_safe.
The PEER2PEER method sets all devices to the minimal (128 byte) MPS, which allows hot plug of devices later that might only support the minimum size, and ensures compatibility of DMA between two devices on the bus.
--- cmd/Kconfig | 10 +++ cmd/Makefile | 1 + cmd/pci_mps.c | 164 ++++++++++++++++++++++++++++++++++++++++++++++++++ include/pci.h | 7 +++ 4 files changed, 182 insertions(+) create mode 100644 cmd/pci_mps.c
cmd/Kconfig +10 -0
@@ -1390,6 +1390,16 @@ config CMD_PCI peripherals. Sub-commands allow bus enumeration, displaying and changing configuration space and a few other features. +config CMD_PCI_MPS + bool "pci_mps - Configure PCI device MPS" + depends on PCI + help + Enables PCI Express Maximum Packet Size (MPS) tuning. This + command configures the PCI Express MPS of each endpoint to the + largest value supported by all devices below the root complex. + The Maximum Read Request Size will not be altered. This method is + the same algorithm as used by Linux pci=pcie_bus_safe. + config CMD_PINMUX bool "pinmux - show pins muxing" depends on PINCTRL
cmd/Makefile +1 -0
@@ -133,6 +133,7 @@ obj-$(CONFIG_CMD_PART) += part.o obj-$(CONFIG_CMD_PCAP) += pcap.o ifdef CONFIG_PCI obj-$(CONFIG_CMD_PCI) += pci.o +obj-$(CONFIG_CMD_PCI_MPS) += pci_mps.o endif obj-$(CONFIG_CMD_PINMUX) += pinmux.o obj-$(CONFIG_CMD_PMC) += pmc.o
cmd/pci_mps.c new file +164 -0
164 lines not on this page · raw message
include/pci.h +7 -0
@@ -360,6 +360,13 @@#define PCI_EXP_TYPE_PCIE_BRIDGE 0x8/* PCI/PCI-X to PCIe Bridge */ #define PCI_EXP_DEVCAP 4/* Device capabilities */ #define PCI_EXP_DEVCAP_FLR 0x10000000/* Function Level Reset */ +#define PCI_EXP_DEVCAP_PAYLOAD 0x0007/* Max payload size supported */ +#define PCI_EXP_DEVCAP_PAYLOAD_128B 0x0000/* 128 Bytes */ +#define PCI_EXP_DEVCAP_PAYLOAD_256B 0x0001/* 256 Bytes */ +#define PCI_EXP_DEVCAP_PAYLOAD_512B 0x0002/* 512 Bytes */ +#define PCI_EXP_DEVCAP_PAYLOAD_1024B 0x0003/* 1024 Bytes */ +#define PCI_EXP_DEVCAP_PAYLOAD_2048B 0x0004/* 2048 Bytes */ +#define PCI_EXP_DEVCAP_PAYLOAD_4096B 0x0005/* 4096 Bytes */ #define PCI_EXP_DEVCTL 8/* Device Control */ #define PCI_EXP_DEVCTL_PAYLOAD 0x00e0/* Max_Payload_Size */ #define PCI_EXP_DEVCTL_PAYLOAD_128B 0x0000/* 128 Bytes */
Signature · 1 line
2.25.1
PATCH v2 2/3 drivers: pci: sandbox: Add stub sandbox PCI MPS support
From: Stephen Carlson <[email protected]>
Reports the sandbox swapcase PCI Express device to support a 256 byte Maximum Payload Size for MPS tuning tests.
--- drivers/misc/swap_case.c | 3 +++ 1 file changed, 3 insertions(+)
drivers/misc/swap_case.c +3 -0
@@ -165,6 +165,9 @@ static int sandbox_swap_case_read_config(const struct udevice *emul,case PCI_CAP_ID_EXP_OFFSET +PCI_CAP_LIST_NEXT : *valuep =PCI_CAP_ID_MSIX_OFFSET ;break ; +case PCI_CAP_ID_EXP_OFFSET +PCI_EXP_DEVCAP : + *valuep =PCI_EXP_DEVCAP_PAYLOAD_256B ; +break ;case PCI_CAP_ID_MSIX_OFFSET :if (sandbox_swap_case_use_ea (emul)) *valuep = (PCI_CAP_ID_EA_OFFSET <<8 ) |PCI_CAP_ID_MSIX ;
Signature · 1 line
2.25.1
Re: [PATCH v2 2/3] drivers: pci: sandbox: Add stub sandbox PCI MPS support
Quoted 11 lines · On Fri, 10 Mar 2023 at 11:08, <[email protected]> wrote:
From: Stephen Carlson <[email protected]>
Reports the sandbox swapcase PCI Express device to support a 256 byte Maximum Payload Size for MPS tuning tests.
Signed-off-by Stephen Carlson <[email protected]>--- drivers/misc/swap_case.c | 3 +++ 1 file changed, 3 insertions(+)
Quoted 9 lines · On Fri, Mar 10, 2023 at 11:07:13AM -0800, [email protected] wrote:
From: Stephen Carlson <[email protected]>
Enable tuning of the PCI Express MPS (Maximum Payload Size) of each device. The Maximum Read Request Size is not altered.
The SAFE method uses the largest MPS value supported by all devices in the system for each device. This method is the same algorithm as used by Linux pci=pcie_bus_safe.
Quoted 5 lines
The PEER2PEER method sets all devices to the minimal (128 byte) MPS, which allows hot plug of devices later that might only support the minimum size, and ensures compatibility of DMA between two devices on the bus.
Signed-off-by Stephen Carlson <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
Re: [PATCH v2 2/3] drivers: pci: sandbox: Add stub sandbox PCI MPS support
In reply to [email protected]Quoted 7 lines · On Fri, Mar 10, 2023 at 11:07:14AM -0800, [email protected] wrote:
From: Stephen Carlson <[email protected]>
Reports the sandbox swapcase PCI Express device to support a 256 byte Maximum Payload Size for MPS tuning tests.
Signed-off-by Stephen Carlson <[email protected]>Reviewed-by Simon Glass <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom
Re: [PATCH v2 3/3] test: Add test for new command pci_mps
In reply to [email protected]Quoted 8 lines · On Fri, Mar 10, 2023 at 11:07:15AM -0800, [email protected] wrote:
From: Stephen Carlson <[email protected]>
Adds a test for the new
pci_mpscommand to ensure that it can set the Maximum Payload Size (MPS) of all devices to 256 bytes in the sandbox environment. Enables thepci_mpscommand in the sandbox environment so that this test can be run.Signed-off-by Stephen Carlson <[email protected]>
Applied to u-boot/next, thanks!
Signature · 1 line
Tom