All of lore.kernel.org
 help / color / mirror / Atom feed
From: Greg KH <greg@kroah.com>
To: CaT <cat@zip.com.au>, linux-kernel@vger.kernel.org
Subject: Re: 2.5.70: pcmcia oops (a real one! honest!)
Date: Thu, 29 May 2003 14:21:39 -0700	[thread overview]
Message-ID: <20030529212139.GA25971@kroah.com> (raw)
In-Reply-To: <20030529090209.B12513@flint.arm.linux.org.uk>

On Thu, May 29, 2003 at 09:02:09AM +0100, Russell King wrote:
> On Wed, May 28, 2003 at 02:26:10PM +1000, CaT wrote:
> > removed my xircom pcmcia realport card and put in another. End result was
> > total loss of ps2 keyboard functionality (everything else, inc the ps2 mouse
> > still works). I then removed the xircom card. The following was in dmesg:
> 
> I'm assuming that this is something Gregkh needs to look into and not
> myself; my guess is that it's related to the pci device accounting stuff.
> 
> Greg?

Yeah, it could be.  Cat, can you revert the following patch from your
tree and let me know if it fixes your problem or not?

thanks,

greg k-h



diff -Nru a/drivers/pci/bus.c b/drivers/pci/bus.c
--- a/drivers/pci/bus.c	Thu May 29 14:18:20 2003
+++ b/drivers/pci/bus.c	Thu May 29 14:18:20 2003
@@ -92,7 +92,7 @@
 		if (!list_empty(&dev->global_list))
 			continue;
 
-		device_register(&dev->dev);
+		device_add(&dev->dev);
 		list_add_tail(&dev->global_list, &pci_devices);
 #ifdef CONFIG_PROC_FS
 		pci_proc_attach_device(dev);
diff -Nru a/drivers/pci/hotplug.c b/drivers/pci/hotplug.c
--- a/drivers/pci/hotplug.c	Thu May 29 14:18:20 2003
+++ b/drivers/pci/hotplug.c	Thu May 29 14:18:20 2003
@@ -275,7 +275,7 @@
 	pci_proc_detach_device(dev);
 #endif
 
-	kfree(dev);
+	pci_put_dev(dev);
 }
 
 /**
diff -Nru a/drivers/pci/pci-driver.c b/drivers/pci/pci-driver.c
--- a/drivers/pci/pci-driver.c	Thu May 29 14:18:20 2003
+++ b/drivers/pci/pci-driver.c	Thu May 29 14:18:20 2003
@@ -199,6 +199,45 @@
 	return 0;
 }
 
+/**
+ * pci_get_dev - increments the reference count of the pci device structure
+ * @dev: the device being referenced
+ *
+ * Each live reference to a device should be refcounted.
+ *
+ * Drivers for PCI devices should normally record such references in
+ * their probe() methods, when they bind to a device, and release
+ * them by calling pci_put_dev(), in their disconnect() methods.
+ *
+ * A pointer to the device with the incremented reference counter is returned.
+ */
+struct pci_dev *pci_get_dev (struct pci_dev *dev)
+{
+	struct device *tmp;
+
+	if (!dev)
+		return NULL;
+
+	tmp = get_device(&dev->dev);
+	if (tmp)        
+		return to_pci_dev(tmp);
+	else
+		return NULL;
+}
+
+/**
+ * pci_put_dev - release a use of the pci device structure
+ * @dev: device that's been disconnected
+ *
+ * Must be called when a user of a device is finished with it.  When the last
+ * user of the device calls this function, the memory of the device is freed.
+ */
+void pci_put_dev(struct pci_dev *dev)
+{
+	if (dev)
+		put_device(&dev->dev);
+}
+
 struct bus_type pci_bus_type = {
 	.name		= "pci",
 	.match		= pci_bus_match,
@@ -217,3 +256,5 @@
 EXPORT_SYMBOL(pci_unregister_driver);
 EXPORT_SYMBOL(pci_dev_driver);
 EXPORT_SYMBOL(pci_bus_type);
+EXPORT_SYMBOL(pci_get_dev);
+EXPORT_SYMBOL(pci_put_dev);
diff -Nru a/drivers/pci/probe.c b/drivers/pci/probe.c
--- a/drivers/pci/probe.c	Thu May 29 14:18:20 2003
+++ b/drivers/pci/probe.c	Thu May 29 14:18:20 2003
@@ -462,6 +462,21 @@
 	return 0;
 }
 
+/**
+ * pci_release_dev - free a pci device structure when all users of it are finished.
+ * @dev: device that's been disconnected
+ *
+ * Will be called only by the device core when all users of this pci device are
+ * done.
+ */
+static void pci_release_dev(struct device *dev)
+{
+	struct pci_dev *pci_dev;
+
+	pci_dev = to_pci_dev(dev);
+	kfree(pci_dev);
+}
+
 /*
  * Read the config data for a PCI device, sanity-check it
  * and fill in the dev structure...
@@ -506,6 +521,9 @@
 		kfree(dev);
 		return NULL;
 	}
+	device_initialize(&dev->dev);
+	dev->dev.release = pci_release_dev;
+	pci_get_dev(dev);
 
 	pci_name_device(dev);
 
diff -Nru a/include/linux/pci.h b/include/linux/pci.h
--- a/include/linux/pci.h	Thu May 29 14:18:20 2003
+++ b/include/linux/pci.h	Thu May 29 14:18:20 2003
@@ -556,6 +556,8 @@
 struct resource *pci_find_parent_resource(const struct pci_dev *dev, struct resource *res);
 int pci_setup_device(struct pci_dev *dev);
 int pci_get_interrupt_pin(struct pci_dev *dev, struct pci_dev **bridge);
+extern struct pci_dev *pci_get_dev(struct pci_dev *dev);
+extern void pci_put_dev(struct pci_dev *dev);
 
 /* Generic PCI functions exported to card drivers */
 

  reply	other threads:[~2003-05-29 21:07 UTC|newest]

Thread overview: 8+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2003-05-28  4:26 2.5.70: pcmcia oops (a real one! honest!) CaT
2003-05-28  4:38 ` CaT
2003-05-29  8:02 ` Russell King
2003-05-29 21:21   ` Greg KH [this message]
2003-05-31 15:41     ` CaT
2003-06-02 21:05       ` Greg KH
2003-06-03 19:28         ` Greg KH
2003-06-05  4:24           ` CaT

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=20030529212139.GA25971@kroah.com \
    --to=greg@kroah.com \
    --cc=cat@zip.com.au \
    --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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.