mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Jeremy Kerr <jk@ozlabs.org>
To: linux-kernel@vger.kernel.org
Cc: Joel Stanley <joel@jms.id.au>,
	Christopher Bostic <cbostic@linux.vnet.ibm.com>,
	Jeremy Kerr <jk@ozlabs.org>
Subject: [PATCH 2/3] fsi/master-gpio: Add locking around gpio operations during break & link enable
Date: Mon, 19 Jun 2017 17:26:44 +0800	[thread overview]
Message-ID: <1497864405-26990-3-git-send-email-jk@ozlabs.org> (raw)
In-Reply-To: <1497864405-26990-1-git-send-email-jk@ozlabs.org>

Currently, we perform GPIO accesses in fsi_master_gpio_break and
fsi_master_link_enable, without holding cmd_lock. This change adds the
appropriate locking.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Reviewed-by: Joel Stanley <joel@jms.id.au>
Reviewed-by: Christopher Bostic <clbostic@linux.vnet.ibm.com>
---
 drivers/fsi/fsi-master-gpio.c | 7 +++++++
 1 file changed, 7 insertions(+)

diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index ae26187..a6d602e 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -461,12 +461,14 @@ static int fsi_master_gpio_term(struct fsi_master *_master,
 static int fsi_master_gpio_break(struct fsi_master *_master, int link)
 {
 	struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
+	unsigned long flags;
 
 	if (link != 0)
 		return -ENODEV;
 
 	trace_fsi_master_gpio_break(master);
 
+	spin_lock_irqsave(&master->cmd_lock, flags);
 	set_sda_output(master, 1);
 	sda_out(master, 1);
 	clock_toggle(master, FSI_PRE_BREAK_CLOCKS);
@@ -475,6 +477,7 @@ static int fsi_master_gpio_break(struct fsi_master *_master, int link)
 	echo_delay(master);
 	sda_out(master, 1);
 	clock_toggle(master, FSI_POST_BREAK_CLOCKS);
+	spin_unlock_irqrestore(&master->cmd_lock, flags);
 
 	/* Wait for logic reset to take effect */
 	udelay(200);
@@ -497,10 +500,14 @@ static void fsi_master_gpio_init(struct fsi_master_gpio *master)
 static int fsi_master_gpio_link_enable(struct fsi_master *_master, int link)
 {
 	struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
+	unsigned long flags;
 
 	if (link != 0)
 		return -ENODEV;
+
+	spin_lock_irqsave(&master->cmd_lock, flags);
 	gpiod_set_value(master->gpio_enable, 1);
+	spin_unlock_irqrestore(&master->cmd_lock, flags);
 
 	return 0;
 }
-- 
2.7.4

  parent reply	other threads:[~2017-06-19  9:27 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-19  9:26 [PATCH 0/3] Add 'external mode' for GPIO-based FSI master Jeremy Kerr
2017-06-19  9:26 ` [PATCH 1/3] fsi: Add fsi_master_rescan() Jeremy Kerr
2017-06-20  2:59   ` [PATCH v2 " Jeremy Kerr
2017-06-19  9:26 ` Jeremy Kerr [this message]
2017-06-19  9:26 ` [PATCH 3/3] fsi/master-gpio: Add external mode Jeremy Kerr
2017-06-19 17:17   ` kbuild test robot
2017-06-21  6:01   ` Joel Stanley
2017-06-21 22:07     ` Jeremy Kerr
2017-06-21 22:10   ` [PATCH v2 " Jeremy Kerr
2018-01-30  4:45     ` Joel Stanley
2017-09-04  6:55 ` [PATCH 0/3] Add 'external mode' for GPIO-based FSI master Joel Stanley

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1497864405-26990-3-git-send-email-jk@ozlabs.org \
    --to=jk@ozlabs.org \
    --cc=cbostic@linux.vnet.ibm.com \
    --cc=joel@jms.id.au \
    --cc=linux-kernel@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®