git: 5a898b2b78ce - main - Set PCIe device's Max_Payload_Size to match PCIe root's.
Alexander Motin
mav at FreeBSD.org
Thu Apr 8 18:02:04 UTC 2021
On 08.04.2021 13:36, John Baldwin wrote:
> On 4/5/21 7:40 AM, Alexander Motin wrote:
>> + rmps = pcie_read_config(root, PCIER_DEVICE_CTL, 2) &
>> + PCIEM_CTL_MAX_PAYLOAD;
>> + mps = pcie_read_config(dev, PCIER_DEVICE_CTL, 2) &
>> + PCIEM_CTL_MAX_PAYLOAD;
>> + if (mps == rmps)
>> + return;
>> + /* Check whether the device is capable of the root's MPS. */
>> + mmps = (pcie_read_config(dev, PCIER_DEVICE_CAP, 2) &
>> + PCIEM_CAP_MAX_PAYLOAD) << 5;
>> + if (rmps > mmps) {
>> + /*
>> + * The device is unable to handle root's MPS. Limit root.
>> + * XXX: We should traverse through all the tree, applying
>> + * it to all the devices.
>> + */
>
> Hmmm, limiting the root seems very dubious here. Do you really need this?
All devices under the same root (at least ones that talk to each other)
must have the same MPS value, otherwise some may consider larger
transfer as an error. In case of direct PCIe connection the root is the
only other device, so this code should be sufficient.
> If not, I'd put it behind a tunable sysctl that defaults to off. Ideally
> what you'd do here is use an and of the two masks and select one of those
> bits to choose the value rather than assuming the root can do the device's
> value.
It is not a bitmask, it is a power-of-2 between 128 bytes and the
maximum device capability. So if the root is already configured for
higher value, then it must support the lover one too.
--
Alexander Motin
More information about the dev-commits-src-main
mailing list