Microsemi / switchtec-kernel

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

tpart_vec returns 1s for non-existent partitions using Tegra TX2 processor #81

Open jmpallotta opened 4 years ago

jmpallotta commented 4 years ago

In switchtec_ntb_init_sndev, tpart_vec reads 0x0000FFFFFFFFFFE for partition 0 in a 2 partition configuration (2 NT endpoints). It seems as though the driver is expecting it to read 0x2. When 0x0000FFFFFFFFFFFE is read, the init fails the following check.

if (__ffs64(tpart_vec) != (fls64(tpart_vec) - 1)) {
  dev_err(&sndev->stdev->dev,
    "ntb driver only supports 1 pair of 1-1 ntb mapping\n");
  return -ENODEV;
}

I suggest the following modification to tpart_vec. This would use the ep_map register to mask the valid bits within tpart_vec.

    part_map = ioread64(&sndev->mmio_ntb->ep_map);
    tpart_vec = ioread32(&sndev->mmio_ntb->ntp_info[self].target_part_high);
    tpart_vec <<= 32;
    tpart_vec |= ioread32(&sndev->mmio_ntb->ntp_info[self].target_part_low);
    tpart_vec &= part_map;
lsgunth commented 4 years ago

I wonder if this is a firmware bug. Doesn't seem like tpart_vec should be returning with other bits set. I suspect the bug is new seeing otherwise it would have never worked at all.

But masking it in software seems like a good workaround. Again, a patch would be appreciated.

jmpallotta commented 4 years ago

Patch is attached. Based upon latest on master branch.

tpart_vec_mask.patch.txt

lsgunth commented 4 years ago

Um, can you do it in git? And submit a PR?

jmpallotta commented 4 years ago

How do I get permission to push to the repository? When I try to push a new branch, I get "permission denied". Sorry, this is the first time that I have contributed to this project and not sure how it works.

lsgunth commented 4 years ago

You need to create a fork and push to it. Once you have a branch there you can submit a pull request back to our tree. See this.