All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/2] esas2r: Replace semaphores with mutexes
@ 2017-06-08 10:07 Binoy Jayan
  2017-06-08 10:07 ` [PATCH 1/2] scsi: esas2r: Replace semaphore fm_api_semaphore with mutex Binoy Jayan
                   ` (3 more replies)
  0 siblings, 4 replies; 5+ messages in thread
From: Binoy Jayan @ 2017-06-08 10:07 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: linux-kernel, Arnd Bergmann, Rajendra, Mark Brown, Bradley Grove,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi

These are a set of patches which removes semaphores from esas2r.
These are part of a bigger effort to eliminate unwanted semaphores
from the linux kernel.

Binoy Jayan (2):
  scsi: esas2r: Replace semaphore fm_api_semaphore with mutex
  scsi: esas2r: Replace semaphore fs_api_semaphore with mutex

 drivers/scsi/esas2r/esas2r.h       |  4 ++--
 drivers/scsi/esas2r/esas2r_init.c  |  4 ++--
 drivers/scsi/esas2r/esas2r_ioctl.c | 10 +++++-----
 3 files changed, 9 insertions(+), 9 deletions(-)

-- 
Binoy Jayan

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

* [PATCH 1/2] scsi: esas2r: Replace semaphore fm_api_semaphore with mutex
  2017-06-08 10:07 [PATCH 0/2] esas2r: Replace semaphores with mutexes Binoy Jayan
@ 2017-06-08 10:07 ` Binoy Jayan
  2017-06-08 10:07 ` [PATCH 2/2] scsi: esas2r: Replace semaphore fs_api_semaphore " Binoy Jayan
                   ` (2 subsequent siblings)
  3 siblings, 0 replies; 5+ messages in thread
From: Binoy Jayan @ 2017-06-08 10:07 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: linux-kernel, Arnd Bergmann, Rajendra, Mark Brown, Bradley Grove,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi

The semaphore 'fm_api_semaphore' is used as a simple mutex, so
it should be written as one. Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
 drivers/scsi/esas2r/esas2r.h       | 2 +-
 drivers/scsi/esas2r/esas2r_init.c  | 2 +-
 drivers/scsi/esas2r/esas2r_ioctl.c | 4 ++--
 3 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index b6030e3..c5013de 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -945,7 +945,7 @@ struct esas2r_adapter {
 	struct list_head vrq_mds_head;
 	struct esas2r_mem_desc *vrq_mds;
 	int num_vrqs;
-	struct semaphore fm_api_semaphore;
+	struct mutex fm_api_mutex;
 	struct semaphore fs_api_semaphore;
 	struct semaphore nvram_semaphore;
 	struct atto_ioctl *local_atto_ioctl;
diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c
index 6432a50..ad85b33 100644
--- a/drivers/scsi/esas2r/esas2r_init.c
+++ b/drivers/scsi/esas2r/esas2r_init.c
@@ -327,7 +327,7 @@ int esas2r_init_adapter(struct Scsi_Host *host, struct pci_dev *pcid,
 	esas2r_debug("new adapter %p, name %s", a, a->name);
 	spin_lock_init(&a->request_lock);
 	spin_lock_init(&a->fw_event_lock);
-	sema_init(&a->fm_api_semaphore, 1);
+	mutex_init(&a->fm_api_mutex);
 	sema_init(&a->fs_api_semaphore, 1);
 	sema_init(&a->nvram_semaphore, 1);
 
diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
index 2d4b7f0..c6b041a 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -110,7 +110,7 @@ static void do_fm_api(struct esas2r_adapter *a, struct esas2r_flash_img *fi)
 {
 	struct esas2r_request *rq;
 
-	if (down_interruptible(&a->fm_api_semaphore)) {
+	if (mutex_lock_interruptible(&a->fm_api_mutex)) {
 		fi->status = FI_STAT_BUSY;
 		return;
 	}
@@ -173,7 +173,7 @@ static void do_fm_api(struct esas2r_adapter *a, struct esas2r_flash_img *fi)
 free_req:
 	esas2r_free_request(a, (struct esas2r_request *)rq);
 free_sem:
-	up(&a->fm_api_semaphore);
+	mutex_unlock(&a->fm_api_mutex);
 	return;
 
 }
-- 
Binoy Jayan

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

* [PATCH 2/2] scsi: esas2r: Replace semaphore fs_api_semaphore with mutex
  2017-06-08 10:07 [PATCH 0/2] esas2r: Replace semaphores with mutexes Binoy Jayan
  2017-06-08 10:07 ` [PATCH 1/2] scsi: esas2r: Replace semaphore fm_api_semaphore with mutex Binoy Jayan
@ 2017-06-08 10:07 ` Binoy Jayan
  2017-06-08 15:05 ` [PATCH 0/2] esas2r: Replace semaphores with mutexes Arnd Bergmann
  2017-06-13  1:18 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Binoy Jayan @ 2017-06-08 10:07 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: linux-kernel, Arnd Bergmann, Rajendra, Mark Brown, Bradley Grove,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi

The semaphore 'fs_api_semaphore' is used as a simple mutex, so
it should be written as one. Semaphores are going away in the future.

Signed-off-by: Binoy Jayan <binoy.jayan@linaro.org>
---
 drivers/scsi/esas2r/esas2r.h       | 2 +-
 drivers/scsi/esas2r/esas2r_init.c  | 2 +-
 drivers/scsi/esas2r/esas2r_ioctl.c | 6 +++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/scsi/esas2r/esas2r.h b/drivers/scsi/esas2r/esas2r.h
index c5013de..1da6407 100644
--- a/drivers/scsi/esas2r/esas2r.h
+++ b/drivers/scsi/esas2r/esas2r.h
@@ -946,7 +946,7 @@ struct esas2r_adapter {
 	struct esas2r_mem_desc *vrq_mds;
 	int num_vrqs;
 	struct mutex fm_api_mutex;
-	struct semaphore fs_api_semaphore;
+	struct mutex fs_api_mutex;
 	struct semaphore nvram_semaphore;
 	struct atto_ioctl *local_atto_ioctl;
 	u8 fw_coredump_buff[ESAS2R_FWCOREDUMP_SZ];
diff --git a/drivers/scsi/esas2r/esas2r_init.c b/drivers/scsi/esas2r/esas2r_init.c
index ad85b33..5b14dd2 100644
--- a/drivers/scsi/esas2r/esas2r_init.c
+++ b/drivers/scsi/esas2r/esas2r_init.c
@@ -328,7 +328,7 @@ int esas2r_init_adapter(struct Scsi_Host *host, struct pci_dev *pcid,
 	spin_lock_init(&a->request_lock);
 	spin_lock_init(&a->fw_event_lock);
 	mutex_init(&a->fm_api_mutex);
-	sema_init(&a->fs_api_semaphore, 1);
+	mutex_init(&a->fs_api_mutex);
 	sema_init(&a->nvram_semaphore, 1);
 
 	esas2r_fw_event_off(a);
diff --git a/drivers/scsi/esas2r/esas2r_ioctl.c b/drivers/scsi/esas2r/esas2r_ioctl.c
index c6b041a..9762300 100644
--- a/drivers/scsi/esas2r/esas2r_ioctl.c
+++ b/drivers/scsi/esas2r/esas2r_ioctl.c
@@ -1962,7 +1962,7 @@ int esas2r_read_fs(struct esas2r_adapter *a, char *buf, long off, int count)
 			(struct esas2r_ioctl_fs *)a->fs_api_buffer;
 
 		/* If another flash request is already in progress, return. */
-		if (down_interruptible(&a->fs_api_semaphore)) {
+		if (mutex_lock_interruptible(&a->fs_api_mutex)) {
 busy:
 			fs->status = ATTO_STS_OUT_OF_RSRC;
 			return -EBUSY;
@@ -1978,7 +1978,7 @@ int esas2r_read_fs(struct esas2r_adapter *a, char *buf, long off, int count)
 		rq = esas2r_alloc_request(a);
 		if (rq == NULL) {
 			esas2r_debug("esas2r_read_fs: out of requests");
-			up(&a->fs_api_semaphore);
+			mutex_unlock(&a->fs_api_mutex);
 			goto busy;
 		}
 
@@ -2006,7 +2006,7 @@ int esas2r_read_fs(struct esas2r_adapter *a, char *buf, long off, int count)
 		;
 dont_wait:
 		/* Free the request and keep going */
-		up(&a->fs_api_semaphore);
+		mutex_unlock(&a->fs_api_mutex);
 		esas2r_free_request(a, (struct esas2r_request *)rq);
 
 		/* Pick up possible error code from above */
-- 
Binoy Jayan

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

* Re: [PATCH 0/2] esas2r: Replace semaphores with mutexes
  2017-06-08 10:07 [PATCH 0/2] esas2r: Replace semaphores with mutexes Binoy Jayan
  2017-06-08 10:07 ` [PATCH 1/2] scsi: esas2r: Replace semaphore fm_api_semaphore with mutex Binoy Jayan
  2017-06-08 10:07 ` [PATCH 2/2] scsi: esas2r: Replace semaphore fs_api_semaphore " Binoy Jayan
@ 2017-06-08 15:05 ` Arnd Bergmann
  2017-06-13  1:18 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Arnd Bergmann @ 2017-06-08 15:05 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: Linux Kernel Mailing List, Rajendra, Mark Brown, Bradley Grove,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi

On Thu, Jun 8, 2017 at 12:07 PM, Binoy Jayan <binoy.jayan@linaro.org> wrote:
> These are a set of patches which removes semaphores from esas2r.
> These are part of a bigger effort to eliminate unwanted semaphores
> from the linux kernel.
>
> Binoy Jayan (2):
>   scsi: esas2r: Replace semaphore fm_api_semaphore with mutex
>   scsi: esas2r: Replace semaphore fs_api_semaphore with mutex

Both conversions looks good. I think the interruption is not handled
correctly here, but your patch doesn't change that.

Reviewed-by: Arnd Bergmann <arnd@arndb.de>

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

* Re: [PATCH 0/2] esas2r: Replace semaphores with mutexes
  2017-06-08 10:07 [PATCH 0/2] esas2r: Replace semaphores with mutexes Binoy Jayan
                   ` (2 preceding siblings ...)
  2017-06-08 15:05 ` [PATCH 0/2] esas2r: Replace semaphores with mutexes Arnd Bergmann
@ 2017-06-13  1:18 ` Martin K. Petersen
  3 siblings, 0 replies; 5+ messages in thread
From: Martin K. Petersen @ 2017-06-13  1:18 UTC (permalink / raw)
  To: Binoy Jayan
  Cc: linux-kernel, Arnd Bergmann, Rajendra, Mark Brown, Bradley Grove,
	James E.J. Bottomley, Martin K. Petersen, linux-scsi


Binoy,

> These are a set of patches which removes semaphores from esas2r.
> These are part of a bigger effort to eliminate unwanted semaphores
> from the linux kernel.

Applied to 4.13/scsi-queue.

-- 
Martin K. Petersen	Oracle Linux Engineering

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

end of thread, other threads:[~2017-06-13  1:18 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2017-06-08 10:07 [PATCH 0/2] esas2r: Replace semaphores with mutexes Binoy Jayan
2017-06-08 10:07 ` [PATCH 1/2] scsi: esas2r: Replace semaphore fm_api_semaphore with mutex Binoy Jayan
2017-06-08 10:07 ` [PATCH 2/2] scsi: esas2r: Replace semaphore fs_api_semaphore " Binoy Jayan
2017-06-08 15:05 ` [PATCH 0/2] esas2r: Replace semaphores with mutexes Arnd Bergmann
2017-06-13  1:18 ` Martin K. Petersen

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.