* [PATCH] ahci: do not powerdown during initialization
@ 2006-11-20 6:42 Tejun Heo
2006-11-24 17:53 ` Berck E. Nash
2006-11-28 9:15 ` Jeff Garzik
0 siblings, 2 replies; 4+ messages in thread
From: Tejun Heo @ 2006-11-20 6:42 UTC (permalink / raw)
To: Jeff Garzik, linux-ide; +Cc: flyboy
ahci_init_controller() calls ahci_deinit_port() to make sure the
controller is stopped before initializing the controller. In turn,
ahci_deinit_port() invokes ahci_power_down() to power down the port.
If the controller supports slumber mode, the link is put into it.
Unfortunately, some devices don't implement link powersaving mode
properly and show erratic behavior after link is put into slumber
mode. For example, HL-DT-ST DVD-RAM GSA-H30N completely locks up on
slumber transition and can only be recovered with the *REAL* hard
reset - power removal and reapply.
Note that this makes the first probing reset different from all
others. If the above dvd-ram is hotplugged after ahci is initialized,
no problem occurs because ahci is already fully initialized with phy
powered up. So, this might also be the reason for other weird AHCI
initial probing abnormalities.
This patch moves power up/down out of port init/deinit and call them
only when needed.
Power down is now called only when suspending. As system suspend
usually involves powering down 12v for storage devices, this shouldn't
cause problem even if the attached device doesn't support slumber
mode. However, in partial power management and suspend failure cases,
devices might lock up after suspend attempt. I thought about removing
transition to slumber mode altogether but ahci spec mandates it before
HBA D3 state transition. Blacklisting such devices might be the
solution.
Signed-off-by: Tejun Heo <htejun@gmail.com>
---
Berck, can you please test this patch? This might fix your problem
too. Jeff, this patch is necessary regardless of Berck's repsonse. I
think this should go into #usptream-fixes too after some testing in
#upstream (and in -mm).
Thanks.
drivers/ata/ahci.c | 14 +++++++-------
1 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/drivers/ata/ahci.c b/drivers/ata/ahci.c
index b05e22f..a6ad324 100644
--- a/drivers/ata/ahci.c
+++ b/drivers/ata/ahci.c
@@ -588,9 +588,6 @@ static void ahci_power_down(void __iomem
static void ahci_init_port(void __iomem *port_mmio, u32 cap,
dma_addr_t cmd_slot_dma, dma_addr_t rx_fis_dma)
{
- /* power up */
- ahci_power_up(port_mmio, cap);
-
/* enable FIS reception */
ahci_start_fis_rx(port_mmio, cap, cmd_slot_dma, rx_fis_dma);
@@ -616,9 +613,6 @@ static int ahci_deinit_port(void __iomem
return rc;
}
- /* put device into slumber mode */
- ahci_power_down(port_mmio, cap);
-
return 0;
}
@@ -1293,7 +1287,9 @@ static int ahci_port_suspend(struct ata_
int rc;
rc = ahci_deinit_port(port_mmio, hpriv->cap, &emsg);
- if (rc) {
+ if (rc == 0)
+ ahci_power_down(port_mmio, hpriv->cap);
+ else {
ata_port_printk(ap, KERN_ERR, "%s (%d)\n", emsg, rc);
ahci_init_port(port_mmio, hpriv->cap,
pp->cmd_slot_dma, pp->rx_fis_dma);
@@ -1309,6 +1305,7 @@ static int ahci_port_resume(struct ata_p
void __iomem *mmio = ap->host->mmio_base;
void __iomem *port_mmio = ahci_port_base(mmio, ap->port_no);
+ ahci_power_up(port_mmio, hpriv->cap);
ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma);
return 0;
@@ -1415,6 +1412,9 @@ static int ahci_port_start(struct ata_po
ap->private_data = pp;
+ /* power up port */
+ ahci_power_up(port_mmio, hpriv->cap);
+
/* initialize port */
ahci_init_port(port_mmio, hpriv->cap, pp->cmd_slot_dma, pp->rx_fis_dma);
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH] ahci: do not powerdown during initialization
2006-11-20 6:42 [PATCH] ahci: do not powerdown during initialization Tejun Heo
@ 2006-11-24 17:53 ` Berck E. Nash
2006-11-28 9:15 ` Jeff Garzik
1 sibling, 0 replies; 4+ messages in thread
From: Berck E. Nash @ 2006-11-24 17:53 UTC (permalink / raw)
To: Tejun Heo; +Cc: linux-ide
Tejun Heo wrote:
> This patch moves power up/down out of port init/deinit and call them
> only when needed.
> ---
>
> Berck, can you please test this patch? This might fix your problem
> too. Jeff, this patch is necessary regardless of Berck's repsonse. I
> think this should go into #usptream-fixes too after some testing in
> #upstream (and in -mm).
Nope, that doesn't do it. All along I've also been getting weird
messages on system power-downs. I just now set up a serial console to
capture them. I dunno if they're of any significance, but they're on
the same device that pauses on boot, so perhaps they're related.
Berck
Will now halt.
[ 538.178188] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.191083] ata2.00: (irq_stat 0x40000001)
[ 538.199288] ata2.00: tag 0 cmd 0xe0 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.222873] ata2.00: configured for UDMA/133
[ 538.231432] ata2: EH complete
[ 538.237406] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.250289] ata2.00: (irq_stat 0x40000001)
[ 538.258497] ata2.00: tag 0 cmd 0xe0 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.282048] ata2.00: configured for UDMA/133
[ 538.290606] ata2: EH complete
[ 538.296580] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.309465] ata2.00: (irq_stat 0x40000001)
[ 538.317672] ata2.00: tag 0 cmd 0xe0 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.341206] ata2.00: configured for UDMA/133
[ 538.349764] ata2: EH complete
[ 538.355738] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.368621] ata2.00: (irq_stat 0x40000001)
[ 538.376834] ata2.00: tag 0 cmd 0xe0 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.400367] ata2.00: configured for UDMA/133
[ 538.408920] ata2: EH complete
[ 538.414894] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.427783] ata2.00: (irq_stat 0x40000001)
[ 538.435987] ata2.00: tag 0 cmd 0xe0 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.459528] ata2.00: configured for UDMA/133
[ 538.468077] ata2: EH complete
[ 538.474054] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.486941] ata2.00: (irq_stat 0x40000001)
[ 538.495144] ata2.00: tag 0 cmd 0xe0 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.518681] ata2.00: configured for UDMA/133
[ 538.527242] ata2: EH complete
[ 538.533219] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.546113] ata2.00: (irq_stat 0x40000001)
[ 538.554319] ata2.00: tag 0 cmd 0x94 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.577860] ata2.00: configured for UDMA/133
[ 538.586410] ata2: EH complete
[ 538.592387] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.605269] ata2.00: (irq_stat 0x40000001)
[ 538.613475] ata2.00: tag 0 cmd 0x94 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.637015] ata2.00: configured for UDMA/133
[ 538.645566] ata2: EH complete
[ 538.651540] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.664425] ata2.00: (irq_stat 0x40000001)
[ 538.672634] ata2.00: tag 0 cmd 0x94 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.696179] ata2.00: configured for UDMA/133
[ 538.704742] ata2: EH complete
[ 538.710716] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.723601] ata2.00: (irq_stat 0x40000001)
[ 538.731807] ata2.00: tag 0 cmd 0x94 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.755349] ata2.00: configured for UDMA/133
[ 538.763900] ata2: EH complete
[ 538.769873] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.782765] ata2.00: (irq_stat 0x40000001)
[ 538.790965] ata2.00: tag 0 cmd 0x94 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.814513] ata2.00: configured for UDMA/133
[ 538.823073] ata2: EH complete
[ 538.829047] ata2.00: exception Emask 0x0 SAct 0x0 SErr 0x0 action 0x0
[ 538.841933] ata2.00: (irq_stat 0x40000001)
[ 538.850140] ata2.00: tag 0 cmd 0x94 Emask 0x1 stat 0x51 err 0x4
(device error)
[ 538.873679] ata2.00: configured for UDMA/133
[ 538.882233] ata2: EH complete
[ 538.888199] SCSI device sdd: 640 512-byte hdwr sectors (0 MB)
[ 538.890404] Synchronizing SCSI cache for disk sde:
[ 538.909477] sdd: Write Protect is off
[ 538.916822] SCSI device sdd: drive cache: write through
[ 538.927285] SCSI device sdd: 640 512-byte hdwr sectors (0 MB)
[ 538.938797] Synchronizing SCSI cache for disk sdc:
[ 538.948561] sdd: Write Protect is off
[ 538.949171] Synchronizing SCSI cache for disk sdb:
[ 538.949424] Synchronizing SCSI cache for disk sda:
[ 538.975451] SCSI device sdd: drive cache: write through
[ 539.441444] Shutdown: hdg
[ 539.446910] Shutdown: hde
[ 539.452716] Power down.
[ 539.457706] acpi_power_off called
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ahci: do not powerdown during initialization
2006-11-20 6:42 [PATCH] ahci: do not powerdown during initialization Tejun Heo
2006-11-24 17:53 ` Berck E. Nash
@ 2006-11-28 9:15 ` Jeff Garzik
2006-11-29 3:52 ` Tejun Heo
1 sibling, 1 reply; 4+ messages in thread
From: Jeff Garzik @ 2006-11-28 9:15 UTC (permalink / raw)
To: Tejun Heo; +Cc: linux-ide, flyboy
Tejun Heo wrote:
> ahci_init_controller() calls ahci_deinit_port() to make sure the
> controller is stopped before initializing the controller. In turn,
> ahci_deinit_port() invokes ahci_power_down() to power down the port.
> If the controller supports slumber mode, the link is put into it.
I would rather just pass a 'dont suspend port' flag to
ahci_deinit_port(). That leaves ahci_port_stop() behavior unchanged.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH] ahci: do not powerdown during initialization
2006-11-28 9:15 ` Jeff Garzik
@ 2006-11-29 3:52 ` Tejun Heo
0 siblings, 0 replies; 4+ messages in thread
From: Tejun Heo @ 2006-11-29 3:52 UTC (permalink / raw)
To: Jeff Garzik; +Cc: linux-ide, flyboy
Jeff Garzik wrote:
> Tejun Heo wrote:
>> ahci_init_controller() calls ahci_deinit_port() to make sure the
>> controller is stopped before initializing the controller. In turn,
>> ahci_deinit_port() invokes ahci_power_down() to power down the port.
>> If the controller supports slumber mode, the link is put into it.
>
> I would rather just pass a 'dont suspend port' flag to
> ahci_deinit_port(). That leaves ahci_port_stop() behavior unchanged.
That behavior change is intended. ahci_port_stop() must not call
ahci_power_down(); otherwise, it will cause strange behaviors on some
devices on driver unloading.
The baseline is that power up/down shouldn't be done as part of
controller init/deinit. Power up/down involves link power management
operation which make some devices choke. They should only be done when
actual power management is required. This is okay even for devices
which choke on link pm because system-wide PM powers those devices down
clearing lockup. I dunno what should be done with partial power
management tho.
--
tejun
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2006-11-29 3:52 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-20 6:42 [PATCH] ahci: do not powerdown during initialization Tejun Heo
2006-11-24 17:53 ` Berck E. Nash
2006-11-28 9:15 ` Jeff Garzik
2006-11-29 3:52 ` Tejun Heo
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).