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