From patchwork Thu Oct 20 08:54:01 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Binoy Jayan X-Patchwork-Id: 78457 Delivered-To: patch@linaro.org Received: by 10.140.97.247 with SMTP id m110csp668707qge; Thu, 20 Oct 2016 01:54:35 -0700 (PDT) X-Received: by 10.99.169.25 with SMTP id u25mr15961150pge.6.1476953675154; Thu, 20 Oct 2016 01:54:35 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id ro4si36837806pab.36.2016.10.20.01.54.34; Thu, 20 Oct 2016 01:54:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S935230AbcJTIyT (ORCPT + 27 others); Thu, 20 Oct 2016 04:54:19 -0400 Received: from mail-pf0-f174.google.com ([209.85.192.174]:36145 "EHLO mail-pf0-f174.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S935159AbcJTIyO (ORCPT ); Thu, 20 Oct 2016 04:54:14 -0400 Received: by mail-pf0-f174.google.com with SMTP id e6so32656835pfk.3 for ; Thu, 20 Oct 2016 01:54:14 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=RVOQFi2cvurJ1W+DeV1Xx3yvNrgdZ/47cpgFJTyOIuY=; b=JKdmCk0mz/4O8HQnTE49fVmeB/w46I2vt9lihSgBN/AwRYbl17/0F/IyHt7rKcmYiY Vp1Vtrsf1nXS7Tn/oEpr2hu7qJy2/j8exFieKZzRNIvXyVHcLzijMaZKS4HjVqWzblZf girrqaDHcJXRJ69IaSo8ekeJydlZ/88XaHT7E= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=RVOQFi2cvurJ1W+DeV1Xx3yvNrgdZ/47cpgFJTyOIuY=; b=Uvg4D+dQqb0Zhg44R95jqOCMyjeOPspvihbARXmUdwdV+85IVnbSXPwZg2YFlXSo9L /qTrJbgjpw6BufkQCl6eMnx4xglfGvccm8kyK8gISSSMIUi+Yjr0t+1TvnKUeSKaG0kI 4xqrq8MgUTmVg9HqGN59O4S55HhuH3aRqhgoKKopc1IoP7PQUVAFCyVn+JxfdcUWgirP qUh2x9Q1mwlTKoIJDPEp5cTu0zgPujCsyS9hQdEbO9NiLKoy1OP3fDA/PAAHmY00fH3Q fStuFjLgRN3K2eP4XjwlGdhRSalkK69E9yZTKZ7lqNHE8ItOaRgPqAWVpzYPmQ426Hw+ wegQ== X-Gm-Message-State: AA6/9Rkb7Jf7DUlLdba5dvA/cFgomxQJvNJWI9MNztGlXDaQvNCZMK+ul6Ds73vtBenKg7HR X-Received: by 10.98.80.2 with SMTP id e2mr19676251pfb.183.1476953653781; Thu, 20 Oct 2016 01:54:13 -0700 (PDT) Received: from blr-ubuntu-59.ap.qualcomm.com ([202.46.23.61]) by smtp.gmail.com with ESMTPSA id s85sm69645878pfi.17.2016.10.20.01.54.09 (version=TLS1_1 cipher=ECDHE-RSA-AES128-SHA bits=128/128); Thu, 20 Oct 2016 01:54:13 -0700 (PDT) From: Binoy Jayan To: "James E.J. Bottomley" , "Martin K. Petersen" Cc: kevin Barnett , Don Brace , Scott Benesh , Johannes Thumshirn , linux-scsi@vger.kernel.org, Arnd Bergmann , linux-kernel@vger.kernel.org, Binoy Jayan Subject: [PATCH 1/2] scsi: smartpqi: Replace semaphore sync_request_sem with mutex Date: Thu, 20 Oct 2016 14:24:01 +0530 Message-Id: <1476953642-2160-2-git-send-email-binoy.jayan@linaro.org> X-Mailer: git-send-email 1.8.2.1 In-Reply-To: <1476953642-2160-1-git-send-email-binoy.jayan@linaro.org> References: <1476953642-2160-1-git-send-email-binoy.jayan@linaro.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Semaphores are going away in the future, so replace the semaphore sync_request_sem with the a mutex lock. timeout_msecs is not used for the lock sync_request_sem, so remove the timed locking too. Signed-off-by: Binoy Jayan --- drivers/scsi/smartpqi/smartpqi.h | 4 +++- drivers/scsi/smartpqi/smartpqi_init.c | 31 ++++++------------------------- 2 files changed, 9 insertions(+), 26 deletions(-) -- The Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project diff --git a/drivers/scsi/smartpqi/smartpqi.h b/drivers/scsi/smartpqi/smartpqi.h index 07b6444..b4559b1 100644 --- a/drivers/scsi/smartpqi/smartpqi.h +++ b/drivers/scsi/smartpqi/smartpqi.h @@ -19,6 +19,8 @@ #if !defined(_SMARTPQI_H) #define _SMARTPQI_H +#include + #pragma pack(1) #define PQI_DEVICE_SIGNATURE "PQI DREG" @@ -961,7 +963,7 @@ struct pqi_ctrl_info { unsigned int num_heartbeats_requested; struct timer_list heartbeat_timer; - struct semaphore sync_request_sem; + struct mutex sync_request_mutex; struct semaphore lun_reset_sem; }; diff --git a/drivers/scsi/smartpqi/smartpqi_init.c b/drivers/scsi/smartpqi/smartpqi_init.c index a535b26..4974f7e 100644 --- a/drivers/scsi/smartpqi/smartpqi_init.c +++ b/drivers/scsi/smartpqi/smartpqi_init.c @@ -3444,29 +3444,11 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info, unsigned long msecs_blocked; size_t iu_length; - /* - * Note that specifying PQI_SYNC_FLAGS_INTERRUPTABLE and a timeout value - * are mutually exclusive. - */ - - if (flags & PQI_SYNC_FLAGS_INTERRUPTABLE) { - if (down_interruptible(&ctrl_info->sync_request_sem)) + if (flags & PQI_SYNC_FLAGS_INTERRUPTABLE) + if (mutex_lock_interruptible(&ctrl_info->sync_request_mutex)) return -ERESTARTSYS; - } else { - if (timeout_msecs == NO_TIMEOUT) { - down(&ctrl_info->sync_request_sem); - } else { - start_jiffies = jiffies; - if (down_timeout(&ctrl_info->sync_request_sem, - msecs_to_jiffies(timeout_msecs))) - return -ETIMEDOUT; - msecs_blocked = - jiffies_to_msecs(jiffies - start_jiffies); - if (msecs_blocked >= timeout_msecs) - return -ETIMEDOUT; - timeout_msecs -= msecs_blocked; - } - } + else + mutex_lock(&ctrl_info->sync_request_mutex); io_request = pqi_alloc_io_request(ctrl_info); @@ -3508,7 +3490,7 @@ static int pqi_submit_raid_request_synchronous(struct pqi_ctrl_info *ctrl_info, pqi_free_io_request(io_request); - up(&ctrl_info->sync_request_sem); + mutex_unlock(&ctrl_info->sync_request_mutex); return rc; } @@ -5540,8 +5522,7 @@ static struct pqi_ctrl_info *pqi_alloc_ctrl_info(int numa_node) INIT_DELAYED_WORK(&ctrl_info->rescan_work, pqi_rescan_worker); INIT_DELAYED_WORK(&ctrl_info->update_time_work, pqi_update_time_worker); - sema_init(&ctrl_info->sync_request_sem, - PQI_RESERVED_IO_SLOTS_SYNCHRONOUS_REQUESTS); + mutex_init(&ctrl_info->sync_request_mutex); sema_init(&ctrl_info->lun_reset_sem, PQI_RESERVED_IO_SLOTS_LUN_RESET); ctrl_info->ctrl_id = atomic_inc_return(&pqi_controller_count) - 1;