From patchwork Thu May 27 07:01:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joel Stanley X-Patchwork-Id: 1484445 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.ozlabs.org (client-ip=112.213.38.117; helo=lists.ozlabs.org; envelope-from=linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org; receiver=) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ohjQGKmp; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [112.213.38.117]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4FrJdP6l6qz9sTD for ; Thu, 27 May 2021 17:01:29 +1000 (AEST) Received: from boromir.ozlabs.org (localhost [IPv6:::1]) by lists.ozlabs.org (Postfix) with ESMTP id 4FrJdP4Sgrz2yYM for ; Thu, 27 May 2021 17:01:29 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ohjQGKmp; dkim-atps=neutral X-Original-To: linux-fsi@lists.ozlabs.org Delivered-To: linux-fsi@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::434; helo=mail-pf1-x434.google.com; envelope-from=joel.stan@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20161025 header.b=ohjQGKmp; dkim-atps=neutral Received: from mail-pf1-x434.google.com (mail-pf1-x434.google.com [IPv6:2607:f8b0:4864:20::434]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 4FrJdL6LwCz2yXH for ; Thu, 27 May 2021 17:01:25 +1000 (AEST) Received: by mail-pf1-x434.google.com with SMTP id f22so2954530pfn.0 for ; Thu, 27 May 2021 00:01:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=2r6TUxQsZ96+6w4ZrMzFEQfnydPgWIO6cIh8ukglOOA=; b=ohjQGKmpGzN9GGd6BueMz1sRy4RwzEp/9+DVrp7DeDR/LACNXRhynL22nNmx722Y3w 43Q0S4hHdcjG6hOvnNKjWs6qpqex3dLkTYqikxcvb8q0+oHy2tYZdX2EQPvkVwAmyZsQ mz/xG1JO+8KtuacaNxK6JPuTdRbDn07Q1gtNWQd2dEU21V5xbzHVKwKotUKGXMeyq42F 1m/5hedY0dT4eNisS/r2Pufa7HXnvOq/ae9YIOLlZY6DGcPZTEWsd05e0Y7K6rZoTAw2 cCowHKO91QLjH01jg8I00yszkLpgoEUxHGTm2D5ZLwgbrUUdWQBy3kYY3v29rBg3FhIP fh8Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :mime-version:content-transfer-encoding; bh=2r6TUxQsZ96+6w4ZrMzFEQfnydPgWIO6cIh8ukglOOA=; b=NpZlNYHoiLh2JX4AZGZA6lqlviY8ugUwW68CwCZQ1iWLLuvd9x0l4YgHB61LX1kj4N vnh9hwLa9V6jbh9VZogMytbSNwo5Eq6hU+EYYRoD7UY2TLoyaPuuMEJg3TSwaEyzge4k vEDtVjSlVcNVMFwYI96UB72xt+oz+QhFo9LPD1kHw+jplnRyLvq2RoUCeYkHvXmN7OUU R6k/sAGy30myVVGreJWnYJJ0kgWJxZrSZVuKtKh4/5PX5RuRlxW7SjP78IIk5sed3pys bhhqT6eI/MqNZCzcDHbXMy+7bJjm9DxnrIpIOhT3zXikUXrLZNn2MZwbX0WHIw54Dm8y Y8Cw== X-Gm-Message-State: AOAM533E3GVW0m0afu00X1SKkxNXpsesjAP7WzDYQ/PiCbmIIDg+dsKb gW6lBaDj610Ocv7f9coDguk= X-Google-Smtp-Source: ABdhPJw87nf/wLta7m8MHzXjyXn+882celEkHa2MlSZZXRDqhy1Eyoi/Z78Ido/FI4m2AvSr+/hpcQ== X-Received: by 2002:a63:6f4e:: with SMTP id k75mr2395954pgc.434.1622098882212; Thu, 27 May 2021 00:01:22 -0700 (PDT) Received: from localhost.localdomain ([45.124.203.14]) by smtp.gmail.com with ESMTPSA id z11sm536574pjp.0.2021.05.27.00.01.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 May 2021 00:01:21 -0700 (PDT) From: Joel Stanley To: Jeremy Kerr , Alistar Popple , Eddie James Subject: [PATCH] fsi: scom: Remove retries Date: Thu, 27 May 2021 16:31:09 +0930 Message-Id: <20210527070109.225198-1-joel@jms.id.au> X-Mailer: git-send-email 2.30.2 MIME-Version: 1.0 X-BeenThere: linux-fsi@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-kernel@vger.kernel.org, linux-fsi@lists.ozlabs.org Errors-To: linux-fsi-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "linux-fsi" On a functioning FSI link there is not need to retry a write when doing a scom in the driver. Allow the higher layers (eg. userspace) to attempt a retry if they want, or to accept that the address they are talking to is not accessible. By removing the retries we can separate the error handling from retry logic. In particular -EBUSY was used to force the get/put scom logic to retry. Signed-off-by: Joel Stanley --- This will go in after Eddie's patch: https://lore.kernel.org/r/20210329151344.14246-1-eajames@linux.ibm.com drivers/fsi/fsi-scom.c | 88 ++++++++++++++---------------------------- 1 file changed, 28 insertions(+), 60 deletions(-) diff --git a/drivers/fsi/fsi-scom.c b/drivers/fsi/fsi-scom.c index b45bfab7b7f5..1d04ffa542c1 100644 --- a/drivers/fsi/fsi-scom.c +++ b/drivers/fsi/fsi-scom.c @@ -60,7 +60,6 @@ #define XSCOM_ADDR_FORM1_HI_SHIFT 20 /* Retries */ -#define SCOM_MAX_RETRIES 100 /* Retries on busy */ #define SCOM_MAX_IND_RETRIES 10 /* Retries indirect not ready */ struct scom_device { @@ -247,7 +246,6 @@ static int handle_fsi2pib_status(struct scom_device *scom, uint32_t status) sizeof(uint32_t)); return -EIO; } - /* Return -EBUSY on PIB abort to force a retry */ if (status & SCOM_STATUS_PIB_ABORT) return -EBUSY; return 0; @@ -284,69 +282,39 @@ static int handle_pib_status(struct scom_device *scom, uint8_t status) static int put_scom(struct scom_device *scom, uint64_t value, uint64_t addr) { - uint32_t status, dummy = -1; - int rc, retries; - - for (retries = 0; retries < SCOM_MAX_RETRIES; retries++) { - rc = raw_put_scom(scom, value, addr, &status); - if (rc) { - /* Try resetting the bridge if FSI fails */ - if (rc != -ENODEV && retries == 0) { - fsi_device_write(scom->fsi_dev, SCOM_FSI2PIB_RESET_REG, - &dummy, sizeof(uint32_t)); - rc = -EBUSY; - } else - return rc; - } else - rc = handle_fsi2pib_status(scom, status); - if (rc && rc != -EBUSY) - break; - if (rc == 0) { - rc = handle_pib_status(scom, - (status & SCOM_STATUS_PIB_RESP_MASK) - >> SCOM_STATUS_PIB_RESP_SHIFT); - if (rc && rc != -EBUSY) - break; - } - if (rc == 0) - break; - msleep(1); - } - return rc; + uint32_t status; + int rc; + + rc = raw_put_scom(scom, value, addr, &status); + if (rc == -ENODEV) + return rc; + + rc = handle_fsi2pib_status(scom, status); + if (rc) + return rc; + + return handle_pib_status(scom, + (status & SCOM_STATUS_PIB_RESP_MASK) + >> SCOM_STATUS_PIB_RESP_SHIFT); } static int get_scom(struct scom_device *scom, uint64_t *value, uint64_t addr) { - uint32_t status, dummy = -1; - int rc, retries; - - for (retries = 0; retries < SCOM_MAX_RETRIES; retries++) { - rc = raw_get_scom(scom, value, addr, &status); - if (rc) { - /* Try resetting the bridge if FSI fails */ - if (rc != -ENODEV && retries == 0) { - fsi_device_write(scom->fsi_dev, SCOM_FSI2PIB_RESET_REG, - &dummy, sizeof(uint32_t)); - rc = -EBUSY; - } else - return rc; - } else - rc = handle_fsi2pib_status(scom, status); - if (rc && rc != -EBUSY) - break; - if (rc == 0) { - rc = handle_pib_status(scom, - (status & SCOM_STATUS_PIB_RESP_MASK) - >> SCOM_STATUS_PIB_RESP_SHIFT); - if (rc && rc != -EBUSY) - break; - } - if (rc == 0) - break; - msleep(1); - } - return rc; + uint32_t status; + int rc; + + rc = raw_get_scom(scom, value, addr, &status); + if (rc == -ENODEV) + return rc; + + rc = handle_fsi2pib_status(scom, status); + if (rc) + return rc; + + return handle_pib_status(scom, + (status & SCOM_STATUS_PIB_RESP_MASK) + >> SCOM_STATUS_PIB_RESP_SHIFT); } static ssize_t scom_read(struct file *filep, char __user *buf, size_t len,