diff mbox

PCI: For d3_delay and d3cold_delay, zero means zero

Message ID 1489497718-4099-1-git-send-email-adrian.hunter@intel.com (mailing list archive)
State Accepted, archived
Headers show

Commit Message

Adrian Hunter March 14, 2017, 1:21 p.m. UTC
msleep() still sleeps 1 jiffy even when told to sleep for zero
milliseconds. That can end up being 1-2 milliseconds or more. In the cases
of d3_delay and d3cold_delay, that unnecessarily increases suspend and/or
resume latencies.

So, do not sleep at all for the respective cases of d3_delay is zero or
d3cold_delay is zero.

Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
---
 drivers/pci/pci.c | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

Comments

Adrian Hunter March 14, 2017, 1:23 p.m. UTC | #1
Forgot to put this is V2, sorry.  It has changes to the commit message as
requested.

On 14/03/17 15:21, Adrian Hunter wrote:
> msleep() still sleeps 1 jiffy even when told to sleep for zero
> milliseconds. That can end up being 1-2 milliseconds or more. In the cases
> of d3_delay and d3cold_delay, that unnecessarily increases suspend and/or
> resume latencies.
> 
> So, do not sleep at all for the respective cases of d3_delay is zero or
> d3cold_delay is zero.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>
> ---
>  drivers/pci/pci.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 7904d02ffdb9..9779483f81fd 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -66,7 +66,8 @@ static void pci_dev_d3_sleep(struct pci_dev *dev)
>  	if (delay < pci_pm_d3_delay)
>  		delay = pci_pm_d3_delay;
>  
> -	msleep(delay);
> +	if (delay)
> +		msleep(delay);
>  }
>  
>  #ifdef CONFIG_PCI_DOMAINS
> @@ -827,7 +828,8 @@ static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
>  		 * because have already delayed for the bridge.
>  		 */
>  		if (dev->runtime_d3cold) {
> -			msleep(dev->d3cold_delay);
> +			if (dev->d3cold_delay)
> +				msleep(dev->d3cold_delay);
>  			/*
>  			 * When powering on a bridge from D3cold, the
>  			 * whole hierarchy may be powered on into
> 

--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Rafael J. Wysocki March 14, 2017, 5:52 p.m. UTC | #2
On Tue, Mar 14, 2017 at 2:21 PM, Adrian Hunter <adrian.hunter@intel.com> wrote:
> msleep() still sleeps 1 jiffy even when told to sleep for zero
> milliseconds. That can end up being 1-2 milliseconds or more. In the cases
> of d3_delay and d3cold_delay, that unnecessarily increases suspend and/or
> resume latencies.
>
> So, do not sleep at all for the respective cases of d3_delay is zero or
> d3cold_delay is zero.
>
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

> ---
>  drivers/pci/pci.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 7904d02ffdb9..9779483f81fd 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -66,7 +66,8 @@ static void pci_dev_d3_sleep(struct pci_dev *dev)
>         if (delay < pci_pm_d3_delay)
>                 delay = pci_pm_d3_delay;
>
> -       msleep(delay);
> +       if (delay)
> +               msleep(delay);
>  }
>
>  #ifdef CONFIG_PCI_DOMAINS
> @@ -827,7 +828,8 @@ static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
>                  * because have already delayed for the bridge.
>                  */
>                 if (dev->runtime_d3cold) {
> -                       msleep(dev->d3cold_delay);
> +                       if (dev->d3cold_delay)
> +                               msleep(dev->d3cold_delay);
>                         /*
>                          * When powering on a bridge from D3cold, the
>                          * whole hierarchy may be powered on into
> --
> 1.9.1
>
> --
> To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Bjorn Helgaas March 14, 2017, 8:04 p.m. UTC | #3
On Tue, Mar 14, 2017 at 03:21:58PM +0200, Adrian Hunter wrote:
> msleep() still sleeps 1 jiffy even when told to sleep for zero
> milliseconds. That can end up being 1-2 milliseconds or more. In the cases
> of d3_delay and d3cold_delay, that unnecessarily increases suspend and/or
> resume latencies.
> 
> So, do not sleep at all for the respective cases of d3_delay is zero or
> d3cold_delay is zero.
> 
> Signed-off-by: Adrian Hunter <adrian.hunter@intel.com>

Applied with Rafael's ack to pci/pm for v4.12, thanks!

> ---
>  drivers/pci/pci.c | 6 ++++--
>  1 file changed, 4 insertions(+), 2 deletions(-)
> 
> diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
> index 7904d02ffdb9..9779483f81fd 100644
> --- a/drivers/pci/pci.c
> +++ b/drivers/pci/pci.c
> @@ -66,7 +66,8 @@ static void pci_dev_d3_sleep(struct pci_dev *dev)
>  	if (delay < pci_pm_d3_delay)
>  		delay = pci_pm_d3_delay;
>  
> -	msleep(delay);
> +	if (delay)
> +		msleep(delay);
>  }
>  
>  #ifdef CONFIG_PCI_DOMAINS
> @@ -827,7 +828,8 @@ static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
>  		 * because have already delayed for the bridge.
>  		 */
>  		if (dev->runtime_d3cold) {
> -			msleep(dev->d3cold_delay);
> +			if (dev->d3cold_delay)
> +				msleep(dev->d3cold_delay);
>  			/*
>  			 * When powering on a bridge from D3cold, the
>  			 * whole hierarchy may be powered on into
> -- 
> 1.9.1
> 
--
To unsubscribe from this list: send the line "unsubscribe linux-acpi" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
diff mbox

Patch

diff --git a/drivers/pci/pci.c b/drivers/pci/pci.c
index 7904d02ffdb9..9779483f81fd 100644
--- a/drivers/pci/pci.c
+++ b/drivers/pci/pci.c
@@ -66,7 +66,8 @@  static void pci_dev_d3_sleep(struct pci_dev *dev)
 	if (delay < pci_pm_d3_delay)
 		delay = pci_pm_d3_delay;
 
-	msleep(delay);
+	if (delay)
+		msleep(delay);
 }
 
 #ifdef CONFIG_PCI_DOMAINS
@@ -827,7 +828,8 @@  static void __pci_start_power_transition(struct pci_dev *dev, pci_power_t state)
 		 * because have already delayed for the bridge.
 		 */
 		if (dev->runtime_d3cold) {
-			msleep(dev->d3cold_delay);
+			if (dev->d3cold_delay)
+				msleep(dev->d3cold_delay);
 			/*
 			 * When powering on a bridge from D3cold, the
 			 * whole hierarchy may be powered on into