From patchwork Wed May 25 16:58:51 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 576213 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 83893C433EF for ; Wed, 25 May 2022 16:59:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245545AbiEYQ7L (ORCPT ); Wed, 25 May 2022 12:59:11 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245544AbiEYQ7G (ORCPT ); Wed, 25 May 2022 12:59:06 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D0970A502C; Wed, 25 May 2022 09:59:05 -0700 (PDT) Received: from pps.filterd (m0098417.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24PFpQB8017100; Wed, 25 May 2022 16:59:01 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=PskLGdI9JIgYggRegGXFky41jIqj4v59+3Z8Hb7wQr8=; b=rPcUgnvQb+4Ee6ntSk/BejaXX+Y7tX5uRNoFuo2om22OtM+vVj1nVxCRVWTI+s1MJTrf Q/W4dSNIaMmhKkv/YANORHUWKKrNm4wanWodEt1GR56rriDvh1+cFjfez0KvrEzUo47l fna3+VJaLJgct95n5IGttEcflBMyqNIwTC1S53ij91d/N9MFh+GtYPUYtirdo9kOCxGS k2yB03RnY5eYKxsBfFDnomyIv6s3oMKwh49SPYpUL4ZdF3xusyZEZQ+ISySkMvbhgUtW 1Gsm55zVkl/vwZQhfHBwGGkI5nKYoy2w1z42sMwAFHb4t7DYqKUGkniN7LeFsHfNYWJ8 fQ== Received: from ppma02dal.us.ibm.com (a.bd.3ea9.ip4.static.sl-reverse.com [169.62.189.10]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g9pwka7sh-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 May 2022 16:59:00 +0000 Received: from pps.filterd (ppma02dal.us.ibm.com [127.0.0.1]) by ppma02dal.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24PGd0BS010050; Wed, 25 May 2022 16:59:00 GMT Received: from b01cxnp22036.gho.pok.ibm.com (b01cxnp22036.gho.pok.ibm.com [9.57.198.26]) by ppma02dal.us.ibm.com with ESMTP id 3g93v895bt-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 May 2022 16:59:00 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp22036.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24PGwxDL5046828 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 May 2022 16:58:59 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 5A4E4112064; Wed, 25 May 2022 16:58:59 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id CBEBA112062; Wed, 25 May 2022 16:58:58 +0000 (GMT) Received: from v0005c16.aus.stglabs.ibm.com (unknown [9.211.60.201]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 25 May 2022 16:58:58 +0000 (GMT) From: Eddie James To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Eddie James Subject: [PATCH 1/2] spi: fsi: Fix spurious timeout Date: Wed, 25 May 2022 11:58:51 -0500 Message-Id: <20220525165852.33167-2-eajames@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220525165852.33167-1-eajames@linux.ibm.com> References: <20220525165852.33167-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-GUID: 0WGKjuUraLEgBZ5lvoe6BQHdSdHgZCl2 X-Proofpoint-ORIG-GUID: 0WGKjuUraLEgBZ5lvoe6BQHdSdHgZCl2 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-25_04,2022-05-25_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 mlxscore=0 lowpriorityscore=0 bulkscore=0 clxscore=1015 priorityscore=1501 impostorscore=0 suspectscore=0 malwarescore=0 mlxlogscore=999 adultscore=0 phishscore=0 spamscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2205250085 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org The driver may return a timeout error even if the status register indicates that the transfer may proceed. Fix this by restructuring the polling loop. Fixes: 89b35e3f2851 ("spi: fsi: Implement a timeout for polling status") Signed-off-by: Eddie James --- I have one concern still, that if the kernel is very busy, it may schedule other work for the entire timeout period between assigning "end" and checking if timed out in the do/while loop... Is it worth worrying about this case? drivers/spi/spi-fsi.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/spi/spi-fsi.c b/drivers/spi/spi-fsi.c index d403a7a3021d..72ab066ce552 100644 --- a/drivers/spi/spi-fsi.c +++ b/drivers/spi/spi-fsi.c @@ -319,12 +319,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx, end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS); do { + if (time_after(jiffies, end)) + return -ETIMEDOUT; + rc = fsi_spi_status(ctx, &status, "TX"); if (rc) return rc; - - if (time_after(jiffies, end)) - return -ETIMEDOUT; } while (status & SPI_FSI_STATUS_TDR_FULL); sent += nb; @@ -337,12 +337,12 @@ static int fsi_spi_transfer_data(struct fsi_spi *ctx, while (transfer->len > recv) { end = jiffies + msecs_to_jiffies(SPI_FSI_STATUS_TIMEOUT_MS); do { + if (time_after(jiffies, end)) + return -ETIMEDOUT; + rc = fsi_spi_status(ctx, &status, "RX"); if (rc) return rc; - - if (time_after(jiffies, end)) - return -ETIMEDOUT; } while (!(status & SPI_FSI_STATUS_RDR_FULL)); rc = fsi_spi_read_reg(ctx, SPI_FSI_DATA_RX, &in); From patchwork Wed May 25 16:58:52 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Eddie James X-Patchwork-Id: 576448 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36D4DC433F5 for ; Wed, 25 May 2022 16:59:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S245542AbiEYQ7G (ORCPT ); Wed, 25 May 2022 12:59:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:48006 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S245528AbiEYQ7F (ORCPT ); Wed, 25 May 2022 12:59:05 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7791A9CC98; Wed, 25 May 2022 09:59:04 -0700 (PDT) Received: from pps.filterd (m0127361.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.5/8.17.1.5) with ESMTP id 24PGwhlc027029; Wed, 25 May 2022 16:59:02 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=s29TMMaPCeov6Umv4/RKkhW1ulUvZ0bFNKT+MfZefKc=; b=jEmQGXjx15Ng6AVbzjonQGKGmIUemdi4xQjoqcOj5gAd7pUAhrMHvcsUGxAQKXudHRud vbd/H4hgyiebV2jNXJ75l4YBfqQyCycmzDjL3gL1wVZdQL7lZGzThI12mjnw15cf5zxx ZSv/+KUoefOl0c2yRMzGOVioAZcb1eDDqW69005wnElYHa4UlSvBYPihniPMpL1Yz3DE qqlK88jB0IANFtqkJpBcPlquEmg3n2Ui2dKQ8Yw9IYrFkV4p/8Qtl1XmydxXld+mZc8J uwz2uIcp/auspVq8RiKbTd5M1ma8L32yi41MvJ4qOQZbdtvGkj2NVpZErEs+nOt9wYeu TQ== Received: from ppma04wdc.us.ibm.com (1a.90.2fa9.ip4.static.sl-reverse.com [169.47.144.26]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3g9rewr063-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 May 2022 16:59:01 +0000 Received: from pps.filterd (ppma04wdc.us.ibm.com [127.0.0.1]) by ppma04wdc.us.ibm.com (8.16.1.2/8.16.1.2) with SMTP id 24PGcUfD032753; Wed, 25 May 2022 16:59:01 GMT Received: from b01cxnp23032.gho.pok.ibm.com (b01cxnp23032.gho.pok.ibm.com [9.57.198.27]) by ppma04wdc.us.ibm.com with ESMTP id 3g93uyqbb0-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Wed, 25 May 2022 16:59:01 +0000 Received: from b01ledav004.gho.pok.ibm.com (b01ledav004.gho.pok.ibm.com [9.57.199.109]) by b01cxnp23032.gho.pok.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 24PGx0nM27263316 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Wed, 25 May 2022 16:59:00 GMT Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id D5F9B112061; Wed, 25 May 2022 16:59:00 +0000 (GMT) Received: from b01ledav004.gho.pok.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 468C1112062; Wed, 25 May 2022 16:59:00 +0000 (GMT) Received: from v0005c16.aus.stglabs.ibm.com (unknown [9.211.60.201]) by b01ledav004.gho.pok.ibm.com (Postfix) with ESMTP; Wed, 25 May 2022 16:59:00 +0000 (GMT) From: Eddie James To: broonie@kernel.org Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, Eddie James Subject: [PATCH 2/2] spi: core: Display return code when failing to transfer message Date: Wed, 25 May 2022 11:58:52 -0500 Message-Id: <20220525165852.33167-3-eajames@linux.ibm.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220525165852.33167-1-eajames@linux.ibm.com> References: <20220525165852.33167-1-eajames@linux.ibm.com> MIME-Version: 1.0 X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: crbBxFRBBMklhPjWNlhgQ79uF7ygIQn4 X-Proofpoint-GUID: crbBxFRBBMklhPjWNlhgQ79uF7ygIQn4 X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.205,Aquarius:18.0.874,Hydra:6.0.486,FMLib:17.11.64.514 definitions=2022-05-25_04,2022-05-25_02,2022-02-23_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 suspectscore=0 priorityscore=1501 mlxlogscore=999 spamscore=0 bulkscore=0 adultscore=0 clxscore=1015 phishscore=0 mlxscore=0 lowpriorityscore=0 malwarescore=0 impostorscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2204290000 definitions=main-2205250085 Precedence: bulk List-ID: X-Mailing-List: linux-spi@vger.kernel.org All the other calls to the controller driver display the error return code. The return code is helpful to understand what went wrong, so include it when failing to transfer one message. Signed-off-by: Eddie James --- drivers/spi/spi.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/spi/spi.c b/drivers/spi/spi.c index 481edea77c62..ea09d1b42bf6 100644 --- a/drivers/spi/spi.c +++ b/drivers/spi/spi.c @@ -1654,7 +1654,8 @@ static void __spi_pump_messages(struct spi_controller *ctlr, bool in_kthread) ret = ctlr->transfer_one_message(ctlr, msg); if (ret) { dev_err(&ctlr->dev, - "failed to transfer one message from queue\n"); + "failed to transfer one message from queue: %d\n", + ret); goto out; }