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 <[email protected]> --- 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/ _______________________________________________ spi-devel-general mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/spi-devel-general
