All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH/RFC] spi: bitbang: add PM QoS support
@ 2012-03-14 21:04 Guennadi Liakhovetski
       [not found] ` <Pine.LNX.4.64.1203141837170.30291-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
  0 siblings, 1 reply; 13+ messages in thread
From: Guennadi Liakhovetski @ 2012-03-14 21:04 UTC (permalink / raw)
  To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
  Cc: Rafael J. Wysocki, Magnus Damm, linux-pm-u79uwXL29TY76Z2rM5mHXA

This patch adds a PM QoS requirement to the spi-bitbang driver, preventing
the underlying SPI hardware driver to suspend for too long a time, as long
as there are transfers on the queue.

Signed-off-by: Guennadi Liakhovetski <g.liakhovetski-Mmb7MZpHnFY@public.gmane.org>
---

RFC, because a patch set has been developed recently, adding a PM QoS 
sysfs attribute to all supporting devices per 
dev_pm_qos_expose_latency_limit(). But I'm not sure, whether and how to 
combine user-space supplied constraint with driver's own idea of which 
code paths should be executed with amended latency requirements. Maybe 
this should be discussed separately, though.

 drivers/spi/spi-bitbang.c       |    6 ++++++
 include/linux/spi/spi_bitbang.h |    2 ++
 2 files changed, 8 insertions(+), 0 deletions(-)

diff --git a/drivers/spi/spi-bitbang.c b/drivers/spi/spi-bitbang.c
index aef59b1..497e725 100644
--- a/drivers/spi/spi-bitbang.c
+++ b/drivers/spi/spi-bitbang.c
@@ -24,6 +24,7 @@
 #include <linux/delay.h>
 #include <linux/errno.h>
 #include <linux/platform_device.h>
+#include <linux/pm_qos.h>
 #include <linux/slab.h>
 
 #include <linux/spi/spi.h>
@@ -260,6 +261,8 @@ static void bitbang_work(struct work_struct *work)
 	struct spi_bitbang	*bitbang =
 		container_of(work, struct spi_bitbang, work);
 	unsigned long		flags;
+	int pmrq = dev_pm_qos_add_request(bitbang->master->dev.parent,
+					  &bitbang->pm_qos, 100);
 
 	spin_lock_irqsave(&bitbang->lock, flags);
 	bitbang->busy = 1;
@@ -376,6 +379,9 @@ static void bitbang_work(struct work_struct *work)
 	}
 	bitbang->busy = 0;
 	spin_unlock_irqrestore(&bitbang->lock, flags);
+
+	if (pmrq >= 0)
+		dev_pm_qos_remove_request(&bitbang->pm_qos);
 }
 
 /**
diff --git a/include/linux/spi/spi_bitbang.h b/include/linux/spi/spi_bitbang.h
index f987a2b..bed583f1 100644
--- a/include/linux/spi/spi_bitbang.h
+++ b/include/linux/spi/spi_bitbang.h
@@ -1,6 +1,7 @@
 #ifndef	__SPI_BITBANG_H
 #define	__SPI_BITBANG_H
 
+#include <linux/pm_qos.h>
 #include <linux/workqueue.h>
 
 struct spi_bitbang {
@@ -12,6 +13,7 @@ struct spi_bitbang {
 	u8			busy;
 	u8			use_dma;
 	u8			flags;		/* extra spi->mode support */
+	struct dev_pm_qos_request pm_qos;
 
 	struct spi_master	*master;
 
-- 
1.7.2.5


------------------------------------------------------------------------------
Virtualization & Cloud Management Using Capacity Planning
Cloud computing makes use of virtualization - but cloud computing 
also focuses on allowing computing to be delivered as a service.
http://www.accelacomm.com/jaw/sfnl/114/51521223/

^ permalink raw reply related	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2012-05-21 11:19 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-03-14 21:04 [PATCH/RFC] spi: bitbang: add PM QoS support Guennadi Liakhovetski
     [not found] ` <Pine.LNX.4.64.1203141837170.30291-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2012-03-15  9:29   ` Grant Likely
2012-03-15 16:57     ` Guennadi Liakhovetski
     [not found]       ` <Pine.LNX.4.64.1203151747480.2988-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2012-03-15 21:21         ` Grant Likely
2012-03-16  9:06     ` Linus Walleij
     [not found]       ` <CACRpkdZNQZyx-HZjzyMctpUQJtNYMwq5KsdE6RTFwKcHuz_X+w-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-16 23:39         ` [PATCH] spi: bitbang: convert to using core message queue Guennadi Liakhovetski
     [not found]           ` <Pine.LNX.4.64.1203170036590.20979-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2012-03-18 23:33             ` Linus Walleij
     [not found]               ` <CACRpkdZFobGAqO-8xe_JqA9stc=S6SHBCNEN4DSXy1AN5Ro8HQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-03-20 14:40                 ` Grant Likely
2012-04-11 20:56                   ` Guennadi Liakhovetski
     [not found]                     ` <Pine.LNX.4.64.1204112254420.10361-0199iw4Nj15frtckUFj5Ag@public.gmane.org>
2012-04-18 12:20                       ` Linus Walleij
2012-05-16  6:57             ` Linus Walleij
     [not found]               ` <CACRpkdYFj6btOx75_myH45+tyqg3h21xnTL7PofydNeOVVQz_g-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
2012-05-20  3:02                 ` Grant Likely
2012-05-21 11:19                   ` Guennadi Liakhovetski

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.