All of lore.kernel.org
 help / color / mirror / Atom feed
From: Eddie James <eajames@linux.vnet.ibm.com>
To: openbmc@lists.ozlabs.org
Cc: joel@jms.id.au, andrew@aj.id.au, "Edward A. James" <eajames@us.ibm.com>
Subject: [PATCH linux dev-4.10 v2 5/9] drivers: fsi: occ: Poll while receiving "command in progress"
Date: Fri, 29 Sep 2017 17:41:04 -0500	[thread overview]
Message-ID: <1506724868-13010-6-git-send-email-eajames@linux.vnet.ibm.com> (raw)
In-Reply-To: <1506724868-13010-1-git-send-email-eajames@linux.vnet.ibm.com>

From: "Edward A. James" <eajames@us.ibm.com>

This should only be done at this level, instead of clients repeating
the entire transfer when they receive "command in progress"

Signed-off-by: Edward A. James <eajames@us.ibm.com>
---
 drivers/fsi/occ.c | 27 ++++++++++++++++++++++++---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/fsi/occ.c b/drivers/fsi/occ.c
index 3313e35..a554550 100644
--- a/drivers/fsi/occ.c
+++ b/drivers/fsi/occ.c
@@ -23,6 +23,7 @@
 #include <linux/of.h>
 #include <linux/of_platform.h>
 #include <linux/platform_device.h>
+#include <linux/sched.h>
 #include <linux/slab.h>
 #include <linux/spinlock.h>
 #include <linux/uaccess.h>
@@ -33,6 +34,9 @@
 #define OCC_CMD_DATA_BYTES	4090
 #define OCC_RESP_DATA_BYTES	4089
 
+#define OCC_TIMEOUT_MS		1000
+#define OCC_CMD_IN_PRG_WAIT_MS	50
+
 struct occ {
 	struct device *sbefifo;
 	char name[32];
@@ -565,6 +569,9 @@ static void occ_worker(struct work_struct *work)
 {
 	int rc = 0, empty, waiting, canceled;
 	u16 resp_data_length;
+	unsigned long start;
+	const unsigned long timeout = msecs_to_jiffies(OCC_TIMEOUT_MS);
+	const long int wait_time = msecs_to_jiffies(OCC_CMD_IN_PRG_WAIT_MS);
 	struct occ_xfr *xfr;
 	struct occ_response *resp;
 	struct occ_client *client;
@@ -586,6 +593,8 @@ static void occ_worker(struct work_struct *work)
 	spin_unlock_irq(&occ->list_lock);
 	mutex_lock(&occ->occ_lock);
 
+	start = jiffies;
+
 	/* write occ command */
 	rc = occ_putsram(sbefifo, 0xFFFBE000, xfr->buf,
 			 xfr->cmd_data_length);
@@ -597,9 +606,21 @@ static void occ_worker(struct work_struct *work)
 		goto done;
 
 	/* read occ response */
-	rc = occ_getsram(sbefifo, 0xFFFBF000, xfr->buf, 8);
-	if (rc)
-		goto done;
+	do {
+		rc = occ_getsram(sbefifo, 0xFFFBF000, xfr->buf, 8);
+		if (rc)
+			goto done;
+
+		if (resp->return_status == OCC_RESP_CMD_IN_PRG) {
+			rc = -EALREADY;
+
+			if (time_after(jiffies, start + timeout))
+				break;
+
+			set_current_state(TASK_INTERRUPTIBLE);
+			schedule_timeout(wait_time);
+		}
+	} while (rc);
 
 	resp_data_length = get_unaligned_be16(&resp->data_length);
 	if (resp_data_length > OCC_RESP_DATA_BYTES) {
-- 
1.8.3.1

  parent reply	other threads:[~2017-09-29 22:41 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-09-29 22:40 [PATCH linux dev-4.10 v2 0/9] drivers: fsi: client fixes and refactor Eddie James
2017-09-29 22:41 ` [PATCH linux dev-4.10 v2 1/9] drivers: fsi: SBEFIFO: General clean-up Eddie James
2017-10-04 23:59   ` Andrew Jeffery
2017-10-05 15:11     ` Eddie James
2017-09-29 22:41 ` [PATCH linux dev-4.10 v2 2/9] drivers: fsi: SBEFIFO: Fix probe() and remove() Eddie James
2017-10-05  0:32   ` Andrew Jeffery
2017-10-05 15:15     ` Eddie James
2017-10-05 17:37       ` Eddie James
2017-09-29 22:41 ` [PATCH linux dev-4.10 v2 3/9] drivers: fsi: SBEFIFO: check for xfr complete in read wait_event Eddie James
2017-10-05  0:35   ` Andrew Jeffery
2017-09-29 22:41 ` [PATCH linux dev-4.10 v2 4/9] drivers: fsi: occ: General clean-up Eddie James
2017-10-05  0:37   ` Andrew Jeffery
2017-10-05 15:27     ` Eddie James
2017-09-29 22:41 ` Eddie James [this message]
2017-10-05  1:01   ` [PATCH linux dev-4.10 v2 5/9] drivers: fsi: occ: Poll while receiving "command in progress" Andrew Jeffery
2017-10-05 15:38     ` Eddie James
2017-10-05 23:24       ` Andrew Jeffery
2017-09-29 22:41 ` [PATCH linux dev-4.10 v2 6/9] drivers: fsi: occ: Add cancel to remove() and fix probe() Eddie James
2017-10-05  1:07   ` Andrew Jeffery
2017-10-05 16:02     ` Eddie James
2017-09-29 22:41 ` [PATCH linux dev-4.10 v2 7/9] drivers: fsi: occ: Fix client memory management Eddie James
2017-10-05  1:12   ` Andrew Jeffery
2017-09-29 22:41 ` [PATCH linux dev-4.10 v2 8/9] drivers/hwmon/occ: Remove repeated ops for OCC command in progress Eddie James
2017-10-05  1:13   ` Andrew Jeffery
2017-09-29 22:41 ` [PATCH linux dev-4.10 v2 9/9] drivers: hwmon: occ: Cancel occ operations in remove() Eddie James
2017-10-05  1:20   ` Andrew Jeffery
2017-10-05 16:38     ` Eddie James

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=1506724868-13010-6-git-send-email-eajames@linux.vnet.ibm.com \
    --to=eajames@linux.vnet.ibm.com \
    --cc=andrew@aj.id.au \
    --cc=eajames@us.ibm.com \
    --cc=joel@jms.id.au \
    --cc=openbmc@lists.ozlabs.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 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.