spin_lock_irqsave(&ap->host_set->lock, flags);
 
+       /* no internal command while frozen */
+       if (ap->flags & ATA_FLAG_FROZEN) {
+               spin_unlock_irqrestore(&ap->host_set->lock, flags);
+               return AC_ERR_SYSTEM;
+       }
+
        /* initialize internal qc */
 
        /* XXX: Tag 0 is used for drivers with legacy EH as some
                sata_scr_write(ap, SCR_ERROR, serror);
 
        /* re-enable interrupts */
-       if (ap->ioaddr.ctl_addr)        /* FIXME: hack. create a hook instead */
-               ata_irq_on(ap);
+       if (!ap->ops->error_handler) {
+               /* FIXME: hack. create a hook instead */
+               if (ap->ioaddr.ctl_addr)
+                       ata_irq_on(ap);
+       }
 
        /* is double-select really necessary? */
        if (classes[0] != ATA_DEV_NONE)
 {
        int rc = -EINVAL;
 
+       ata_eh_freeze_port(ap);
+
        if (probeinit)
                probeinit(ap);
 
        if (rc == 0) {
                if (postreset)
                        postreset(ap, classes);
+
+               ata_eh_thaw_port(ap);
+
                if (classes[0] == ATA_DEV_UNKNOWN)
                        rc = -ENODEV;
        }
        struct ata_queued_cmd *qc = NULL;
        unsigned int i;
 
+       /* no command while frozen */
+       if (unlikely(ap->flags & ATA_FLAG_FROZEN))
+               return NULL;
+
        /* the last tag is reserved for internal command. */
        for (i = 0; i < ATA_MAX_QUEUE - 1; i++)
                if (!test_and_set_bit(i, &ap->qactive)) {
 
                ata_chk_status(ap);
                host_set->ops->irq_clear(ap);
+               ata_eh_freeze_port(ap); /* freeze port before requesting IRQ */
                count++;
        }
 
 EXPORT_SYMBOL_GPL(ata_eng_timeout);
 EXPORT_SYMBOL_GPL(ata_port_schedule_eh);
 EXPORT_SYMBOL_GPL(ata_port_abort);
+EXPORT_SYMBOL_GPL(ata_port_freeze);
+EXPORT_SYMBOL_GPL(ata_eh_freeze_port);
+EXPORT_SYMBOL_GPL(ata_eh_thaw_port);
 EXPORT_SYMBOL_GPL(ata_eh_qc_complete);
 EXPORT_SYMBOL_GPL(ata_eh_qc_retry);
 
        return nr_aborted;
 }
 
+/**
+ *     __ata_port_freeze - freeze port
+ *     @ap: ATA port to freeze
+ *
+ *     This function is called when HSM violation or some other
+ *     condition disrupts normal operation of the port.  Frozen port
+ *     is not allowed to perform any operation until the port is
+ *     thawed, which usually follows a successful reset.
+ *
+ *     ap->ops->freeze() callback can be used for freezing the port
+ *     hardware-wise (e.g. mask interrupt and stop DMA engine).  If a
+ *     port cannot be frozen hardware-wise, the interrupt handler
+ *     must ack and clear interrupts unconditionally while the port
+ *     is frozen.
+ *
+ *     LOCKING:
+ *     spin_lock_irqsave(host_set lock)
+ */
+static void __ata_port_freeze(struct ata_port *ap)
+{
+       WARN_ON(!ap->ops->error_handler);
+
+       if (ap->ops->freeze)
+               ap->ops->freeze(ap);
+
+       ap->flags |= ATA_FLAG_FROZEN;
+
+       DPRINTK("ata%u port frozen\n", ap->id);
+}
+
+/**
+ *     ata_port_freeze - abort & freeze port
+ *     @ap: ATA port to freeze
+ *
+ *     Abort and freeze @ap.
+ *
+ *     LOCKING:
+ *     spin_lock_irqsave(host_set lock)
+ *
+ *     RETURNS:
+ *     Number of aborted commands.
+ */
+int ata_port_freeze(struct ata_port *ap)
+{
+       int nr_aborted;
+
+       WARN_ON(!ap->ops->error_handler);
+
+       nr_aborted = ata_port_abort(ap);
+       __ata_port_freeze(ap);
+
+       return nr_aborted;
+}
+
+/**
+ *     ata_eh_freeze_port - EH helper to freeze port
+ *     @ap: ATA port to freeze
+ *
+ *     Freeze @ap.
+ *
+ *     LOCKING:
+ *     None.
+ */
+void ata_eh_freeze_port(struct ata_port *ap)
+{
+       unsigned long flags;
+
+       if (!ap->ops->error_handler)
+               return;
+
+       spin_lock_irqsave(&ap->host_set->lock, flags);
+       __ata_port_freeze(ap);
+       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+}
+
+/**
+ *     ata_port_thaw_port - EH helper to thaw port
+ *     @ap: ATA port to thaw
+ *
+ *     Thaw frozen port @ap.
+ *
+ *     LOCKING:
+ *     None.
+ */
+void ata_eh_thaw_port(struct ata_port *ap)
+{
+       unsigned long flags;
+
+       if (!ap->ops->error_handler)
+               return;
+
+       spin_lock_irqsave(&ap->host_set->lock, flags);
+
+       ap->flags &= ~ATA_FLAG_FROZEN;
+
+       if (ap->ops->thaw)
+               ap->ops->thaw(ap);
+
+       spin_unlock_irqrestore(&ap->host_set->lock, flags);
+
+       DPRINTK("ata%u port thawed\n", ap->id);
+}
+
 static void ata_eh_scsidone(struct scsi_cmnd *scmd)
 {
        /* nada */