diff options
author | Clemens Ladisch <clemens@ladisch.de> | 2010-06-10 02:22:07 -0400 |
---|---|---|
committer | Clemens Ladisch <clemens@ladisch.de> | 2010-06-10 02:22:07 -0400 |
commit | 153e3979201b76dbd5788f032fb683e95121e159 (patch) | |
tree | aae0a3a5dcbc0eb815e7030176b03c84da8792b9 /drivers/firewire | |
parent | f9c70f9129f2d88645c3a26711302a7f6ba9afd0 (diff) |
firewire: ohci: speed up PHY register accesses
Most PHY chips, when idle, can complete a register access in the time
needed for two or three PCI read transactions; bigger delays occur only
when data is currently being moved over the link/PHY interface. So if
we busy-wait a few times when waiting for the register access to finish,
it is likely that we can finish without having to sleep.
Signed-off-by: Clemens Ladisch <clemens@ladisch.de>
Diffstat (limited to 'drivers/firewire')
-rw-r--r-- | drivers/firewire/ohci.c | 14 |
1 files changed, 10 insertions, 4 deletions
diff --git a/drivers/firewire/ohci.c b/drivers/firewire/ohci.c index de5ff376231c..65b9bdb8541a 100644 --- a/drivers/firewire/ohci.c +++ b/drivers/firewire/ohci.c | |||
@@ -474,12 +474,17 @@ static int read_phy_reg(struct fw_ohci *ohci, int addr) | |||
474 | int i; | 474 | int i; |
475 | 475 | ||
476 | reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr)); | 476 | reg_write(ohci, OHCI1394_PhyControl, OHCI1394_PhyControl_Read(addr)); |
477 | for (i = 0; i < 10; i++) { | 477 | for (i = 0; i < 3 + 100; i++) { |
478 | val = reg_read(ohci, OHCI1394_PhyControl); | 478 | val = reg_read(ohci, OHCI1394_PhyControl); |
479 | if (val & OHCI1394_PhyControl_ReadDone) | 479 | if (val & OHCI1394_PhyControl_ReadDone) |
480 | return OHCI1394_PhyControl_ReadData(val); | 480 | return OHCI1394_PhyControl_ReadData(val); |
481 | 481 | ||
482 | msleep(1); | 482 | /* |
483 | * Try a few times without waiting. Sleeping is necessary | ||
484 | * only when the link/PHY interface is busy. | ||
485 | */ | ||
486 | if (i >= 3) | ||
487 | msleep(1); | ||
483 | } | 488 | } |
484 | fw_error("failed to read phy reg\n"); | 489 | fw_error("failed to read phy reg\n"); |
485 | 490 | ||
@@ -492,12 +497,13 @@ static int write_phy_reg(const struct fw_ohci *ohci, int addr, u32 val) | |||
492 | 497 | ||
493 | reg_write(ohci, OHCI1394_PhyControl, | 498 | reg_write(ohci, OHCI1394_PhyControl, |
494 | OHCI1394_PhyControl_Write(addr, val)); | 499 | OHCI1394_PhyControl_Write(addr, val)); |
495 | for (i = 0; i < 100; i++) { | 500 | for (i = 0; i < 3 + 100; i++) { |
496 | val = reg_read(ohci, OHCI1394_PhyControl); | 501 | val = reg_read(ohci, OHCI1394_PhyControl); |
497 | if (!(val & OHCI1394_PhyControl_WritePending)) | 502 | if (!(val & OHCI1394_PhyControl_WritePending)) |
498 | return 0; | 503 | return 0; |
499 | 504 | ||
500 | msleep(1); | 505 | if (i >= 3) |
506 | msleep(1); | ||
501 | } | 507 | } |
502 | fw_error("failed to write phy reg\n"); | 508 | fw_error("failed to write phy reg\n"); |
503 | 509 | ||