linux-ide.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc
@ 2011-04-24 19:28 James Bottomley
  2011-04-24 19:30 ` [PATCH 1/2] pata_cm64x: fix boot crash " James Bottomley
                   ` (2 more replies)
  0 siblings, 3 replies; 6+ messages in thread
From: James Bottomley @ 2011-04-24 19:28 UTC (permalink / raw)
  To: linux-ide; +Cc: Parisc List, Alan Cox, Sergei Shtylyov

currently libata-sff is completely ignoring the enabled/disabled status
of the interfaces.  This is a real problem on parisc because if you
touch a non responding memory area (i.e. a disabled interface) you crash
the box.

Fix by checking the CNTRL bits to see if the port is enabled before
trying to poke it.

James

---

James Bottomley (2):
  pata_cm64x: fix boot crash on parisc
  libata-sff: prevent irq descriptions for dummy ports

 drivers/ata/libata-sff.c  |    9 +++++++--
 drivers/ata/pata_cmd64x.c |   42 ++++++++++++++++++++++++++++++++++++++----
 include/linux/pci_ids.h   |    2 ++
 3 files changed, 47 insertions(+), 6 deletions(-)

-- 
1.7.4.1




^ permalink raw reply	[flat|nested] 6+ messages in thread

* [PATCH 1/2] pata_cm64x: fix boot crash on parisc
  2011-04-24 19:28 [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc James Bottomley
@ 2011-04-24 19:30 ` James Bottomley
  2011-04-24 19:31 ` [PATCH 0/2] libata-sff: prevent irq descriptions for dummy ports James Bottomley
  2011-05-13 17:01 ` [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc James Bottomley
  2 siblings, 0 replies; 6+ messages in thread
From: James Bottomley @ 2011-04-24 19:30 UTC (permalink / raw)
  To: linux-ide; +Cc: Parisc List, Alan Cox, Sergei Shtylyov

The old IDE cmd64x checks the status of the CNTRL register to see if
the ports are enabled before probing them.  pata_cmd64x doesn't do
this, which causes a HPMC on parisc when it tries to poke at the
secondary port because apparently the BAR isn't wired up (and a
non-responding piece of memory causes a HPMC).

Fix this by porting the CNTRL register port detection logic from IDE
cmd64x.  In addition, following converns from Alan Cox, add a check to
see if a mobility electronics bridge is the immediate parent and forgo
the check if it is (prevents problems on hotplug controllers).

Signed-off-by: James Bottomley <James.Bottomley@suse.de>
---
 drivers/ata/pata_cmd64x.c |   42 ++++++++++++++++++++++++++++++++++++++----
 include/linux/pci_ids.h   |    2 ++
 2 files changed, 40 insertions(+), 4 deletions(-)

diff --git a/drivers/ata/pata_cmd64x.c b/drivers/ata/pata_cmd64x.c
index 905ff76..7bafc16 100644
--- a/drivers/ata/pata_cmd64x.c
+++ b/drivers/ata/pata_cmd64x.c
@@ -41,6 +41,9 @@
 enum {
 	CFR 		= 0x50,
 		CFR_INTR_CH0  = 0x04,
+	CNTRL		= 0x51,
+		CNTRL_CH0     = 0x04,
+		CNTRL_CH1     = 0x08,
 	CMDTIM 		= 0x52,
 	ARTTIM0 	= 0x53,
 	DRWTIM0 	= 0x54,
@@ -328,9 +331,19 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 			.port_ops = &cmd648_port_ops
 		}
 	};
-	const struct ata_port_info *ppi[] = { &cmd_info[id->driver_data], NULL };
-	u8 mrdmode;
+	const struct ata_port_info *ppi[] = { 
+		&cmd_info[id->driver_data],
+		&cmd_info[id->driver_data],
+		NULL
+	};
+	u8 mrdmode, reg;
 	int rc;
+	struct pci_dev *bridge = pdev->bus->self;
+	/* mobility split bridges don't report enabled ports correctly */
+	int port_ok = !(bridge && bridge->vendor ==
+			PCI_VENDOR_ID_MOBILITY_ELECTRONICS);
+	/* all (with exceptions below) apart from 643 have CNTRL_CH0 bit */
+	int cntrl_ch0_ok = (id->driver_data != 0);
 
 	rc = pcim_enable_device(pdev);
 	if (rc)
@@ -341,11 +354,18 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 
 	if (pdev->device == PCI_DEVICE_ID_CMD_646) {
 		/* Does UDMA work ? */
-		if (pdev->revision > 4)
+		if (pdev->revision > 4) {
 			ppi[0] = &cmd_info[2];
+			ppi[1] = &cmd_info[2];
+		}
 		/* Early rev with other problems ? */
-		else if (pdev->revision == 1)
+		else if (pdev->revision == 1) {
 			ppi[0] = &cmd_info[3];
+			ppi[1] = &cmd_info[3];
+		}
+		/* revs 1,2 have no CNTRL_CH0 */
+		if (pdev->revision < 3)
+			cntrl_ch0_ok = 0;
 	}
 
 	pci_write_config_byte(pdev, PCI_LATENCY_TIMER, 64);
@@ -354,6 +374,20 @@ static int cmd64x_init_one(struct pci_dev *pdev, const struct pci_device_id *id)
 	mrdmode |= 0x02;	/* Memory read line enable */
 	pci_write_config_byte(pdev, MRDMODE, mrdmode);
 
+	/* check for enabled ports */
+	pci_read_config_byte(pdev, CNTRL, &reg);
+	if (!port_ok)
+		dev_printk(KERN_NOTICE, &pdev->dev, "Mobility Bridge detected, ignoring CNTRL port enable/disable\n");
+	if (port_ok && cntrl_ch0_ok && !(reg & CNTRL_CH0)) {
+		dev_printk(KERN_NOTICE, &pdev->dev, "Primary port is disabled\n");
+		ppi[0] = &ata_dummy_port_info;
+		
+	}
+	if (port_ok && !(reg & CNTRL_CH1)) {
+		dev_printk(KERN_NOTICE, &pdev->dev, "Secondary port is disabled\n");
+		ppi[1] = &ata_dummy_port_info;
+	}
+
 	/* Force PIO 0 here.. */
 
 	/* PPC specific fixup copied from old driver */
diff --git a/include/linux/pci_ids.h b/include/linux/pci_ids.h
index 4e2c915..7a0ac45 100644
--- a/include/linux/pci_ids.h
+++ b/include/linux/pci_ids.h
@@ -608,6 +608,8 @@
 #define PCI_DEVICE_ID_MATROX_G550	0x2527
 #define PCI_DEVICE_ID_MATROX_VIA	0x4536
 
+#define PCI_VENDOR_ID_MOBILITY_ELECTRONICS	0x14f2
+
 #define PCI_VENDOR_ID_CT		0x102c
 #define PCI_DEVICE_ID_CT_69000		0x00c0
 #define PCI_DEVICE_ID_CT_65545		0x00d8
-- 
1.7.4.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 0/2] libata-sff: prevent irq descriptions for dummy ports
  2011-04-24 19:28 [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc James Bottomley
  2011-04-24 19:30 ` [PATCH 1/2] pata_cm64x: fix boot crash " James Bottomley
@ 2011-04-24 19:31 ` James Bottomley
  2011-05-13 17:01 ` [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc James Bottomley
  2 siblings, 0 replies; 6+ messages in thread
From: James Bottomley @ 2011-04-24 19:31 UTC (permalink / raw)
  To: linux-ide; +Cc: Parisc List, Alan Cox, Sergei Shtylyov

This is a cosmetic change to prevent libata-sff adding irq
descriptions to dummy ports, since the information, while largely
unused, is erroneous.

Signed-off-by: James Bottomley <James.Bottomley@suse.de>
---
 drivers/ata/libata-sff.c |    9 +++++++--
 1 files changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c
index f8380ce..b1b926c 100644
--- a/drivers/ata/libata-sff.c
+++ b/drivers/ata/libata-sff.c
@@ -2447,13 +2447,18 @@ int ata_pci_sff_activate_host(struct ata_host *host,
 		return -ENOMEM;
 
 	if (!legacy_mode && pdev->irq) {
+		int i;
+
 		rc = devm_request_irq(dev, pdev->irq, irq_handler,
 				      IRQF_SHARED, drv_name, host);
 		if (rc)
 			goto out;
 
-		ata_port_desc(host->ports[0], "irq %d", pdev->irq);
-		ata_port_desc(host->ports[1], "irq %d", pdev->irq);
+		for (i = 0; i < 2; i++) {
+			if (ata_port_is_dummy(host->ports[i]))
+				continue;
+			ata_port_desc(host->ports[i], "irq %d", pdev->irq);
+		}
 	} else if (legacy_mode) {
 		if (!ata_port_is_dummy(host->ports[0])) {
 			rc = devm_request_irq(dev, ATA_PRIMARY_IRQ(pdev),
-- 
1.7.4.1




^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc
  2011-04-24 19:28 [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc James Bottomley
  2011-04-24 19:30 ` [PATCH 1/2] pata_cm64x: fix boot crash " James Bottomley
  2011-04-24 19:31 ` [PATCH 0/2] libata-sff: prevent irq descriptions for dummy ports James Bottomley
@ 2011-05-13 17:01 ` James Bottomley
  2011-05-14 19:01   ` Jeff Garzik
  2 siblings, 1 reply; 6+ messages in thread
From: James Bottomley @ 2011-05-13 17:01 UTC (permalink / raw)
  To: linux-ide; +Cc: Parisc List, Alan Cox, Sergei Shtylyov

On Sun, 2011-04-24 at 14:28 -0500, James Bottomley wrote:
> currently libata-sff is completely ignoring the enabled/disabled status
> of the interfaces.  This is a real problem on parisc because if you
> touch a non responding memory area (i.e. a disabled interface) you crash
> the box.
> 
> Fix by checking the CNTRL bits to see if the port is enabled before
> trying to poke it.

Ping on this.

Since 1/2 is an essential fix to prevent a boot panic on parisc, I can
just take them through the parisc tree.

James


> James
> 
> ---
> 
> James Bottomley (2):
>   pata_cm64x: fix boot crash on parisc
>   libata-sff: prevent irq descriptions for dummy ports
> 
>  drivers/ata/libata-sff.c  |    9 +++++++--
>  drivers/ata/pata_cmd64x.c |   42 ++++++++++++++++++++++++++++++++++++++----
>  include/linux/pci_ids.h   |    2 ++
>  3 files changed, 47 insertions(+), 6 deletions(-)
> 



^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc
  2011-05-13 17:01 ` [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc James Bottomley
@ 2011-05-14 19:01   ` Jeff Garzik
  2011-07-15 15:45     ` Sergei Shtylyov
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff Garzik @ 2011-05-14 19:01 UTC (permalink / raw)
  To: James Bottomley; +Cc: linux-ide, Parisc List, Alan Cox, Sergei Shtylyov

On 05/13/2011 01:01 PM, James Bottomley wrote:
> On Sun, 2011-04-24 at 14:28 -0500, James Bottomley wrote:
>> currently libata-sff is completely ignoring the enabled/disabled status
>> of the interfaces.  This is a real problem on parisc because if you
>> touch a non responding memory area (i.e. a disabled interface) you crash
>> the box.
>>
>> Fix by checking the CNTRL bits to see if the port is enabled before
>> trying to poke it.
>
> Ping on this.
>
> Since 1/2 is an essential fix to prevent a boot panic on parisc, I can
> just take them through the parisc tree.

It's in libata-dev.git#upstream and #NEXT (linux-next) at present.

	Jeff




^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc
  2011-05-14 19:01   ` Jeff Garzik
@ 2011-07-15 15:45     ` Sergei Shtylyov
  0 siblings, 0 replies; 6+ messages in thread
From: Sergei Shtylyov @ 2011-07-15 15:45 UTC (permalink / raw)
  To: Jeff Garzik
  Cc: James Bottomley, linux-ide, Parisc List, Alan Cox,
	Sergei Shtylyov

Hello.

Jeff Garzik wrote:

>> On Sun, 2011-04-24 at 14:28 -0500, James Bottomley wrote:
>>> currently libata-sff is completely ignoring the enabled/disabled status
>>> of the interfaces.  This is a real problem on parisc because if you
>>> touch a non responding memory area (i.e. a disabled interface) you crash
>>> the box.

>>> Fix by checking the CNTRL bits to see if the port is enabled before
>>> trying to poke it.

>> Ping on this.

>> Since 1/2 is an essential fix to prevent a boot panic on parisc, I can
>> just take them through the parisc tree.

> It's in libata-dev.git#upstream and #NEXT (linux-next) at present.

    I'm wondering about the other drivers that check the channel enable bits in 
their prereset() methods. James has shown that such code would still crash on 
such platforms as PARISC (I suspect many more platfroms which don't silently 
ignore the target aborts in the PCI space like x86 does). I think all such 
drivers should be converted to the early port disable detection scheme used in 
the pata_cmd64x driver (an some others)...

>     Jeff

WBR, Sergei


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2011-07-15 15:47 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-04-24 19:28 [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc James Bottomley
2011-04-24 19:30 ` [PATCH 1/2] pata_cm64x: fix boot crash " James Bottomley
2011-04-24 19:31 ` [PATCH 0/2] libata-sff: prevent irq descriptions for dummy ports James Bottomley
2011-05-13 17:01 ` [PATCH 0/2] fix libata-sff and pata_cmd64x to not crash on boot on parisc James Bottomley
2011-05-14 19:01   ` Jeff Garzik
2011-07-15 15:45     ` Sergei Shtylyov

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).