summaryrefslogtreecommitdiff
path: root/sys/dev
diff options
context:
space:
mode:
authorBryan Steele <brynet@cvs.openbsd.org>2015-03-12 14:24:03 +0000
committerBryan Steele <brynet@cvs.openbsd.org>2015-03-12 14:24:03 +0000
commit451cd5fd7bc6103e8566798f90dcdc754287e8f5 (patch)
tree7250a8f5b489df6db95e8de74b69394e5e1e88df /sys/dev
parenta3a1602d9261b32d9d51f14fc9fed06e76f4c3c7 (diff)
Print the current link speed for SATA devices attached on ahci(4).
The port numbers correspond to scsibus(4) targets: ahci0: port 0, at 6Gbps ahci0: port 2, at 3Gbps scsibus1 at ahci0: 32 targets sd0 at scsibus1 targ 0 .. sd1 at scsibus1 targ 2 .. ok deraadt@, tested by bmercer@
Diffstat (limited to 'sys/dev')
-rw-r--r--sys/dev/ic/ahci.c21
1 files changed, 20 insertions, 1 deletions
diff --git a/sys/dev/ic/ahci.c b/sys/dev/ic/ahci.c
index fb36dd3bbfc..558a4d6d4ad 100644
--- a/sys/dev/ic/ahci.c
+++ b/sys/dev/ic/ahci.c
@@ -1,4 +1,4 @@
-/* $OpenBSD: ahci.c,v 1.19 2015/02/11 07:13:44 jmatthew Exp $ */
+/* $OpenBSD: ahci.c,v 1.20 2015/03/12 14:24:02 brynet Exp $ */
/*
* Copyright (c) 2006 David Gwynne <dlg@openbsd.org>
@@ -641,6 +641,25 @@ nomem:
DPRINTF(AHCI_D_VERBOSE, "%s: detected device on port %d; %d\n",
DEVNAME(sc), port, rc);
+ /* Read current link speed */
+ const char *speed;
+ switch(ahci_pread(ap, AHCI_PREG_SSTS) & AHCI_PREG_SSTS_SPD) {
+ case AHCI_PREG_SSTS_SPD_GEN1:
+ speed = "1.5Gbps";
+ break;
+ case AHCI_PREG_SSTS_SPD_GEN2:
+ speed = "3Gbps";
+ break;
+ case AHCI_PREG_SSTS_SPD_GEN3:
+ speed = "6Gbps";
+ break;
+ default:
+ speed = NULL;
+ break;
+ }
+ if (speed != NULL)
+ printf("%s: port %d, at %s\n", PORTNAME(ap), port, speed);
+
/* Enable command transfers on port */
if (ahci_port_start(ap, 0)) {
printf("%s: failed to start command DMA on port %d, "