Date: Mon, 22 Mar 2010 23:15:19 +0000 (UTC) From: Pyun YongHyeon <yongari@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org Subject: svn commit: r205489 - stable/7/sys/dev/pci Message-ID: <201003222315.o2MNFJVk069473@svn.freebsd.org>
next in thread | raw e-mail | index | archive | help
Author: yongari Date: Mon Mar 22 23:15:19 2010 New Revision: 205489 URL: http://svn.freebsd.org/changeset/base/205489 Log: MFC r203528: Add pci_get|set_max_read_req() helper functions to control maximum PCIe read request size. Modified: stable/7/sys/dev/pci/pci.c stable/7/sys/dev/pci/pcivar.h Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/dev/pci/pci.c ============================================================================== --- stable/7/sys/dev/pci/pci.c Mon Mar 22 23:04:12 2010 (r205488) +++ stable/7/sys/dev/pci/pci.c Mon Mar 22 23:15:19 2010 (r205489) @@ -1564,6 +1564,40 @@ pci_ht_map_msi(device_t dev, uint64_t ad } } +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. */ Modified: stable/7/sys/dev/pci/pcivar.h ============================================================================== --- stable/7/sys/dev/pci/pcivar.h Mon Mar 22 23:04:12 2010 (r205488) +++ stable/7/sys/dev/pci/pcivar.h Mon Mar 22 23:15:19 2010 (r205489) @@ -465,6 +465,9 @@ int pci_msi_device_blacklisted(device_t 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_ */ /*
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201003222315.o2MNFJVk069473>