From imed.benromdhane at ardia.com.tn  Tue Mar  1 09:32:46 2011
From: imed.benromdhane at ardia.com.tn (imed benromdhane)
Date: Tue, 1 Mar 2011 15:32:46 +0100
Subject: working with Libertas wi2wi as a wifi server
Message-ID: <20110301143421.55CEF6DCA2@bsmtp2.gnet.tn>

Good morning,

I have a prototype working with Libertas wifi chip (SDIO/MMC) under Linux
kernel.

I want to install a wifi server on my prototype and launch it using "udhcpd"
DHCP server, but when scanning for wifi access points, I don't get my
prototype access point.

Is there a problem on working with Libertas chip as a wifi server or is it
dedicated to work as a client or ADHOC only ( I get those two modes working
perfectly).

Thanks in advance,

Imed

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.infradead.org/pipermail/libertas-dev/attachments/20110301/e5af75fd/attachment.html>

From error27 at gmail.com  Thu Mar 10 10:23:26 2011
From: error27 at gmail.com (Dan Carpenter)
Date: Thu, 10 Mar 2011 18:23:26 +0300
Subject: [patch] libertas: fix write past end of array in mesh_id_get()
Message-ID: <20110310152326.GA2008@bicker>

defs.meshie.val.mesh_id is 32 chars long.  It's not supposed to be NUL
terminated.  This code puts a terminator on the end to make it easier to
print to sysfs.  The problem is that if the mesh_id fills the entire
buffer the original code puts the terminator one spot past the end.

The way the original code was written, there was a check to make sure
that maxlen was less than PAGE_SIZE.  Since we know that maxlen is at
most 34 chars, I just removed the check.

Signed-off-by: Dan Carpenter <error27 at gmail.com>

diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
index acf3bf6..9d097b9 100644
--- a/drivers/net/wireless/libertas/mesh.c
+++ b/drivers/net/wireless/libertas/mesh.c
@@ -918,7 +918,6 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
 			   char *buf)
 {
 	struct mrvl_mesh_defaults defs;
-	int maxlen;
 	int ret;
 
 	ret = mesh_get_default_parameters(dev, &defs);
@@ -931,13 +930,11 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
 		defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN;
 	}
 
-	/* SSID not null terminated: reserve room for \0 + \n */
-	maxlen = defs.meshie.val.mesh_id_len + 2;
-	maxlen = (PAGE_SIZE > maxlen) ? maxlen : PAGE_SIZE;
+	memcpy(buf, defs.meshie.val.mesh_id, defs.meshie.val.mesh_id_len);
+	buf[defs.meshie.val.mesh_id_len] = '\n';
+	buf[defs.meshie.val.mesh_id_len + 1] = '\0';
 
-	defs.meshie.val.mesh_id[defs.meshie.val.mesh_id_len] = '\0';
-
-	return snprintf(buf, maxlen, "%s\n", defs.meshie.val.mesh_id);
+	return defs.meshie.val.mesh_id_len + 1;
 }
 
 /**


From dcbw at redhat.com  Thu Mar 10 12:02:02 2011
From: dcbw at redhat.com (Dan Williams)
Date: Thu, 10 Mar 2011 11:02:02 -0600
Subject: [patch] libertas: fix write past end of array in mesh_id_get()
In-Reply-To: <20110310152326.GA2008@bicker>
References: <20110310152326.GA2008@bicker>
Message-ID: <1299776524.17443.14.camel@dcbw.foobar.com>

On Thu, 2011-03-10 at 18:23 +0300, Dan Carpenter wrote:
> defs.meshie.val.mesh_id is 32 chars long.  It's not supposed to be NUL
> terminated.  This code puts a terminator on the end to make it easier to
> print to sysfs.  The problem is that if the mesh_id fills the entire
> buffer the original code puts the terminator one spot past the end.
> 
> The way the original code was written, there was a check to make sure
> that maxlen was less than PAGE_SIZE.  Since we know that maxlen is at
> most 34 chars, I just removed the check.
> 
> Signed-off-by: Dan Carpenter <error27 at gmail.com>

Acked-by: Dan Williams <dcbw at redhat.com>

> diff --git a/drivers/net/wireless/libertas/mesh.c b/drivers/net/wireless/libertas/mesh.c
> index acf3bf6..9d097b9 100644
> --- a/drivers/net/wireless/libertas/mesh.c
> +++ b/drivers/net/wireless/libertas/mesh.c
> @@ -918,7 +918,6 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
>  			   char *buf)
>  {
>  	struct mrvl_mesh_defaults defs;
> -	int maxlen;
>  	int ret;
>  
>  	ret = mesh_get_default_parameters(dev, &defs);
> @@ -931,13 +930,11 @@ static ssize_t mesh_id_get(struct device *dev, struct device_attribute *attr,
>  		defs.meshie.val.mesh_id_len = IEEE80211_MAX_SSID_LEN;
>  	}
>  
> -	/* SSID not null terminated: reserve room for \0 + \n */
> -	maxlen = defs.meshie.val.mesh_id_len + 2;
> -	maxlen = (PAGE_SIZE > maxlen) ? maxlen : PAGE_SIZE;
> +	memcpy(buf, defs.meshie.val.mesh_id, defs.meshie.val.mesh_id_len);
> +	buf[defs.meshie.val.mesh_id_len] = '\n';
> +	buf[defs.meshie.val.mesh_id_len + 1] = '\0';
>  
> -	defs.meshie.val.mesh_id[defs.meshie.val.mesh_id_len] = '\0';
> -
> -	return snprintf(buf, maxlen, "%s\n", defs.meshie.val.mesh_id);
> +	return defs.meshie.val.mesh_id_len + 1;
>  }
>  
>  /**
> --
> To unsubscribe from this list: send the line "unsubscribe linux-wireless" in
> the body of a message to majordomo at vger.kernel.org
> More majordomo info at  http://vger.kernel.org/majordomo-info.html




From AlexanderWright at my.unt.edu  Tue Mar 15 14:03:00 2011
From: AlexanderWright at my.unt.edu (Wright, Alexander)
Date: Tue, 15 Mar 2011 18:03:00 +0000
Subject: libertas: tx watch dog timeout 
In-Reply-To: <7719A15B549F584B9F4FBB3A7F93FCCE0FD92502@CH1PRD0104MB017.prod.exchangelabs.com>
References: <7719A15B549F584B9F4FBB3A7F93FCCE0FD92502@CH1PRD0104MB017.prod.exchangelabs.com>
Message-ID: <7719A15B549F584B9F4FBB3A7F93FCCE0FD9DBC2@CH1PRD0104MB017.prod.exchangelabs.com>

Here is more detailed info on my kernel and the error message:
(sorry for double posting)

Hello, I have the openembedded distribution installed on a microsd card as explained here:
http://wiki.gumstix.org/index.php?title=Verdex_Git_Repository

The hardware is a gumstix verdex-pro XL6P inside an acroname garcia robot.

I have intermittant wifi problems with the libertas wireless module with the 2.6.31 kernel that I didnt experience when running 2.6.21 off the jffs2 filesystem.

This is the kernel module version info according to opkg:
kernel-module-libertas - 2.6.31-r0.5


The error is as follows:
WARNING: at net/sched/sch_generic.c:246 dev_watchdog+0x148/0x234()
NETDEV WATCHDOG: wlan0 (libertas_cs): transmit queue 0 timed out
Modules linked in: i2c_dev i2c_pxa libertas_cs libertas lib80211 tsc2003 i2c_core smsc911x libphy rfcomm pxa2xx_cs pxa2xx_core proc_gpio pcmcia pcmcia_core firmware_class ohci_hcd usbcore hidp hid l2cap bluetooth gumstix_bluetooth evdev vfat fat nls_base
[<c00345e8>] (unwind_backtrace+0x0/0xdc) from [<c0042bd0>] (warn_slowpath_common+0x4c/0x80)
[<c0042bd0>] (warn_slowpath_common+0x4c/0x80) from [<c0042c40>] (warn_slowpath_fmt+0x28/0x38)
[<c0042c40>] (warn_slowpath_fmt+0x28/0x38) from [<c01879c4>] (dev_watchdog+0x148/0x234)
[<c01879c4>] (dev_watchdog+0x148/0x234) from [<c004b3c0>] (run_timer_softirq+0x198/0x22c)
[<c004b3c0>] (run_timer_softirq+0x198/0x22c) from [<c0047840>] (__do_softirq+0x84/0x114)
[<c0047840>] (__do_softirq+0x84/0x114) from [<c0047910>] (irq_exit+0x40/0x90)
[<c0047910>] (irq_exit+0x40/0x90) from [<c002f070>] (_text+0x70/0x8c)
[<c002f070>] (_text+0x70/0x8c) from [<c002fa70>] (__irq_svc+0x30/0xc0)
Exception stack(0xc026ff78 to 0xc026ffc0)
ff60:                                                       00000001 40000013
ff80: 012f2482 60000013 c026e000 c0271b94 c028d3ac c0271b88 a001ac5c 69054117
ffa0: a001ac28 00000000 c0273848 c026ffc4 c0030914 c0030924 60000013 ffffffff
[<c002fa70>] (__irq_svc+0x30/0xc0) from [<c0030924>] (default_idle+0x30/0x34)
[<c0030924>] (default_idle+0x30/0x34) from [<c02a3ba0>] (0xc02a3ba0)
---[ end trace 06b4323742f86df0 ]---
libertas: tx watch dog timeout
libertas: command 0x001f timed out
libertas: requeueing command 0x001f due to timeout (#1)
libertas: tx watch dog timeout
libertas: command 0x001f timed out
libertas: requeueing command 0x001f due to timeout (#2)
libertas: command 0x001f timed out
libertas: requeueing command 0x001f due to timeout (#3)
libertas: command 0x001f timed out
libertas: Excessive timeouts submitting command 0x001f
libertas: tx watch dog timeout
libertas: command 0x001f timed out
libertas: requeueing command 0x001f due to timeout (#1)
libertas: tx watch dog timeout


________________________________________
From: Wright, Alexander
Sent: Monday, February 28, 2011 9:27 PM
To: libertas-dev at lists.infradead.org
Subject: libertas: tx watch dog timeout

Hello, I have an acroname garcia robot with a gumstix verdex-pro 600mhz board.
(http://www.gumstix.net/Hardware/view/Hardware-Feature-Overview-Sheets/Gumstix-Verdex-Pro-Feature-Overview/112.html)

I am running into the following problem using the "wifistix" marvel 88W8385 module with the latest openembedded kernel / filesystem
http://old.nabble.com/-verdex--libertas-wifi-driver-hangs-td28842840.html

The wifi on the original kernel / file system work fine, but I need to reinstall everything to run off a microsd card for more disk space. Is this a firmware problem? If so where can I get a recent version of the firmware and how do I install it onto my openembedded machine?

-Thanks
Alex Wright


From anarsoul at gmail.com  Tue Mar 15 16:31:25 2011
From: anarsoul at gmail.com (Vasily Khoruzhick)
Date: Tue, 15 Mar 2011 22:31:25 +0200
Subject: [PATCH 0/3] libertas_spi fixes
In-Reply-To: <201102261144.43721.anarsoul@gmail.com>
References: <1295642690-16646-1-git-send-email-anarsoul@gmail.com>
	<201102081352.51062.marek.vasut@gmail.com>
	<201102261144.43721.anarsoul@gmail.com>
Message-ID: <201103152231.25726.anarsoul@gmail.com>

On Saturday 26 February 2011 11:44:43 Vasily Khoruzhick wrote:
> On Tuesday 08 February 2011 14:52:50 Marek Vasut wrote:
> > > Nope, it can't, I tried to do so and it hangs on resume (console cursor
> > > flickers, so it's not complete hang, but it does not return control to
> > > shell). Can investigate why if you want.
> > 
> > Please do. It's not that I want to block this, but the code seems quick
> > enough.
> > 
> > Btw. Dan, sorry for not looking into this as I promised, but as I can
> > see, it isn't needed anymore. Open Source is so awesome at this :-)
> 
> Hi,
> 
> and sorry for a long delay.
> 
> It fails on firmware request, looks like pxa2xx-mci driver is not ready
> yet. It works OK without workqueue if I compile firmware into kernel (but
> it's not a way to go, right?)

Ping :) should I resend 3rd patch?

Regards
Vasily


From linville at tuxdriver.com  Tue Mar 15 16:41:55 2011
From: linville at tuxdriver.com (John W. Linville)
Date: Tue, 15 Mar 2011 16:41:55 -0400
Subject: [PATCH 0/3] libertas_spi fixes
In-Reply-To: <201103152231.25726.anarsoul@gmail.com>
References: <1295642690-16646-1-git-send-email-anarsoul@gmail.com>
	<201102081352.51062.marek.vasut@gmail.com>
	<201102261144.43721.anarsoul@gmail.com>
	<201103152231.25726.anarsoul@gmail.com>
Message-ID: <20110315204155.GE2542@tuxdriver.com>

On Tue, Mar 15, 2011 at 10:31:25PM +0200, Vasily Khoruzhick wrote:
> On Saturday 26 February 2011 11:44:43 Vasily Khoruzhick wrote:
> > On Tuesday 08 February 2011 14:52:50 Marek Vasut wrote:
> > > > Nope, it can't, I tried to do so and it hangs on resume (console cursor
> > > > flickers, so it's not complete hang, but it does not return control to
> > > > shell). Can investigate why if you want.
> > > 
> > > Please do. It's not that I want to block this, but the code seems quick
> > > enough.
> > > 
> > > Btw. Dan, sorry for not looking into this as I promised, but as I can
> > > see, it isn't needed anymore. Open Source is so awesome at this :-)
> > 
> > Hi,
> > 
> > and sorry for a long delay.
> > 
> > It fails on firmware request, looks like pxa2xx-mci driver is not ready
> > yet. It works OK without workqueue if I compile firmware into kernel (but
> > it's not a way to go, right?)
> 
> Ping :) should I resend 3rd patch?

It would seem so...

-- 
John W. Linville		Someday the world will need a hero, and you
linville at tuxdriver.com			might be all we have.  Be ready.


From anarsoul at gmail.com  Wed Mar 16 10:41:46 2011
From: anarsoul at gmail.com (Vasily Khoruzhick)
Date: Wed, 16 Mar 2011 16:41:46 +0200
Subject: [PATCH RESEND] libertas_spi: Add support for suspend/resume
In-Reply-To: <20110315204155.GE2542@tuxdriver.com>
References: <20110315204155.GE2542@tuxdriver.com>
Message-ID: <1300286506-13318-1-git-send-email-anarsoul@gmail.com>

Add support for suspend/resume in if_spi.

Signed-off-by: Vasily Khoruzhick <anarsoul at gmail.com>
---
 drivers/net/wireless/libertas/if_spi.c |   65 ++++++++++++++++++++++++++++++++
 1 files changed, 65 insertions(+), 0 deletions(-)

diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
index f6c2cd6..078ef43 100644
--- a/drivers/net/wireless/libertas/if_spi.c
+++ b/drivers/net/wireless/libertas/if_spi.c
@@ -57,6 +57,7 @@ struct if_spi_card {
 	/* Handles all SPI communication (except for FW load) */
 	struct workqueue_struct		*workqueue;
 	struct work_struct		packet_work;
+	struct work_struct		resume_work;
 
 	u8				cmd_buffer[IF_SPI_CMD_BUF_SIZE];
 
@@ -68,6 +69,9 @@ struct if_spi_card {
 
 	/* Protects cmd_packet_list and data_packet_list */
 	spinlock_t			buffer_lock;
+
+	/* True is card suspended */
+	u8				suspended;
 };
 
 static void free_if_spi_card(struct if_spi_card *card)
@@ -1057,6 +1061,28 @@ out:
 	return err;
 }
 
+static void if_spi_resume_worker(struct work_struct *work)
+{
+	struct if_spi_card *card;
+
+	card = container_of(work, struct if_spi_card, resume_work);
+
+	if (card->suspended) {
+		if (card->pdata->setup)
+			card->pdata->setup(card->spi);
+
+		/* Init card ... */
+		if_spi_init_card(card);
+
+		enable_irq(card->spi->irq);
+
+		/* And resume it ... */
+		lbs_resume(card->priv);
+
+		card->suspended = 0;
+	}
+}
+
 static int __devinit if_spi_probe(struct spi_device *spi)
 {
 	struct if_spi_card *card;
@@ -1107,6 +1133,7 @@ static int __devinit if_spi_probe(struct spi_device *spi)
 		goto free_card;
 	}
 	card->priv = priv;
+	priv->setup_fw_on_resume = 1;
 	priv->card = card;
 	priv->hw_host_to_card = if_spi_host_to_card;
 	priv->enter_deep_sleep = NULL;
@@ -1117,6 +1144,7 @@ static int __devinit if_spi_probe(struct spi_device *spi)
 	/* Initialize interrupt handling stuff. */
 	card->workqueue = create_workqueue("libertas_spi");
 	INIT_WORK(&card->packet_work, if_spi_host_to_card_worker);
+	INIT_WORK(&card->resume_work, if_spi_resume_worker);
 
 	err = request_irq(spi->irq, if_spi_host_interrupt,
 			IRQF_TRIGGER_FALLING, "libertas_spi", card);
@@ -1161,6 +1189,8 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
 	lbs_deb_spi("libertas_spi_remove\n");
 	lbs_deb_enter(LBS_DEB_SPI);
 
+	cancel_work_sync(&card->resume_work);
+
 	lbs_stop_card(priv);
 	lbs_remove_card(priv); /* will call free_netdev */
 
@@ -1174,6 +1204,40 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
 	return 0;
 }
 
+static int if_spi_suspend(struct device *dev)
+{
+	struct spi_device *spi = to_spi_device(dev);
+	struct if_spi_card *card = spi_get_drvdata(spi);
+
+	if (!card->suspended) {
+		lbs_suspend(card->priv);
+		flush_workqueue(card->workqueue);
+		disable_irq(spi->irq);
+
+		if (card->pdata->teardown)
+			card->pdata->teardown(spi);
+		card->suspended = 1;
+	}
+
+	return 0;
+}
+
+static int if_spi_resume(struct device *dev)
+{
+	struct spi_device *spi = to_spi_device(dev);
+	struct if_spi_card *card = spi_get_drvdata(spi);
+
+	/* Schedule delayed work */
+	schedule_work(&card->resume_work);
+
+	return 0;
+}
+
+static const struct dev_pm_ops if_spi_pm_ops = {
+	.suspend	= if_spi_suspend,
+	.resume		= if_spi_resume,
+};
+
 static struct spi_driver libertas_spi_driver = {
 	.probe	= if_spi_probe,
 	.remove = __devexit_p(libertas_spi_remove),
@@ -1181,6 +1245,7 @@ static struct spi_driver libertas_spi_driver = {
 		.name	= "libertas_spi",
 		.bus	= &spi_bus_type,
 		.owner	= THIS_MODULE,
+		.pm	= &if_spi_pm_ops,
 	},
 };
 
-- 
1.7.4.1



From dcbw at redhat.com  Thu Mar 17 12:44:27 2011
From: dcbw at redhat.com (Dan Williams)
Date: Thu, 17 Mar 2011 11:44:27 -0500
Subject: [PATCH RESEND] libertas_spi: Add support for suspend/resume
In-Reply-To: <1300286506-13318-1-git-send-email-anarsoul@gmail.com>
References: <20110315204155.GE2542@tuxdriver.com>
	<1300286506-13318-1-git-send-email-anarsoul@gmail.com>
Message-ID: <1300380270.11539.8.camel@dcbw.foobar.com>

On Wed, 2011-03-16 at 16:41 +0200, Vasily Khoruzhick wrote:
> Add support for suspend/resume in if_spi.
> 
> Signed-off-by: Vasily Khoruzhick <anarsoul at gmail.com>

Unless Marek chimes in, I don't have a problem with this patch if it
fixes the problem.  The one issue I can see is that if userspace isn't
ready yet, the request_firmware() call will fail because we're not
caching firmware anywhere, and we probably shouldn't be since the
firmware is large.  I'm not sure there's a good solution without caching
firmware though, but I don't want that to block the patch...

Acked-by: Dan Williams <dcbw at redhat.com>

> ---
>  drivers/net/wireless/libertas/if_spi.c |   65 ++++++++++++++++++++++++++++++++
>  1 files changed, 65 insertions(+), 0 deletions(-)
> 
> diff --git a/drivers/net/wireless/libertas/if_spi.c b/drivers/net/wireless/libertas/if_spi.c
> index f6c2cd6..078ef43 100644
> --- a/drivers/net/wireless/libertas/if_spi.c
> +++ b/drivers/net/wireless/libertas/if_spi.c
> @@ -57,6 +57,7 @@ struct if_spi_card {
>  	/* Handles all SPI communication (except for FW load) */
>  	struct workqueue_struct		*workqueue;
>  	struct work_struct		packet_work;
> +	struct work_struct		resume_work;
>  
>  	u8				cmd_buffer[IF_SPI_CMD_BUF_SIZE];
>  
> @@ -68,6 +69,9 @@ struct if_spi_card {
>  
>  	/* Protects cmd_packet_list and data_packet_list */
>  	spinlock_t			buffer_lock;
> +
> +	/* True is card suspended */
> +	u8				suspended;
>  };
>  
>  static void free_if_spi_card(struct if_spi_card *card)
> @@ -1057,6 +1061,28 @@ out:
>  	return err;
>  }
>  
> +static void if_spi_resume_worker(struct work_struct *work)
> +{
> +	struct if_spi_card *card;
> +
> +	card = container_of(work, struct if_spi_card, resume_work);
> +
> +	if (card->suspended) {
> +		if (card->pdata->setup)
> +			card->pdata->setup(card->spi);
> +
> +		/* Init card ... */
> +		if_spi_init_card(card);
> +
> +		enable_irq(card->spi->irq);
> +
> +		/* And resume it ... */
> +		lbs_resume(card->priv);
> +
> +		card->suspended = 0;
> +	}
> +}
> +
>  static int __devinit if_spi_probe(struct spi_device *spi)
>  {
>  	struct if_spi_card *card;
> @@ -1107,6 +1133,7 @@ static int __devinit if_spi_probe(struct spi_device *spi)
>  		goto free_card;
>  	}
>  	card->priv = priv;
> +	priv->setup_fw_on_resume = 1;
>  	priv->card = card;
>  	priv->hw_host_to_card = if_spi_host_to_card;
>  	priv->enter_deep_sleep = NULL;
> @@ -1117,6 +1144,7 @@ static int __devinit if_spi_probe(struct spi_device *spi)
>  	/* Initialize interrupt handling stuff. */
>  	card->workqueue = create_workqueue("libertas_spi");
>  	INIT_WORK(&card->packet_work, if_spi_host_to_card_worker);
> +	INIT_WORK(&card->resume_work, if_spi_resume_worker);
>  
>  	err = request_irq(spi->irq, if_spi_host_interrupt,
>  			IRQF_TRIGGER_FALLING, "libertas_spi", card);
> @@ -1161,6 +1189,8 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
>  	lbs_deb_spi("libertas_spi_remove\n");
>  	lbs_deb_enter(LBS_DEB_SPI);
>  
> +	cancel_work_sync(&card->resume_work);
> +
>  	lbs_stop_card(priv);
>  	lbs_remove_card(priv); /* will call free_netdev */
>  
> @@ -1174,6 +1204,40 @@ static int __devexit libertas_spi_remove(struct spi_device *spi)
>  	return 0;
>  }
>  
> +static int if_spi_suspend(struct device *dev)
> +{
> +	struct spi_device *spi = to_spi_device(dev);
> +	struct if_spi_card *card = spi_get_drvdata(spi);
> +
> +	if (!card->suspended) {
> +		lbs_suspend(card->priv);
> +		flush_workqueue(card->workqueue);
> +		disable_irq(spi->irq);
> +
> +		if (card->pdata->teardown)
> +			card->pdata->teardown(spi);
> +		card->suspended = 1;
> +	}
> +
> +	return 0;
> +}
> +
> +static int if_spi_resume(struct device *dev)
> +{
> +	struct spi_device *spi = to_spi_device(dev);
> +	struct if_spi_card *card = spi_get_drvdata(spi);
> +
> +	/* Schedule delayed work */
> +	schedule_work(&card->resume_work);
> +
> +	return 0;
> +}
> +
> +static const struct dev_pm_ops if_spi_pm_ops = {
> +	.suspend	= if_spi_suspend,
> +	.resume		= if_spi_resume,
> +};
> +
>  static struct spi_driver libertas_spi_driver = {
>  	.probe	= if_spi_probe,
>  	.remove = __devexit_p(libertas_spi_remove),
> @@ -1181,6 +1245,7 @@ static struct spi_driver libertas_spi_driver = {
>  		.name	= "libertas_spi",
>  		.bus	= &spi_bus_type,
>  		.owner	= THIS_MODULE,
> +		.pm	= &if_spi_pm_ops,
>  	},
>  };
>  




From marek.vasut at gmail.com  Sat Mar 19 15:00:37 2011
From: marek.vasut at gmail.com (Marek Vasut)
Date: Sat, 19 Mar 2011 20:00:37 +0100
Subject: [PATCH RESEND] libertas_spi: Add support for suspend/resume
In-Reply-To: <1300380270.11539.8.camel@dcbw.foobar.com>
References: <20110315204155.GE2542@tuxdriver.com>
	<1300286506-13318-1-git-send-email-anarsoul@gmail.com>
	<1300380270.11539.8.camel@dcbw.foobar.com>
Message-ID: <201103192000.37787.marek.vasut@gmail.com>

On Thursday 17 March 2011 17:44:27 Dan Williams wrote:
> On Wed, 2011-03-16 at 16:41 +0200, Vasily Khoruzhick wrote:
> > Add support for suspend/resume in if_spi.
> > 
> > Signed-off-by: Vasily Khoruzhick <anarsoul at gmail.com>
> 
> Unless Marek chimes in, I don't have a problem with this patch if it
> fixes the problem.  The one issue I can see is that if userspace isn't
> ready yet, the request_firmware() call will fail because we're not
> caching firmware anywhere, and we probably shouldn't be since the
> firmware is large.  I'm not sure there's a good solution without caching
> firmware though, but I don't want that to block the patch...

Maybe we should implement in-kernel FW cache for this kind of situations. Such 
feature could be configurable too ?

Cheers
> 
> Acked-by: Dan Williams <dcbw at redhat.com>
> 
> > ---
> > 
> >  drivers/net/wireless/libertas/if_spi.c |   65
> >  ++++++++++++++++++++++++++++++++ 1 files changed, 65 insertions(+), 0
> >  deletions(-)
> > 
> > diff --git a/drivers/net/wireless/libertas/if_spi.c
> > b/drivers/net/wireless/libertas/if_spi.c index f6c2cd6..078ef43 100644
> > --- a/drivers/net/wireless/libertas/if_spi.c
> > +++ b/drivers/net/wireless/libertas/if_spi.c
> > @@ -57,6 +57,7 @@ struct if_spi_card {
> > 
> >  	/* Handles all SPI communication (except for FW load) */
> >  	struct workqueue_struct		*workqueue;
> >  	struct work_struct		packet_work;
> > 
> > +	struct work_struct		resume_work;
> > 
> >  	u8				cmd_buffer[IF_SPI_CMD_BUF_SIZE];
> > 
> > @@ -68,6 +69,9 @@ struct if_spi_card {
> > 
> >  	/* Protects cmd_packet_list and data_packet_list */
> >  	spinlock_t			buffer_lock;
> > 
> > +
> > +	/* True is card suspended */
> > +	u8				suspended;
> > 
> >  };
> >  
> >  static void free_if_spi_card(struct if_spi_card *card)
> > 
> > @@ -1057,6 +1061,28 @@ out:
> >  	return err;
> >  
> >  }
> > 
> > +static void if_spi_resume_worker(struct work_struct *work)
> > +{
> > +	struct if_spi_card *card;
> > +
> > +	card = container_of(work, struct if_spi_card, resume_work);
> > +
> > +	if (card->suspended) {
> > +		if (card->pdata->setup)
> > +			card->pdata->setup(card->spi);
> > +
> > +		/* Init card ... */
> > +		if_spi_init_card(card);
> > +
> > +		enable_irq(card->spi->irq);
> > +
> > +		/* And resume it ... */
> > +		lbs_resume(card->priv);
> > +
> > +		card->suspended = 0;
> > +	}
> > +}
> > +
> > 
> >  static int __devinit if_spi_probe(struct spi_device *spi)
> >  {
> >  
> >  	struct if_spi_card *card;
> > 
> > @@ -1107,6 +1133,7 @@ static int __devinit if_spi_probe(struct spi_device
> > *spi)
> > 
> >  		goto free_card;
> >  	
> >  	}
> >  	card->priv = priv;
> > 
> > +	priv->setup_fw_on_resume = 1;
> > 
> >  	priv->card = card;
> >  	priv->hw_host_to_card = if_spi_host_to_card;
> >  	priv->enter_deep_sleep = NULL;
> > 
> > @@ -1117,6 +1144,7 @@ static int __devinit if_spi_probe(struct spi_device
> > *spi)
> > 
> >  	/* Initialize interrupt handling stuff. */
> >  	card->workqueue = create_workqueue("libertas_spi");
> >  	INIT_WORK(&card->packet_work, if_spi_host_to_card_worker);
> > 
> > +	INIT_WORK(&card->resume_work, if_spi_resume_worker);
> > 
> >  	err = request_irq(spi->irq, if_spi_host_interrupt,
> >  	
> >  			IRQF_TRIGGER_FALLING, "libertas_spi", card);
> > 
> > @@ -1161,6 +1189,8 @@ static int __devexit libertas_spi_remove(struct
> > spi_device *spi)
> > 
> >  	lbs_deb_spi("libertas_spi_remove\n");
> >  	lbs_deb_enter(LBS_DEB_SPI);
> > 
> > +	cancel_work_sync(&card->resume_work);
> > +
> > 
> >  	lbs_stop_card(priv);
> >  	lbs_remove_card(priv); /* will call free_netdev */
> > 
> > @@ -1174,6 +1204,40 @@ static int __devexit libertas_spi_remove(struct
> > spi_device *spi)
> > 
> >  	return 0;
> >  
> >  }
> > 
> > +static int if_spi_suspend(struct device *dev)
> > +{
> > +	struct spi_device *spi = to_spi_device(dev);
> > +	struct if_spi_card *card = spi_get_drvdata(spi);
> > +
> > +	if (!card->suspended) {
> > +		lbs_suspend(card->priv);
> > +		flush_workqueue(card->workqueue);
> > +		disable_irq(spi->irq);
> > +
> > +		if (card->pdata->teardown)
> > +			card->pdata->teardown(spi);
> > +		card->suspended = 1;
> > +	}
> > +
> > +	return 0;
> > +}
> > +
> > +static int if_spi_resume(struct device *dev)
> > +{
> > +	struct spi_device *spi = to_spi_device(dev);
> > +	struct if_spi_card *card = spi_get_drvdata(spi);
> > +
> > +	/* Schedule delayed work */
> > +	schedule_work(&card->resume_work);
> > +
> > +	return 0;
> > +}
> > +
> > +static const struct dev_pm_ops if_spi_pm_ops = {
> > +	.suspend	= if_spi_suspend,
> > +	.resume		= if_spi_resume,
> > +};
> > +
> > 
> >  static struct spi_driver libertas_spi_driver = {
> >  
> >  	.probe	= if_spi_probe,
> >  	.remove = __devexit_p(libertas_spi_remove),
> > 
> > @@ -1181,6 +1245,7 @@ static struct spi_driver libertas_spi_driver = {
> > 
> >  		.name	= "libertas_spi",
> >  		.bus	= &spi_bus_type,
> >  		.owner	= THIS_MODULE,
> > 
> > +		.pm	= &if_spi_pm_ops,
> > 
> >  	},
> >  
> >  };


From thecrap at shaw.ca  Mon Mar 21 11:58:33 2011
From: thecrap at shaw.ca (' ')
Date: Mon, 21 Mar 2011 08:58:33 -0700
Subject: Kernel Oops on umid mbook M1 (sd9696)
Message-ID: <4D8775A9.5010102@shaw.ca>

Hello all,

I've posted this to Ubuntu launchpad
(https://bugs.launchpad.net/ubuntu/+source/libertas-firmware/+bug/722725),
but have not received any advice, so I'm posting here.

Using 10.10 netbook ubuntu, tried libertas 9.70.7.p0-1 and 9.70.7.p0.0-1 .

Networks show up in nm-applet, but they can't be connected to, the
password gets asked over and over again.

dmesg shows a kernel oops, highlight:

[ 52.216283] Oops: 0000 [#2] SMP
[ 52.216296] last sysfs file:
/sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:00/PNP0C0A:00/power_supply/BAT0/voltage_now
[ 52.216313] Modules linked in: nls_iso8859_1 nls_cp437 vfat fat
binfmt_misc parport_pc ppdev snd_hda_codec_realtek snd_hda_intel rfcomm
snd_hda_codec snd_hwdep snd_pcm snd_seq_midi sco snd_rawmidi bnep
snd_seq_midi_event snd_seq l2cap libertas_sdio libertas snd_timer
snd_seq_device cfg80211 btusb sch_gpio snd bluetooth i2c_isch lib80211
video psmouse output serio_raw soundcore lpc_sch snd_page_alloc lp
parport usbhid hid usb_storage mmc_block pata_sch sdhci_pci sdhci led_class
[ 52.216459]
[ 52.216474] Pid: 791, comm: lbs_main Tainted: G D 2.6.35-22-generic
#33-Ubuntu To be filled by O.E.M./M-BOOK
[ 52.216490] EIP: 0060:[<c04db126>] EFLAGS: 00010286 CPU: 1
[ 52.216504] EIP is at sdio_align_size+0x16/0x220
[ 52.216516] EAX: 04f25000 EBX: 04f25000 ECX: dd840000 EDX: 00000043
[ 52.216528] ESI: 00000001 EDI: 0000003f EBP: de3dbee8 ESP: de3dbed4
[ 52.216541] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
[ 52.216554] Process lbs_main (pid: 791, ti=de3da000 task=de3bf230
task.ti=de3da000)
[ 52.216564] Stack:
[ 52.216571] df076580 de3dbf00 de28c2c0 00000001 0000003f de3dbf18
dfebf760 c013eabd
[ 52.216599] <0> 0000003f 00000043 de3dbf04 de294000 013dbf18 dd840000
de28c2c0 de294000
[ 52.216630] <0> de13ea00 de3dbf40 dff4cb0a 0000003f de3dbf2c de28e200
000004e2 00068b9f
[ 52.216662] Call Trace:
[ 52.216695] [<dfebf760>] ? if_sdio_host_to_card+0x60/0x140 [libertas_sdio]
[ 52.216708] [<c013eabd>] ? finish_task_switch+0x3d/0xc0
[ 52.216728] [<dff4cb0a>] ? lbs_submit_command+0x7a/0x110 [libertas]
[ 52.216745] [<dff4d118>] ? lbs_execute_next_command+0xc8/0x210 [libertas]
[ 52.216757] [<c01660d1>] ? remove_wait_queue+0x41/0x50
[ 52.216776] [<dff508d1>] ? lbs_thread+0x3c1/0x4e0 [libertas]
[ 52.216788] [<c0142d20>] ? default_wake_function+0x0/0x20
[ 52.216806] [<dff50510>] ? lbs_thread+0x0/0x4e0 [libertas]
[ 52.216816] [<c01659e4>] ? kthread+0x74/0x80
[ 52.216825] [<c0165970>] ? kthread+0x0/0x80
[ 52.216835] [<c010363e>] ? kernel_thread_helper+0x6/0x10
[ 52.216840] Code: 90 8d 74 26 00 0f b7 86 64 01 00 00 83 c4 04 5b 5e 5d
c3 66 90 55 89 e5 83 ec 14 89 5d f4 89 75 f8 89 7d fc 0f 1f 44 00 00 89
c3 <8b> 00 89 d6 e8 d1 8c ff ff 89 45 f0 8b 0b 8b 01 8b 90 6c 01 00
[ 52.216937] EIP: [<c04db126>] sdio_align_size+0x16/0x220 SS:ESP
0068:de3dbed4
[ 52.216950] CR2: 0000000004f25000
[ 52.216958] ---[ end trace 07da2f4d2d15513d ]---

Full dmesg can be access through the ubuntu bug report.

Thanks for your time,
B.


From dcbw at redhat.com  Thu Mar 31 13:43:35 2011
From: dcbw at redhat.com (Dan Williams)
Date: Thu, 31 Mar 2011 12:43:35 -0500
Subject: Kernel Oops on umid mbook M1 (sd9696)
In-Reply-To: <4D8775A9.5010102@shaw.ca>
References: <4D8775A9.5010102@shaw.ca>
Message-ID: <1301593416.6681.11.camel@dcbw.foobar.com>

On Mon, 2011-03-21 at 08:58 -0700, ' ' wrote:
> Hello all,
> 
> I've posted this to Ubuntu launchpad
> (https://bugs.launchpad.net/ubuntu/+source/libertas-firmware/+bug/722725),
> but have not received any advice, so I'm posting here.
> 
> Using 10.10 netbook ubuntu, tried libertas 9.70.7.p0-1 and 9.70.7.p0.0-1 .

We're going to need some libertas debug output I think.  Also, what SDIO
controller do you have?  "lspci" should tell us since I think your
controller is a PCI-based device.

You can get libertas debug info by using this option when loading the
'libertas' module:

libertas_debug=0x5063a7

That can also go into /etc/modprobe.conf or /etc/modprobe.d/local.conf
as:

options libertas libertas_debug=0x5063a7

and you'll get a lot more spew in dmesg about what's going on.

Dan


> Networks show up in nm-applet, but they can't be connected to, the
> password gets asked over and over again.
> 
> dmesg shows a kernel oops, highlight:
> 
> [ 52.216283] Oops: 0000 [#2] SMP
> [ 52.216296] last sysfs file:
> /sys/devices/LNXSYSTM:00/LNXSYBUS:00/PNP0A08:00/device:00/PNP0C0A:00/power_supply/BAT0/voltage_now
> [ 52.216313] Modules linked in: nls_iso8859_1 nls_cp437 vfat fat
> binfmt_misc parport_pc ppdev snd_hda_codec_realtek snd_hda_intel rfcomm
> snd_hda_codec snd_hwdep snd_pcm snd_seq_midi sco snd_rawmidi bnep
> snd_seq_midi_event snd_seq l2cap libertas_sdio libertas snd_timer
> snd_seq_device cfg80211 btusb sch_gpio snd bluetooth i2c_isch lib80211
> video psmouse output serio_raw soundcore lpc_sch snd_page_alloc lp
> parport usbhid hid usb_storage mmc_block pata_sch sdhci_pci sdhci led_class
> [ 52.216459]
> [ 52.216474] Pid: 791, comm: lbs_main Tainted: G D 2.6.35-22-generic
> #33-Ubuntu To be filled by O.E.M./M-BOOK
> [ 52.216490] EIP: 0060:[<c04db126>] EFLAGS: 00010286 CPU: 1
> [ 52.216504] EIP is at sdio_align_size+0x16/0x220
> [ 52.216516] EAX: 04f25000 EBX: 04f25000 ECX: dd840000 EDX: 00000043
> [ 52.216528] ESI: 00000001 EDI: 0000003f EBP: de3dbee8 ESP: de3dbed4
> [ 52.216541] DS: 007b ES: 007b FS: 00d8 GS: 00e0 SS: 0068
> [ 52.216554] Process lbs_main (pid: 791, ti=de3da000 task=de3bf230
> task.ti=de3da000)
> [ 52.216564] Stack:
> [ 52.216571] df076580 de3dbf00 de28c2c0 00000001 0000003f de3dbf18
> dfebf760 c013eabd
> [ 52.216599] <0> 0000003f 00000043 de3dbf04 de294000 013dbf18 dd840000
> de28c2c0 de294000
> [ 52.216630] <0> de13ea00 de3dbf40 dff4cb0a 0000003f de3dbf2c de28e200
> 000004e2 00068b9f
> [ 52.216662] Call Trace:
> [ 52.216695] [<dfebf760>] ? if_sdio_host_to_card+0x60/0x140 [libertas_sdio]
> [ 52.216708] [<c013eabd>] ? finish_task_switch+0x3d/0xc0
> [ 52.216728] [<dff4cb0a>] ? lbs_submit_command+0x7a/0x110 [libertas]
> [ 52.216745] [<dff4d118>] ? lbs_execute_next_command+0xc8/0x210 [libertas]
> [ 52.216757] [<c01660d1>] ? remove_wait_queue+0x41/0x50
> [ 52.216776] [<dff508d1>] ? lbs_thread+0x3c1/0x4e0 [libertas]
> [ 52.216788] [<c0142d20>] ? default_wake_function+0x0/0x20
> [ 52.216806] [<dff50510>] ? lbs_thread+0x0/0x4e0 [libertas]
> [ 52.216816] [<c01659e4>] ? kthread+0x74/0x80
> [ 52.216825] [<c0165970>] ? kthread+0x0/0x80
> [ 52.216835] [<c010363e>] ? kernel_thread_helper+0x6/0x10
> [ 52.216840] Code: 90 8d 74 26 00 0f b7 86 64 01 00 00 83 c4 04 5b 5e 5d
> c3 66 90 55 89 e5 83 ec 14 89 5d f4 89 75 f8 89 7d fc 0f 1f 44 00 00 89
> c3 <8b> 00 89 d6 e8 d1 8c ff ff 89 45 f0 8b 0b 8b 01 8b 90 6c 01 00
> [ 52.216937] EIP: [<c04db126>] sdio_align_size+0x16/0x220 SS:ESP
> 0068:de3dbed4
> [ 52.216950] CR2: 0000000004f25000
> [ 52.216958] ---[ end trace 07da2f4d2d15513d ]---
> 
> Full dmesg can be access through the ubuntu bug report.
> 
> Thanks for your time,
> B.
> 
> _______________________________________________
> libertas-dev mailing list
> libertas-dev at lists.infradead.org
> http://lists.infradead.org/mailman/listinfo/libertas-dev




