* [PATCH] libata-sff: Don't try and activate channels which are not in use
@ 2007-01-08 12:10 Alan
2007-01-09 10:40 ` Jeff Garzik
0 siblings, 1 reply; 2+ messages in thread
From: Alan @ 2007-01-08 12:10 UTC (permalink / raw)
To: akpm, jgarzik, linux-kernel
An ATA controller in native mode may have one or more channels disabled
and not assigned resources. In that case the existing code crashes trying
to access I/O ports 0-7.
Add the neccessary check.
Signed-off-by: Alan Cox <alan@redhat.com>
diff -u --new-file --recursive --exclude-from /usr/src/exclude linux.vanilla-2.6.20-rc3-mm1/drivers/ata/libata-sff.c linux-2.6.20-rc3-mm1/drivers/ata/libata-sff.c
--- linux.vanilla-2.6.20-rc3-mm1/drivers/ata/libata-sff.c 2007-01-05 13:09:36.000000000 +0000
+++ linux-2.6.20-rc3-mm1/drivers/ata/libata-sff.c 2007-01-05 14:08:32.000000000 +0000
@@ -831,6 +831,21 @@
}
#ifdef CONFIG_PCI
+
+static int ata_resources_present(struct pci_dev *pdev, int port)
+{
+ int i;
+
+ /* Check the PCI resources for this channel are enabled */
+ port = port * 2;
+ for (i = 0; i < 2; i ++) {
+ if (pci_resource_start(pdev, port + i) == 0 ||
+ pci_resource_len(pdev, port + i) == 0)
+ return 0;
+ }
+ return 1;
+}
+
/**
* ata_pci_init_native_mode - Initialize native-mode driver
* @pdev: pci device to be initialized
@@ -862,6 +877,13 @@
probe_ent->irq = pdev->irq;
probe_ent->irq_flags = IRQF_SHARED;
+
+ /* Discard disabled ports. Some controllers show their
+ unused channels this way */
+ if (ata_resources_present(pdev, 0) == 0)
+ ports &= ~ATA_PORT_PRIMARY;
+ if (ata_resources_present(pdev, 1) == 0)
+ ports &= ~ATA_PORT_SECONDARY;
if (ports & ATA_PORT_PRIMARY) {
probe_ent->port[p].cmd_addr = pci_resource_start(pdev, 0);
^ permalink raw reply [flat|nested] 2+ messages in thread
* Re: [PATCH] libata-sff: Don't try and activate channels which are not in use
2007-01-08 12:10 [PATCH] libata-sff: Don't try and activate channels which are not in use Alan
@ 2007-01-09 10:40 ` Jeff Garzik
0 siblings, 0 replies; 2+ messages in thread
From: Jeff Garzik @ 2007-01-09 10:40 UTC (permalink / raw)
To: Alan; +Cc: akpm, linux-kernel
Alan wrote:
> An ATA controller in native mode may have one or more channels disabled
> and not assigned resources. In that case the existing code crashes trying
> to access I/O ports 0-7.
>
> Add the neccessary check.
>
> Signed-off-by: Alan Cox <alan@redhat.com>
applied. perfect form, except for the whitespace:
Applying 'libata-sff: Don't try and activate channels which are not in use'
Adds trailing whitespace.
.dotest/patch:12:
Adds trailing whitespace.
.dotest/patch:22:
Adds trailing whitespace.
.dotest/patch:30:
warning: 3 lines add trailing whitespaces.
Wrote tree 209dcf80a25abdd730fc84f379ba7b4981ca8249
Committed: 0711dff09b21432c70a0c44fa5110b38da28385b
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2007-01-09 10:40 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-01-08 12:10 [PATCH] libata-sff: Don't try and activate channels which are not in use Alan
2007-01-09 10:40 ` Jeff Garzik
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox