From 2f0cd59c6ff91b4bae4b6650ef9bfe00639b5061 Mon Sep 17 00:00:00 2001 From: Mauro Carvalho Chehab Date: Fri, 23 Oct 2020 18:33:10 +0200 Subject: PCI: Fix kernel-doc markup Update kernel-doc so the names in the doc match the prototypes. Link: https://lore.kernel.org/r/f19caf7a68f8365c8b573a42b4ac89ec21925c73.1603469755.git.mchehab+huawei@kernel.org Signed-off-by: Mauro Carvalho Chehab Signed-off-by: Bjorn Helgaas --- drivers/pci/p2pdma.c | 10 +++++----- drivers/pci/pci-driver.c | 4 ++-- drivers/pci/pci.c | 2 +- drivers/pci/probe.c | 4 ++-- drivers/pci/slot.c | 5 +++-- 5 files changed, 13 insertions(+), 12 deletions(-) (limited to 'drivers/pci') diff --git a/drivers/pci/p2pdma.c b/drivers/pci/p2pdma.c index de1c331dbed4..bace04145c5f 100644 --- a/drivers/pci/p2pdma.c +++ b/drivers/pci/p2pdma.c @@ -609,7 +609,7 @@ bool pci_has_p2pmem(struct pci_dev *pdev) EXPORT_SYMBOL_GPL(pci_has_p2pmem); /** - * pci_p2pmem_find - find a peer-to-peer DMA memory device compatible with + * pci_p2pmem_find_many - find a peer-to-peer DMA memory device compatible with * the specified list of clients and shortest distance (as determined * by pci_p2pmem_dma()) * @clients: array of devices to check (NULL-terminated) @@ -674,7 +674,7 @@ struct pci_dev *pci_p2pmem_find_many(struct device **clients, int num_clients) EXPORT_SYMBOL_GPL(pci_p2pmem_find_many); /** - * pci_alloc_p2p_mem - allocate peer-to-peer DMA memory + * pci_alloc_p2pmem - allocate peer-to-peer DMA memory * @pdev: the device to allocate memory from * @size: number of bytes to allocate * @@ -727,7 +727,7 @@ void pci_free_p2pmem(struct pci_dev *pdev, void *addr, size_t size) EXPORT_SYMBOL_GPL(pci_free_p2pmem); /** - * pci_virt_to_bus - return the PCI bus address for a given virtual + * pci_p2pmem_virt_to_bus - return the PCI bus address for a given virtual * address obtained with pci_alloc_p2pmem() * @pdev: the device the memory was allocated from * @addr: address of the memory that was allocated @@ -859,7 +859,7 @@ static int __pci_p2pdma_map_sg(struct pci_p2pdma_pagemap *p2p_pgmap, } /** - * pci_p2pdma_map_sg - map a PCI peer-to-peer scatterlist for DMA + * pci_p2pdma_map_sg_attrs - map a PCI peer-to-peer scatterlist for DMA * @dev: device doing the DMA request * @sg: scatter list to map * @nents: elements in the scatterlist @@ -896,7 +896,7 @@ int pci_p2pdma_map_sg_attrs(struct device *dev, struct scatterlist *sg, EXPORT_SYMBOL_GPL(pci_p2pdma_map_sg_attrs); /** - * pci_p2pdma_unmap_sg - unmap a PCI peer-to-peer scatterlist that was + * pci_p2pdma_unmap_sg_attrs - unmap a PCI peer-to-peer scatterlist that was * mapped with pci_p2pdma_map_sg() * @dev: device doing the DMA request * @sg: scatter list to map diff --git a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c index 8b587fc97f7b..591ab353844a 100644 --- a/drivers/pci/pci-driver.c +++ b/drivers/pci/pci-driver.c @@ -90,7 +90,7 @@ static void pci_free_dynids(struct pci_driver *drv) } /** - * store_new_id - sysfs frontend to pci_add_dynid() + * new_id_store - sysfs frontend to pci_add_dynid() * @driver: target device driver * @buf: buffer for scanning device ID data * @count: input size @@ -158,7 +158,7 @@ static ssize_t new_id_store(struct device_driver *driver, const char *buf, static DRIVER_ATTR_WO(new_id); /** - * store_remove_id - remove a PCI device ID from this driver + * remove_id_store - remove a PCI device ID from this driver * @driver: target device driver * @buf: buffer for scanning device ID data * @count: input size diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index e578d34095e9..3ef63a101fa1 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -3480,7 +3480,7 @@ bool pci_acs_enabled(struct pci_dev *pdev, u16 acs_flags) } /** - * pci_acs_path_enable - test ACS flags from start to end in a hierarchy + * pci_acs_path_enabled - test ACS flags from start to end in a hierarchy * @start: starting downstream device * @end: ending upstream device or NULL to search to the root bus * @acs_flags: required flags diff --git a/drivers/pci/probe.c b/drivers/pci/probe.c index 4289030b0fff..eb1ec037f9e7 100644 --- a/drivers/pci/probe.c +++ b/drivers/pci/probe.c @@ -165,7 +165,7 @@ static inline unsigned long decode_bar(struct pci_dev *dev, u32 bar) #define PCI_COMMAND_DECODE_ENABLE (PCI_COMMAND_MEMORY | PCI_COMMAND_IO) /** - * pci_read_base - Read a PCI BAR + * __pci_read_base - Read a PCI BAR * @dev: the PCI device * @type: type of the BAR * @res: resource buffer to be filled in @@ -1612,7 +1612,7 @@ static bool pci_ext_cfg_is_aliased(struct pci_dev *dev) } /** - * pci_cfg_space_size - Get the configuration space size of the PCI device + * pci_cfg_space_size_ext - Get the configuration space size of the PCI device * @dev: PCI device * * Regular PCI devices have 256 bytes, but PCI-X 2 and PCI Express devices diff --git a/drivers/pci/slot.c b/drivers/pci/slot.c index 3861505741e6..8fdb23abe651 100644 --- a/drivers/pci/slot.c +++ b/drivers/pci/slot.c @@ -323,7 +323,7 @@ EXPORT_SYMBOL_GPL(pci_destroy_slot); #if defined(CONFIG_HOTPLUG_PCI) || defined(CONFIG_HOTPLUG_PCI_MODULE) #include /** - * pci_hp_create_link - create symbolic link to the hotplug driver module. + * pci_hp_create_module_link - create symbolic link to hotplug driver module * @pci_slot: struct pci_slot * * Helper function for pci_hotplug_core.c to create symbolic link to @@ -349,7 +349,8 @@ void pci_hp_create_module_link(struct pci_slot *pci_slot) EXPORT_SYMBOL_GPL(pci_hp_create_module_link); /** - * pci_hp_remove_link - remove symbolic link to the hotplug driver module. + * pci_hp_remove_module_link - remove symbolic link to the hotplug driver + * module. * @pci_slot: struct pci_slot * * Helper function for pci_hotplug_core.c to remove symbolic link to -- cgit 1.4.1 From 6534aac198b58309ff2337981d3f893e0be1d19d Mon Sep 17 00:00:00 2001 From: Bjorn Helgaas Date: Thu, 5 Nov 2020 14:51:36 -0600 Subject: PCI: Bounds-check command-line resource alignment requests 32-bit BARs are limited to 2GB size (2^31). By extension, I assume 64-bit BARs are limited to 2^63 bytes. Limit the alignment requested by the "pci=resource_alignment=" command-line parameter to 2^63. Link: https://lore.kernel.org/r/20201007123045.GS4282@kadam Reported-by: Dan Carpenter Signed-off-by: Bjorn Helgaas --- drivers/pci/pci.c | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) (limited to 'drivers/pci') diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 3ef63a101fa1..711268776371 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6202,19 +6202,21 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev, while (*p) { count = 0; if (sscanf(p, "%d%n", &align_order, &count) == 1 && - p[count] == '@') { + p[count] == '@') { p += count + 1; + if (align_order > 63) { + pr_err("PCI: Invalid requested alignment (order %d)\n", + align_order); + align_order = PAGE_SHIFT; + } } else { - align_order = -1; + align_order = PAGE_SHIFT; } ret = pci_dev_str_match(dev, p, &p); if (ret == 1) { *resize = true; - if (align_order == -1) - align = PAGE_SIZE; - else - align = 1 << align_order; + align = 1 << align_order; break; } else if (ret < 0) { pr_err("PCI: Can't parse resource_alignment parameter: %s\n", -- cgit 1.4.1 From cc73eb321d246776e5a9f7723d15708809aa3699 Mon Sep 17 00:00:00 2001 From: Colin Ian King Date: Sat, 14 Nov 2020 15:48:04 -0600 Subject: PCI: Fix overflow in command-line resource alignment requests The shift of 1 by align_order is evaluated using 32 bit arithmetic and the result is assigned to a resource_size_t type variable that is a 64 bit unsigned integer on 64 bit platforms. Fix an overflow before widening issue by making the 1 a ULL. Addresses-Coverity: ("Unintentional integer overflow") Fixes: 32a9a682bef2 ("PCI: allow assignment of memory resources with a specified alignment") Signed-off-by: Colin Ian King Signed-off-by: Bjorn Helgaas Reviewed-by: Logan Gunthorpe --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/pci') diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index 711268776371..dd4bbb699abd 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -6216,7 +6216,7 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev, ret = pci_dev_str_match(dev, p, &p); if (ret == 1) { *resize = true; - align = 1 << align_order; + align = 1ULL << align_order; break; } else if (ret < 0) { pr_err("PCI: Can't parse resource_alignment parameter: %s\n", -- cgit 1.4.1 From 0aec75a5963e8d72c59a42055c5b5c524893b910 Mon Sep 17 00:00:00 2001 From: Heiner Kallweit Date: Tue, 8 Dec 2020 18:57:02 +0100 Subject: PCI: Reduce pci_set_cacheline_size() message to debug level Drivers like ehci_hcd and xhci_hcd use pci_set_mwi() and emit an annnoying message like the following that results in user questions whether something is broken: xhci_hcd 0000:00:15.0: cache line size of 64 is not supported Root cause of the message is that on several chips the Cache Line Size register is hard-wired to 0. Change this message to debug level; an interested caller can still inform the user (if deemed helpful) based on the return code. Link: https://lore.kernel.org/r/be1ed3a2-98b9-ee1d-20b8-477f3d93961d@gmail.com Signed-off-by: Heiner Kallweit Signed-off-by: Bjorn Helgaas --- drivers/pci/pci.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'drivers/pci') diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c index dd4bbb699abd..556fb5e00d86 100644 --- a/drivers/pci/pci.c +++ b/drivers/pci/pci.c @@ -4317,7 +4317,7 @@ int pci_set_cacheline_size(struct pci_dev *dev) if (cacheline_size == pci_cache_line_size) return 0; - pci_info(dev, "cache line size of %d is not supported\n", + pci_dbg(dev, "cache line size of %d is not supported\n", pci_cache_line_size << 2); return -EINVAL; -- cgit 1.4.1