Microsemi / switchtec-kernel

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

In crosslink_setup_mws, xlate_pos should be calculated after size #83

Open jmpallotta opened 4 years ago

jmpallotta commented 4 years ago

In crosslink_setup_mws, size is calculated based upon the available BAR space. After xlate_pos is calculated, the size is potentially adjusted to the offset size if conditions are met. I believe xlate_pos should be recalculated if the size is adjusted.

Current master branch has:

size = pci_resource_len(sndev->ntb.pdev, bar) - offset;
xlate_pos = ilog2(size);

if (offset && size > offset)
  size = offset;

If I am correct, it should be:

size = pci_resource_len(sndev->ntb.pdev, bar) - offset;
if (offset && size > offset)
  size = offset;
xlate_pos = ilog2(size);
lsgunth commented 4 years ago

Looks correct to me. Better if you just send PRs for problems you have solutions to. We can review and merge them much quicker. Thanks!