Merge branch 'pci/misc'
- Use devm_add_action_or_reset() helper (Fuqian Huang) - Mark expected switch fall-through (Gustavo A. R. Silva) - Convert sysfs device attributes from __ATTR() to DEVICE_ATTR() (Kelsey Skunberg) - Convert sysfs file permissions from S_IRUSR etc to octal (Kelsey Skunberg) - Move SR-IOV sysfs functions to iov.c (Kelsey Skunberg) - Add pci_info_ratelimited() to ratelimit PCI messages separately (Krzysztof Wilczynski) - Fix "'static' not at beginning of declaration" warnings (Krzysztof Wilczynski) - Clean up resource_alignment parameter to not require static buffer (Logan Gunthorpe) - Add ACS quirk for iProc PAXB (Abhinav Ratna) - Add pci_irq_vector() and other stubs for !CONFIG_PCI (Herbert Xu) * pci/misc: PCI: Add pci_irq_vector() and other stubs when !CONFIG_PCI PCI: Add ACS quirk for iProc PAXB PCI: Force trailing new line to resource_alignment_param in sysfs PCI: Move pci_[get|set]_resource_alignment_param() into their callers PCI: Clean up resource_alignment parameter to not require static buffer PCI: Use static const struct, not const static struct PCI: Add pci_info_ratelimited() to ratelimit PCI separately PCI/IOV: Remove group write permission from sriov_numvfs, sriov_drivers_autoprobe PCI/IOV: Move sysfs SR-IOV functions to iov.c PCI: sysfs: Change permissions from symbolic to octal PCI: sysfs: Change DEVICE_ATTR() to DEVICE_ATTR_WO() PCI: sysfs: Define device attributes with DEVICE_ATTR*() PCI: Mark expected switch fall-through PCI: Use devm_add_action_or_reset()
This commit is contained in:
@@ -890,8 +890,8 @@ static int pci_raw_set_power_state(struct pci_dev *dev, pci_power_t state)
|
||||
|
||||
pci_read_config_word(dev, dev->pm_cap + PCI_PM_CTRL, &pmcsr);
|
||||
dev->current_state = (pmcsr & PCI_PM_CTRL_STATE_MASK);
|
||||
if (dev->current_state != state && printk_ratelimit())
|
||||
pci_info(dev, "Refused to change power state, currently in D%d\n",
|
||||
if (dev->current_state != state)
|
||||
pci_info_ratelimited(dev, "Refused to change power state, currently in D%d\n",
|
||||
dev->current_state);
|
||||
|
||||
/*
|
||||
@@ -5932,8 +5932,7 @@ resource_size_t __weak pcibios_default_alignment(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#define RESOURCE_ALIGNMENT_PARAM_SIZE COMMAND_LINE_SIZE
|
||||
static char resource_alignment_param[RESOURCE_ALIGNMENT_PARAM_SIZE] = {0};
|
||||
static char *resource_alignment_param;
|
||||
static DEFINE_SPINLOCK(resource_alignment_lock);
|
||||
|
||||
/**
|
||||
@@ -5954,7 +5953,7 @@ static resource_size_t pci_specified_resource_alignment(struct pci_dev *dev,
|
||||
|
||||
spin_lock(&resource_alignment_lock);
|
||||
p = resource_alignment_param;
|
||||
if (!*p && !align)
|
||||
if (!p || !*p)
|
||||
goto out;
|
||||
if (pci_has_flag(PCI_PROBE_ONLY)) {
|
||||
align = 0;
|
||||
@@ -6118,35 +6117,41 @@ void pci_reassigndev_resource_alignment(struct pci_dev *dev)
|
||||
}
|
||||
}
|
||||
|
||||
static ssize_t pci_set_resource_alignment_param(const char *buf, size_t count)
|
||||
{
|
||||
if (count > RESOURCE_ALIGNMENT_PARAM_SIZE - 1)
|
||||
count = RESOURCE_ALIGNMENT_PARAM_SIZE - 1;
|
||||
spin_lock(&resource_alignment_lock);
|
||||
strncpy(resource_alignment_param, buf, count);
|
||||
resource_alignment_param[count] = '\0';
|
||||
spin_unlock(&resource_alignment_lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t pci_get_resource_alignment_param(char *buf, size_t size)
|
||||
{
|
||||
size_t count;
|
||||
spin_lock(&resource_alignment_lock);
|
||||
count = snprintf(buf, size, "%s", resource_alignment_param);
|
||||
spin_unlock(&resource_alignment_lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t resource_alignment_show(struct bus_type *bus, char *buf)
|
||||
{
|
||||
return pci_get_resource_alignment_param(buf, PAGE_SIZE);
|
||||
size_t count = 0;
|
||||
|
||||
spin_lock(&resource_alignment_lock);
|
||||
if (resource_alignment_param)
|
||||
count = snprintf(buf, PAGE_SIZE, "%s", resource_alignment_param);
|
||||
spin_unlock(&resource_alignment_lock);
|
||||
|
||||
/*
|
||||
* When set by the command line, resource_alignment_param will not
|
||||
* have a trailing line feed, which is ugly. So conditionally add
|
||||
* it here.
|
||||
*/
|
||||
if (count >= 2 && buf[count - 2] != '\n' && count < PAGE_SIZE - 1) {
|
||||
buf[count - 1] = '\n';
|
||||
buf[count++] = 0;
|
||||
}
|
||||
|
||||
return count;
|
||||
}
|
||||
|
||||
static ssize_t resource_alignment_store(struct bus_type *bus,
|
||||
const char *buf, size_t count)
|
||||
{
|
||||
return pci_set_resource_alignment_param(buf, count);
|
||||
char *param = kstrndup(buf, count, GFP_KERNEL);
|
||||
|
||||
if (!param)
|
||||
return -ENOMEM;
|
||||
|
||||
spin_lock(&resource_alignment_lock);
|
||||
kfree(resource_alignment_param);
|
||||
resource_alignment_param = param;
|
||||
spin_unlock(&resource_alignment_lock);
|
||||
return count;
|
||||
}
|
||||
|
||||
static BUS_ATTR_RW(resource_alignment);
|
||||
@@ -6275,8 +6280,7 @@ static int __init pci_setup(char *str)
|
||||
} else if (!strncmp(str, "cbmemsize=", 10)) {
|
||||
pci_cardbus_mem_size = memparse(str + 10, &str);
|
||||
} else if (!strncmp(str, "resource_alignment=", 19)) {
|
||||
pci_set_resource_alignment_param(str + 19,
|
||||
strlen(str + 19));
|
||||
resource_alignment_param = str + 19;
|
||||
} else if (!strncmp(str, "ecrc=", 5)) {
|
||||
pcie_ecrc_get_policy(str + 5);
|
||||
} else if (!strncmp(str, "hpiosize=", 9)) {
|
||||
@@ -6311,15 +6315,18 @@ static int __init pci_setup(char *str)
|
||||
early_param("pci", pci_setup);
|
||||
|
||||
/*
|
||||
* 'disable_acs_redir_param' is initialized in pci_setup(), above, to point
|
||||
* to data in the __initdata section which will be freed after the init
|
||||
* sequence is complete. We can't allocate memory in pci_setup() because some
|
||||
* architectures do not have any memory allocation service available during
|
||||
* an early_param() call. So we allocate memory and copy the variable here
|
||||
* before the init section is freed.
|
||||
* 'resource_alignment_param' and 'disable_acs_redir_param' are initialized
|
||||
* in pci_setup(), above, to point to data in the __initdata section which
|
||||
* will be freed after the init sequence is complete. We can't allocate memory
|
||||
* in pci_setup() because some architectures do not have any memory allocation
|
||||
* service available during an early_param() call. So we allocate memory and
|
||||
* copy the variable here before the init section is freed.
|
||||
*
|
||||
*/
|
||||
static int __init pci_realloc_setup_params(void)
|
||||
{
|
||||
resource_alignment_param = kstrdup(resource_alignment_param,
|
||||
GFP_KERNEL);
|
||||
disable_acs_redir_param = kstrdup(disable_acs_redir_param, GFP_KERNEL);
|
||||
|
||||
return 0;
|
||||
|
Reference in New Issue
Block a user