From: Davin McCall <davmac@ozonline.com.au>
To: Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl>
Cc: linux-kernel@vger.kernel.org, linux-ide@vger.kernel.org
Subject: Re: [PATCH] fix issues with loading PCI ide drivers as modules (linux 2.6.0)
Date: Mon, 5 Jan 2004 13:09:39 +1100 [thread overview]
Message-ID: <20040105130939.3cca1648.davmac@ozonline.com.au> (raw)
In-Reply-To: <200401041547.52615.bzolnier@elka.pw.edu.pl>
On Sun, 4 Jan 2004 15:47:52 +0100
Bartlomiej Zolnierkiewicz <B.Zolnierkiewicz@elka.pw.edu.pl> wrote:
> Please explain me why to change current behavior. "takeover" still want be
> possible, so it will be only cosmetic change which complicates code.
>
> --bart
>
Alright - I have a PIIX4 chipset in my system. when I compile the PIIX4 ide driver as a module (ie. "piix.ko") and load it after booting the system I get kernel messages because
1) it can't allocate the I/O ports for the ide interfaces, io 0x170-0x177 0x1F0-0x1F7 etc
because they have been allocated by the non-PCI driver (ide.c)
2) it can't register block devices; they've already been allocated
Looking at the code it is clear that when I get these messages, the hwif will then be marked "not present" (ie. hwif->present = 0) and the drives (hda, hdb and hdc in my case) will also be marked not present.
The "hwif" structures corresponding to ide0/ide1 have been trashed - even though the piix module shouldn't have been granted control of the interfaces. The reason is that "ide_hwif_configure()" (setup-pci.c) calls "ide_match_hwif" which returns whatever hwif structure matches the io-base address (which the chipset is "ide_unknown" or "ide_generic"), and then, ide_hwif_configure() USES that hwif and for instance sets its chipset to "ide_pci" and returns it to the caller (ide_pci_setup_ports) which continues to trash it, tries to allocate the base and ctl ports (which fails) and register the block devices (which fails).
You can verify that the hwif has been modified by "cat /proc/ide/ide0/model" before and after inserting the piix module - before, i get "unknown", afterwards i get "pci".
Sure, the current code doesn't cause a crash - but it's very, very ugly. It generates some confusing error messages, and it makes it look like the module has taken control of the IDE interfaces but really the drives haven't been re-probed etc.
Is this not worth fixing?
>
> Ehh, more hwif->chipset crap.
>
Alright, this newer patch below mostly avoids the "hwif->chipset crap" (it doesn't introduce any new chipset types). But it has to export the "initializing" variable from ide.c (I changed its name to "ide_initializing").
Plus, everything works as before - including "idex=..." parameters.
Davin.
diff -urN linux-2.6.0-vanilla/drivers/ide/ide-probe.c linux-2.6.0/drivers/ide/ide-probe.c
--- linux-2.6.0-vanilla/drivers/ide/ide-probe.c Thu Nov 27 07:44:24 2003
+++ linux-2.6.0/drivers/ide/ide-probe.c Sun Jan 4 14:46:04 2004
@@ -1343,6 +1343,7 @@
int unit;
if (!hwif->present)
continue;
+ if (hwif->chipset == ide_unknown) hwif->chipset = ide_generic;
for (unit = 0; unit < MAX_DRIVES; ++unit)
if (hwif->drives[unit].present)
ata_attach(&hwif->drives[unit]);
diff -urN linux-2.6.0-vanilla/drivers/ide/ide.c linux-2.6.0/drivers/ide/ide.c
--- linux-2.6.0-vanilla/drivers/ide/ide.c Thu Nov 27 07:43:29 2003
+++ linux-2.6.0/drivers/ide/ide.c Sun Jan 4 19:36:42 2004
@@ -173,7 +173,9 @@
static int idebus_parameter; /* holds the "idebus=" parameter */
static int system_bus_speed; /* holds what we think is VESA/PCI bus speed */
-static int initializing; /* set while initializing built-in drivers */
+
+int ide_initializing; /* set while initializing built-in drivers */
+EXPORT_SYMBOL(ide_initializing);
DECLARE_MUTEX(ide_cfg_sem);
spinlock_t ide_lock __cacheline_aligned_in_smp = SPIN_LOCK_UNLOCKED;
@@ -1011,8 +1013,8 @@
hwif = &ide_hwifs[index];
if (hwif->hold)
continue;
- if ((!hwif->present && !hwif->mate && !initializing) ||
- (!hwif->hw.io_ports[IDE_DATA_OFFSET] && initializing))
+ if ((!hwif->present && !hwif->mate && !ide_initializing) ||
+ (!hwif->hw.io_ports[IDE_DATA_OFFSET] && ide_initializing))
goto found;
}
for (index = 0; index < MAX_HWIFS; index++)
@@ -1032,7 +1034,7 @@
hwif->noprobe = 0;
hwif->chipset = hw->chipset;
- if (!initializing) {
+ if (!ide_initializing) {
ide_probe_module();
#ifdef CONFIG_PROC_FS
create_proc_ide_interfaces();
@@ -1042,7 +1044,7 @@
if (hwifp)
*hwifp = hwif;
- return (initializing || hwif->present) ? index : -1;
+ return (ide_initializing || hwif->present) ? index : -1;
}
EXPORT_SYMBOL(ide_register_hw);
@@ -2606,9 +2608,9 @@
(void)qd65xx_init();
#endif
- initializing = 1;
+ ide_initializing = 1;
ide_init_builtin_drivers();
- initializing = 0;
+ ide_initializing = 0;
return 0;
}
diff -urN linux-2.6.0-vanilla/drivers/ide/setup-pci.c linux-2.6.0/drivers/ide/setup-pci.c
--- linux-2.6.0-vanilla/drivers/ide/setup-pci.c Thu Nov 27 07:43:39 2003
+++ linux-2.6.0/drivers/ide/setup-pci.c Sun Jan 4 19:41:09 2004
@@ -441,6 +441,9 @@
}
if ((hwif = ide_match_hwif(base, d->bootable, d->name)) == NULL)
return NULL; /* no room in ide_hwifs[] */
+ if (hwif->chipset == ide_generic && ! ide_initializing )
+ return NULL; /* clash with already allocated hwif */
+
if (hwif->io_ports[IDE_DATA_OFFSET] != base) {
fixup_address:
ide_init_hwif_ports(&hwif->hw, base, (ctl | 2), NULL);
diff -urN linux-2.6.0-vanilla/include/linux/ide.h linux-2.6.0/include/linux/ide.h
--- linux-2.6.0-vanilla/include/linux/ide.h Thu Nov 27 07:43:36 2003
+++ linux-2.6.0/include/linux/ide.h Sun Jan 4 19:40:28 2004
@@ -1246,6 +1246,8 @@
extern ide_devices_t *idetape;
extern ide_devices_t *idescsi;
+extern int ide_initializing;
+
#endif
extern int noautodma;
next prev parent reply other threads:[~2004-01-05 2:06 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2004-01-03 4:28 Davin McCall
2004-01-04 1:56 ` Bartlomiej Zolnierkiewicz
2004-01-04 3:21 ` Davin McCall
2004-01-04 3:52 ` Bartlomiej Zolnierkiewicz
2004-01-04 6:31 ` Davin McCall
2004-01-04 14:47 ` Bartlomiej Zolnierkiewicz
2004-01-05 2:09 ` Davin McCall [this message]
2004-01-05 14:16 ` Bartlomiej Zolnierkiewicz
2004-01-06 2:51 ` Davin McCall
2004-01-06 11:13 ` Bartlomiej Zolnierkiewicz
2004-01-06 13:09 ` Davin McCall
2004-01-06 13:45 ` Davin McCall
2004-01-30 3:27 ` [PATCH] various IDE patches/cleanups Davin McCall
2004-01-30 3:30 ` Davin McCall
2004-01-30 3:33 ` Davin McCall
2004-01-30 3:34 ` Davin McCall
2004-01-30 3:35 ` Davin McCall
2004-02-05 5:21 ` Davin McCall
2004-02-05 6:37 ` Davin McCall
2004-02-03 19:41 ` Bartlomiej Zolnierkiewicz
2004-02-05 3:51 ` Davin McCall
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=20040105130939.3cca1648.davmac@ozonline.com.au \
--to=davmac@ozonline.com.au \
--cc=B.Zolnierkiewicz@elka.pw.edu.pl \
--cc=linux-ide@vger.kernel.org \
--cc=linux-kernel@vger.kernel.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
all inboxes | Powered by JetHome®