]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/2.6.38.8/pata_cm64x-fix-boot-crash-on-parisc.patch
Fixes for 4.19
[thirdparty/kernel/stable-queue.git] / releases / 2.6.38.8 / pata_cm64x-fix-boot-crash-on-parisc.patch
1 From 9281b16caac1276817b77033c5b8a1f5ca30102c Mon Sep 17 00:00:00 2001
2 From: James Bottomley <James.Bottomley@suse.de>
3 Date: Sun, 24 Apr 2011 14:30:14 -0500
4 Subject: pata_cm64x: fix boot crash on parisc
5
6 From: James Bottomley <James.Bottomley@suse.de>
7
8 commit 9281b16caac1276817b77033c5b8a1f5ca30102c upstream.
9
10 The old IDE cmd64x checks the status of the CNTRL register to see if
11 the ports are enabled before probing them. pata_cmd64x doesn't do
12 this, which causes a HPMC on parisc when it tries to poke at the
13 secondary port because apparently the BAR isn't wired up (and a
14 non-responding piece of memory causes a HPMC).
15
16 Fix this by porting the CNTRL register port detection logic from IDE
17 cmd64x. In addition, following converns from Alan Cox, add a check to
18 see if a mobility electronics bridge is the immediate parent and forgo
19 the check if it is (prevents problems on hotplug controllers).
20
21 Signed-off-by: James Bottomley <James.Bottomley@suse.de>
22 Signed-off-by: Jeff Garzik <jgarzik@pobox.com>
23 Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
24
25 ---
26 drivers/ata/pata_cmd64x.c | 42 ++++++++++++++++++++++++++++++++++++++----
27 include/linux/pci_ids.h | 2 ++
28 2 files changed, 40 insertions(+), 4 deletions(-)
29
30 --- a/drivers/ata/pata_cmd64x.c
31 +++ b/drivers/ata/pata_cmd64x.c
32 @@ -41,6 +41,9 @@
33 enum {
34 CFR = 0x50,
35 CFR_INTR_CH0 = 0x04,
36 + CNTRL = 0x51,
37 + CNTRL_CH0 = 0x04,
38 + CNTRL_CH1 = 0x08,
39 CMDTIM = 0x52,
40 ARTTIM0 = 0x53,
41 DRWTIM0 = 0x54,
42 @@ -328,9 +331,19 @@ static int cmd64x_init_one(struct pci_de
43 .port_ops = &cmd648_port_ops
44 }
45 };
46 - const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL };
47 - u8 mrdmode;
48 + const struct ata_port_info *ppi[] = {
49 + &cmd_info[id->driver_data],
50 + &cmd_info[id->driver_data],
51 + NULL
52 + };
53 + u8 mrdmode, reg;
54 int rc;
55 + struct pci_dev *bridge = pdev->bus->self;
56 + /* mobility split bridges don't report enabled ports correctly */
57 + int port_ok = !(bridge && bridge->vendor ==
58 + PCI_VENDOR_ID_MOBILITY_ELECTRONICS);
59 + /* all (with exceptions below) apart from 643 have CNTRL_CH0 bit */
60 + int cntrl_ch0_ok = (id->driver_data != 0);
61
62 rc = pcim_enable_device(pdev);
63 if (rc)
64 @@ -341,11 +354,18 @@ static int cmd64x_init_one(struct pci_de
65
66 if (pdev->device == PCI_DEVICE_ID_CMD_646) {
67 /* Does UDMA work ? */
68 - if (pdev->revision > 4)
69 + if (pdev->revision > 4) {
70 ppi[0] = &cmd_info[2];
71 + ppi[1] = &cmd_info[2];
72 + }
73 /* Early rev with other problems ? */
74 - else if (pdev->revision == 1)
75 + else if (pdev->revision == 1) {
76 ppi[0] = &cmd_info[3];
77 + ppi[1] = &cmd_info[3];
78 + }
79 + /* revs 1,2 have no CNTRL_CH0 */
80 + if (pdev->revision < 3)
81 + cntrl_ch0_ok = 0;
82 }
83
84 pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
85 @@ -354,6 +374,20 @@ static int cmd64x_init_one(struct pci_de
86 mrdmode |= 0x02; /* Memory read line enable */
87 pci_write_config_byte(pdev, MRDMODE, mrdmode);
88
89 + /* check for enabled ports */
90 + pci_read_config_byte(pdev, CNTRL, &reg);
91 + if (!port_ok)
92 + dev_printk(KERN_NOTICE, &pdev->dev, "Mobility Bridge detected, ignoring CNTRL port enable/disable\n");
93 + if (port_ok && cntrl_ch0_ok && !(reg & CNTRL_CH0)) {
94 + dev_printk(KERN_NOTICE, &pdev->dev, "Primary port is disabled\n");
95 + ppi[0] = &ata_dummy_port_info;
96 +
97 + }
98 + if (port_ok && !(reg & CNTRL_CH1)) {
99 + dev_printk(KERN_NOTICE, &pdev->dev, "Secondary port is disabled\n");
100 + ppi[1] = &ata_dummy_port_info;
101 + }
102 +
103 /* Force PIO 0 here.. */
104
105 /* PPC specific fixup copied from old driver */
106 --- a/include/linux/pci_ids.h
107 +++ b/include/linux/pci_ids.h
108 @@ -607,6 +607,8 @@
109 #define PCI_DEVICE_ID_MATROX_G550 0x2527
110 #define PCI_DEVICE_ID_MATROX_VIA 0x4536
111
112 +#define PCI_VENDOR_ID_MOBILITY_ELECTRONICS 0x14f2
113 +
114 #define PCI_VENDOR_ID_CT 0x102c
115 #define PCI_DEVICE_ID_CT_69000 0x00c0
116 #define PCI_DEVICE_ID_CT_65545 0x00d8