Return-Path: Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=linux.vnet.ibm.com (client-ip=148.163.156.1; helo=mx0a-001b2d01.pphosted.com; envelope-from=eajames@linux.vnet.ibm.com; receiver=) Received: from mx0a-001b2d01.pphosted.com (mx0a-001b2d01.pphosted.com [148.163.156.1]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3yNM2K1RmxzDqlH for ; Fri, 27 Oct 2017 09:22:32 +1100 (AEDT) Received: from pps.filterd (m0098399.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.16.0.21/8.16.0.21) with SMTP id v9QMJYOL090225 for ; Thu, 26 Oct 2017 18:22:29 -0400 Received: from e14.ny.us.ibm.com (e14.ny.us.ibm.com [129.33.205.204]) by mx0a-001b2d01.pphosted.com with ESMTP id 2dupejmwp9-1 (version=TLSv1.2 cipher=AES256-SHA bits=256 verify=NOT) for ; Thu, 26 Oct 2017 18:22:28 -0400 Received: from localhost by e14.ny.us.ibm.com with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted for from ; Thu, 26 Oct 2017 18:22:27 -0400 Received: from b01cxnp23033.gho.pok.ibm.com (9.57.198.28) by e14.ny.us.ibm.com (146.89.104.201) with IBM ESMTP SMTP Gateway: Authorized Use Only! Violators will be prosecuted; Thu, 26 Oct 2017 18:22:24 -0400 Received: from b01ledav003.gho.pok.ibm.com (b01ledav003.gho.pok.ibm.com [9.57.199.108]) by b01cxnp23033.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id v9QMMOdO53870612; Thu, 26 Oct 2017 22:22:24 GMT Received: from b01ledav003.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 01B2BB204D; Thu, 26 Oct 2017 18:19:38 -0400 (EDT) Received: from oc3016140333.ibm.com (unknown [9.41.174.252]) by b01ledav003.gho.pok.ibm.com (Postfix) with ESMTP id 9D626B2046; Thu, 26 Oct 2017 18:19:37 -0400 (EDT) From: Eddie James To: openbmc@lists.ozlabs.org Cc: andrew@aj.id.au, bradleyb@fuzziesquirrel.com, "Edward A. James" Subject: [PATCH linux dev-4.10] drivers (fsi): sbefifo: Add timeout for waiting for data Date: Thu, 26 Oct 2017 17:22:21 -0500 X-Mailer: git-send-email 1.8.3.1 X-TM-AS-GCONF: 00 x-cbid: 17102622-0052-0000-0000-000002781CB2 X-IBM-SpamModules-Scores: X-IBM-SpamModules-Versions: BY=3.00007957; HX=3.00000241; KW=3.00000007; PH=3.00000004; SC=3.00000239; SDB=6.00936918; UDB=6.00472176; IPR=6.00717181; BA=6.00005660; NDR=6.00000001; ZLA=6.00000005; ZF=6.00000009; ZB=6.00000000; ZP=6.00000000; ZH=6.00000000; ZU=6.00000002; MB=3.00017730; XFM=3.00000015; UTC=2017-10-26 22:22:26 X-IBM-AV-DETECTION: SAVI=unused REMOTE=unused XFE=unused x-cbparentid: 17102622-0053-0000-0000-00005271344B Message-Id: <1509056541-13282-1-git-send-email-eajames@linux.vnet.ibm.com> X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2017-10-26_09:, , signatures=0 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 priorityscore=1501 malwarescore=0 suspectscore=1 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 impostorscore=0 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1707230000 definitions=main-1710260282 X-BeenThere: openbmc@lists.ozlabs.org X-Mailman-Version: 2.1.24 Precedence: list List-Id: Development list for OpenBMC List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 26 Oct 2017 22:22:33 -0000 From: "Edward A. James" During a transfer, in the event that the SBE isn't running, the driver will wait for data to appear in the FIFO forever. This doesn't work at BMC boot time if any transfers are attempted (by OCC driver probing, for example), as it will just hang the boot. So add a simple timeout mechanism when the driver reschdules waiting for data to show up in the FIFO. Tested on witherspoon by rebooting the BMC successfully with chassis power on. Signed-off-by: Edward A. James --- drivers/fsi/fsi-sbefifo.c | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/drivers/fsi/fsi-sbefifo.c b/drivers/fsi/fsi-sbefifo.c index f756822..421f86e 100644 --- a/drivers/fsi/fsi-sbefifo.c +++ b/drivers/fsi/fsi-sbefifo.c @@ -54,6 +54,7 @@ #define SBEFIFO_EOT_ACK 0x14 #define SBEFIFO_RESCHEDULE msecs_to_jiffies(500) +#define SBEFIFO_MAX_RESCHDULE msecs_to_jiffies(5000) struct sbefifo { struct timer_list poll_timer; @@ -77,6 +78,7 @@ struct sbefifo_buf { }; struct sbefifo_xfr { + unsigned long wait_data_timeout; struct sbefifo_buf *rbuf; struct sbefifo_buf *wbuf; struct list_head client; @@ -450,6 +452,20 @@ static void sbefifo_poll_timer(unsigned long data) devn = sbefifo_dev_nwreadable(sts); if (devn == 0) { + /* + * Limit the maximum waiting period for data in the + * FIFO. If the SBE isn't running, we will wait + * forever. + */ + if (!xfr->wait_data_timeout) { + xfr->wait_data_timeout = + jiffies + SBEFIFO_MAX_RESCHDULE; + } else if (time_after(jiffies, + xfr->wait_data_timeout)) { + ret = -ETIME; + goto out; + } + /* No data yet. Reschedule. */ sbefifo->poll_timer.expires = jiffies + SBEFIFO_RESCHEDULE; -- 1.8.3.1