[kernel] r17165 - in dists/squeeze/linux-2.6/debian: . patches/bugfix/all patches/series

Ben Hutchings benh at alioth.debian.org
Wed Mar 30 21:38:48 UTC 2011


Author: benh
Date: Wed Mar 30 21:38:40 2011
New Revision: 17165

Log:
via-ircc: Fix device list management and DMA buffer allocation (Closes: #619450)

Added:
   dists/squeeze/linux-2.6/debian/patches/bugfix/all/via-ircc-Pass-PCI-device-pointer-to-dma_-alloc-free-.patch
   dists/squeeze/linux-2.6/debian/patches/bugfix/all/via-ircc-Use-pci_-get-set-_drvdata-instead-of-static.patch
Modified:
   dists/squeeze/linux-2.6/debian/changelog
   dists/squeeze/linux-2.6/debian/patches/series/33

Modified: dists/squeeze/linux-2.6/debian/changelog
==============================================================================
--- dists/squeeze/linux-2.6/debian/changelog	Wed Mar 30 21:32:08 2011	(r17164)
+++ dists/squeeze/linux-2.6/debian/changelog	Wed Mar 30 21:38:40 2011	(r17165)
@@ -9,6 +9,8 @@
   * [powerpc] Fix default_machine_crash_shutdown #ifdef botch
     (FTBFS in non-SMP flavours in 2.6.32-32)
   * [x86] Enable VMWARE_PVSCSI as module (Really closes: #600957)
+  * via-ircc: Fix device list management and DMA buffer allocation
+    (Closes: #619450)
 
  -- maximilian attems <maks at debian.org>  Tue, 29 Mar 2011 18:56:55 +0200
 

Added: dists/squeeze/linux-2.6/debian/patches/bugfix/all/via-ircc-Pass-PCI-device-pointer-to-dma_-alloc-free-.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/squeeze/linux-2.6/debian/patches/bugfix/all/via-ircc-Pass-PCI-device-pointer-to-dma_-alloc-free-.patch	Wed Mar 30 21:38:40 2011	(r17165)
@@ -0,0 +1,66 @@
+From 0edcdd33fcc5b564f45ef433679a97338d195b6a Mon Sep 17 00:00:00 2001
+From: Ben Hutchings <ben at decadent.org.uk>
+Date: Sat, 26 Mar 2011 17:36:00 +0000
+Subject: [PATCH 2/2] via-ircc: Pass PCI device pointer to dma_{alloc,free}_coherent()
+
+via-ircc has been passing a NULL pointer to DMA allocation functions,
+which is completely invalid and results in a BUG on PowerPC.  Now
+that we always have the device pointer available, pass it in.
+
+Reference: http://bugs.debian.org/619450
+Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
+---
+ drivers/net/irda/via-ircc.c |   12 ++++++------
+ 1 files changed, 6 insertions(+), 6 deletions(-)
+
+diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
+index cc6faca..186cd28 100644
+--- a/drivers/net/irda/via-ircc.c
++++ b/drivers/net/irda/via-ircc.c
+@@ -363,7 +363,7 @@ static __devinit int via_ircc_open(struct pci_dev *pdev, chipio_t * info,
+ 
+ 	/* Allocate memory if needed */
+ 	self->rx_buff.head =
+-		dma_alloc_coherent(NULL, self->rx_buff.truesize,
++		dma_alloc_coherent(&pdev->dev, self->rx_buff.truesize,
+ 				   &self->rx_buff_dma, GFP_KERNEL);
+ 	if (self->rx_buff.head == NULL) {
+ 		err = -ENOMEM;
+@@ -372,7 +372,7 @@ static __devinit int via_ircc_open(struct pci_dev *pdev, chipio_t * info,
+ 	memset(self->rx_buff.head, 0, self->rx_buff.truesize);
+ 
+ 	self->tx_buff.head =
+-		dma_alloc_coherent(NULL, self->tx_buff.truesize,
++		dma_alloc_coherent(&pdev->dev, self->tx_buff.truesize,
+ 				   &self->tx_buff_dma, GFP_KERNEL);
+ 	if (self->tx_buff.head == NULL) {
+ 		err = -ENOMEM;
+@@ -404,10 +404,10 @@ static __devinit int via_ircc_open(struct pci_dev *pdev, chipio_t * info,
+ 	via_hw_init(self);
+ 	return 0;
+  err_out4:
+-	dma_free_coherent(NULL, self->tx_buff.truesize,
++	dma_free_coherent(&pdev->dev, self->tx_buff.truesize,
+ 			  self->tx_buff.head, self->tx_buff_dma);
+  err_out3:
+-	dma_free_coherent(NULL, self->rx_buff.truesize,
++	dma_free_coherent(&pdev->dev, self->rx_buff.truesize,
+ 			  self->rx_buff.head, self->rx_buff_dma);
+  err_out2:
+ 	release_region(self->io.fir_base, self->io.fir_ext);
+@@ -441,10 +441,10 @@ static void __devexit via_remove_one(struct pci_dev *pdev)
+ 		   __func__, self->io.fir_base);
+ 	release_region(self->io.fir_base, self->io.fir_ext);
+ 	if (self->tx_buff.head)
+-		dma_free_coherent(NULL, self->tx_buff.truesize,
++		dma_free_coherent(&pdev->dev, self->tx_buff.truesize,
+ 				  self->tx_buff.head, self->tx_buff_dma);
+ 	if (self->rx_buff.head)
+-		dma_free_coherent(NULL, self->rx_buff.truesize,
++		dma_free_coherent(&pdev->dev, self->rx_buff.truesize,
+ 				  self->rx_buff.head, self->rx_buff_dma);
+ 	pci_set_drvdata(pdev, NULL);
+ 
+-- 
+1.7.4.1
+

Added: dists/squeeze/linux-2.6/debian/patches/bugfix/all/via-ircc-Use-pci_-get-set-_drvdata-instead-of-static.patch
==============================================================================
--- /dev/null	00:00:00 1970	(empty, because file is newly added)
+++ dists/squeeze/linux-2.6/debian/patches/bugfix/all/via-ircc-Use-pci_-get-set-_drvdata-instead-of-static.patch	Wed Mar 30 21:38:40 2011	(r17165)
@@ -0,0 +1,192 @@
+From 27928c547835ec6acb9e1fa7808c45ec813193a3 Mon Sep 17 00:00:00 2001
+From: Ben Hutchings <ben at decadent.org.uk>
+Date: Sat, 26 Mar 2011 17:30:58 +0000
+Subject: [PATCH 1/2] via-ircc: Use pci_{get,set}_drvdata() instead of static pointer variable
+
+via-ircc still maintains its own array of device pointers in Linux 2.4
+style.  Worse, it always uses index 0, so it will crash if there are
+multiple suitable devices in the system.
+
+Signed-off-by: Ben Hutchings <ben at decadent.org.uk>
+---
+ drivers/net/irda/via-ircc.c |   82 ++++++++-----------------------------------
+ 1 files changed, 15 insertions(+), 67 deletions(-)
+
+diff --git a/drivers/net/irda/via-ircc.c b/drivers/net/irda/via-ircc.c
+index 67c0ad4..cc6faca 100644
+--- a/drivers/net/irda/via-ircc.c
++++ b/drivers/net/irda/via-ircc.c
+@@ -75,15 +75,9 @@ static int dongle_id = 0;	/* default: probe */
+ /* We can't guess the type of connected dongle, user *must* supply it. */
+ module_param(dongle_id, int, 0);
+ 
+-/* FIXME : we should not need this, because instances should be automatically
+- * managed by the PCI layer. Especially that we seem to only be using the
+- * first entry. Jean II */
+-/* Max 4 instances for now */
+-static struct via_ircc_cb *dev_self[] = { NULL, NULL, NULL, NULL };
+-
+ /* Some prototypes */
+-static int via_ircc_open(int i, chipio_t * info, unsigned int id);
+-static int via_ircc_close(struct via_ircc_cb *self);
++static int via_ircc_open(struct pci_dev *pdev, chipio_t * info,
++			 unsigned int id);
+ static int via_ircc_dma_receive(struct via_ircc_cb *self);
+ static int via_ircc_dma_receive_complete(struct via_ircc_cb *self,
+ 					 int iobase);
+@@ -215,7 +209,7 @@ static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_devi
+ 			pci_write_config_byte(pcidev,0x42,(bTmp | 0xf0));
+ 			pci_write_config_byte(pcidev,0x5a,0xc0);
+ 			WriteLPCReg(0x28, 0x70 );
+-			if (via_ircc_open(0, &info,0x3076) == 0)
++			if (via_ircc_open(pcidev, &info, 0x3076) == 0)
+ 				rc=0;
+ 		} else
+ 			rc = -ENODEV; //IR not turn on	 
+@@ -254,7 +248,7 @@ static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_devi
+ 			info.irq=FirIRQ;
+ 			info.dma=FirDRQ1;
+ 			info.dma2=FirDRQ0;
+-			if (via_ircc_open(0, &info,0x3096) == 0)
++			if (via_ircc_open(pcidev, &info, 0x3096) == 0)
+ 				rc=0;
+ 		} else
+ 			rc = -ENODEV; //IR not turn on !!!!!
+@@ -264,48 +258,10 @@ static int __devinit via_init_one (struct pci_dev *pcidev, const struct pci_devi
+ 	return rc;
+ }
+ 
+-/*
+- * Function via_ircc_clean ()
+- *
+- *    Close all configured chips
+- *
+- */
+-static void via_ircc_clean(void)
+-{
+-	int i;
+-
+-	IRDA_DEBUG(3, "%s()\n", __func__);
+-
+-	for (i=0; i < ARRAY_SIZE(dev_self); i++) {
+-		if (dev_self[i])
+-			via_ircc_close(dev_self[i]);
+-	}
+-}
+-
+-static void __devexit via_remove_one (struct pci_dev *pdev)
+-{
+-	IRDA_DEBUG(3, "%s()\n", __func__);
+-
+-	/* FIXME : This is ugly. We should use pci_get_drvdata(pdev);
+-	 * to get our driver instance and call directly via_ircc_close().
+-	 * See vlsi_ir for details...
+-	 * Jean II */
+-	via_ircc_clean();
+-
+-	/* FIXME : This should be in via_ircc_close(), because here we may
+-	 * theoritically disable still configured devices :-( - Jean II */
+-	pci_disable_device(pdev);
+-}
+-
+ static void __exit via_ircc_cleanup(void)
+ {
+ 	IRDA_DEBUG(3, "%s()\n", __func__);
+ 
+-	/* FIXME : This should be redundant, as pci_unregister_driver()
+-	 * should call via_remove_one() on each device.
+-	 * Jean II */
+-	via_ircc_clean();
+-
+ 	/* Cleanup all instances of the driver */
+ 	pci_unregister_driver (&via_driver); 
+ }
+@@ -324,12 +280,13 @@ static const struct net_device_ops via_ircc_fir_ops = {
+ };
+ 
+ /*
+- * Function via_ircc_open (iobase, irq)
++ * Function via_ircc_open(pdev, iobase, irq)
+  *
+  *    Open driver instance
+  *
+  */
+-static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
++static __devinit int via_ircc_open(struct pci_dev *pdev, chipio_t * info,
++				   unsigned int id)
+ {
+ 	struct net_device *dev;
+ 	struct via_ircc_cb *self;
+@@ -337,9 +294,6 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
+ 
+ 	IRDA_DEBUG(3, "%s()\n", __func__);
+ 
+-	if (i >= ARRAY_SIZE(dev_self))
+-		return -ENOMEM;
+-
+ 	/* Allocate new instance of the driver */
+ 	dev = alloc_irdadev(sizeof(struct via_ircc_cb));
+ 	if (dev == NULL) 
+@@ -349,13 +303,8 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
+ 	self->netdev = dev;
+ 	spin_lock_init(&self->lock);
+ 
+-	/* FIXME : We should store our driver instance in the PCI layer,
+-	 * using pci_set_drvdata(), not in this array.
+-	 * See vlsi_ir for details... - Jean II */
+-	/* FIXME : 'i' is always 0 (see via_init_one()) :-( - Jean II */
+-	/* Need to store self somewhere */
+-	dev_self[i] = self;
+-	self->index = i;
++	pci_set_drvdata(pdev, self);
++
+ 	/* Initialize Resource */
+ 	self->io.cfg_base = info->cfg_base;
+ 	self->io.fir_base = info->fir_base;
+@@ -463,25 +412,24 @@ static __devinit int via_ircc_open(int i, chipio_t * info, unsigned int id)
+  err_out2:
+ 	release_region(self->io.fir_base, self->io.fir_ext);
+  err_out1:
++	pci_set_drvdata(pdev, NULL);
+ 	free_netdev(dev);
+-	dev_self[i] = NULL;
+ 	return err;
+ }
+ 
+ /*
+- * Function via_ircc_close (self)
++ * Function via_remove_one(pdev)
+  *
+  *    Close driver instance
+  *
+  */
+-static int via_ircc_close(struct via_ircc_cb *self)
++static void __devexit via_remove_one(struct pci_dev *pdev)
+ {
++	struct via_ircc_cb *self = pci_get_drvdata(pdev);
+ 	int iobase;
+ 
+ 	IRDA_DEBUG(3, "%s()\n", __func__);
+ 
+-	IRDA_ASSERT(self != NULL, return -1;);
+-
+ 	iobase = self->io.fir_base;
+ 
+ 	ResetChip(iobase, 5);	//hardware reset.
+@@ -498,11 +446,11 @@ static int via_ircc_close(struct via_ircc_cb *self)
+ 	if (self->rx_buff.head)
+ 		dma_free_coherent(NULL, self->rx_buff.truesize,
+ 				  self->rx_buff.head, self->rx_buff_dma);
+-	dev_self[self->index] = NULL;
++	pci_set_drvdata(pdev, NULL);
+ 
+ 	free_netdev(self->netdev);
+ 
+-	return 0;
++	pci_disable_device(pdev);
+ }
+ 
+ /*
+-- 
+1.7.4.1
+

Modified: dists/squeeze/linux-2.6/debian/patches/series/33
==============================================================================
--- dists/squeeze/linux-2.6/debian/patches/series/33	Wed Mar 30 21:32:08 2011	(r17164)
+++ dists/squeeze/linux-2.6/debian/patches/series/33	Wed Mar 30 21:38:40 2011	(r17165)
@@ -1,3 +1,5 @@
 + bugfix/all/drm-radeon-fall-back-to-GTT-if-bo-creation-validatio.patch
 + bugfix/all/drm-radeon-kms-Fix-retrying-ttm_bo_init-after-it-fai.patch
 + bugfix/powerpc/powerpc-Fix-default_machine_crash_shutdown-not-SMP.patch
++ bugfix/all/via-ircc-Use-pci_-get-set-_drvdata-instead-of-static.patch
++ bugfix/all/via-ircc-Pass-PCI-device-pointer-to-dma_-alloc-free-.patch



More information about the Kernel-svn-changes mailing list