From 616f8261d7da32ac011308482010a88178e31f35 Mon Sep 17 00:00:00 2001 From: Patrick Wildt Date: Sun, 2 Oct 2016 18:56:06 +0000 Subject: Some HABs reset parts of AHCI_PREG_CMD when AHCI_PREG_SCTL_DET_INIT gets set. Therefore, ahci_port_softreset() restores the sate of the former register once the device detection sequence is finished. The device detection code in ahci_pmp_port_portreset() does not restore AHCI_PREG_CMD afterwards, so let it catch up. Apparently, this part was an oversight as ahci_pmp_port_portreset() did not otherwise use "cmd". From Marius Strobl tested by awolk (amd64), bluhm (amd64, i386), myself (amd64, armv7) ok jmatthew@ --- sys/dev/ic/ahci.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) (limited to 'sys') diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c index 8fa7e0b9cc7..d600f3eff3a 100644 --- a/sys/dev/ic/ahci.c +++ b/sys/dev/ic/ahci.c @@ -1,4 +1,4 @@ -/* $OpenBSD: ahci.c,v 1.27 2016/10/02 18:54:02 patrick Exp $ */ +/* $OpenBSD: ahci.c,v 1.28 2016/10/02 18:56:05 patrick Exp $ */ /* * Copyright (c) 2006 David Gwynne @@ -1313,6 +1313,7 @@ ahci_pmp_port_portreset(struct ahci_port *ap, int pmp_port) DPRINTF(AHCI_D_VERBOSE, "%s.%d: PMP port reset\n", PORTNAME(ap), pmp_port); + /* Save previous command register state */ cmd = ahci_pread(ap, AHCI_PREG_CMD) & ~AHCI_PREG_CMD_ICC; /* turn off power management and disable the PHY */ @@ -1390,6 +1391,8 @@ ahci_pmp_port_portreset(struct ahci_port *ap, int pmp_port) rc = 0; err: + /* Restore preserved port state */ + ahci_pwrite(ap, AHCI_PREG_CMD, cmd); splx(s); return (rc); } -- cgit v1.2.3