]> git.proxmox.com Git - pve-kernel-2.6.32.git/blob - ata_generic-implement-ATA_GEN_-flags-and-force-enable-DMA-on-MBP-7,1.patch
update to vzkernel-2.6.32-042stab045.1.src.rpm
[pve-kernel-2.6.32.git] / ata_generic-implement-ATA_GEN_-flags-and-force-enable-DMA-on-MBP-7,1.patch
1 [Backported to Debian's 2.6.32 by dann frazier <dannf@debian.org>]
2
3 commit 1529c69adce1e95f7ae72f0441590c226bbac7fc
4 Author: Tejun Heo <tj@kernel.org>
5 Date: Tue Jun 22 12:27:26 2010 +0200
6
7 ata_generic: implement ATA_GEN_* flags and force enable DMA on MBP 7,1
8
9 IDE mode of MCP89 on MBP 7,1 doesn't set DMA enable bits in the BMDMA
10 status register. Make the following changes to work around the problem.
11
12 * Instead of using hard coded 1 in id->driver_data as class code
13 match, use ATA_GEN_CLASS_MATCH and carry the matched id in
14 host->private_data.
15
16 * Instead of matching PCI_VENDOR_ID_CENATEK, use ATA_GEN_FORCE_DMA
17 flag in id instead.
18
19 * Add ATA_GEN_FORCE_DMA to the id entry of MBP 7,1.
20
21 Signed-off-by: Tejun Heo <tj@kernel.org>
22 Cc: Peer Chen <pchen@nvidia.com>
23 Cc: stable@kernel.org
24 Reported-by: Anders Ă˜sthus <grapz666@gmail.com>
25 Reported-by: Andreas Graf <andreas_graf@csgraf.de>
26 Reported-by: Benoit Gschwind <gschwind@gnu-log.net>
27 Reported-by: Damien Cassou <damien.cassou@gmail.com>
28 Reported-by: tixetsal@juno.com
29 Signed-off-by: Jeff Garzik <jgarzik@redhat.com>
30
31 diff -urpN a/drivers/ata/ata_generic.c b/drivers/ata/ata_generic.c
32 --- a/drivers/ata/ata_generic.c 2010-10-18 17:18:22.160591155 -0600
33 +++ b/drivers/ata/ata_generic.c 2010-10-18 17:28:35.700130856 -0600
34 @@ -32,6 +32,11 @@
35 * A generic parallel ATA driver using libata
36 */
37
38 +enum {
39 + ATA_GEN_CLASS_MATCH = (1 << 0),
40 + ATA_GEN_FORCE_DMA = (1 << 1),
41 +};
42 +
43 /**
44 * generic_set_mode - mode setting
45 * @link: link to set up
46 @@ -46,13 +51,17 @@
47 static int generic_set_mode(struct ata_link *link, struct ata_device **unused)
48 {
49 struct ata_port *ap = link->ap;
50 + const struct pci_device_id *id = ap->host->private_data;
51 int dma_enabled = 0;
52 struct ata_device *dev;
53 struct pci_dev *pdev = to_pci_dev(ap->host->dev);
54
55 - /* Bits 5 and 6 indicate if DMA is active on master/slave */
56 - if (ap->ioaddr.bmdma_addr)
57 + if (id->driver_data & ATA_GEN_FORCE_DMA) {
58 + dma_enabled = 0xff;
59 + } else if (ap->ioaddr.bmdma_addr) {
60 + /* Bits 5 and 6 indicate if DMA is active on master/slave */
61 dma_enabled = ioread8(ap->ioaddr.bmdma_addr + ATA_DMA_STATUS);
62 + }
63
64 if (pdev->vendor == PCI_VENDOR_ID_CENATEK)
65 dma_enabled = 0xFF;
66 @@ -126,7 +135,7 @@ static int ata_generic_init_one(struct p
67 const struct ata_port_info *ppi[] = { &info, NULL };
68
69 /* Don't use the generic entry unless instructed to do so */
70 - if (id->driver_data == 1 && all_generic_ide == 0)
71 + if ((id->driver_data & ATA_GEN_CLASS_MATCH) && all_generic_ide == 0)
72 return -ENODEV;
73
74 /* Devices that need care */
75 @@ -155,7 +164,7 @@ static int ata_generic_init_one(struct p
76 return rc;
77 pcim_pin_device(dev);
78 }
79 - return ata_pci_sff_init_one(dev, ppi, &generic_sht, NULL);
80 + return ata_pci_sff_init_one(dev, ppi, &generic_sht, (void *)id);
81 }
82
83 static struct pci_device_id ata_generic[] = {
84 @@ -167,18 +176,21 @@ static struct pci_device_id ata_generic[
85 { PCI_DEVICE(PCI_VENDOR_ID_HINT, PCI_DEVICE_ID_HINT_VXPROII_IDE), },
86 { PCI_DEVICE(PCI_VENDOR_ID_VIA, PCI_DEVICE_ID_VIA_82C561), },
87 { PCI_DEVICE(PCI_VENDOR_ID_OPTI, PCI_DEVICE_ID_OPTI_82C558), },
88 - { PCI_DEVICE(PCI_VENDOR_ID_CENATEK,PCI_DEVICE_ID_CENATEK_IDE), },
89 + { PCI_DEVICE(PCI_VENDOR_ID_CENATEK,PCI_DEVICE_ID_CENATEK_IDE),
90 + .driver_data = ATA_GEN_FORCE_DMA },
91 /*
92 * For some reason, MCP89 on MacBook 7,1 doesn't work with
93 * ahci, use ata_generic instead.
94 */
95 { PCI_VENDOR_ID_NVIDIA, PCI_DEVICE_ID_NVIDIA_NFORCE_MCP89_SATA,
96 - PCI_VENDOR_ID_APPLE, 0xcb89, },
97 + PCI_VENDOR_ID_APPLE, 0xcb89,
98 + .driver_data = ATA_GEN_FORCE_DMA },
99 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO), },
100 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_1), },
101 { PCI_DEVICE(PCI_VENDOR_ID_TOSHIBA,PCI_DEVICE_ID_TOSHIBA_PICCOLO_2), },
102 /* Must come last. If you add entries adjust this table appropriately */
103 - { PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_ANY_ID, PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL, 1},
104 + { PCI_DEVICE_CLASS(PCI_CLASS_STORAGE_IDE << 8, 0xFFFFFF00UL),
105 + .driver_data = ATA_GEN_CLASS_MATCH },
106 { 0, },
107 };
108