linux-pci.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] PCI: Remove the use of printk_ratelimit() in pci.c
@ 2019-08-25 22:46 Krzysztof Wilczynski
  2019-08-27 23:25 ` Bjorn Helgaas
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Wilczynski @ 2019-08-25 22:46 UTC (permalink / raw)
  To: Bjorn Helgaas; +Cc: linux-pci, linux-kernel

Do not use printk_ratelimit() in drivers/pci/pci.c as it shares the
rate limiting state with all other callers to the printk_ratelimit().

Add pci_info_ratelimited macro similar to pci_notice_ratelimited
added in the commit a88a7b3eb076 ("vfio: Use dev_printk() when
possible") and use it instead of pr_info inside the if-statement.

Signed-off-by: Krzysztof Wilczynski <kw@linux.com>
---
 drivers/pci/pci.c   | 4 ++--
 include/linux/pci.h | 3 +++
 2 files changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index f20a3de57d21..e3d190d003c5 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -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);
 
 	/*
diff --git a/include/linux/pci.h b/include/linux/pci.h
index 463486016290..73ce8d908322 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -2367,4 +2367,7 @@ void pci_uevent_ers(struct pci_dev *pdev, enum  pci_ers_result err_type);
 #define pci_notice_ratelimited(pdev, fmt, arg...) \
 	dev_notice_ratelimited(&(pdev)->dev, fmt, ##arg)
 
+#define pci_info_ratelimited(pdev, fmt, arg...) \
+	dev_info_ratelimited(&(pdev)->dev, fmt, ##arg)
+
 #endif /* LINUX_PCI_H */
-- 
2.22.1


^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] PCI: Remove the use of printk_ratelimit() in pci.c
  2019-08-25 22:46 [PATCH] PCI: Remove the use of printk_ratelimit() in pci.c Krzysztof Wilczynski
@ 2019-08-27 23:25 ` Bjorn Helgaas
  0 siblings, 0 replies; 2+ messages in thread
From: Bjorn Helgaas @ 2019-08-27 23:25 UTC (permalink / raw)
  To: Krzysztof Wilczynski; +Cc: linux-pci, linux-kernel

On Mon, Aug 26, 2019 at 12:46:16AM +0200, Krzysztof Wilczynski wrote:
> Do not use printk_ratelimit() in drivers/pci/pci.c as it shares the
> rate limiting state with all other callers to the printk_ratelimit().
> 
> Add pci_info_ratelimited macro similar to pci_notice_ratelimited
> added in the commit a88a7b3eb076 ("vfio: Use dev_printk() when
> possible") and use it instead of pr_info inside the if-statement.
> 
> Signed-off-by: Krzysztof Wilczynski <kw@linux.com>

Applied to pci/misc for v5.4, thanks!

> ---
>  drivers/pci/pci.c   | 4 ++--
>  include/linux/pci.h | 3 +++
>  2 files changed, 5 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index f20a3de57d21..e3d190d003c5 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -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);
>  
>  	/*
> diff --git a/include/linux/pci.h b/include/linux/pci.h
> index 463486016290..73ce8d908322 100644
> --- a/include/linux/pci.h
> +++ b/include/linux/pci.h
> @@ -2367,4 +2367,7 @@ void pci_uevent_ers(struct pci_dev *pdev, enum  pci_ers_result err_type);
>  #define pci_notice_ratelimited(pdev, fmt, arg...) \
>  	dev_notice_ratelimited(&(pdev)->dev, fmt, ##arg)
>  
> +#define pci_info_ratelimited(pdev, fmt, arg...) \
> +	dev_info_ratelimited(&(pdev)->dev, fmt, ##arg)
> +
>  #endif /* LINUX_PCI_H */
> -- 
> 2.22.1
> 

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2019-08-27 23:25 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-08-25 22:46 [PATCH] PCI: Remove the use of printk_ratelimit() in pci.c Krzysztof Wilczynski
2019-08-27 23:25 ` Bjorn Helgaas

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).