serial: 8250_exar: Fix number of ports for Commtech PCIe cards
PATCH 1/1 serial: 8250_exar: Fix number of ports for Commtech PCIe cards
The following in 8250_exar.c line 589 is used to determine the number of ports for each Exar board:
nr_ports = board->num_ports ? board->num_ports : pcidev->device & 0x0f;
If the number of ports a card has is not explicitly specified, it defaults to the rightmost 4 bits of the PCI device ID. This is prone to error since not all PCI device IDs contain a number which corresponds to the number of ports that card provides.
This particular case involves COMMTECH_4222PCIE, COMMTECH_4224PCIE and COMMTECH_4228PCIE cards with device IDs 0x0022, 0x0020 and 0x0021. Currently the multiport cards receive 2, 0 and 1 port instead of 2, 4 and 8 ports respectively.
To fix this, each Commtech Fastcom PCIe card is given a struct where the number of ports is explicitly specified. This ensures 'board->num_ports' is used instead of the default 'pcidev->device & 0x0f'.
---
Thank you,
Valmer Huhn
drivers/tty/serial/8250/8250_exar.c +21 -3
@@ -734,6 +734,24 @@ static const struct exar8250_board pbn_exar_XR17V35x = { .exit = pci_xr17v35x_exit, }; +static const struct exar8250_board pbn_fastcom35x_2 = { + .num_ports =2 , + .setup = pci_xr17v35x_setup, + .exit = pci_xr17v35x_exit, +}; + +static const struct exar8250_board pbn_fastcom35x_4 = { + .num_ports =4 , + .setup = pci_xr17v35x_setup, + .exit = pci_xr17v35x_exit, +}; + +static const struct exar8250_board pbn_fastcom35x_8 = { + .num_ports =8 , + .setup = pci_xr17v35x_setup, + .exit = pci_xr17v35x_exit, +}; +static const struct exar8250_board pbn_exar_XR17V4358 = { .num_ports =12 , .setup = pci_xr17v35x_setup,
@@ -801,9 +819,9 @@ static const struct pci_device_id exar_pci_tbl[] = {EXAR_DEVICE (EXAR ,XR17V358 , pbn_exar_XR17V35x),EXAR_DEVICE (EXAR ,XR17V4358 , pbn_exar_XR17V4358),EXAR_DEVICE (EXAR ,XR17V8358 , pbn_exar_XR17V8358), - EXAR_DEVICE(COMMTECH, 4222PCIE, pbn_exar_XR17V35x), - EXAR_DEVICE(COMMTECH, 4224PCIE, pbn_exar_XR17V35x), - EXAR_DEVICE(COMMTECH, 4228PCIE, pbn_exar_XR17V35x), + EXAR_DEVICE(COMMTECH, 4222PCIE, pbn_fastcom35x_2), + EXAR_DEVICE(COMMTECH, 4224PCIE, pbn_fastcom35x_4), + EXAR_DEVICE(COMMTECH, 4228PCIE, pbn_fastcom35x_8), EXAR_DEVICE(COMMTECH, 4222PCI335, pbn_fastcom335_2), EXAR_DEVICE(COMMTECH, 4224PCI335, pbn_fastcom335_4),
On Thu, Aug 13, 2020 at 12:52:55PM -0400, Valmer Huhn wrote:
Thanks for an update, my comments below.
Quoted 18 lines
The following in
8250_exar.cline 589 is used to determine the number of ports for each Exar board:
nr_ports=board->num_ports?board->num_ports:pcidev->device&0x0f;If the number of ports a card has is not explicitly specified, it defaults to the rightmost 4 bits of the PCI device ID. This is prone to error since not all PCI device IDs contain a number which corresponds to the number of ports that card provides.
This particular case involves
COMMTECH_4222PCIE,COMMTECH_4224PCIEandCOMMTECH_4228PCIEcards with device IDs0x0022,0x0020and0x0021. Currently the multiport cards receive 2, 0 and 1 port instead of 2, 4 and 8 ports respectively.To fix this, each Commtech Fastcom PCIe card is given a struct where the number of ports is explicitly specified. This ensures '
board->num_ports' is used instead of the default 'pcidev->device&0x0f'.
...
Quoted 3 lines
Fixes d0aeaa83f0b0 ("serial: exar: split out the exar code from 8250_pci")
Shouldn't be blank line here.
Quoted 1 line
Signed-off-by Valmer Huhn <[email protected]>
...
Quoted 1 line
Tested-by Valmer Huhn <[email protected]>
This tag (Tested-by: Author_of_the_patch) is implied. We don't want patches that weren't tested by authors.
After cutter line '---' you missed to provide a changelog along with bumping patch version. Hint, use -v<X> when run git format-patch ...
P.S. Next should be v3, so git format-patch -v3 ....
Signature · 2 lines
With Best Regards, Andy Shevchenko