I am trying to get at least a manually assisted hotplug with use of rmmod/modprobe as the platform does not seem to recognize a hotplugged SATA drive. We compiled the TEGRA AHCI as module and it uses these modules:
I can’t answer, but I would assume this is using a hotplug carrier and not directly plugging into and unplugging from the SATA connector of the Jetson dev carrier. Is this correct? If not, then you probably can’t succeed since the hardware on that connector is itself not capable of hotplug (you’d have to add a carrier with that capability). If you are using a hotplug carrier, then it is still possible software is not set up for hotplug.
Another bug: when there is no drive attached from the start, one can not do rmmod ahci_tegra, as the rmmod will stay forever in uninterruptible call.
A hotplug carier does not feature any electronics so that is not the case. We are hotplugging the drive with a cable on an ASMedia PCIe controller fine (on the same TX2), the process involves an automatic SATA link reset, see this dmesg:
Unplug:
[ 478.607918] ata4: exception Emask 0x10 SAct 0x0 SErr 0x90002 action 0xe frozen
[ 478.615154] ata4: irq_stat 0x00400000, PHY RDY changed
[ 478.620314] ata4: SError: { RecovComm PHYRdyChg 10B8B }
[ 478.625653] ata4: hard resetting link
[ 479.352277] ata4: SATA link down (SStatus 0 SControl 300)
[ 484.356255] ata4: hard resetting link
[ 484.676276] ata4: SATA link down (SStatus 0 SControl 300)
[ 484.681680] ata4: limiting SATA link speed to 1.5 Gbps
[ 489.680260] ata4: hard resetting link
[ 490.000280] ata4: SATA link down (SStatus 0 SControl 310)
[ 490.005689] ata4.00: disabled
[ 490.008679] ata4: EH complete
[ 490.011698] ata4.00: detaching (SCSI 3:0:0:0)
[ 490.016692] sd 3:0:0:0: [sda] Synchronizing SCSI cache
[ 490.021897] sd 3:0:0:0: [sda] Synchronize Cache(10) failed: Result: hostbyte=0x04 driverbyte=0x00
[ 490.030838] sd 3:0:0:0: [sda] Stopping disk
[ 490.035149] sd 3:0:0:0: [sda] Start/Stop Unit failed: Result: hostbyte=0x04 driverbyte=0x00
Plug:
[ 491.322464] ata4: exception Emask 0x10 SAct 0x0 SErr 0x4040000 action 0xe frozen
[ 491.329857] ata4: irq_stat 0x00000040, connection status changed
[ 491.335869] ata4: SError: { CommWake DevExch }
[ 491.340323] ata4: hard resetting link
[ 494.644271] ata4: SATA link up 6.0 Gbps (SStatus 133 SControl 300)
[ 494.650668] ata4.00: supports DRM functions and may not be fully accessible
[ 494.658051] ata4.00: disabling queued TRIM support
[ 494.658056] ata4.00: ATA-9: Samsung SSD 850 EVO 500GB, EMT02B6Q, max UDMA/133
[ 494.665238] ata4.00: 976773168 sectors, multi 1: LBA48 NCQ (depth 31/32), AA
[ 494.672902] ata4.00: supports DRM functions and may not be fully accessible
[ 494.680072] ata4.00: disabling queued TRIM support
[ 494.680417] ata4.00: configured for UDMA/133
[ 494.684689] ata4: EH complete
[ 494.691851] scsi 3:0:0:0: Direct-Access ATA Samsung SSD 850 2B6Q PQ: 0 ANSI: 5
[ 494.700263] sd 3:0:0:0: [sda] 976773168 512-byte logical blocks: (500 GB/466 GiB)
[ 494.707883] sd 3:0:0:0: [sda] Write Protect is off
[ 494.712687] sd 3:0:0:0: [sda] Mode Sense: 00 3a 00 00
[ 494.712732] sd 3:0:0:0: [sda] Write cache: enabled, read cache: enabled, doesn't support DPO or FUA
[ 494.722612] sda: sda1 sda2 < sda5 >
[ 494.726750] sd 3:0:0:0: [sda] Attached SCSI disk
So far as I know a hot-plug carrier provides the equivalent of a power switch which cuts power without surge prior to actually pulling the data cable (electronics modifying the connect/disconnect sequence). Unlocking the drive for removal provides a surge-free unpower prior to pulling the drive/data cable out. Possibly something in the host system can detect power connect/disconnect as well. I believe the connector on the dev board does not directly support connecting/disconnecting on a powered live system.
It does seem you should be able to rmmod ahci_tegra if nothing depends on it, but I’m wondering (just speculating) if module format is fully supported (it could be that you are able to select this in module format, but if there is a bug in this then it might work only when integrated into the kernel). By default this is integrated, not a module. Someone at NVIDIA may be able to verify if CONFIG_SATA_AHCI_TEGRA fully supports kernel module format before trying to debug further.
Please stop dealing with hardware issues we could have. This is not the case - the tests with ASMedia controller are done with the drive powered from the Jetson SATA power port. Yes - the Jetson baseboard lacks two 10-20 ohm pre-charge resistors which would be needed for proper hot plug support, but there are obviously no spikes as the ASMedia controller works. The system does not recognize that the drive is disconnected and lost as it happens with the ASmedia PCIe controller (logs above) - there are absolutely no messages, until the drive is connected back again:
Unplug:
-nothing-
Replug:
[ 153.346506] ata1: exception Emask 0x10 SAct 0x0 SErr 0x59c0000 action 0xe frozen
[ 153.353904] ata1: irq_stat 0x00000040, connection status changed
[ 153.359941] ata1: SError: { CommWake 10B8B Dispar LinkSeq TrStaTrns DevExch }
[ 153.367100] ata1: hard resetting link
[ 157.232776] ata1: SATA link up 3.0 Gbps (SStatus 123 SControl 300)
[ 157.239222] ata1.00: supports DRM functions and may not be fully accessible
[ 157.247124] ata1.00: supports DRM functions and may not be fully accessible
[ 157.254526] ata1.00: configured for UDMA/133
[ 157.272764] ata1: EH complete
If there was no drive at all during boot, there wont be anything detected afterwards.
There is not much about hotplug support in the Parker TRM, but the support of eSATA shall imply that the port will be hotplugged!
Yes, we got the same result trying to hot-swap sata by using insmod/rmmod, we think the hardware controller of TX2 does not implement hot-swap function or the driver code is incomplete.