CC: kernel: update 3.18 to 3.18.20
[15.05/openwrt.git] / target / linux / oxnas / patches-3.18 / 999-libata-hacks.patch
1 --- a/drivers/ata/libata-core.c
2 +++ b/drivers/ata/libata-core.c
3 @@ -1581,6 +1581,14 @@ unsigned ata_exec_internal_sg(struct ata
4                 return AC_ERR_SYSTEM;
5         }
6  
7 +       if (ap->ops->acquire_hw && !ap->ops->acquire_hw(ap, 0, 0)) {
8 +               spin_unlock_irqrestore(ap->lock, flags);
9 +               if (!ap->ops->acquire_hw(ap, 1, (2*HZ))) {
10 +                       return AC_ERR_TIMEOUT;
11 +               }
12 +               spin_lock_irqsave(ap->lock, flags);
13 +       }
14 +
15         /* initialize internal qc */
16  
17         /* XXX: Tag 0 is used for drivers with legacy EH as some
18 @@ -4757,6 +4765,9 @@ static struct ata_queued_cmd *ata_qc_new
19         if (unlikely(ap->pflags & ATA_PFLAG_FROZEN))
20                 return NULL;
21  
22 +       if (ap->ops->qc_new && ap->ops->qc_new(ap))
23 +               return NULL;
24 +
25         for (i = 0, tag = ap->last_tag + 1; i < max_queue; i++, tag++) {
26                 if (ap->flags & ATA_FLAG_LOWTAG)
27                         tag = i;
28 @@ -4829,6 +4840,8 @@ void ata_qc_free(struct ata_queued_cmd *
29         if (likely(ata_tag_valid(tag))) {
30                 qc->tag = ATA_TAG_POISON;
31                 clear_bit(tag, &ap->qc_allocated);
32 +               if (ap->ops->qc_free)
33 +                       ap->ops->qc_free(qc);
34         }
35  }
36  
37 --- a/include/linux/libata.h
38 +++ b/include/linux/libata.h
39 @@ -901,6 +901,8 @@ struct ata_port_operations {
40         void (*qc_prep)(struct ata_queued_cmd *qc);
41         unsigned int (*qc_issue)(struct ata_queued_cmd *qc);
42         bool (*qc_fill_rtf)(struct ata_queued_cmd *qc);
43 +       int (*qc_new)(struct ata_port *ap);
44 +       void (*qc_free)(struct ata_queued_cmd *qc);
45  
46         /*
47          * Configuration and exception handling
48 @@ -991,6 +993,9 @@ struct ata_port_operations {
49         void (*phy_reset)(struct ata_port *ap);
50         void (*eng_timeout)(struct ata_port *ap);
51  
52 +       int (*acquire_hw)(struct ata_port *ap, int may_sleep,
53 +                         int timeout_jiffies);
54 +
55         /*
56          * ->inherits must be the last field and all the preceding
57          * fields must be pointers.