Skip to contentSkip to conversation

Wrong LTR-related check in nbif_v6_3_1_program_ltr()

DISCUSSION Heiner Kallweit 1 participant 1 message Feb 22, 2025 PCI

lore
Share & tools
lore
#0 lore raw

In nbif_v6_3_1_program_ltr() (and maybe other functions as well) you have the following:

pcie_capability_read_word(adev->pdev, PCI_EXP_DEVCTL2, &devctl2);

if (adev->pdev->ltr_path == (devctl2 & PCI_EXP_DEVCTL2_LTR_EN))

	return;

if (adev->pdev->ltr_path)

	pcie_capability_set_word(adev->pdev, PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_LTR_EN);
else
	pcie_capability_clear_word(adev->pdev, PCI_EXP_DEVCTL2, PCI_EXP_DEVCTL2_LTR_EN);

The comparison to (devctl2 & PCI_EXP_DEVCTL2_LTR_EN) looks wrong, as this expression can only be 0 or 0x400. I think what you want is
if (adev->pdev->ltr_path == !!(devctl2 & PCI_EXP_DEVCTL2_LTR_EN))

In general I wonder whether the code part is needed and why pci_configure_ltr() in PCI core isn't sufficient for you.