Bug 22882

Summary: (2.6.37-rc1) amd64-agp module crashed on second load
Product: Drivers Reporter: Maciej Rutecki (maciej.rutecki)
Component: Video(AGP)Assignee: Dave Airlie (airlied)
Status: CLOSED CODE_FIX    
Severity: normal CC: cebbert, devzero, florian, maciej.rutecki, randy.dunlap, rjw
Priority: P1    
Hardware: All   
OS: Linux   
Kernel Version: 2.6.37-rc1 Subsystem:
Regression: Yes Bisected commit-id:
Bug Depends on:    
Bug Blocks: 21782    
Attachments: Update of Florian's patch to 2.6.38-rc3.

Description Maciej Rutecki 2010-11-14 19:38:41 UTC
Subject    : (2.6.37-rc1) amd64-agp module crashed on second load
Submitter  : Randy Dunlap <randy.dunlap@oracle.com>
Date       : 2010-11-05 0:13
Message-ID : 20101104171333.fea1f498.randy.dunlap@oracle.com
References : http://marc.info/?l=linux-kernel&m=128891605213447&w=2

This entry is being used for tracking a regression from 2.6.36. Please don't
close it until the problem is fixed in the mainline.
Comment 1 Randy Dunlap 2010-11-19 21:28:46 UTC
Still happens with 2.6.37-rc2-git4.
Comment 2 Randy Dunlap 2010-12-07 18:18:40 UTC
Still happens with 2.6.37-rc5.
Comment 3 Randy Dunlap 2010-12-28 17:19:54 UTC
Still happens on 2.6.37-rc7.
Comment 4 Florian Mickler 2011-01-15 11:59:49 UTC
Just a guess, but maybe it's fixed by something along the lines of:

diff --git a/drivers/char/agp/amd64-agp.c b/drivers/char/agp/amd64-agp.c
index 42396df..6788fdf 100644
--- a/drivers/char/agp/amd64-agp.c
+++ b/drivers/char/agp/amd64-agp.c
@@ -774,18 +774,23 @@ int __init agp_amd64_init(void)
 #else
 			printk(KERN_INFO PFX "You can boot with agp=try_unsupported\n");
 #endif
+			pci_unregister_driver(&agp_amd64_pci_driver);
 			return -ENODEV;
 		}
 
 		/* First check that we have at least one AMD64 NB */
-		if (!pci_dev_present(k8_nb_ids))
+		if (!pci_dev_present(k8_nb_ids)) {
+			pci_unregister_driver(&agp_amd64_pci_driver);
 			return -ENODEV;
+		}
 
 		/* Look for any AGP bridge */
 		agp_amd64_pci_driver.id_table = agp_amd64_pci_promisc_table;
 		err = driver_attach(&agp_amd64_pci_driver.driver);
-		if (err == 0 && agp_bridges_found == 0)
+		if (err == 0 && agp_bridges_found == 0) {
+			pci_unregister_driver(&agp_amd64_pci_driver);
 			err = -ENODEV;
+		}
 	}
 	return err;
 }
Comment 5 Randy Dunlap 2011-02-07 04:42:23 UTC
Still happens in 2.6.38-rc3, but I just saw Florian's patch,
so I'll test it.
Comment 6 Randy Dunlap 2011-02-07 06:01:38 UTC
Created attachment 46682 [details]
Update of Florian's patch to 2.6.38-rc3.

This update of Florian's patch fixes this bug for me.
I loaded the driver 5 times without an error.
Comment 7 Rafael J. Wysocki 2011-02-07 09:22:55 UTC
Handled-By : Florian Mickler <florian@mickler.org>
Patch : https://bugzilla.kernel.org/attachment.cgi?id=46682
Comment 8 Chuck Ebbert 2011-02-25 14:50:22 UTC
Fixed by commit 49495d44dfa4ba76cf7d1ed8fe84746dd9552255
Comment 9 Florian Mickler 2011-03-04 23:36:16 UTC
merged for .38-rc7:

commit 49495d44dfa4ba76cf7d1ed8fe84746dd9552255
Author: Florian Mickler <florian@mickler.org>
Date:   Mon Feb 7 23:29:31 2011 +0100

    amd64-agp: fix crash at second module load
Comment 10 Alan 2012-08-14 15:14:54 UTC
*** Bug 25862 has been marked as a duplicate of this bug. ***