* Re: [PATCH] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id
2024-04-03 14:45 [PATCH] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id Rick Wertenbroek
@ 2024-04-03 14:55 ` Rick Wertenbroek
2024-05-07 7:39 ` Damien Le Moal
` (2 subsequent siblings)
3 siblings, 0 replies; 6+ messages in thread
From: Rick Wertenbroek @ 2024-04-03 14:55 UTC (permalink / raw)
To: rick.wertenbroek
Cc: dlemoal, stable, Shawn Lin, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Heiko Stuebner, linux-pci, linux-rockchip, linux-arm-kernel,
linux-kernel
On Wed, Apr 3, 2024 at 4:45 PM Rick Wertenbroek
<rick.wertenbroek@gmail.com> wrote:
>
> Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem
> Vendor ID are u16 variables and are written to a u32 register of the
> controller. The Subsystem Vendor ID was always 0 because the u16 value
> was masked incorrectly with GENMASK(31,16) resulting in all lower 16
> bits being set to 0 prior to the shift.
>
> Remove both masks as they are unnecessary and set the register correctly
> i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the
> Subsystem Vendor ID.
>
> This is documented in the RK3399 TRM section 17.6.7.1.17
>
> Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")
> Signed-off-by: Rick Wertenbroek <rick.wertenbroek@gmail.com>
> Cc: stable@vger.kernel.org
> ---
> drivers/pci/controller/pcie-rockchip-ep.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-rockchip-ep.c b/drivers/pci/controller/pcie-rockchip-ep.c
> index c9046e97a1d2..37d4bcb8bd5b 100644
> --- a/drivers/pci/controller/pcie-rockchip-ep.c
> +++ b/drivers/pci/controller/pcie-rockchip-ep.c
> @@ -98,10 +98,9 @@ static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn,
>
> /* All functions share the same vendor ID with function 0 */
> if (fn == 0) {
> - u32 vid_regs = (hdr->vendorid & GENMASK(15, 0)) |
> - (hdr->subsys_vendor_id & GENMASK(31, 16)) << 16;
> -
> - rockchip_pcie_write(rockchip, vid_regs,
> + rockchip_pcie_write(rockchip,
> + hdr->vendorid |
> + hdr->subsys_vendor_id << 16,
> PCIE_CORE_CONFIG_VENDOR);
> }
>
> --
> 2.25.1
>
This patch was tested on linux next-20240403.
The PCI endpoint test function was used and an arbitrary value e.g., 0x1234
was written to /sys/kernel/config/pci_ep/functions/pci_epf_test/pci_epf_test.0/subsys_vendor_id
This value was then verified with lspci -x / lspci -v on a host
computer acting as PCI root complex.
Cheers,
Rick
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id
2024-04-03 14:45 [PATCH] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id Rick Wertenbroek
2024-04-03 14:55 ` Rick Wertenbroek
@ 2024-05-07 7:39 ` Damien Le Moal
2024-05-15 20:55 ` Bjorn Helgaas
2024-05-17 11:18 ` Krzysztof Wilczyński
3 siblings, 0 replies; 6+ messages in thread
From: Damien Le Moal @ 2024-05-07 7:39 UTC (permalink / raw)
To: Rick Wertenbroek, rick.wertenbroek
Cc: stable, Shawn Lin, Lorenzo Pieralisi, Krzysztof Wilczyński,
Rob Herring, Bjorn Helgaas, Heiko Stuebner, linux-pci,
linux-rockchip, linux-arm-kernel, linux-kernel
On 4/3/24 23:45, Rick Wertenbroek wrote:
> Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem
> Vendor ID are u16 variables and are written to a u32 register of the
> controller. The Subsystem Vendor ID was always 0 because the u16 value
> was masked incorrectly with GENMASK(31,16) resulting in all lower 16
> bits being set to 0 prior to the shift.
>
> Remove both masks as they are unnecessary and set the register correctly
> i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the
> Subsystem Vendor ID.
>
> This is documented in the RK3399 TRM section 17.6.7.1.17
>
> Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")
> Signed-off-by: Rick Wertenbroek <rick.wertenbroek@gmail.com>
> Cc: stable@vger.kernel.org
Reviewed-by: Damien Le Moal <dlemoal@kernel.org>
> ---
> drivers/pci/controller/pcie-rockchip-ep.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-rockchip-ep.c b/drivers/pci/controller/pcie-rockchip-ep.c
> index c9046e97a1d2..37d4bcb8bd5b 100644
> --- a/drivers/pci/controller/pcie-rockchip-ep.c
> +++ b/drivers/pci/controller/pcie-rockchip-ep.c
> @@ -98,10 +98,9 @@ static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn,
>
> /* All functions share the same vendor ID with function 0 */
> if (fn == 0) {
> - u32 vid_regs = (hdr->vendorid & GENMASK(15, 0)) |
> - (hdr->subsys_vendor_id & GENMASK(31, 16)) << 16;
> -
> - rockchip_pcie_write(rockchip, vid_regs,
> + rockchip_pcie_write(rockchip,
> + hdr->vendorid |
> + hdr->subsys_vendor_id << 16,
> PCIE_CORE_CONFIG_VENDOR);
> }
>
--
Damien Le Moal
Western Digital Research
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id
2024-04-03 14:45 [PATCH] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id Rick Wertenbroek
2024-04-03 14:55 ` Rick Wertenbroek
2024-05-07 7:39 ` Damien Le Moal
@ 2024-05-15 20:55 ` Bjorn Helgaas
2024-05-15 21:13 ` Bjorn Helgaas
2024-05-17 11:18 ` Krzysztof Wilczyński
3 siblings, 1 reply; 6+ messages in thread
From: Bjorn Helgaas @ 2024-05-15 20:55 UTC (permalink / raw)
To: Rick Wertenbroek
Cc: rick.wertenbroek, dlemoal, stable, Shawn Lin, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Heiko Stuebner, linux-pci, linux-rockchip, linux-arm-kernel,
linux-kernel
On Wed, Apr 03, 2024 at 04:45:08PM +0200, Rick Wertenbroek wrote:
> Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem
> Vendor ID are u16 variables and are written to a u32 register of the
> controller. The Subsystem Vendor ID was always 0 because the u16 value
> was masked incorrectly with GENMASK(31,16) resulting in all lower 16
> bits being set to 0 prior to the shift.
>
> Remove both masks as they are unnecessary and set the register correctly
> i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the
> Subsystem Vendor ID.
>
> This is documented in the RK3399 TRM section 17.6.7.1.17
>
> Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")
> Signed-off-by: Rick Wertenbroek <rick.wertenbroek@gmail.com>
> Cc: stable@vger.kernel.org
Applied to pci/controller/rockchip by Krzysztof, but his outgoing mail
queue got stuck. I added Damien's Reviewed-by. Trying to squeeze
into v6.9.
> ---
> drivers/pci/controller/pcie-rockchip-ep.c | 7 +++----
> 1 file changed, 3 insertions(+), 4 deletions(-)
>
> diff --git a/drivers/pci/controller/pcie-rockchip-ep.c b/drivers/pci/controller/pcie-rockchip-ep.c
> index c9046e97a1d2..37d4bcb8bd5b 100644
> --- a/drivers/pci/controller/pcie-rockchip-ep.c
> +++ b/drivers/pci/controller/pcie-rockchip-ep.c
> @@ -98,10 +98,9 @@ static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn,
>
> /* All functions share the same vendor ID with function 0 */
> if (fn == 0) {
> - u32 vid_regs = (hdr->vendorid & GENMASK(15, 0)) |
> - (hdr->subsys_vendor_id & GENMASK(31, 16)) << 16;
> -
> - rockchip_pcie_write(rockchip, vid_regs,
> + rockchip_pcie_write(rockchip,
> + hdr->vendorid |
> + hdr->subsys_vendor_id << 16,
> PCIE_CORE_CONFIG_VENDOR);
> }
>
> --
> 2.25.1
>
^ permalink raw reply [flat|nested] 6+ messages in thread* Re: [PATCH] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id
2024-05-15 20:55 ` Bjorn Helgaas
@ 2024-05-15 21:13 ` Bjorn Helgaas
0 siblings, 0 replies; 6+ messages in thread
From: Bjorn Helgaas @ 2024-05-15 21:13 UTC (permalink / raw)
To: Rick Wertenbroek
Cc: rick.wertenbroek, dlemoal, stable, Shawn Lin, Lorenzo Pieralisi,
Krzysztof Wilczyński, Rob Herring, Bjorn Helgaas,
Heiko Stuebner, linux-pci, linux-rockchip, linux-arm-kernel,
linux-kernel
On Wed, May 15, 2024 at 03:55:49PM -0500, Bjorn Helgaas wrote:
> On Wed, Apr 03, 2024 at 04:45:08PM +0200, Rick Wertenbroek wrote:
> > Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem
> > Vendor ID are u16 variables and are written to a u32 register of the
> > controller. The Subsystem Vendor ID was always 0 because the u16 value
> > was masked incorrectly with GENMASK(31,16) resulting in all lower 16
> > bits being set to 0 prior to the shift.
> >
> > Remove both masks as they are unnecessary and set the register correctly
> > i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the
> > Subsystem Vendor ID.
> >
> > This is documented in the RK3399 TRM section 17.6.7.1.17
> >
> > Fixes: cf590b078391 ("PCI: rockchip: Add EP driver for Rockchip PCIe controller")
> > Signed-off-by: Rick Wertenbroek <rick.wertenbroek@gmail.com>
> > Cc: stable@vger.kernel.org
>
> Applied to pci/controller/rockchip by Krzysztof, but his outgoing mail
> queue got stuck. I added Damien's Reviewed-by. Trying to squeeze
> into v6.9.
Sorry, I meant v6.10. v6.9 is already done.
> > ---
> > drivers/pci/controller/pcie-rockchip-ep.c | 7 +++----
> > 1 file changed, 3 insertions(+), 4 deletions(-)
> >
> > diff --git a/drivers/pci/controller/pcie-rockchip-ep.c b/drivers/pci/controller/pcie-rockchip-ep.c
> > index c9046e97a1d2..37d4bcb8bd5b 100644
> > --- a/drivers/pci/controller/pcie-rockchip-ep.c
> > +++ b/drivers/pci/controller/pcie-rockchip-ep.c
> > @@ -98,10 +98,9 @@ static int rockchip_pcie_ep_write_header(struct pci_epc *epc, u8 fn, u8 vfn,
> >
> > /* All functions share the same vendor ID with function 0 */
> > if (fn == 0) {
> > - u32 vid_regs = (hdr->vendorid & GENMASK(15, 0)) |
> > - (hdr->subsys_vendor_id & GENMASK(31, 16)) << 16;
> > -
> > - rockchip_pcie_write(rockchip, vid_regs,
> > + rockchip_pcie_write(rockchip,
> > + hdr->vendorid |
> > + hdr->subsys_vendor_id << 16,
> > PCIE_CORE_CONFIG_VENDOR);
> > }
> >
> > --
> > 2.25.1
> >
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id
2024-04-03 14:45 [PATCH] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id Rick Wertenbroek
` (2 preceding siblings ...)
2024-05-15 20:55 ` Bjorn Helgaas
@ 2024-05-17 11:18 ` Krzysztof Wilczyński
3 siblings, 0 replies; 6+ messages in thread
From: Krzysztof Wilczyński @ 2024-05-17 11:18 UTC (permalink / raw)
To: Rick Wertenbroek
Cc: rick.wertenbroek, dlemoal, stable, Shawn Lin, Lorenzo Pieralisi,
Rob Herring, Bjorn Helgaas, Heiko Stuebner, linux-pci,
linux-rockchip, linux-arm-kernel, linux-kernel
> Remove wrong mask on subsys_vendor_id. Both the Vendor ID and Subsystem
> Vendor ID are u16 variables and are written to a u32 register of the
> controller. The Subsystem Vendor ID was always 0 because the u16 value
> was masked incorrectly with GENMASK(31,16) resulting in all lower 16
> bits being set to 0 prior to the shift.
>
> Remove both masks as they are unnecessary and set the register correctly
> i.e., the lower 16-bits are the Vendor ID and the upper 16-bits are the
> Subsystem Vendor ID.
>
> This is documented in the RK3399 TRM section 17.6.7.1.17
Applied to controller/rockchip, thank you!
[1/1] PCI: rockchip-ep: Remove wrong mask on subsys_vendor_id
https://git.kernel.org/pci/pci/c/2f014bf195ae
Krzysztof
^ permalink raw reply [flat|nested] 6+ messages in thread