From: Greg KH <gregkh@suse.de>
To: linux-kernel@vger.kernel.org, stable@kernel.org
Cc: stable-review@kernel.org, torvalds@linux-foundation.org,
akpm@linux-foundation.org, alan@lxorguk.ukuu.org.uk,
Bjorn Helgaas <bjorn.helgaas@hp.com>,
Philippe De Muyter <phdm@macqel.be>,
Adam M Belay <abelay@mit.edu>,
Robert Hancock <hancockrwd@gmail.com>
Subject: [patch 15/30] floppy: request and release only the ports we actually use
Date: Tue, 30 Jun 2009 16:59:59 -0700 [thread overview]
Message-ID: <20090701000358.640178641@mini.kroah.org> (raw)
In-Reply-To: <20090701002817.GA6156@kroah.com>
[-- Attachment #1: floppy-request-and-release-only-the-ports-we-actually-use.patch --]
[-- Type: text/plain, Size: 5812 bytes --]
2.6.27-stable review patch. If anyone has any objections, please let us know.
------------------
From: Philippe De Muyter <phdm@macqel.be>
commit 5a74db06cc8d36a325913aa4968ae169f997a466 upstream.
The floppy driver requests an I/O port it doesn't need, and sometimes this
causes a conflict with a motherboard device reported by PNPBIOS.
This patch makes the floppy driver request and release only the ports it
actually uses. It also factors out the request/release stuff and the
io-ports list so they're all in one place now.
The current floppy driver uses only these ports:
0x3f2 (FD_DOR)
0x3f4 (FD_STATUS)
0x3f5 (FD_DATA)
0x3f7 (FD_DCR/FD_DIR)
but it requests 0x3f2-0x3f5 and 0x3f7, which includes the unused port
0x3f3.
Some BIOSes report 0x3f3 as a motherboard resource. The PNP system driver
reserves that, which causes a conflict when the floppy driver requests
0x3f2-0x3f5 later.
Philippe reported that this conflict broke the floppy driver between
2.6.11 and 2.6.22. His PNPBIOS reports these devices:
$ cat 00:07/id 00:07/resources # motherboard device
PNP0c02
state = active
io 0x80-0x80
io 0x10-0x1f
io 0x22-0x3f
io 0x44-0x5f
io 0x90-0x9f
io 0xa2-0xbf
io 0x3f0-0x3f1
io 0x3f3-0x3f3
$ cat 00:03/id 00:03/resources # floppy device
PNP0700
state = active
io 0x3f4-0x3f5
io 0x3f2-0x3f2
Reference:
http://lkml.org/lkml/2009/1/31/162
Signed-off-by: Bjorn Helgaas <bjorn.helgaas@hp.com>
Signed-off-by: Philippe De Muyter <phdm@macqel.be>
Reported-by: Philippe De Muyter <phdm@macqel.be>
Tested-by: Philippe De Muyter <phdm@macqel.be>
Cc: Adam M Belay <abelay@mit.edu>
Cc: Robert Hancock <hancockrwd@gmail.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@suse.de>
---
drivers/block/floppy.c | 79 ++++++++++++++++++++++++++++++++-----------------
1 file changed, 52 insertions(+), 27 deletions(-)
--- a/drivers/block/floppy.c
+++ b/drivers/block/floppy.c
@@ -552,6 +552,8 @@ static void process_fd_request(void);
static void recalibrate_floppy(void);
static void floppy_shutdown(unsigned long);
+static int floppy_request_regions(int);
+static void floppy_release_regions(int);
static int floppy_grab_irq_and_dma(void);
static void floppy_release_irq_and_dma(void);
@@ -4274,8 +4276,7 @@ static int __init floppy_init(void)
FDCS->rawcmd = 2;
if (user_reset_fdc(-1, FD_RESET_ALWAYS, 0)) {
/* free ioports reserved by floppy_grab_irq_and_dma() */
- release_region(FDCS->address + 2, 4);
- release_region(FDCS->address + 7, 1);
+ floppy_release_regions(fdc);
FDCS->address = -1;
FDCS->version = FDC_NONE;
continue;
@@ -4284,8 +4285,7 @@ static int __init floppy_init(void)
FDCS->version = get_fdc_version();
if (FDCS->version == FDC_NONE) {
/* free ioports reserved by floppy_grab_irq_and_dma() */
- release_region(FDCS->address + 2, 4);
- release_region(FDCS->address + 7, 1);
+ floppy_release_regions(fdc);
FDCS->address = -1;
continue;
}
@@ -4358,6 +4358,47 @@ out_put_disk:
static DEFINE_SPINLOCK(floppy_usage_lock);
+static const struct io_region {
+ int offset;
+ int size;
+} io_regions[] = {
+ { 2, 1 },
+ /* address + 3 is sometimes reserved by pnp bios for motherboard */
+ { 4, 2 },
+ /* address + 6 is reserved, and may be taken by IDE.
+ * Unfortunately, Adaptec doesn't know this :-(, */
+ { 7, 1 },
+};
+
+static void floppy_release_allocated_regions(int fdc, const struct io_region *p)
+{
+ while (p != io_regions) {
+ p--;
+ release_region(FDCS->address + p->offset, p->size);
+ }
+}
+
+#define ARRAY_END(X) (&((X)[ARRAY_SIZE(X)]))
+
+static int floppy_request_regions(int fdc)
+{
+ const struct io_region *p;
+
+ for (p = io_regions; p < ARRAY_END(io_regions); p++) {
+ if (!request_region(FDCS->address + p->offset, p->size, "floppy")) {
+ DPRINT("Floppy io-port 0x%04lx in use\n", FDCS->address + p->offset);
+ floppy_release_allocated_regions(fdc, p);
+ return -EBUSY;
+ }
+ }
+ return 0;
+}
+
+static void floppy_release_regions(int fdc)
+{
+ floppy_release_allocated_regions(fdc, ARRAY_END(io_regions));
+}
+
static int floppy_grab_irq_and_dma(void)
{
unsigned long flags;
@@ -4399,18 +4440,8 @@ static int floppy_grab_irq_and_dma(void)
for (fdc = 0; fdc < N_FDC; fdc++) {
if (FDCS->address != -1) {
- if (!request_region(FDCS->address + 2, 4, "floppy")) {
- DPRINT("Floppy io-port 0x%04lx in use\n",
- FDCS->address + 2);
- goto cleanup1;
- }
- if (!request_region(FDCS->address + 7, 1, "floppy DIR")) {
- DPRINT("Floppy io-port 0x%04lx in use\n",
- FDCS->address + 7);
- goto cleanup2;
- }
- /* address + 6 is reserved, and may be taken by IDE.
- * Unfortunately, Adaptec doesn't know this :-(, */
+ if (floppy_request_regions(fdc))
+ goto cleanup;
}
}
for (fdc = 0; fdc < N_FDC; fdc++) {
@@ -4432,15 +4463,11 @@ static int floppy_grab_irq_and_dma(void)
fdc = 0;
irqdma_allocated = 1;
return 0;
-cleanup2:
- release_region(FDCS->address + 2, 4);
-cleanup1:
+cleanup:
fd_free_irq();
fd_free_dma();
- while (--fdc >= 0) {
- release_region(FDCS->address + 2, 4);
- release_region(FDCS->address + 7, 1);
- }
+ while (--fdc >= 0)
+ floppy_release_regions(fdc);
spin_lock_irqsave(&floppy_usage_lock, flags);
usage_count--;
spin_unlock_irqrestore(&floppy_usage_lock, flags);
@@ -4501,10 +4528,8 @@ static void floppy_release_irq_and_dma(v
#endif
old_fdc = fdc;
for (fdc = 0; fdc < N_FDC; fdc++)
- if (FDCS->address != -1) {
- release_region(FDCS->address + 2, 4);
- release_region(FDCS->address + 7, 1);
- }
+ if (FDCS->address != -1)
+ floppy_release_regions(fdc);
fdc = old_fdc;
}
next prev parent reply other threads:[~2009-07-01 0:34 UTC|newest]
Thread overview: 37+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20090630235944.868879272@mini.kroah.org>
2009-07-01 0:28 ` [patch 00/30] 2.6.27-stable review Greg KH
2009-06-30 23:59 ` [patch 01/30] parport: netmos 9845 & 9855 1P4S fixes Greg KH
2009-06-30 23:59 ` [patch 02/30] atmel_lcdfb: correct fifo size for some products Greg KH
2009-06-30 23:59 ` [patch 03/30] bonding: fix multiple module load problem Greg KH
2009-06-30 23:59 ` [patch 04/30] char: moxa, prevent opening unavailable ports Greg KH
2009-06-30 23:59 ` [patch 05/30] char: mxser, fix ISA board lookup Greg KH
2009-06-30 23:59 ` [patch 06/30] firmware_map: fix hang with x86/32bit Greg KH
2009-06-30 23:59 ` [patch 07/30] jbd: fix race in buffer processing in commit code Greg KH
2009-06-30 23:59 ` [patch 08/30] PCI: disable ASPM on VIA root-port-under-bridge configurations Greg KH
2009-06-30 23:59 ` [patch 09/30] r8169: fix crash when large packets are received Greg KH
2009-06-30 23:59 ` [patch 10/30] ISDN: Fix DMA alloc for hfcpci Greg KH
2009-06-30 23:59 ` [patch 11/30] x86: Add quirk for reboot stalls on a Dell Optiplex 360 Greg KH
2009-06-30 23:59 ` [patch 12/30] x86: quirk for reboot stalls on a Dell Optiplex 330 Greg KH
2009-06-30 23:59 ` [patch 13/30] ALSA: ca0106 - Add missing registrations of vmaster controls Greg KH
2009-06-30 23:59 ` [patch 14/30] floppy: provide a PNP device table in the module Greg KH
2009-06-30 23:59 ` Greg KH [this message]
2009-07-01 0:00 ` [patch 16/30] IB/mlx4: Add strong ordering to local inval and fast reg work requests Greg KH
2009-07-01 0:00 ` [patch 17/30] x86: handle initrd that extends into unusable memory Greg KH
2009-07-01 0:00 ` [patch 18/30] lockdep: Select frame pointers on x86 Greg KH
2009-07-01 0:00 ` [patch 19/30] md/raid5: add missing call to schedule() after prepare_to_wait() Greg KH
2009-07-01 0:00 ` [patch 20/30] tcp: advertise MSS requested by user Greg KH
2009-07-01 0:00 ` [patch 21/30] parport_pc: after superio probing restore original register values Greg KH
2009-07-01 0:00 ` [patch 22/30] parport_pc: set properly the dma_mask for parport_pc device Greg KH
2009-07-01 0:00 ` [patch 23/30] PCI PM: Fix handling of devices without PM support by pci_target_state() Greg KH
2009-07-01 0:00 ` [patch 24/30] PCI PM: Follow PCI_PM_CTRL_NO_SOFT_RESET during transitions from D3 Greg KH
2009-07-01 0:00 ` [patch 25/30] pcmcia/cm4000: fix lock imbalance Greg KH
2009-07-01 0:00 ` [patch 26/30] sound: seq_midi_event: fix decoding of (N)RPN events Greg KH
2009-07-01 0:00 ` [patch 27/30] mm: fix handling of pagesets for downed cpus Greg KH
2009-07-01 0:00 ` [patch 28/30] dm mpath: validate hw_handler argument count Greg KH
2009-07-01 0:00 ` [patch 29/30] dm mpath: validate table " Greg KH
2009-07-01 0:00 ` [patch 30/30] dm: sysfs skip output when device is being destroyed Greg KH
2009-07-01 6:04 ` [patch 00/30] 2.6.27-stable review Christoph Biedl
2009-07-01 18:49 ` [stable] " Greg KH
2009-07-17 19:43 ` Greg KH
2009-07-01 18:35 ` Greg KH
2009-07-01 18:36 ` [patch 31/30] bsdacct: fix access to invalid filp in acct_on() Greg KH
2009-07-01 18:38 ` [patch 32/30] kbuild: fix C libary confusion in unifdef.c due to getline() Greg KH
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090701000358.640178641@mini.kroah.org \
--to=gregkh@suse.de \
--cc=abelay@mit.edu \
--cc=akpm@linux-foundation.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=bjorn.helgaas@hp.com \
--cc=hancockrwd@gmail.com \
--cc=linux-kernel@vger.kernel.org \
--cc=phdm@macqel.be \
--cc=stable-review@kernel.org \
--cc=stable@kernel.org \
--cc=torvalds@linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox