# eSATA eject - camcontrol devlist still sees disk



## johnedstone (Jun 11, 2010)

I am using the the HighPoint RocketRaid 2302 PCI-e card
http://www.highpoint-tech.com/usa/rr2302.htm

I have used their cards successfully for several years.
This is the first eSATA card I've used.

Hotswapping has the following problem.  Has anyone seen this problem, and found a solution?

Problem: When the command 
	
	



```
camcontrol eject da2
```
 is issued, and the eSATA is physically disconnected, and after 
	
	



```
camcontrol rescan all
```
 is run, the command 
	
	



```
camcontrol devlist
```
 still shows the disk

Here is an example of an eSATA (da2) being successfully recognized, when it is attached:

```
tail -3 /var/log/messages
Jun 11 11:40:57 potter34 kernel: hptrr: start channel [0,0]
Jun 11 11:40:57 potter34 kernel: hptrr: [0 0] Start channel soft reset.
Jun 11 11:40:57 potter34 kernel: hptrr: channel [0,0] started successfully

camcontrol devlist
<HPT DISK 0_0 4.00>                at scbus0 target 0 lun 0 (pass0,da0)
<HPT DISK 0_1 4.00>                at scbus0 target 1 lun 0 (pass1,da1)
<PIONEER DVD-RW  DVR-218L 1.02>    at scbus1 target 0 lun 0 (pass2,cd0)

camcontrol rescan all
Re-scan of bus 0 was successful
Re-scan of bus 1 was successful
Re-scan of bus 2 was successful
Re-scan of bus 3 was successful
Re-scan of bus 4 was successful
Re-scan of bus 5 was successful

camcontrol devlist
<HPT DISK 0_0 4.00>                at scbus0 target 0 lun 0 (pass0,da0)
<HPT DISK 0_1 4.00>                at scbus0 target 1 lun 0 (pass1,da1)
<HPT DISK 0_2 4.00>                at scbus0 target 2 lun 0 (da2,pass3)
<PIONEER DVD-RW  DVR-218L 1.02>    at scbus1 target 0 lun 0 (pass2,cd0)
```

Hardware details listed here, note at boot time the eSATA is not turned on

```
uname -a
FreeBSD potter34.johnedstone.net 8.0-RELEASE-p2 FreeBSD 8.0-RELEASE-p2 #0: Tue Mar 30 07:56:28 EDT 2010     root@ejstone34.johnedstone.net:/usr/obj/usr/src/sys/GENERIC  amd64

egrep hptrr /var/run/dmesg.boot 
hptrr0: <sx508x> port 0x2000-0x20ff mem 0xd3200000-0xd32fffff irq 17 at device 0.0 on pci5
hptrr: adapter at PCI 5:0:0, IRQ 17
hptrr: start channel [0,0]
hptrr: start channel [0,1]
hptrr: start channel [0,2]
hptrr: start channel [0,3]
hptrr: [0 2] Start channel soft reset.
hptrr: [0 3] Start channel soft reset.
hptrr: channel [0,2] started successfully
hptrr: channel [0,3] started successfully
hptrr: [0 0] Failed to perform channel hard reset.
hptrr: [0 1] Failed to perform channel hard reset.
hptrr0: [GIANT-LOCKED]
hptrr0: [ITHREAD]
da0 at hptrr0 bus 0 target 0 lun 0
da1 at hptrr0 bus 0 target 1 lun 0
```


----------



## johnedstone (Jun 11, 2010)

*Additional information for current environment*


```
cat /boot/loader.conf
## snd_driver_load="YES"
snd_hda_load="YES"
atapicam_load="YES"
hw.ata.atapi_dma="1"
geom_mirror_load="YES"
ext2fs_load="YES"
vboxdrv_load="YES"
nvidia_load="YES"

kldstat
Id Refs Address            Size     Name
 1   29 0xffffffff80100000 d188c0   kernel
 2    1 0xffffffff80e19000 20ab0    geom_mirror.ko
 3    1 0xffffffff80e3a000 23ed0    snd_hda.ko
 4    2 0xffffffff80e5e000 75708    sound.ko
 5    1 0xffffffff80ed4000 52d0     atapicam.ko
 6    1 0xffffffff80eda000 15310    ext2fs.ko
 7    3 0xffffffff80ef0000 45e18    vboxdrv.ko
 8    1 0xffffffff80f36000 d440e0   nvidia.ko
 9    2 0xffffffff81e22000 28ce     vboxnetflt.ko
10    2 0xffffffff81e25000 8d44     netgraph.ko
11    1 0xffffffff81e2e000 13be     ng_ether.ko
12    1 0xffffffff81e30000 d2c      vboxnetadp.ko
```


----------



## johnedstone (Jun 11, 2010)

And, for completeness sake, the following command

```
camcontrol reset 0:2:0
```
or 

```
camcontrol reset 0:2:0
camcontrol rescan all
```
does not fix the problem, that is

```
camcontrol devlist
```
still 'sees' the disk that is not there.


----------



## Carpetsmoker (Jun 11, 2010)

Did you try using atacontrol(8)?


----------



## johnedstone (Jun 12, 2010)

I had thought of that, but this disk is seen as a SCSI disk, not as an ATA disk, so it turns out that

```
atacontrol list
```
doesn't even see the disk.  This is confirmed by the man page.
Thanks though, for the suggestion.


----------



## aragon (Jun 13, 2010)

johnedstone said:
			
		

> And, for completeness sake, the following command
> 
> ```
> camcontrol reset 0:2:0
> ...


Can you try:


```
camcontrol reset 0
camcontrol rescan 0
```

?


----------



## johnedstone (Jun 13, 2010)

```
camcontrol reset 0
```

never returns to the prompt.  And, in the process table you see this

```
root        1449  0.0  0.0  6052  1120  v0  D+   10:06AM   0:00.00 camcontrol reset 0
```
Which means, as you know

```
D       Marks a process in disk (or other short term, uninterâ€ruptible) wait
```

hmmm ... in uninterruptible wait.

I can not simply, from another xterm

```
kill -9 1449
```

But, I can open another terminal and do

```
halt -p
```

I should also note that the following sequence where 'camcontrol reset 0:2:0' returns an error
And, in a moment I'm going to place a note about 'halt -p' off my first thread, about the alarm on the card going off, and it not powering off (later this evening)

Look at this sequence and the error

```
# camcontrol eject da2
Unit stopped successfully, Media ejected

# camcontrol reset 0:2:0
Reset of 0:2:0 returned error 0x6

# camcontrol rescan all
Re-scan of bus 0 was successful
Re-scan of bus 1 was successful
Re-scan of bus 2 was successful
Re-scan of bus 3 was successful
Re-scan of bus 4 was successful
Re-scan of bus 5 was successful

# camcontrol reset 0:2:0
Reset of 0:2:0 returned error 0x6

# camcontrol devlist
<HPT DISK 0_0 4.00>                at scbus0 target 0 lun 0 (pass0,da0)
<HPT DISK 0_1 4.00>                at scbus0 target 1 lun 0 (pass1,da1)
<HPT DISK 0_2 4.00>                at scbus0 target 2 lun 0 (da2,pass3)
<PIONEER DVD-RW  DVR-218L 1.02>    at scbus1 target 0 lun 0 (pass2,cd0)
```

Argg, it's still there.


----------



## johnedstone (Jun 14, 2010)

*Also hptrr hangs at halt -p*

Also, a relevent observation is that upon issuing

```
halt -p
```
all of the disks get sync'd properly, and then the following message appears on the console


```
hptrr: [0 1] Failed to perform channel hard reset
hptrr: [0,1,0] device is disconnected on channel
```

and then either the RocketRaid card starts, and continues to beep, or the system board beeps, I'm not sure which one.  And then, I have to manually power it off.  It reboots w/o error since the disks have been sync'd

This leads me to believe that when the command 

```
camcontrol eject da2
```
somehow the hptrr driver is not 'letting go' of the device.
Or, perhaps the RocketRaid card can not 'let go', and so this never gets back to the hptrr driver.

I will ask the contact in the man page for hptrr to look at this, and maybe HighPoint to take a look at this.


----------



## johnedstone (Jun 18, 2010)

*Solved - HighPoint supplied 2 packages*

This has been fixed.
I ask http://www.highpoint-tech.com to take a look at this thread.

And after some discussion w/ them, they sent two packages,

 hptraidconf-3.4-1.tbz
 hptsvr-3.13-6.tbz

and a Readme and a pdf.

These packages provided a cli tool (I believe they also have a gui, and a web version) that allows me to 'unplug' the eSATA.

There is a lot of other functionality, e.g. creating raid arrays, with these packages, but I am only using them to 'unplug' the eSATA.

Together with their command line interface, and camcontrol I was able to cleanly unplug the eSATA.  It is also useful, of course to watch /var/log/messages at every step of the way.

Here's an example of plugging in and unplugging an eSATA
I've intermixed their command line tool with the OS commands, in the order I ran them.

Watch da2 (WDC WD10EALS-00Z8A0) apppear, and then disappear.  I will not post /var/log/messages, but it showed no errors.

The eSATA was first powered on (AC), then plugged into the eSATA connection.  Then the following commands were run.  


```
HighPoint CLI>query devices
ID      Capacity    MaxFree     Flag    Status    ModelNumber
-------------------------------------------------------------------------------
1/3     1000.20     0           SINGLE  LEGACY    ST31000528AS
1/4     1000.20     0           SINGLE  LEGACY    ST31000528AS
-------------------------------------------------------------------------------
HighPoint CLI>rescan devices
HighPoint CLI>query devices
ID      Capacity    MaxFree     Flag    Status    ModelNumber
-------------------------------------------------------------------------------
1/2     1000.20     0           SINGLE  LEGACY    WDC WD10EALS-00Z8A0
1/3     1000.20     0           SINGLE  LEGACY    ST31000528AS
1/4     1000.20     0           SINGLE  LEGACY    ST31000528AS

# camcontrol devlist
<HPT DISK 0_0 4.00>                at scbus0 target 0 lun 0 (pass0,da0)
<HPT DISK 0_1 4.00>                at scbus0 target 1 lun 0 (pass1,da1)
<PIONEER DVD-RW  DVR-218L 1.02>    at scbus1 target 0 lun 0 (pass2,cd0)

# camcontrol rescan all
Re-scan of bus 0 was successful
Re-scan of bus 1 was successful
Re-scan of bus 2 was successful
Re-scan of bus 3 was successful
Re-scan of bus 4 was successful
Re-scan of bus 5 was successful

# camcontrol devlist
<HPT DISK 0_0 4.00>                at scbus0 target 0 lun 0 (pass0,da0)
<HPT DISK 0_1 4.00>                at scbus0 target 1 lun 0 (pass1,da1)
<HPT DISK 0_2 4.00>                at scbus0 target 2 lun 0 (da2,pass3)
<PIONEER DVD-RW  DVR-218L 1.02>    at scbus1 target 0 lun 0 (pass2,cd0)

# echo starting the unplug sequence
starting the unplug sequence

# camcontrol eject da2
Unit stopped successfully, Media ejected

HighPoint CLI>unplug 1/2
HighPoint CLI>query devices
ID      Capacity    MaxFree     Flag    Status    ModelNumber
-------------------------------------------------------------------------------
1/3     1000.20     0           SINGLE  LEGACY    ST31000528AS
1/4     1000.20     0           SINGLE  LEGACY    ST31000528AS
-------------------------------------------------------------------------------

# camcontrol rescan all
Re-scan of bus 0 was successful
Re-scan of bus 1 was successful
Re-scan of bus 2 was successful
Re-scan of bus 3 was successful
Re-scan of bus 4 was successful
Re-scan of bus 5 was successful

# camcontrol devlist
<HPT DISK 0_0 4.00>                at scbus0 target 0 lun 0 (pass0,da0)
<HPT DISK 0_1 4.00>                at scbus0 target 1 lun 0 (pass1,da1)
<PIONEER DVD-RW  DVR-218L 1.02>    at scbus1 target 0 lun 0 (pass2,cd0)
```

After this sequence of commands, the eSATA was unplugged from the eSATA connection, and then powered down, in that order.

Thanks everyone for help thinking through this
-- johnedstone


----------

