Add pci_get|set_max_read_req() helper functions to control maximum PCIe

read request size.

Reviewed by:	jhb@
This commit is contained in:
Alexander Motin 2010-02-05 17:18:48 +00:00
parent 21cc242f25
commit 24d6a5ed27
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=203528
2 changed files with 37 additions and 0 deletions

View File

@ -1626,6 +1626,40 @@ pci_ht_map_msi(device_t dev, uint64_t addr)
}
}
int
pci_get_max_read_req(device_t dev)
{
int cap;
uint16_t val;
if (pci_find_extcap(dev, PCIY_EXPRESS, &cap) != 0)
return (0);
val = pci_read_config(dev, cap + PCIR_EXPRESS_DEVICE_CTL, 2);
val &= PCIM_EXP_CTL_MAX_READ_REQUEST;
val >>= 12;
return (1 << (val + 7));
}
int
pci_set_max_read_req(device_t dev, int size)
{
int cap;
uint16_t val;
if (pci_find_extcap(dev, PCIY_EXPRESS, &cap) != 0)
return (0);
if (size < 128)
size = 128;
if (size > 4096)
size = 4096;
size = (1 << (fls(size) - 1));
val = pci_read_config(dev, cap + PCIR_EXPRESS_DEVICE_CTL, 2);
val &= ~PCIM_EXP_CTL_MAX_READ_REQUEST;
val |= (fls(size) - 8) << 12;
pci_write_config(dev, cap + PCIR_EXPRESS_DEVICE_CTL, val, 2);
return (size);
}
/*
* Support for MSI message signalled interrupts.
*/

View File

@ -458,6 +458,9 @@ int pci_msi_device_blacklisted(device_t dev);
void pci_ht_map_msi(device_t dev, uint64_t addr);
int pci_get_max_read_req(device_t dev);
int pci_set_max_read_req(device_t dev, int size);
#endif /* _SYS_BUS_H_ */
/*