[PATCH linux dev-4.10 v3 27/31] drivers: fsi: occ: Poll while receiving "command in progress"
Eddie James
eajames at linux.vnet.ibm.com
Fri Oct 6 12:04:31 AEDT 2017
On 10/05/2017 06:27 PM, Andrew Jeffery wrote:
> On Thu, 2017-10-05 at 14:24 -0500, Eddie James wrote:
>> From: "Edward A. James" <eajames at us.ibm.com>
>>
>> Waiting for OCC to return something other than "command in progress"
>> should only be done in the worker function, instead of clients repeating
>> the entire transfer when they receive "command in progress." In this way
>> clients don't have to check for that return status.
>>
>> Signed-off-by: Edward A. James <eajames at 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 29a17ed..8555e99 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
> Where doe 50ms come from? Is it a bum-plucked number? Or should I dig out my
> OCC documentation?
>
> The rest looks okay though, so:
I just fabricated it. OCC spec doesn't provide any info on what to do
here. Just a way to do polling on the "command in progress" response.
Thanks,
Eddie
>
> Acked-by: Andrew Jeffery <andrew at aj.id.au>
>
>> +
>> struct occ {
>> struct device *sbefifo;
>> char name[32];
>> @@ -569,6 +573,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;
>> @@ -590,6 +597,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);
>> @@ -601,9 +610,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) {
More information about the openbmc
mailing list