Skip to contentSkip to conversation

ide-generic: add some notes to clarify probing PCI devices

PATCH In review Luiz Carlos Ramos 2 participants 2 messages Feb 21, 2017 libata

lore
Share & tools
lore
#0 lore raw

PATCH 1/2 ide-generic: add some notes to clarify probing PCI devices

Some inline comments were added in ide-generic, to make clear to developers the way probe_mask is managed when PCI IDE devices are present.

A not-so-deep analysis of the code could make it is buggy, as it seems that if a device is detected, the probing procedure is avoided, suggesting some kind of reversed logic.

---
 drivers/ide/ide-generic.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/ide/ide-generic.c +27 -0
index 54d7c4685d23aa5e62ce606e7b994a57bb54b08a..ee11edcdba3170c077381d603918498d79ffa3bb 100644
@@ -96,6 +96,33 @@ static int __init ide_generic_init(void)
 		printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" "
 		     "module parameter for probing all legacy ISA IDE ports\n");
 
+		/* Here the logic seems reversed, but it's not. *primary would
+		 * be 1 if there is a device at 0x1f0 and *secondary would be 1
+		 * if a device is detected at 0x170.
+		 *
+		 * However, the main intention here is to not allow PCI IDE devices
+		 * using ide-generic unless the user chooses so, as this driver is
+		 * designed to support ISA IDE devices mainly.
+		 *
+		 * In this case, users are strongly encouraged to use the designated
+		 * PCI IDE driver, and not isa-generic.
+		 *
+		 * Pure ISA IDE devices OTOH will use ide-generic. In this case, *primary
+		 * and *secondary will return from ide_generic_check_pci_legacy_iobases()
+		 * with zero (because they are not PCI...), and probe_mask will be set
+		 * accordingly (to 0x01, 0x02 or 0x03, depending on which io ports are
+		 * present).
+		 *
+		 * Users would even use ide-generic with such PCI IDE devices, choosing a
+		 * nonzero value for probe_mask when initializing ide-generic. Using
+		 * probe_mask=0x03 is sufficient to make it detect common IDE interfaces
+		 * (with primary at 0x1f0 and secondary at 0x170), but in the more
+		 * general case, one should set probe_mask to 0x3f to check all possible
+		 * io addresses. In this case, it is up to the user the task of checking
+		 * for eventual conflicts between ide-generic and any other driver and
+		 * manage those conflicts properly.
+		 */
+
 		if (primary == 0)
 			probe_mask |= 0x1;
 
Signature · 1 line
2.8.2
#1 lore raw

Hi,

Quoted 9 lines · Luiz Carlos Ramos

Some inline comments were added in ide-generic, to make clear to developers the way probe_mask is managed when PCI IDE devices are present.

A not-so-deep analysis of the code could make it is buggy, as it seems that if a device is detected, the probing procedure is avoided, suggesting some kind of reversed logic.

Looks fine overall, some minor nits below.

Quoted 9 lines
---
 drivers/ide/ide-generic.c | 27 +++++++++++++++++++++++++++
 1 file changed, 27 insertions(+)
drivers/ide/ide-generic.c +0 -0
index 54d7c4685d23aa5e62ce606e7b994a57bb54b08a..ee11edcdba3170c077381d603918498d79ffa3bb 100644

drivers/ide/ide-generic.c static int __init ide_generic_init(void) · line 105

Quoted 10 lines
drivers/ide/ide-generic.c +7 -0
@@ -96,6 +96,33 @@ static int __init ide_generic_init(void)
 		printk(KERN_INFO DRV_NAME ": please use \"probe_mask=0x3f\" "
 		     "module parameter for probing all legacy ISA IDE ports\n");
 
+		/* Here the logic seems reversed, but it's not. *primary would
+		 * be 1 if there is a device at 0x1f0 and *secondary would be 1
+		 * if a device is detected at 0x170.
+		 *
+		 * However, the main intention here is to not allow PCI IDE devices
+		 * using ide-generic unless the user chooses so, as this driver is
+		 * designed to support ISA IDE devices mainly.

designed to support legacy ISA IDE devices that don't have chipset specific support.

drivers/ide/ide-generic.c static int __init ide_generic_init(void) · line 108

Quoted 3 lines
drivers/ide/ide-generic.c +3 -0
+		 *
+		 * In this case, users are strongly encouraged to use the designated
+		 * PCI IDE driver, and not isa-generic.

PCI IDE drivers, and not ide-generic.

drivers/ide/ide-generic.c static int __init ide_generic_init(void) · line 116

Quoted 8 lines
drivers/ide/ide-generic.c +8 -0
+		 *
+		 * Pure ISA IDE devices OTOH will use ide-generic. In this case, *primary
+		 * and *secondary will return from ide_generic_check_pci_legacy_iobases()
+		 * with zero (because they are not PCI...), and probe_mask will be set
+		 * accordingly (to 0x01, 0x02 or 0x03, depending on which io ports are
+		 * present).
+		 *
+		 * Users would even use ide-generic with such PCI IDE devices, choosing a

Users who would like to use ide-generic with PCI IDE devices (which is not recommended) should choose a

drivers/ide/ide-generic.c static int __init ide_generic_init(void) · line 121

Quoted 5 lines
drivers/ide/ide-generic.c +5 -0
+		 * nonzero value for probe_mask when initializing ide-generic. Using
+		 * probe_mask=0x03 is sufficient to make it detect common IDE interfaces
+		 * (with primary at 0x1f0 and secondary at 0x170), but in the more
+		 * general case, one should set probe_mask to 0x3f to check all possible
+		 * io addresses. In this case, it is up to the user the task of checking

IO addresses. When using probe_mask it is up to the user to check

drivers/ide/ide-generic.c static int __init ide_generic_init(void) · line 127

Quoted 6 lines
drivers/ide/ide-generic.c +4 -0
+		 * for eventual conflicts between ide-generic and any other driver and
+		 * manage those conflicts properly.
+		 */
+
 		if (primary == 0)
 			probe_mask |= 0x1;

Best regards,
--
Bartlomiej Zolnierkiewicz
Samsung R&D Institute Poland
Samsung Electronics