From nobody@FreeBSD.org  Fri Nov 15 03:18:55 2013
Return-Path: <nobody@FreeBSD.org>
Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1])
	(using TLSv1 with cipher ADH-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by hub.freebsd.org (Postfix) with ESMTPS id 421A3138
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 15 Nov 2013 03:18:55 +0000 (UTC)
Received: from oldred.freebsd.org (oldred.freebsd.org [8.8.178.121])
	(using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits))
	(No client certificate requested)
	by mx1.freebsd.org (Postfix) with ESMTPS id 174A72390
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 15 Nov 2013 03:18:55 +0000 (UTC)
Received: from oldred.freebsd.org ([127.0.1.6])
	by oldred.freebsd.org (8.14.5/8.14.7) with ESMTP id rAF3IsE9001540
	for <freebsd-gnats-submit@FreeBSD.org>; Fri, 15 Nov 2013 03:18:54 GMT
	(envelope-from nobody@oldred.freebsd.org)
Received: (from nobody@localhost)
	by oldred.freebsd.org (8.14.5/8.14.5/Submit) id rAF3IsB4001517;
	Fri, 15 Nov 2013 03:18:54 GMT
	(envelope-from nobody)
Message-Id: <201311150318.rAF3IsB4001517@oldred.freebsd.org>
Date: Fri, 15 Nov 2013 03:18:54 GMT
From: Marie Helene <marieheleneka@gmail.com>
To: freebsd-gnats-submit@FreeBSD.org
Subject: Unreliable hotplug support with Intel Patsburg AHCI SATA controller
X-Send-Pr-Version: www-3.1
X-GNATS-Notify:

>Number:         183980
>Category:       kern
>Synopsis:       [ata] Unreliable hotplug support with Intel Patsburg AHCI SATA controller
>Confidential:   no
>Severity:       non-critical
>Priority:       low
>Responsible:    freebsd-bugs
>State:          open
>Quarter:        
>Keywords:       
>Date-Required:  
>Class:          sw-bug
>Submitter-Id:   current-users
>Arrival-Date:   Fri Nov 15 03:20:00 UTC 2013
>Closed-Date:    
>Last-Modified:  Sun Nov 17 23:53:44 UTC 2013
>Originator:     Marie Helene
>Release:        10.0-BETA3
>Organization:
>Environment:
FreeBSD homer 10.0-BETA3 FreeBSD 10.0-BETA3 #0 r257580: Sun Nov  3 19:43:01 UTC 2013     root@snap.freebsd.org:/usr/obj/usr/src/sys/GENERIC  amd64
>Description:
Removing a hotplug-able drive tray connected to a hotplug-aware controller does not always properly destroy the device.
Mainboard: Supermicro X9SRL-F (http://www.supermicro.nl/products/motherboard/xeon/c600/x9srl-f.cfm)
CPU: Intel Xeon E5-1620v2 (http://ark.intel.com/products/75779/)

Example output when hotplug fails:
<remove from hotplug bay>
Nov 15 03:16:40 homer kernel: ada1 at ahcich1 bus 0 scbus3 target 0 lun 0
Nov 15 03:16:40 homer kernel: ada1: <SAMSUNG MZ7PD120HAFV-000DA DXM02W1Q> s/n xxx detached
<insert into hotplug bay>
Nov 15 03:20:32 homer kernel: cam_periph_alloc: attempt to re-allocate valid device ada1 rejected flags 0x118 refcount 2

Note the absence of 'Periph destroyed' in the above output.

If a port successfully handles hotplugging, it will keep doing so until next reboot, at which point it may or may not support hotplugging again.

Relevant dmesg output is attached
>How-To-Repeat:

>Fix:


Patch attached with submission follows:

ahci0: <Intel Patsburg AHCI SATA controller> port 0xf050-0xf057,0xf040-0xf043,0xf030-0xf037,0xf020-0xf023,0xf000-0xf01f mem 0xfb921000-0xfb9217ff irq 18 at device 31.2 on pci0
ahci0: AHCI v1.30 with 6 6Gbps ports, Port Multiplier not supported
ahcich0: <AHCI channel> at channel 0 on ahci0
ahcich1: <AHCI channel> at channel 1 on ahci0
ahcich2: <AHCI channel> at channel 2 on ahci0
ahcich3: <AHCI channel> at channel 3 on ahci0
ahcich4: <AHCI channel> at channel 4 on ahci0
ahcich5: <AHCI channel> at channel 5 on ahci0
ahciem0: <AHCI enclosure management bridge> on ahci0

ada0 at ahcich0 bus 0 scbus2 target 0 lun 0
<several da* devices connected to another controller>
ada0: <SAMSUNG MZ7PD120HAFV-000DA DXM02W1Q> ATA-9 SATA 3.x device
ada0: Serial Number xxx
ada0: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 8192bytes)
ada0: Command Queueing enabled
ada0: 114473MB (234441648 512 byte sectors: 16H 63S/T 16383C)
ada0: Previously was known as ad4
ada1 at ahcich1 bus 0 scbus3 target 0 lun 0
ada1: <SAMSUNG MZ7PD120HAFV-000DA DXM02W1Q> ATA-9 SATA 3.x device
ada1: Serial Number xxx
ada1: 600.000MB/s transfers (SATA 3.x, UDMA6, PIO 8192bytes)
ada1: Command Queueing enabled
ada1: 114473MB (234441648 512 byte sectors: 16H 63S/T 16383C)
ada1: Previously was known as ad6

>Release-Note:
>Audit-Trail:

From: Marie <marieheleneka@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org
Cc:  
Subject: Re: misc/183980: Unreliable hotplug support with Intel Patsburg AHCI
 SATA controller
Date: Fri, 15 Nov 2013 05:17:34 +0100

 --047d7b6d7a10456b8104eb2f7a09
 Content-Type: text/plain; charset=ISO-8859-1
 
 I've tried to reproduce the problem with FreeBSD 9.2-RELEASE (AMD64), but
 have so far been unable to. I've tried 20 times across 5 reboots. I
 therefore believe this may be a regression. The hardware in question will
 be available for experimentation for a couple of weeks, so please let me
 know if there's anything else I should do to pinpoint the error.
 
 --047d7b6d7a10456b8104eb2f7a09--

From: Marie <marieheleneka@gmail.com>
To: FreeBSD-gnats-submit@freebsd.org, freebsd-bugs@freebsd.org
Cc:  
Subject: Re: misc/183980: Unreliable hotplug support with Intel Patsburg AHCI
 SATA controller
Date: Fri, 15 Nov 2013 11:25:41 +0100

 --001a11331e46cbbc9004eb349edd
 Content-Type: text/plain; charset=ISO-8859-1
 
 Following suggestions from mav@ on the FreeBSD forums (
 http://forums.freebsd.org/showthread.php?t=43238), I've discovered that the
 problem was somehow caused by SWAP being enabled on the device which was
 being unplugged. Considering that 'top' output indicated no swap was being
 used, and that the system had nearly 63 GB unused memory at the time, I
 would be surprised if anything was swapped.
 
 Although the issue is not what I initially thought it was, I still believe
 this is a problem which needs resolving, as a hdd dying for whatever reason
 should not make a port unavailable for what seems like an arbitary period
 of time. (I have not yet managed to make the port work again by any other
 way than a reboot, but I only left the system running for up to 15 minutes)
 
 --001a11331e46cbbc9004eb349edd--
>Unformatted:
