Skip to contentSkip to conversation

PCI: rcar: Poll more often in rcar_pcie_wait_for_dl()

PATCH In review Marek Vasut 2 participants 5 messages May 21, 2018 – May 22, 2018

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/1 PCI: rcar: Poll more often in rcar_pcie_wait_for_dl()

The data link active signal usually takes ~20 uSec to be asserted, poll the bit more often to avoid useless delays in this function. Use udelay() instead of usleep() for such a small delay as suggested by the timer documentation and because this will be used in atomic context later on when the suspend/resume patches land.

Cc Geert Uytterhoeven <[email protected]>
Cc Phil Edworthy <[email protected]>
Cc Simon Horman <[email protected]>
Cc Wolfram Sang <[email protected]>

---
V2: s/content/context in commit message

---
 drivers/pci/host/pcie-rcar.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)
drivers/pci/host/pcie-rcar.c +2 -2
index 5c365f743df5..65ebe7aa3488 100644
@@ -529,13 +529,13 @@ static void phy_write_reg(struct rcar_pcie *pcie,
 
 static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)
 {
-	unsigned int timeout = 10;
+	unsigned int timeout = 10000;
 
 	while (timeout--) {
 		if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE))
 			return 0;
 
-		msleep(5);
+		udelay(5);
 	}
 
 	return -ETIMEDOUT;
Signature · 1 line
2.16.2
#1 lore raw

Hi Marek,

Quoted 7 lines · Marek Vasut

The data link active signal usually takes ~20 uSec to be asserted, poll the bit more often to avoid useless delays in this function. Use udelay() instead of usleep() for such a small delay as suggested by the timer documentation and because this will be used in atomic context later on when the suspend/resume patches land.

Thanks for your patch!

Quoted 5 lines
drivers/pci/host/pcie-rcar.c +0 -0
@@ -529,13 +529,13 @@ static void phy_write_reg(struct rcar_pcie *pcie,
 
 static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)

drivers/pci/host/pcie-rcar.c static void phy_write_reg(struct rcar_pcie *pcie, · line 538

Quoted 10 lines
drivers/pci/host/pcie-rcar.c +2 -2
 {
-       unsigned int timeout = 10;
+       unsigned int timeout = 10000;
 
        while (timeout--) {
                if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE))
                        return 0;
 
-               msleep(5);
+               udelay(5);

+ cpu_relax()?

drivers/pci/host/pcie-rcar.c static void phy_write_reg(struct rcar_pcie *pcie, · line 539

Quoted 1 line
drivers/pci/host/pcie-rcar.c +0 -0
        }

if this ever happens, it will have blocked for more than 50 ms...

drivers/pci/host/pcie-rcar.c static void phy_write_reg(struct rcar_pcie *pcie, · line 541

Quoted 1 line
drivers/pci/host/pcie-rcar.c +0 -0
        return -ETIMEDOUT;

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#2 lore raw
Quoted 1 line · Geert Uytterhoeven

Hi Marek,

Hi,

Quoted 20 lines · Marek Vasut
Quoted 7 lines

The data link active signal usually takes ~20 uSec to be asserted, poll the bit more often to avoid useless delays in this function. Use udelay() instead of usleep() for such a small delay as suggested by the timer documentation and because this will be used in atomic context later on when the suspend/resume patches land.

Thanks for your patch!

Quoted 9 lines
drivers/pci/host/pcie-rcar.c +1 -1
@@ -529,13 +529,13 @@ static void phy_write_reg(struct rcar_pcie *pcie,
 
 static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)
 {
-       unsigned int timeout = 10;
+       unsigned int timeout = 10000;
 
Quoted 8 lines

drivers/pci/host/pcie-rcar.c static void phy_write_reg(struct rcar_pcie *pcie, · line 538

Quoted 6 lines
drivers/pci/host/pcie-rcar.c +1 -1
        while (timeout--) {
                if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE))
                        return 0;
 
-               msleep(5);
+               udelay(5);

+ cpu_relax()?

Is it safe to use in atomic context ? Because of that suspend/resume thing.

Quoted 3 lines

drivers/pci/host/pcie-rcar.c static void phy_write_reg(struct rcar_pcie *pcie, · line 539

Quoted 1 line
drivers/pci/host/pcie-rcar.c +0 -0
        }

if this ever happens, it will have blocked for more than 50 ms...

Well yes, so did the previous thing.

Signature · 2 lines
Best regards,
Marek Vasut
#3 lore raw

Hi Marek,

Quoted 25 lines · Marek Vasut
Quoted 24 lines · Geert Uytterhoeven
Quoted 7 lines · Marek Vasut

The data link active signal usually takes ~20 uSec to be asserted, poll the bit more often to avoid useless delays in this function. Use udelay() instead of usleep() for such a small delay as suggested by the timer documentation and because this will be used in atomic context later on when the suspend/resume patches land.

Thanks for your patch!

Quoted 13 lines
drivers/pci/host/pcie-rcar.c +1 -1
@@ -529,13 +529,13 @@ static void phy_write_reg(struct rcar_pcie *pcie,
 
 static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)
 {
-       unsigned int timeout = 10;
+       unsigned int timeout = 10000;
 
        while (timeout--) {
                if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE))
                        return 0;
 
Quoted 6 lines
Quoted 4 lines

drivers/pci/host/pcie-rcar.c static void phy_write_reg(struct rcar_pcie *pcie, · line 538

Quoted 2 lines
drivers/pci/host/pcie-rcar.c +1 -1
-               msleep(5);
+               udelay(5);

+ cpu_relax()?

Is it safe to use in atomic context ? Because of that suspend/resume thing.

Yes.

Quoted 5 lines
Quoted 3 lines

drivers/pci/host/pcie-rcar.c static void phy_write_reg(struct rcar_pcie *pcie, · line 539

Quoted 1 line
drivers/pci/host/pcie-rcar.c +0 -0
        }

if this ever happens, it will have blocked for more than 50 ms...

Well yes, so did the previous thing.

No, the previous thing slept. Big difference.

Gr{oetje,eeting}s,

Geert

Signature · 5 lines
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- [email protected]

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
                                -- Linus Torvalds
#4 lore raw
Quoted 28 lines · Geert Uytterhoeven

Hi Marek,

Quoted 25 lines · Marek Vasut
Quoted 24 lines · Geert Uytterhoeven
Quoted 7 lines · Marek Vasut

The data link active signal usually takes ~20 uSec to be asserted, poll the bit more often to avoid useless delays in this function. Use udelay() instead of usleep() for such a small delay as suggested by the timer documentation and because this will be used in atomic context later on when the suspend/resume patches land.

Thanks for your patch!

Quoted 13 lines
drivers/pci/host/pcie-rcar.c +1 -1
@@ -529,13 +529,13 @@ static void phy_write_reg(struct rcar_pcie *pcie,
 
 static int rcar_pcie_wait_for_dl(struct rcar_pcie *pcie)
 {
-       unsigned int timeout = 10;
+       unsigned int timeout = 10000;
 
        while (timeout--) {
                if ((rcar_pci_read_reg(pcie, PCIETSTR) & DATA_LINK_ACTIVE))
                        return 0;
 
Quoted 8 lines
Quoted 6 lines
Quoted 4 lines

drivers/pci/host/pcie-rcar.c static void phy_write_reg(struct rcar_pcie *pcie, · line 538

Quoted 2 lines
drivers/pci/host/pcie-rcar.c +1 -1
-               msleep(5);
+               udelay(5);

+ cpu_relax()?

Is it safe to use in atomic context ? Because of that suspend/resume thing.

Yes.

OK, added.

Quoted 7 lines
Quoted 5 lines
Quoted 3 lines

drivers/pci/host/pcie-rcar.c static void phy_write_reg(struct rcar_pcie *pcie, · line 539

Quoted 1 line
drivers/pci/host/pcie-rcar.c +0 -0
        }

if this ever happens, it will have blocked for more than 50 ms...

Well yes, so did the previous thing.

No, the previous thing slept. Big difference.

True

Signature · 2 lines
Best regards,
Marek Vasut