PCI/DPC: Add 'nodpc' parameter
Subsystems (3)
PATCH 1/2 PCI/DPC: Add 'nodpc' parameter
Some users may want to disable downstream port containment (DPC), so give them this option
--- drivers/pci/pci.c | 2 ++ drivers/pci/pci.h | 6 ++++++ drivers/pci/pcie/dpc.c | 48 ++++++++++++++++++++++++++++++++++++++---------- include/linux/pci.h | 6 ++++++ 4 files changed, 52 insertions(+), 10 deletions(-)
drivers/pci/pci.c +2 -0
@@ -6062,6 +6062,8 @@ static int __init pci_setup(char *str) pcie_ats_disabled = true; }else if (!strcmp (str,"noaer" )) {pci_no_aer (); + }else if (!strcmp (str,"nodpc" )) { +pci_no_dpc (); }else if (!strcmp (str,"earlydump" )) { pci_early_dump = true; }else if (!strncmp (str,"realloc=" ,8 )) {
drivers/pci/pci.h +6 -0
@@ -536,4 +536,10 @@ static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { }static inline void pci_aer_clear_device_status (struct pci_dev *dev) { }#endif +#ifdef CONFIG_PCIE_DPC +void pci_no_dpc (void ); +#else +static inline void pci_no_dpc (void ) { } +#endif +#endif /* DRIVERS_PCI_H */
drivers/pci/pcie/dpc.c +38 -10
83 lines not on this page · raw message
include/linux/pci.h +6 -0
@@ -1473,6 +1473,12 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d,static inline bool pci_aer_available (void ) {return false; }#endif +#ifdef CONFIG_PCIE_DPC +bool pci_dpc_available (void ); +#else +static inline bool pci_dpc_available (void ) {return false; } +#endif +#ifdef CONFIG_PCIE_ECRC void pcie_set_ecrc_checking (struct pci_dev *dev);void pcie_ecrc_get_policy (char *str);
Signature · 1 line
1.8.3.1
PATCH 2/2 Documentation: Document pci=nodpc
Document disabling downstream port containment through pci parameter
--- Documentation/admin-guide/kernel-parameters.txt | 3 +++ 1 file changed, 3 insertions(+)
Documentation/admin-guide/kernel-parameters.txt +3 -0
@@ -3041,6 +3041,9 @@ noaer [PCIE] If the PCIEAER kernel config parameter is enabled, this kernel boot option can be used to disable the use of PCIE advanced error reporting. + nodpc [PCIE] If the PCIE_DPC kernel config parameter is + enabled, this kernel boot option can be used to + disable the use of PCIE downstream port containment nodomains [PCI] Disable support for multiple PCI root domains (aka PCI segments, in ACPI-speak). nommconf [X86] Disable use of MMCONFIG for PCI
Signature · 1 line
1.8.3.1
Quoted 11 lines · Jon Derrick
drivers/pci/pci.h +5
-0@@ -536,4 +536,10 @@ static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { }static inline void pci_aer_clear_device_status (struct pci_dev *dev) { }#endif +#ifdef CONFIG_PCIE_DPC +void pci_no_dpc (void ); +#else +static inline void pci_no_dpc (void ) { } +#endif
<snip>
include/linux/pci.h static inline int pci_irqd_intx_xlate(struct irq_domain *d, · line 1480
Quoted 11 lines
include/linux/pci.h +5
-0@@ -1473,6 +1473,12 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d,static inline bool pci_aer_available (void ) {return false; }#endif +#ifdef CONFIG_PCIE_DPC +bool pci_dpc_available (void ); +#else +static inline bool pci_dpc_available (void ) {return false; } +#endif
Seems like these two sections belong together. Otherwise, looks fine.
Quoted 50 lines · Jon Derrick
Some users may want to disable downstream port containment (DPC), so give them this option
Signed-off-by Jon Derrick <[email protected]>--- drivers/pci/pci.c | 2 ++ drivers/pci/pci.h | 6 ++++++ drivers/pci/pcie/dpc.c | 48 ++++++++++++++++++++++++++++++++++++++---------- include/linux/pci.h | 6 ++++++ 4 files changed, 52 insertions(+), 10 deletions(-)drivers/pci/pci.c +2
-0@@ -6062,6 +6062,8 @@ static int __init pci_setup(char *str) pcie_ats_disabled = true; }else if (!strcmp (str,"noaer" )) {pci_no_aer (); + }else if (!strcmp (str,"nodpc" )) { +pci_no_dpc (); }else if (!strcmp (str,"earlydump" )) { pci_early_dump = true; }else if (!strncmp (str,"realloc=" ,8 )) {drivers/pci/pci.h +6
-0@@ -536,4 +536,10 @@ static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { }static inline void pci_aer_clear_device_status (struct pci_dev *dev) { }#endif +#ifdef CONFIG_PCIE_DPC +void pci_no_dpc (void ); +#else +static inline void pci_no_dpc (void ) { } +#endif +#endif /* DRIVERS_PCI_H */ drivers/pci/pcie/dpc.c +0
-0@@ -44,6 +44,18 @@ struct dpc_dev { "Memory Request Completion Timeout", /* Bit Position 18 */ };
drivers/pci/pcie/dpc.c struct dpc_dev { · line 56
Quoted 10 lines
drivers/pci/pcie/dpc.c +10
-0+static int pcie_dpc_disable; + +void pci_no_dpc (void ) +{ + pcie_dpc_disable =1 ; +} + +bool pci_dpc_available (void ) +{ +return !pcie_dpc_disable &&pci_aer_available () &&pci_msi_enabled ();
1) why do you check pci_aer_available() ?
2) and pci_aer_available() already internally checks pci_msi_enabled();
Quoted 92 lines
drivers/pci/pcie/dpc.c +28
-10+} +static int dpc_wait_rp_inactive (struct dpc_dev *dpc) {unsigned long timeout = jiffies +HZ ;@@ -209,6 +221,17 @@ static irqreturn_t dpc_irq(int irq, void *context)return IRQ_HANDLED ; } +static void dpc_disable (struct pci_dev *pdev) +{ +u16 cap_pos, ctl; + + cap_pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_DPC ); +pci_read_config_word (pdev, cap_pos +PCI_EXP_DPC_CTL , &ctl); + ctl &= ~(PCI_EXP_DPC_CTL_EN_FATAL |PCI_EXP_DPC_CTL_EN_NONFATAL | +PCI_EXP_DPC_CTL_INT_EN ); +pci_write_config_word (pdev, cap_pos +PCI_EXP_DPC_CTL , ctl); +} +#define FLAG (x, y) (((x) & (y)) ? '+' : '-')static int dpc_probe (struct pcie_device *dev) {@@ -221,9 +244,16 @@ static int dpc_probe(struct pcie_device *dev)if (pcie_aer_get_firmware_first (pdev))return -ENOTSUPP ; +if (!pci_dpc_available ()) { + status = -ENOTSUPP ; + goto disable_dpc; + } + dpc =devm_kzalloc (device,sizeof (*dpc),GFP_KERNEL ); -if (!dpc) -return -ENOMEM ; +if (!dpc) { + status = -ENOMEM ; + goto disable_dpc; + } dpc->cap_pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_DPC ); dpc->dev = dev;@@ -235,7 +265,7 @@ static int dpc_probe(struct pcie_device *dev)if (status) {dev_warn (device,"request IRQ%d failed: %d\n" , dev->irq, status); -return status; + goto disable_dpc; }pci_read_config_word (pdev, dpc->cap_pos +PCI_EXP_DPC_CAP , &cap);@@ -260,17 +290,15 @@ static int dpc_probe(struct pcie_device *dev)FLAG (cap,PCI_EXP_DPC_CAP_SW_TRIGGER ), dpc->rp_log_size, FLAG(cap, PCI_EXP_DPC_CAP_DL_ACTIVE));return status; + +disable_dpc: +dpc_disable (pdev); +return status; }static void dpc_remove (struct pcie_device *dev) { -struct dpc_dev *dpc =get_service_data (dev); -struct pci_dev *pdev = dev->port; -u16 ctl; - -pci_read_config_word (pdev, dpc->cap_pos +PCI_EXP_DPC_CTL , &ctl); - ctl &= ~(PCI_EXP_DPC_CTL_EN_FATAL |PCI_EXP_DPC_CTL_INT_EN ); -pci_write_config_word (pdev, dpc->cap_pos +PCI_EXP_DPC_CTL , ctl); +dpc_disable (dev->port); }static struct pcie_port_service_driver dpcdriver = {include/linux/pci.h +6
-0@@ -1473,6 +1473,12 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d, static inline bool pci_aer_available(void) { return false; }#endif +#ifdef CONFIG_PCIE_DPC +bool pci_dpc_available (void ); +#else +static inline bool pci_dpc_available (void ) {return false; } +#endif +#ifdef CONFIG_PCIE_ECRC void pcie_set_ecrc_checking (struct pci_dev *dev);void
pcie_ecrc_get_policy(char *str);
Quoted 54 lines · On Thu, 2018-08-16 at 14:57 +0530, [email protected] wrote:
Quoted 53 lines · Jon Derrick
Some users may want to disable downstream port containment (DPC), so
give them this optionSigned-off-by Jon Derrick <[email protected]>--- drivers/pci/pci.c | 2 ++ drivers/pci/pci.h | 6 ++++++ drivers/pci/pcie/dpc.c | 48 ++++++++++++++++++++++++++++++++++++++---------- include/linux/pci.h | 6 ++++++ 4 files changed, 52 insertions(+), 10 deletions(-)drivers/pci/pci.c +2
-0@@ -6062,6 +6062,8 @@ static int __init pci_setup(char *str) pcie_ats_disabled = true; }else if (!strcmp (str,"noaer" )) {pci_no_aer (); + }else if (!strcmp (str,"nodpc" )) { +pci_no_dpc (); }else if (!strcmp (str,"earlydump" )) { pci_early_dump = true; }else if (!strncmp (str,"realloc=" ,8 )) {drivers/pci/pci.h +6
-0@@ -536,4 +536,10 @@ static inline void pci_aer_clear_fatal_status(struct pci_dev *dev) { }static inline void pci_aer_clear_device_status (struct pci_dev *dev) { }#endif +#ifdef CONFIG_PCIE_DPC +void pci_no_dpc (void ); +#else +static inline void pci_no_dpc (void ) { } +#endif +#endif /* DRIVERS_PCI_H */ drivers/pci/pcie/dpc.c +0
-0@@ -44,6 +44,18 @@ struct dpc_dev { "Memory Request Completion Timeout", /*Bit Position 18 */
};
Quoted 13 lines
Quoted 11 lines
drivers/pci/pcie/dpc.c +10
-0+static int pcie_dpc_disable; + +void pci_no_dpc (void ) +{ + pcie_dpc_disable =1 ; +} + +bool pci_dpc_available (void ) +{ + return !pcie_dpc_disable && pci_aer_available() &&
pci_msi_enabled();1) why do you check
pci_aer_available()?
I'd assumed a dependency on aer, but looking at it again I see it calls into err.c without a requirement on aer.
Then it also seems the pci_aer_available() and AER dependency check in portdrv_core.c is unneccessary too.
Quoted 107 lines
2) and
pci_aer_available()already internally checkspci_msi_enabled();Quoted 104 lines
drivers/pci/pcie/dpc.c +9
-0+} +static int dpc_wait_rp_inactive (struct dpc_dev *dpc) {unsigned long timeout = jiffies +HZ ;@@ -209,6 +221,17 @@ static irqreturn_t dpc_irq(int irq, void *context)return IRQ_HANDLED ; } +static void dpc_disable (struct pci_dev *pdev) +{ +u16 cap_pos, ctl; + + cap_pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_DPC ); +pci_read_config_word (pdev, cap_pos +PCI_EXP_DPC_CTL , &ctl); + ctl &= ~(PCI_EXP_DPC_CTL_EN_FATAL |
PCI_EXP_DPC_CTL_EN_NONFATAL|drivers/pci/pcie/dpc.c +2
-0+ PCI_EXP_DPC_CTL_INT_EN); + pci_write_config_word(pdev, cap_pos + PCI_EXP_DPC_CTL,ctl);
drivers/pci/pcie/dpc.c +11
-2+} +#define FLAG (x, y) (((x) & (y)) ? '+' : '-')static int dpc_probe (struct pcie_device *dev) {@@ -221,9 +244,16 @@ static int dpc_probe(struct pcie_device *dev)if (pcie_aer_get_firmware_first (pdev))return -ENOTSUPP ; +if (!pci_dpc_available ()) { + status = -ENOTSUPP ; + goto disable_dpc; + } + dpc =devm_kzalloc (device,sizeof (*dpc),GFP_KERNEL ); -if (!dpc) -return -ENOMEM ; +if (!dpc) { + status = -ENOMEM ; + goto disable_dpc; + } dpc->cap_pos =pci_find_ext_capability (pdev,PCI_EXT_CAP_ID_DPC );drivers/pci/pcie/dpc.c +1
-1dpc->dev = dev;@@ -235,7 +265,7 @@ static int dpc_probe(struct pcie_device *dev)if (status) {dev_warn (device,"request IRQ%d failed: %d\n" , dev->irq, status); -return status; + goto disable_dpc; }pci_read_config_word(pdev,
dpc->cap_pos+PCI_EXP_DPC_CAP,
&cap);drivers/pci/pcie/dpc.c +4
-7@@ -260,17 +290,15 @@ static int dpc_probe(struct pcie_device *dev)FLAG (cap,PCI_EXP_DPC_CAP_SW_TRIGGER ), dpc- >rp_log_size, FLAG(cap, PCI_EXP_DPC_CAP_DL_ACTIVE));return status; + +disable_dpc: +dpc_disable (pdev); +return status; }static void dpc_remove (struct pcie_device *dev) { -struct dpc_dev *dpc =get_service_data (dev); -struct pci_dev *pdev = dev->port; -u16 ctl; - -pci_read_config_word (pdev, dpc->cap_pos +PCI_EXP_DPC_CTL , &ctl); - ctl &= ~(PCI_EXP_DPC_CTL_EN_FATAL | PCI_EXP_DPC_CTL_INT_EN); - pci_write_config_word(pdev, dpc->cap_pos +
PCI_EXP_DPC_CTL, ctl);drivers/pci/pcie/dpc.c +1
-0+dpc_disable (dev->port); }static struct pcie_port_service_driver dpcdriver = {include/linux/pci.h +6
-0@@ -1473,6 +1473,12 @@ static inline int pci_irqd_intx_xlate(struct irq_domain *d, static inline bool pci_aer_available(void) { return false; }#endif +#ifdef CONFIG_PCIE_DPC +bool pci_dpc_available (void ); +#else +static inline bool pci_dpc_available (void ) {return false; } +#endif +#ifdef CONFIG_PCIE_ECRC void pcie_set_ecrc_checking (struct pci_dev *dev);void
pcie_ecrc_get_policy(char *str);
Quoted 2 lines · Jon Derrick
Some users may want to disable downstream port containment (DPC), so give them this option
Is it possible they might only want to disable DPC on a subset of the hierarchy rather than globally?
Quoted 7 lines · Matthew Wilcox
Quoted 3 lines · Jon Derrick
Some users may want to disable downstream port containment (DPC), so
give them this optionIs it possible they might only want to disable DPC on a subset of the hierarchy rather than globally?
Absolutely. I was hoping Logan's pci dev_str would land because I have a few others I want to convert to that api for granular tuning
Quoted 11 lines · Jonathan
Quoted 7 lines · Matthew Wilcox
Quoted 3 lines · Jon Derrick
Some users may want to disable downstream port containment (DPC), so
give them this optionIs it possible they might only want to disable DPC on a subset of the hierarchy rather than globally?
Absolutely. I was hoping Logan's pci
dev_strwould land because I have a few others I want to convert to that api for granular tuning
What's the use case here? I acknowledge there are cases where we need them, but I'm not a fan of kernel parameters in general because they're a real hassle for users.
Is there something wrong with DPC? Is there some way we can make it smarter so it does the right thing automatically?
I'm more OK with a blanket "nodpc" switch intended for debugging. If we add the complexity of subsets of the hierarchy it starts sounding like an administrative thing that makes me more hesitant.
Could this be done via a sysfs switch instead? That potentially could work for hot-added things where a kernel parameter doesn't work so well.
Please squash the doc patch and the code change so it's easier to keep them together.
Bjorn
Hi Bjorn,
Quoted 16 lines · Bjorn Helgaas
Quoted 7 lines · Jonathan
Quoted 6 lines · Matthew Wilcox
Quoted 4 lines · Jon Derrick
Some users may want to disable downstream port containment (DPC),
so
give them this optionQuoted 7 lines
Quoted 3 lines
Is it possible they might only want to disable DPC on a subset of the
hierarchy rather than globally?Absolutely. I was hoping Logan's pci
dev_strwould land because I have
a few others I want to convert to that api for granular tuning
Quoted 7 lines
What's the use case here? I acknowledge there are cases where we need
them, but I'm not a fan of kernel parameters in general because they're a real hassle for users.Is there something wrong with DPC? Is there some way we can make it smarter so it does the right thing automatically?
I've encountered some BIOS or switches (not sure who) who've appeared to have enabled DPC by default, prior to kernel setup. Some users may just not want this, but it was primarily intended for debugging when I conceived it.
There's also the ongoing thread in linux-pci about err handling in PPC EEH, who may also desire to disable DPC until those issues are resolved.
It can also be disabled with setpci, but is that any less of a hassle? Genuine question to understand your point of view.
Quoted 5 lines
I'm more OK with a blanket "nodpc" switch intended for debugging. If we add the complexity of subsets of the hierarchy it starts sounding like an administrative thing that makes me more hesitant.
That's ok with me. I was having trouble cleanly keeping the string around after early_param anyways.
To again understand your point of view, is there anything wrong with administrative things in kernel boot parameters? There will be cases where we may want to deviate from default or global pci=* parameters for certain hierarchies and they can't necessarily be set after the fact (ex, hpmemsize).
Quoted 10 lines
Could this be done via a sysfs switch instead? That potentially could
work for hot-added things where a kernel parameter doesn't work so well.Please squash the doc patch and the code change so it's easier to keep
them together.Bjorn
Quoted 2 lines · Jonathan
It can also be disabled with setpci, but is that any less of a hassle? Genuine question to understand your point of view.
That is not a real solution, IMO. 'setpci' is good to inject things for testing, but it changes config space without the kernel aware that you've done that, so it is inherently racey with other kernel threads touching pci config space. And the kernel or platform may end up undoing what you had 'setpci' do anyway with no immediate way to be notified it was changed.
Quoted 5 lines · Keith Busch
Quoted 3 lines · Jonathan
It can also be disabled with setpci, but is that any less of a hassle?
Genuine question to understand your point of view.
Quoted 9 lines
That is not a real solution, IMO. 'setpci' is good to inject things for testing, but it changes config space without the kernel aware that
you've done that, so it is inherently racey with other kernel threads touching pci config space. And the kernel or platform may end up undoing
what you had 'setpci' do anyway with no immediate way to be notified it
was changed.
It sounds like a sysfs toggle could be useful regardless of the boot parameter.
Quoted 24 lines · Jonathan
Quoted 16 lines · Bjorn Helgaas
Quoted 7 lines · Jonathan
Quoted 6 lines · Matthew Wilcox
Quoted 4 lines · Jon Derrick
Some users may want to disable downstream port containment (DPC),
so
give them this optionQuoted 7 lines
Quoted 3 lines
Is it possible they might only want to disable DPC on a subset of the
hierarchy rather than globally?Absolutely. I was hoping Logan's pci
dev_strwould land because I have
a few others I want to convert to that api for granular tuningQuoted 7 lines
What's the use case here? I acknowledge there are cases where we need
them, but I'm not a fan of kernel parameters in general because they're a real hassle for users.Is there something wrong with DPC? Is there some way we can make it smarter so it does the right thing automatically?
Quoted 8 lines
I've encountered some BIOS or switches (not sure who) who've appeared to have enabled DPC by default, prior to kernel setup. Some users may just not want this, but it was primarily intended for debugging when I conceived it.
There's also the ongoing thread in linux-pci about err handling in PPC EEH, who may also desire to disable DPC until those issues are resolved.
I haven't caught up on that thread yet. If DPC is incompatible with PPC EEH, there's always the possibility of a switch in the code to disable DPC automatically on PPC.
Quoted 2 lines
It can also be disabled with setpci, but is that any less of a hassle? Genuine question to understand your point of view.
Keith already answered here; setpci is primarily for debugging and shouldn't be recommended as normal practice.
Quoted 9 lines
Quoted 3 lines
I'm more OK with a blanket "nodpc" switch intended for debugging. If we add the complexity of subsets of the hierarchy it starts sounding like an administrative thing that makes me more hesitant.
...
To again understand your point of view, is there anything wrong with administrative things in kernel boot parameters? There will be cases where we may want to deviate from default or global pci=* parameters for certain hierarchies and they can't necessarily be set after the fact (ex, hpmemsize).
"There will be cases" sounds like we're doing something that *might* be useful in the future. It's better if we wait until we actually discover a need for something.
There's also a tendency among users to trip over a problem, discover a boot parameter like "pci=nomsi", and conclude that the problem is "fixed". In fact, we want the bug report so we can fix the kernel so no boot parameter is needed.
I agree there are things that can't be set after boot. Is this one of them? This seems like something that could be controlled at run-time. But even there, I will ask what the requirement for it is, because we don't want to clutter sysfs with things only needed for debugging.
Boot parameters are a hassle because it's hard to build a user interface on top of them, and they require a reboot to take effect.
Hi Bjorn,
Thanks for your pov.
I'm going a lot of different ways on this one, but it seems like the most reasonable option right now is to drop it until someone actually presents a non-debugging need to disable DPC from sysfs or globally.
Best regards,
Jon
Quoted 88 lines · Bjorn Helgaas
Quoted 37 lines · Jonathan
Quoted 19 lines · Bjorn Helgaas
Quoted 12 lines · Jonathan
Quoted 10 lines · Matthew Wilcox
Quoted 4 lines · Jon Derrick
Some users may want to disable downstream port containment (DPC),
so
give them this optionIs it possible they might only want to disable DPC on a subset of
the
hierarchy rather than globally?Quoted 4 lines
Absolutely. I was hoping Logan's pci
dev_strwould land because I
have
a few others I want to convert to that api for granular tuningQuoted 8 lines
What's the use case here? I acknowledge there are cases where we need
them, but I'm not a fan of kernel parameters in general because they're a real hassle for users.Is there something wrong with DPC? Is there some way we can make it
smarter so it does the right thing automatically?I've encountered some BIOS or switches (not sure who) who've appeared
to have enabled DPC by default, prior to kernel setup. Some users may
just not want this, but it was primarily intended for debugging when I
conceived it.Quoted 4 lines
There's also the ongoing thread in linux-pci about err handling in PPC
EEH, who may also desire to disable DPC until those issues are resolved.I haven't caught up on that thread yet. If DPC is incompatible with PPC EEH, there's always the possibility of a switch in the code to disable DPC automatically on PPC.
Quoted 3 lines
It can also be disabled with setpci, but is that any less of a hassle?
Genuine question to understand your point of view.Keith already answered here; setpci is primarily for debugging and shouldn't be recommended as normal practice.
Quoted 5 lines
Quoted 4 lines
I'm more OK with a blanket "nodpc" switch intended for debugging. If we add the complexity of subsets of the hierarchy it starts sounding like an administrative thing that makes me more hesitant.
Quoted 9 lines
...
To again understand your point of view, is there anything wrong with
administrative things in kernel boot parameters? There will be cases
where we may want to deviate from default or global pci=* parameters
for certain hierarchies and they can't necessarily be set after the fact (ex, hpmemsize)."There will be cases" sounds like we're doing something that *might* be useful in the future. It's better if we wait until we actually discover a need for something.
There's also a tendency among users to trip over a problem, discover a
boot parameter like "pci=nomsi", and conclude that the problem is "fixed". In fact, we want the bug report so we can fix the kernel so no boot parameter is needed.I agree there are things that can't be set after boot. Is this one of
them? This seems like something that could be controlled at run- time.
But even there, I will ask what the requirement for it is, because we don't want to clutter sysfs with things only needed for debugging.Boot parameters are a hassle because it's hard to build a user interface on top of them, and they require a reboot to take effect.