oxnas: prepare for kernel 4.1
[openwrt.git] / target / linux / oxnas / patches-4.1 / 999-libata-hacks.patch
1 --- a/drivers/ata/libata-core.c
2 +++ b/drivers/ata/libata-core.c
3 @@ -1589,6 +1589,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 @@ -4781,6 +4789,9 @@ struct ata_queued_cmd *ata_qc_new_init(s
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         /* libsas case */
26         if (ap->flags & ATA_FLAG_SAS_HOST) {
27                 tag = ata_sas_allocate_tag(ap);
28 @@ -4826,6 +4837,8 @@ void ata_qc_free(struct ata_queued_cmd *
29                 qc->tag = ATA_TAG_POISON;
30                 if (ap->flags & ATA_FLAG_SAS_HOST)
31                         ata_sas_free_tag(tag, ap);
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 @@ -902,6 +902,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 @@ -992,6 +994,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.