Microsemi / switchtec-kernel

A kernel module for the Microsemi PCIe switch
GNU General Public License v2.0
45 stars 31 forks source link

switchtec_ntb_part_link_speed causes crash in certain hardware configurations #80

Open jmpallotta opened 4 years ago

jmpallotta commented 4 years ago

The pff ioread32 currently is: u32 pff = ioread32(&stdev->mmio_part_cfg[partition].vep_pff_inst_id);

but it should be: u32 pff = ioread32(&stdev->mmio_part_cfg_all[partition].vep_pff_inst_id);

Since the partition index is provided as an argument, the index should apply to the base of the partition config registers (mmio_part_cfg_all), not the self_partition offset (mmio_part_cfg). This line of code caused an issue when we had 3 partitions and the 3rd partition returned an invalid pff (0xFFFFFFFF).

Also, the code should verify that pff is a valid index. I suggest the following.

    pff = ioread32(&stdev->mmio_part_cfg_all[partition].vep_pff_inst_id);
    if(pff == 0xFFFFFFFF)
    {
            dev_warn(&sndev->stdev->dev,
                    "ntb_part_link_speed - invalid pff, setting speed/width to 0");
            *speed=0;
            *width=0;
            return;
    }
    linksta = ioread32(&stdev->mmio_pff_csr[pff].pci_cap_region[13]);
lsgunth commented 4 years ago

Yes, this looks correct. A patch would be appreciated. Thanks!

jmpallotta commented 4 years ago

Patch attached. Thanks for the quick response. pff_read_fix.patch.txt