mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: linux-kernel@vger.kernel.org
Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Jeremy Kerr <jk@ozlabs.org>, Joel Stanley <joel@jms.id.au>,
	Christopher Bostic <cbostic@linux.vnet.ibm.com>,
	Benjamin Herrenschmidt <benh@kernel.crashing.org>
Subject: [PATCH 09/15] fsi/gpio: Include command build in locked section
Date: Tue, 29 May 2018 11:30:38 +1000	[thread overview]
Message-ID: <20180529013044.23815-10-benh@kernel.crashing.org> (raw)
In-Reply-To: <20180529013044.23815-1-benh@kernel.crashing.org>

From: Jeremy Kerr <jk@ozlabs.org>

For implementing relative addressing mode, we'll need to build a command
that is coherent with CFAM state. To do that, include the
build_command_* functions in the locked section of read/write/term.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
---
 drivers/fsi/fsi-master-gpio.c | 25 ++++++++++++++++++-------
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/fsi/fsi-master-gpio.c b/drivers/fsi/fsi-master-gpio.c
index e1bde9e3f855..d50ea4849377 100644
--- a/drivers/fsi/fsi-master-gpio.c
+++ b/drivers/fsi/fsi-master-gpio.c
@@ -463,14 +463,10 @@ static int fsi_master_gpio_xfer(struct fsi_master_gpio *master, uint8_t slave,
 {
 	int rc;
 
-	mutex_lock(&master->cmd_lock);
-
 	rc = send_request(master, cmd);
 	if (!rc)
 		rc = poll_for_response(master, slave, resp_len, resp);
 
-	mutex_unlock(&master->cmd_lock);
-
 	return rc;
 }
 
@@ -479,12 +475,17 @@ static int fsi_master_gpio_read(struct fsi_master *_master, int link,
 {
 	struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
 	struct fsi_gpio_msg cmd;
+	int rc;
 
 	if (link != 0)
 		return -ENODEV;
 
+	mutex_lock(&master->cmd_lock);
 	build_abs_ar_command(&cmd, id, addr, size, NULL);
-	return fsi_master_gpio_xfer(master, id, &cmd, size, val);
+	rc = fsi_master_gpio_xfer(master, id, &cmd, size, val);
+	mutex_unlock(&master->cmd_lock);
+
+	return rc;
 }
 
 static int fsi_master_gpio_write(struct fsi_master *_master, int link,
@@ -492,12 +493,17 @@ static int fsi_master_gpio_write(struct fsi_master *_master, int link,
 {
 	struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
 	struct fsi_gpio_msg cmd;
+	int rc;
 
 	if (link != 0)
 		return -ENODEV;
 
+	mutex_lock(&master->cmd_lock);
 	build_abs_ar_command(&cmd, id, addr, size, val);
-	return fsi_master_gpio_xfer(master, id, &cmd, 0, NULL);
+	rc = fsi_master_gpio_xfer(master, id, &cmd, 0, NULL);
+	mutex_unlock(&master->cmd_lock);
+
+	return rc;
 }
 
 static int fsi_master_gpio_term(struct fsi_master *_master,
@@ -505,12 +511,17 @@ static int fsi_master_gpio_term(struct fsi_master *_master,
 {
 	struct fsi_master_gpio *master = to_fsi_master_gpio(_master);
 	struct fsi_gpio_msg cmd;
+	int rc;
 
 	if (link != 0)
 		return -ENODEV;
 
+	mutex_lock(&master->cmd_lock);
 	build_term_command(&cmd, id);
-	return fsi_master_gpio_xfer(master, id, &cmd, 0, NULL);
+	rc = fsi_master_gpio_xfer(master, id, &cmd, 0, NULL);
+	mutex_unlock(&master->cmd_lock);
+
+	return rc;
 }
 
 static int fsi_master_gpio_break(struct fsi_master *_master, int link)
-- 
2.17.0

  parent reply	other threads:[~2018-05-29  1:49 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-05-29  1:30 [PATCH 00/15] fsi: Overall improvements and new SBE fifo driver Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 01/15] fsi: gpio: Trace busy count Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 02/15] fsi: gpio: Remove unused 'id' variable Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 03/15] fsi: gpio: Use a mutex to protect transfers Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 04/15] fsi/fsi-master-gpio: Sample input data on different clock phase Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 05/15] fsi/fsi-master-gpio: Add "no-gpio-delays" option Benjamin Herrenschmidt
2018-05-29  1:42   ` Benjamin Herrenschmidt
2018-05-29  1:43   ` [PATCH] dt-bindings: fsi-master-gpio: Document "no-gpio-delays" property Benjamin Herrenschmidt
2018-05-31 17:13     ` Rob Herring
2018-05-29  1:30 ` [PATCH 06/15] fsi/fsi-master-gpio: Reduce turnaround clocks Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 07/15] fsi/fsi-master-gpio: Reduce dpoll clocks Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 08/15] fsi/fsi-master-gpio: Delay sampling of FSI data input Benjamin Herrenschmidt
2018-05-29  1:30 ` Benjamin Herrenschmidt [this message]
2018-05-29  1:30 ` [PATCH 10/15] fsi/gpio: Use relative-addressing commands Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 11/15] fsi/fsi-master-gpio: Implement CRC error recovery Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 12/15] fsi/fsi-master-gpio: More error handling cleanup Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 13/15] fsi/master-gpio: Replace bit_bit lock with IRQ disable/enable Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 14/15] fsi: scom: Remove PIB reset during probe Benjamin Herrenschmidt
2018-05-29  1:30 ` [PATCH 15/15] fsi/sbefifo: Add driver for the SBE FIFO Benjamin Herrenschmidt
2018-05-29 12:30 ` [PATCH 00/15] fsi: Overall improvements and new SBE fifo driver Joel Stanley
2018-06-10  6:46   ` Benjamin Herrenschmidt
2018-06-10  6:57     ` Greg Kroah-Hartman

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=20180529013044.23815-10-benh@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=cbostic@linux.vnet.ibm.com \
    --cc=gregkh@linuxfoundation.org \
    --cc=jk@ozlabs.org \
    --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

Powered by JetHome