Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

PCI: Remove unused Latency Tolerance Reporting support

My philosophy is unused code is dead code. And dead code is subject to bit
rot and is a likely source of bugs. Use it or lose it.

This reverts 51c2e0a7e5bc ("PCI: add latency tolerance reporting
enable/disable support"), removing these interfaces:

pci_enable_ltr()
pci_disable_ltr()
pci_set_ltr()

[bhelgaas: split to separate patch, also remove prototypes from pci.h]
Signed-off-by: Stephen Hemminger <stephen@networkplumber.org>
Signed-off-by: Bjorn Helgaas <bhelgaas@google.com>
CC: Jesse Barnes <jbarnes@virtuousgeek.org>

authored by

Stephen Hemminger and committed by
Bjorn Helgaas
3ea8197e b340cacc

-127
-123
drivers/pci/pci.c
··· 2223 2223 } 2224 2224 EXPORT_SYMBOL(pci_disable_obff); 2225 2225 2226 - /** 2227 - * pci_ltr_supported - check whether a device supports LTR 2228 - * @dev: PCI device 2229 - * 2230 - * RETURNS: 2231 - * True if @dev supports latency tolerance reporting, false otherwise. 2232 - */ 2233 - static bool pci_ltr_supported(struct pci_dev *dev) 2234 - { 2235 - u32 cap; 2236 - 2237 - pcie_capability_read_dword(dev, PCI_EXP_DEVCAP2, &cap); 2238 - 2239 - return cap & PCI_EXP_DEVCAP2_LTR; 2240 - } 2241 - 2242 - /** 2243 - * pci_enable_ltr - enable latency tolerance reporting 2244 - * @dev: PCI device 2245 - * 2246 - * Enable LTR on @dev if possible, which means enabling it first on 2247 - * upstream ports. 2248 - * 2249 - * RETURNS: 2250 - * Zero on success, errno on failure. 2251 - */ 2252 - int pci_enable_ltr(struct pci_dev *dev) 2253 - { 2254 - int ret; 2255 - 2256 - /* Only primary function can enable/disable LTR */ 2257 - if (PCI_FUNC(dev->devfn) != 0) 2258 - return -EINVAL; 2259 - 2260 - if (!pci_ltr_supported(dev)) 2261 - return -ENOTSUPP; 2262 - 2263 - /* Enable upstream ports first */ 2264 - if (dev->bus->self) { 2265 - ret = pci_enable_ltr(dev->bus->self); 2266 - if (ret) 2267 - return ret; 2268 - } 2269 - 2270 - return pcie_capability_set_word(dev, PCI_EXP_DEVCTL2, 2271 - PCI_EXP_DEVCTL2_LTR_EN); 2272 - } 2273 - EXPORT_SYMBOL(pci_enable_ltr); 2274 - 2275 - /** 2276 - * pci_disable_ltr - disable latency tolerance reporting 2277 - * @dev: PCI device 2278 - */ 2279 - void pci_disable_ltr(struct pci_dev *dev) 2280 - { 2281 - /* Only primary function can enable/disable LTR */ 2282 - if (PCI_FUNC(dev->devfn) != 0) 2283 - return; 2284 - 2285 - if (!pci_ltr_supported(dev)) 2286 - return; 2287 - 2288 - pcie_capability_clear_word(dev, PCI_EXP_DEVCTL2, 2289 - PCI_EXP_DEVCTL2_LTR_EN); 2290 - } 2291 - EXPORT_SYMBOL(pci_disable_ltr); 2292 - 2293 - static int __pci_ltr_scale(int *val) 2294 - { 2295 - int scale = 0; 2296 - 2297 - while (*val > 1023) { 2298 - *val = (*val + 31) / 32; 2299 - scale++; 2300 - } 2301 - return scale; 2302 - } 2303 - 2304 - /** 2305 - * pci_set_ltr - set LTR latency values 2306 - * @dev: PCI device 2307 - * @snoop_lat_ns: snoop latency in nanoseconds 2308 - * @nosnoop_lat_ns: nosnoop latency in nanoseconds 2309 - * 2310 - * Figure out the scale and set the LTR values accordingly. 2311 - */ 2312 - int pci_set_ltr(struct pci_dev *dev, int snoop_lat_ns, int nosnoop_lat_ns) 2313 - { 2314 - int pos, ret, snoop_scale, nosnoop_scale; 2315 - u16 val; 2316 - 2317 - if (!pci_ltr_supported(dev)) 2318 - return -ENOTSUPP; 2319 - 2320 - snoop_scale = __pci_ltr_scale(&snoop_lat_ns); 2321 - nosnoop_scale = __pci_ltr_scale(&nosnoop_lat_ns); 2322 - 2323 - if (snoop_lat_ns > PCI_LTR_VALUE_MASK || 2324 - nosnoop_lat_ns > PCI_LTR_VALUE_MASK) 2325 - return -EINVAL; 2326 - 2327 - if ((snoop_scale > (PCI_LTR_SCALE_MASK >> PCI_LTR_SCALE_SHIFT)) || 2328 - (nosnoop_scale > (PCI_LTR_SCALE_MASK >> PCI_LTR_SCALE_SHIFT))) 2329 - return -EINVAL; 2330 - 2331 - pos = pci_find_ext_capability(dev, PCI_EXT_CAP_ID_LTR); 2332 - if (!pos) 2333 - return -ENOTSUPP; 2334 - 2335 - val = (snoop_scale << PCI_LTR_SCALE_SHIFT) | snoop_lat_ns; 2336 - ret = pci_write_config_word(dev, pos + PCI_LTR_MAX_SNOOP_LAT, val); 2337 - if (ret != 4) 2338 - return -EIO; 2339 - 2340 - val = (nosnoop_scale << PCI_LTR_SCALE_SHIFT) | nosnoop_lat_ns; 2341 - ret = pci_write_config_word(dev, pos + PCI_LTR_MAX_NOSNOOP_LAT, val); 2342 - if (ret != 4) 2343 - return -EIO; 2344 - 2345 - return 0; 2346 - } 2347 - EXPORT_SYMBOL(pci_set_ltr); 2348 - 2349 2226 static int pci_acs_enable; 2350 2227 2351 2228 /**
-4
include/linux/pci.h
··· 1009 1009 int pci_enable_obff(struct pci_dev *dev, enum pci_obff_signal_type); 1010 1010 void pci_disable_obff(struct pci_dev *dev); 1011 1011 1012 - int pci_enable_ltr(struct pci_dev *dev); 1013 - void pci_disable_ltr(struct pci_dev *dev); 1014 - int pci_set_ltr(struct pci_dev *dev, int snoop_lat_ns, int nosnoop_lat_ns); 1015 - 1016 1012 /* For use by arch with custom probe code */ 1017 1013 void set_pcie_port_type(struct pci_dev *pdev); 1018 1014 void set_pcie_hotplug_bridge(struct pci_dev *pdev);