From c1fd1d86dc5671c5b29e86a58938fe42e1f9212c Mon Sep 17 00:00:00 2001 From: Matthew Dillon Date: Mon, 10 Jun 2013 17:15:21 -0700 Subject: [PATCH] AHCI - Fix panic if additional I/O is queued during SATA error processing. * If additional I/O is queued during SATA error processing the AHCI driver was improperly trying to initiate the new I/O. This caused the error processing code to assert on unexpected command activity. * Fix by implying exclusive access mode when the error CCB is in use and giving the error CCB queueing priority over all other CCBs. --- sys/dev/disk/ahci/ahci.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/sys/dev/disk/ahci/ahci.c b/sys/dev/disk/ahci/ahci.c index 7e269a701d..8661259850 100644 --- a/sys/dev/disk/ahci/ahci.c +++ b/sys/dev/disk/ahci/ahci.c @@ -2174,9 +2174,18 @@ ahci_issue_pending_commands(struct ahci_port *ap, struct ahci_ccb *ccb) /* * Pull the next ccb off the queue and run it if possible. + * + * The error CCB supercedes all normal queue operations and + * implies exclusive access while the error CCB is active. */ - if ((ccb = TAILQ_FIRST(&ap->ap_ccb_pending)) == NULL) - return; + if (ccb != ap->ap_err_ccb) { + if ((ccb = TAILQ_FIRST(&ap->ap_ccb_pending)) == NULL) + return; + if (ap->ap_flags & AP_F_ERR_CCB_RESERVED) { + kprintf("DELAY CCB slot %d\n", ccb->ccb_slot); + return; + } + } /* * Handle exclusivity requirements. -- 2.41.0