Skip to contentSkip to conversation

BusLogic: eliminate deprecated check_region()

PATCH RESEND In review Jesse Millan 2 participants 3 messages Sep 25, 2005 – Sep 27, 2005

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

PATCH RESEND 1/1 BusLogic: eliminate deprecated check_region()

This patch eliminates the deprecated calls to check_region(). It's replaced with request_region(). New version is a little more wordy due to the fact that requst_region() cannot be easily compacted into the ? operator.

This patch eliminates the deprecated calls to check_region(). It's replaced with request_region(). New version is a little more wordy due to the fact that requst_region() cannot be easily compacted into the ? operator.

---

 drivers/scsi/BusLogic.c |  133 ++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 107 insertions(+), 26 deletions(-)
drivers/scsi/BusLogic.c renamed from drivers/scsi/BusLogic.c~deprecated_check_region_BusLogic +107 -26
diff -puN drivers/scsi/BusLogic.c~deprecated_check_region_BusLogic drivers/scsi/BusLogic.c
@@ -582,18 +582,45 @@ static void __init BusLogic_InitializePr
 	/*
 	   Append the list of standard BusLogic MultiMaster ISA I/O Addresses.
 	 */
-	if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0)
-		BusLogic_AppendProbeAddressISA(0x330);
-	if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0)
-		BusLogic_AppendProbeAddressISA(0x334);
-	if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0)
-		BusLogic_AppendProbeAddressISA(0x230);
-	if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0)
-		BusLogic_AppendProbeAddressISA(0x234);
-	if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0)
-		BusLogic_AppendProbeAddressISA(0x130);
-	if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0)
-		BusLogic_AppendProbeAddressISA(0x134);
+	if(BusLogic_ProbeOptions.LimitedProbeISA) {
+		if(BusLogic_ProbeOptions.Probe330)
+			BusLogic_AppendProbeAddressISA(0x330);
+		if(BusLogic_ProbeOptions.Probe334)
+			BusLogic_AppendProbeAddressISA(0x334);
+		if(BusLogic_ProbeOptions.Probe230)
+			BusLogic_AppendProbeAddressISA(0x230);
+		if(BusLogic_ProbeOptions.Probe234)
+			BusLogic_AppendProbeAddressISA(0x234);
+		if(BusLogic_ProbeOptions.Probe130)
+			BusLogic_AppendProbeAddressISA(0x130);
+		if(BusLogic_ProbeOptions.Probe134)
+			BusLogic_AppendProbeAddressISA(0x134);
+	} else {
+		if(request_region(0x330, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+			release_region(0x330, BusLogic_MultiMasterAddressCount)
+			BusLogic_AppendProbeAddressISA(0x330);
+		}
+		if(request_region(0x334, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+			release_region(0x334, BusLogic_MultiMasterAddressCount)
+			BusLogic_AppendProbeAddressISA(0x334);
+		}
+		if(request_region(0x230, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+			release_region(0x230, BusLogic_MultiMasterAddressCount)
+			BusLogic_AppendProbeAddressISA(0x230);
+		}
+		if(request_region(0x234, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+			release_region(0x234, BusLogic_MultiMasterAddressCount)
+			BusLogic_AppendProbeAddressISA(0x234);
+		}
+		if(request_region(0x130, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+			release_region(0x130, BusLogic_MultiMasterAddressCount)
+			BusLogic_AppendProbeAddressISA(0x130);
+		}
+		if(request_region(0x134, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+			release_region(0x134, BusLogic_MultiMasterAddressCount)
+			BusLogic_AppendProbeAddressISA(0x134);
+		}
+	}
 }
 
 
@@ -798,26 +825,80 @@ static int __init BusLogic_InitializeMul
 	   host adapters are probed.
 	 */
 	if (!BusLogic_ProbeOptions.NoProbeISA)
-		if (PrimaryProbeInfo->IO_Address == 0 && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0)) {
-			PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster;
-			PrimaryProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus;
-			PrimaryProbeInfo->IO_Address = 0x330;
+		if (PrimaryProbeInfo->IO_Address == 0) {
+			if (BusLogic_ProbeOptions.LimitedProbeISA) {
+				if (BusLogic_ProbeOptions.Probe330) {
+					/* BusLogic_ProbeOptions.LimitedProbeISA && BusLogic_ProbeOptions.Probe330 */
+					PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster;
+					PrimaryProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus;
+					PrimaryProbeInfo->IO_Address = 0x330;
+				}
+			} else {
+				if (request_region(0x330, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+					/* BusLogic_ProbeOptions.LimitedProbeISA && request_region */
+					release_region(0x330, BusLogic_MultiMasterAddressCount);
+					PrimaryProbeInfo->HostAdapterType = BusLogic_MultiMaster;
+					PrimaryProbeInfo->HostAdapterBusType = BusLogic_ISA_Bus;
+					PrimaryProbeInfo->IO_Address = 0x330;
+				}
+			}
 		}
+
 	/*
 	   Append the list of standard BusLogic MultiMaster ISA I/O Addresses,
 	   omitting the Primary I/O Address which has already been handled.
 	 */
 	if (!BusLogic_ProbeOptions.NoProbeISA) {
-		if (!StandardAddressSeen[1] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe334 : check_region(0x334, BusLogic_MultiMasterAddressCount) == 0))
-			BusLogic_AppendProbeAddressISA(0x334);
-		if (!StandardAddressSeen[2] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe230 : check_region(0x230, BusLogic_MultiMasterAddressCount) == 0))
-			BusLogic_AppendProbeAddressISA(0x230);
-		if (!StandardAddressSeen[3] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe234 : check_region(0x234, BusLogic_MultiMasterAddressCount) == 0))
-			BusLogic_AppendProbeAddressISA(0x234);
-		if (!StandardAddressSeen[4] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe130 : check_region(0x130, BusLogic_MultiMasterAddressCount) == 0))
-			BusLogic_AppendProbeAddressISA(0x130);
-		if (!StandardAddressSeen[5] && (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe134 : check_region(0x134, BusLogic_MultiMasterAddressCount) == 0))
-			BusLogic_AppendProbeAddressISA(0x134);
+		if (!StandardAddressSeen[1]) {
+			if(BusLogic_ProbeOptions.LimitedProbeISA) {
+				if(BusLogic_ProbeOptions.Probe334)
+					BusLogic_AppendProbeAddressISA(0x334);
+				else if(request_region(0x334, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+					release_region(0x334, BusLogic_MultiMasterAddressCount);
+					BusLogic_AppendProbeAddressISA(0x334);
+				}
+			}
+		}
+		if (!StandardAddressSeen[2]) {
+			if(BusLogic_ProbeOptions.LimitedProbeISA) {
+				if(BusLogic_ProbeOptions.Probe334)
+					BusLogic_AppendProbeAddressISA(0x230);
+				else if(request_region(0x230, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+					release_region(0x230, BusLogic_MultiMasterAddressCount);
+					BusLogic_AppendProbeAddressISA(0x230);
+				}
+			}
+		}
+		if (!StandardAddressSeen[3]) {
+			if(BusLogic_ProbeOptions.LimitedProbeISA) {
+				if(BusLogic_ProbeOptions.Probe334)
+					BusLogic_AppendProbeAddressISA(0x234);
+				else if(request_region(0x234, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+					release_region(0x234, BusLogic_MultiMasterAddressCount);
+					BusLogic_AppendProbeAddressISA(0x234);
+				}
+			}
+		}
+		if (!StandardAddressSeen[4]) {
+			if(BusLogic_ProbeOptions.LimitedProbeISA) {
+				if(BusLogic_ProbeOptions.Probe334)
+					BusLogic_AppendProbeAddressISA(0x130);
+				else if(request_region(0x130, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+					release_region(0x130, BusLogic_MultiMasterAddressCount);
+					BusLogic_AppendProbeAddressISA(0x130);
+				}
+			}
+		}
+		if (!StandardAddressSeen[5]) {
+			if(BusLogic_ProbeOptions.LimitedProbeISA) {
+				if(BusLogic_ProbeOptions.Probe334)
+					BusLogic_AppendProbeAddressISA(0x134);
+				else if(request_region(0x134, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+					release_region(0x134, BusLogic_MultiMasterAddressCount);
+					BusLogic_AppendProbeAddressISA(0x134);
+				}
+			}
+		}
 	}
 	/*
 	   Iterate over the older non-compliant MultiMaster PCI Host Adapters,

_

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#1 lore raw

Re: [KJ] [PATCH][RESEND] BusLogic: eliminate deprecated

Quoted 4 lines · Jesse Millan

This patch eliminates the deprecated calls to check_region(). It's replaced with request_region(). New version is a little more wordy due to the fact that requst_region() cannot be easily compacted into the ? operator.

I _was_ low on coffee:

drivers/scsi/BusLogic.c static void __init BusLogic_InitializePr · line 606

Quoted 11 lines
drivers/scsi/BusLogic.c renamed from drivers/scsi/BusLogic.c~deprecated_check_region_BusLogic +9 -2
-	if (BusLogic_ProbeOptions.LimitedProbeISA ? BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0)
-		BusLogic_AppendProbeAddressISA(0x330);
+	if(BusLogic_ProbeOptions.LimitedProbeISA) {
+		if(BusLogic_ProbeOptions.Probe330)
+			BusLogic_AppendProbeAddressISA(0x330);
+	} else {
+		if(request_region(0x330, BusLogic_MultiMasterAddressCount, "BusLogic")) {
+			release_region(0x330, BusLogic_MultiMasterAddressCount)
+			BusLogic_AppendProbeAddressISA(0x330);
+		}
+	}

You removed check_region(), yes. You haven't made the code race free and that was the rationale for check_region() deprecating.

	if (request_region()) {
		release_region();
		...
	}

modulo return values is equivalent to

	if (check_region() == 0) {
		...
	}

Ports that were free will stay free after your combo. Ports that were busy will stay busy.

So, a window for races is still in place - before "check_region" and final request_region() .

Agree?

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors

#2 lore raw

Re: [KJ] [PATCH][RESEND] BusLogic: eliminate deprecated

In reply to Jesse Millan
Quoted 34 lines · Alexey Dobriyan
Quoted 5 lines · Jesse Millan

This patch eliminates the deprecated calls to check_region(). It's replaced with request_region(). New version is a little more wordy due to the fact that requst_region() cannot be easily compacted into the ? operator.

I _was_ low on coffee:

Quoted 10 lines

- if (BusLogic_ProbeOptions.LimitedProbeISA ?
BusLogic_ProbeOptions.Probe330 : check_region(0x330, BusLogic_MultiMasterAddressCount) == 0)

drivers/scsi/BusLogic.c renamed from drivers/scsi/BusLogic.c~deprecated_check_region_BusLogic +5 -1
-        BusLogic_AppendProbeAddressISA(0x330);
+    if(BusLogic_ProbeOptions.LimitedProbeISA) {
+        if(BusLogic_ProbeOptions.Probe330)
+            BusLogic_AppendProbeAddressISA(0x330);
+    } else {
+        if(request_region(0x330,  

BusLogic_MultiMasterAddressCount, "BusLogic")) {

drivers/scsi/BusLogic.c static void __init BusLogic_InitializePr · line 606

Quoted 4 lines
drivers/scsi/BusLogic.c renamed from drivers/scsi/BusLogic.c~deprecated_check_region_BusLogic +4 -0
+            release_region(0x330, BusLogic_MultiMasterAddressCount)
+            BusLogic_AppendProbeAddressISA(0x330);
+        }
+    }

You removed check_region(), yes. You haven't made the code race free and that was the rationale for check_region() deprecating.

    if (request_region()) {
        release_region();
        ...
    }
Quoted 9 lines

modulo return values is equivalent to

    if (check_region() == 0) {
        ...
    }

Ports that were free will stay free after your combo. Ports that were busy will stay busy.

And port addresses that are added to the "list" may later be later unavailable (like when you get around to reading the list).

Quoted 4 lines

So, a window for races is still in place - before "check_region" and final request_region() .

Agree?

I agree that in order to get around some of these issues there would need to be some significant restructuring of the code.

You could also argue that the code has worked for a number of years "as is" with check_region and would still work with request/release region as well. The issues we are discussing were issues in the driver from day 1.

Quoted 2 lines

Hmm...

--
Jesse Millan
CNS Unix Team
Portland State University
Phone: (503) 725-9151
Homepage: www.system-calls.com

2 + 2 = 5 (For extremely large values of 2)

_______________________________________________
Kernel-janitors mailing list
[email protected]
https://lists.osdl.org/mailman/listinfo/kernel-janitors