2013-10-14 16:18:58

by Dorau, Lukasz

[permalink] [raw]
Subject: [PATCH 2] libahci: fix turning on LEDs in ahci_start_port()

If EM Transmit bit is busy during init ata_msleep() is called.
It is wrong - msleep() should be used instead of ata_msleep(),
because if EM Transmit bit is busy for one port, it will be busy
for all other ports too, so using ata_msleep() causes wasting
tries for another ports.

The most common scenario looks like that now
(six ports try to transmit a LED meaasege):
- port #0 tries for the 1st time and succeeds
- ports #1-5 try for the 1st time and sleeps
- port #1 tries for the 2nd time and succeeds
- ports #2-5 try for the 2nd time and sleeps
- port #2 tries for the 3rd time and succeeds
- ports #3-5 try for the 3rd time and sleeps
- port #3 tries for the 4th time and succeeds
- ports #4-5 try for the 4th time and sleeps
- port #4 tries for the 5th time and succeeds
- port #5 tries for the 5th time and sleeps
At this moment port #5 wasted all its five tries and failed to initialize.
Because there are only 5 (EM_MAX_RETRY) tries available usually only five ports
succeed to initialize. The sixth port and next ones usually will fail.

If msleep() is used instead of ata_msleep() the first port succeeds to initialize
in the first try and next ones usually succeed to initialize in the second try.

Signed-off-by: Lukasz Dorau <[email protected]>
---
drivers/ata/libahci.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/ata/libahci.c b/drivers/ata/libahci.c
index acfd0f7..8fb7092 100644
--- a/drivers/ata/libahci.c
+++ b/drivers/ata/libahci.c
@@ -779,7 +779,11 @@ static void ahci_start_port(struct ata_port *ap)
emp->led_state,
4);
if (rc == -EBUSY)
- ata_msleep(ap, 1);
+ /* Do not release ownership of @ap's EH,
+ * because EM Transmit bit is busy for
+ * all ports sharing the @ap->host.
+ */
+ msleep(1);
else
break;
}


2013-10-15 13:41:33

by Tejun Heo

[permalink] [raw]
Subject: Re: [PATCH 2] libahci: fix turning on LEDs in ahci_start_port()

On Mon, Oct 14, 2013 at 06:18:53PM +0200, Lukasz Dorau wrote:
> If EM Transmit bit is busy during init ata_msleep() is called.
> It is wrong - msleep() should be used instead of ata_msleep(),
> because if EM Transmit bit is busy for one port, it will be busy
> for all other ports too, so using ata_msleep() causes wasting
> tries for another ports.
>
> The most common scenario looks like that now
> (six ports try to transmit a LED meaasege):
> - port #0 tries for the 1st time and succeeds
> - ports #1-5 try for the 1st time and sleeps
> - port #1 tries for the 2nd time and succeeds
> - ports #2-5 try for the 2nd time and sleeps
> - port #2 tries for the 3rd time and succeeds
> - ports #3-5 try for the 3rd time and sleeps
> - port #3 tries for the 4th time and succeeds
> - ports #4-5 try for the 4th time and sleeps
> - port #4 tries for the 5th time and succeeds
> - port #5 tries for the 5th time and sleeps
> At this moment port #5 wasted all its five tries and failed to initialize.
> Because there are only 5 (EM_MAX_RETRY) tries available usually only five ports
> succeed to initialize. The sixth port and next ones usually will fail.
>
> If msleep() is used instead of ata_msleep() the first port succeeds to initialize
> in the first try and next ones usually succeed to initialize in the second try.
>
> Signed-off-by: Lukasz Dorau <[email protected]>

Applied to libata/for-3.12-fixes with minor updates.

Thanks.

--
tejun

2013-10-16 07:10:09

by Dorau, Lukasz

[permalink] [raw]
Subject: RE: [PATCH 2] libahci: fix turning on LEDs in ahci_start_port()

On Tuesday, October 15, 2013 3:41 PM Tejun Heo <[email protected]> wrote:
> On Mon, Oct 14, 2013 at 06:18:53PM +0200, Lukasz Dorau wrote:
> > If EM Transmit bit is busy during init ata_msleep() is called.
> > It is wrong - msleep() should be used instead of ata_msleep(), because
> > if EM Transmit bit is busy for one port, it will be busy for all other
> > ports too, so using ata_msleep() causes wasting tries for another
> > ports.
> >
> > The most common scenario looks like that now (six ports try to
> > transmit a LED meaasege):
> > - port #0 tries for the 1st time and succeeds
> > - ports #1-5 try for the 1st time and sleeps
> > - port #1 tries for the 2nd time and succeeds
> > - ports #2-5 try for the 2nd time and sleeps
> > - port #2 tries for the 3rd time and succeeds
> > - ports #3-5 try for the 3rd time and sleeps
> > - port #3 tries for the 4th time and succeeds
> > - ports #4-5 try for the 4th time and sleeps
> > - port #4 tries for the 5th time and succeeds
> > - port #5 tries for the 5th time and sleeps At this moment port #5
> > wasted all its five tries and failed to initialize.
> > Because there are only 5 (EM_MAX_RETRY) tries available usually only
> > five ports succeed to initialize. The sixth port and next ones usually will fail.
> >
> > If msleep() is used instead of ata_msleep() the first port succeeds to
> > initialize in the first try and next ones usually succeed to initialize in the second
> try.
> >
> > Signed-off-by: Lukasz Dorau <[email protected]>
>
> Applied to libata/for-3.12-fixes with minor updates.
>
> Thanks.
>
Thanks.

Lukasz