From mboxrd@z Thu Jan 1 00:00:00 1970 From: Guennadi Liakhovetski Subject: [PATCH/RFC] spi: bitbang: add PM QoS support Date: Wed, 14 Mar 2012 22:04:25 +0100 (CET) Message-ID: Mime-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Cc: "Rafael J. Wysocki" , Magnus Damm , linux-pm-u79uwXL29TY76Z2rM5mHXA@public.gmane.org To: spi-devel-general-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org Return-path: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: spi-devel-general-bounces-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f@public.gmane.org List-Id: linux-spi.vger.kernel.org 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 --- 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 #include #include +#include #include #include @@ -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 #include 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/