From patchwork Fri May 24 12:53:05 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lorenzo Pieralisi X-Patchwork-Id: 2611231 Return-Path: X-Original-To: patchwork-linux-arm@patchwork.kernel.org Delivered-To: patchwork-process-083081@patchwork2.kernel.org Received: from casper.infradead.org (casper.infradead.org [85.118.1.10]) by patchwork2.kernel.org (Postfix) with ESMTP id 37B7CDF24C for ; Fri, 24 May 2013 12:55:17 +0000 (UTC) Received: from merlin.infradead.org ([2001:4978:20e::2]) by casper.infradead.org with esmtps (Exim 4.80.1 #2 (Red Hat Linux)) id 1UfrVh-0007lw-78; Fri, 24 May 2013 12:54:18 +0000 Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UfrVR-0006j2-E2; Fri, 24 May 2013 12:54:01 +0000 Received: from service87.mimecast.com ([91.220.42.44]) by merlin.infradead.org with esmtp (Exim 4.80.1 #2 (Red Hat Linux)) id 1UfrV9-0006fX-GN for linux-arm-kernel@lists.infradead.org; Fri, 24 May 2013 12:53:46 +0000 Received: from cam-owa2.Emea.Arm.com (fw-tnat.cambridge.arm.com [217.140.96.21]) by service87.mimecast.com; Fri, 24 May 2013 13:53:23 +0100 Received: from e102568-lin.cambridge.arm.com ([10.1.255.212]) by cam-owa2.Emea.Arm.com with Microsoft SMTPSVC(6.0.3790.3959); Fri, 24 May 2013 13:53:21 +0100 From: Lorenzo Pieralisi To: linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org Subject: [RFC PATCH 2/3] drivers: mfd: vexpress: add timeout API to vexpress config interface Date: Fri, 24 May 2013 13:53:05 +0100 Message-Id: <1369399986-15649-3-git-send-email-lorenzo.pieralisi@arm.com> X-Mailer: git-send-email 1.8.2.2 In-Reply-To: <1369399986-15649-1-git-send-email-lorenzo.pieralisi@arm.com> References: <1369399986-15649-1-git-send-email-lorenzo.pieralisi@arm.com> X-OriginalArrivalTime: 24 May 2013 12:53:21.0462 (UTC) FILETIME=[ABAB7560:01CE587D] X-MC-Unique: 113052413532301501 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20130524_085343_768020_FE9DD5FC X-CRM114-Status: GOOD ( 10.50 ) X-Spam-Score: -2.6 (--) X-Spam-Report: SpamAssassin version 3.3.2 on merlin.infradead.org summary: Content analysis details: (-2.6 points) pts rule name description ---- ---------------------- -------------------------------------------------- -0.7 RCVD_IN_DNSWL_LOW RBL: Sender listed at http://www.dnswl.org/, low trust [91.220.42.44 listed in list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% [score: 0.0000] Cc: Nicolas Pitre , Jon Medhurst , Lorenzo Pieralisi , Samuel Ortiz , Pawel Moll , Sudeep KarkadaNagesha , devicetree-discuss@lists.ozlabs.org, Amit Kucheria , Achin Gupta X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+patchwork-linux-arm=patchwork.kernel.org@lists.infradead.org In case some transactions to the Serial Power Controller (SPC) are lost owing to multiple operations handled at once by the M3 controller the OS needs to rely on a configuration API that can time out so that failures do not result in an unusable system. This patch adds a timeout API to the vexpress config programming interface, and refactors the existing read/write functions so that they can be reused seamlessly on top of the newly defined API. Cc: Samuel Ortiz Cc: Achin Gupta Cc: Sudeep KarkadaNagesha Cc: Pawel Moll Cc: Nicolas Pitre Cc: Amit Kucheria Cc: Jon Medhurst Signed-off-by: Lorenzo Pieralisi --- drivers/mfd/vexpress-config.c | 26 +++++++--- include/linux/vexpress.h | 23 ++++++-- 2 files changed, 37 insertions(+), 12 deletions(-) diff --git a/drivers/mfd/vexpress-config.c b/drivers/mfd/vexpress-config.c index 1af2b0e..6f4aa5a 100644 --- a/drivers/mfd/vexpress-config.c +++ b/drivers/mfd/vexpress-config.c @@ -266,8 +266,18 @@ int vexpress_config_wait(struct vexpress_config_trans *trans) } EXPORT_SYMBOL(vexpress_config_wait); -int vexpress_config_read(struct vexpress_config_func *func, int offset, - u32 *data) +int vexpress_config_wait_timeout(struct vexpress_config_trans *trans, + long jiffies) +{ + int ret; + ret = wait_for_completion_timeout(&trans->completion, jiffies); + + return ret ? trans->status : -ETIMEDOUT; +} +EXPORT_SYMBOL(vexpress_config_wait_timeout); + +int vexpress_config_read_timeout(struct vexpress_config_func *func, int offset, + u32 *data, long jiffies) { struct vexpress_config_trans trans = { .func = func, @@ -279,14 +289,14 @@ int vexpress_config_read(struct vexpress_config_func *func, int offset, int status = vexpress_config_schedule(&trans); if (status == VEXPRESS_CONFIG_STATUS_WAIT) - status = vexpress_config_wait(&trans); + status = vexpress_config_wait_timeout(&trans, jiffies); return status; } -EXPORT_SYMBOL(vexpress_config_read); +EXPORT_SYMBOL(vexpress_config_read_timeout); -int vexpress_config_write(struct vexpress_config_func *func, int offset, - u32 data) +int vexpress_config_write_timeout(struct vexpress_config_func *func, + int offset, u32 data, long jiffies) { struct vexpress_config_trans trans = { .func = func, @@ -298,8 +308,8 @@ int vexpress_config_write(struct vexpress_config_func *func, int offset, int status = vexpress_config_schedule(&trans); if (status == VEXPRESS_CONFIG_STATUS_WAIT) - status = vexpress_config_wait(&trans); + status = vexpress_config_wait_timeout(&trans, jiffies); return status; } -EXPORT_SYMBOL(vexpress_config_write); +EXPORT_SYMBOL(vexpress_config_write_timeout); diff --git a/include/linux/vexpress.h b/include/linux/vexpress.h index 50368e0..e5015d8 100644 --- a/include/linux/vexpress.h +++ b/include/linux/vexpress.h @@ -15,6 +15,7 @@ #define _LINUX_VEXPRESS_H #include +#include #define VEXPRESS_SITE_MB 0 #define VEXPRESS_SITE_DB1 1 @@ -102,10 +103,24 @@ struct vexpress_config_func *__vexpress_config_func_get( void vexpress_config_func_put(struct vexpress_config_func *func); /* Both may sleep! */ -int vexpress_config_read(struct vexpress_config_func *func, int offset, - u32 *data); -int vexpress_config_write(struct vexpress_config_func *func, int offset, - u32 data); +int vexpress_config_read_timeout(struct vexpress_config_func *func, int offset, + u32 *data, long jiffies); +int vexpress_config_write_timeout(struct vexpress_config_func *func, + int offset, u32 data, long jiffies); + +static inline int vexpress_config_read(struct vexpress_config_func *func, + int offset, u32 *data) +{ + return vexpress_config_read_timeout(func, offset, data, + MAX_SCHEDULE_TIMEOUT); +} + +static inline int vexpress_config_write(struct vexpress_config_func *func, + int offset, u32 data) +{ + return vexpress_config_write_timeout(func, offset, data, + MAX_SCHEDULE_TIMEOUT); +} /* Platform control */