From patchwork Tue May 31 15:26:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ira Weiny X-Patchwork-Id: 12865874 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 7C1CEC433EF for ; Tue, 31 May 2022 15:27:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345694AbiEaP1I (ORCPT ); Tue, 31 May 2022 11:27:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:32934 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1345679AbiEaP1D (ORCPT ); Tue, 31 May 2022 11:27:03 -0400 Received: from mga14.intel.com (mga14.intel.com [192.55.52.115]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24EB941338; Tue, 31 May 2022 08:27:02 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=intel.com; i=@intel.com; q=dns/txt; s=Intel; t=1654010822; x=1685546822; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version:content-transfer-encoding; bh=l6Ptm6qMXpyQPZSb/pJ6DCgdCa2Af4FyN5x310HyCKk=; b=BCp8aYArsmMQqFnNGxnbrNJsQW4vStzNmS+yiO4N17+/3O6EhiXfRwQI CLZku4peKdwI9kN8ZTGMJuqc1BOM2F8oTrBSAua01E51IXNxbuDR6qaOx qy8SxK7n9By1adao3k/VwaxIulu1FLT1V1oJcx00xilPlZlwP3s2hBdrZ iyBZzNgW2D5wxQdxqTfE2C7IhsCNcDcgiT7TuDYwO0GJmj+qNcS1Ry9xg RSoPTCXNOMD0ScaYTOLqjJZk3xqLC+MwVSgFN5uysZ14CM6ViS/TX8Kgr yNMjqE4kHPEdYKntLdcw6+IGnqfzS8AfLs/fbGJ7z2lhZPR8bR6yoORUP w==; X-IronPort-AV: E=McAfee;i="6400,9594,10364"; a="275374331" X-IronPort-AV: E=Sophos;i="5.91,265,1647327600"; d="scan'208";a="275374331" Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 08:27:01 -0700 X-IronPort-AV: E=Sophos;i="5.91,265,1647327600"; d="scan'208";a="755078908" Received: from mdossant-mobl1.amr.corp.intel.com (HELO localhost) ([10.212.154.135]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 31 May 2022 08:27:00 -0700 From: ira.weiny@intel.com To: Dan Williams , Bjorn Helgaas , Jonathan Cameron Cc: Alison Schofield , Vishal Verma , Ira Weiny , Dave Jiang , Ben Widawsky , linux-kernel@vger.kernel.org, linux-cxl@vger.kernel.org, linux-pci@vger.kernel.org Subject: [PATCH V9 8/9] cxl/port: Retry reading CDAT on failure Date: Tue, 31 May 2022 08:26:31 -0700 Message-Id: <20220531152632.1397976-9-ira.weiny@intel.com> X-Mailer: git-send-email 2.35.1 In-Reply-To: <20220531152632.1397976-1-ira.weiny@intel.com> References: <20220531152632.1397976-1-ira.weiny@intel.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-cxl@vger.kernel.org From: Ira Weiny The CDAT read may fail for a number of reasons but mainly it is possible to get different parts of a valid state. The checksum in the CDAT table protects against this. Now that the cdat data is validated issue a retries if the CDAT read fails. For now 5 retries are implemented. Signed-off-by: Ira Weiny --- Changes from V8 Move code to cxl/core/pci.c Changes from V6 Move to pci.c Fix retries count Change to 5 retries Changes from V5: New patch -- easy to push off or drop. --- drivers/cxl/core/pci.c | 32 +++++++++++++++++++++----------- 1 file changed, 21 insertions(+), 11 deletions(-) diff --git a/drivers/cxl/core/pci.c b/drivers/cxl/core/pci.c index bb370df1cb6c..7f7dac9030a6 100644 --- a/drivers/cxl/core/pci.c +++ b/drivers/cxl/core/pci.c @@ -620,20 +620,18 @@ static int cxl_cdat_read_table(struct cxl_port *port, return rc; } -void read_cdat_data(struct cxl_port *port) +static int __read_cdat_data(struct cxl_port *port) { struct device *dev = &port->dev; size_t cdat_length; int ret; if (cxl_cdat_get_length(port, &cdat_length)) - return; + return 0; port->cdat.table = devm_kzalloc(dev, cdat_length, GFP_KERNEL); - if (!port->cdat.table) { - ret = -ENOMEM; - goto error; - } + if (!port->cdat.table) + return -ENOMEM; port->cdat.length = cdat_length; ret = cxl_cdat_read_table(port, &port->cdat); @@ -641,12 +639,24 @@ void read_cdat_data(struct cxl_port *port) devm_kfree(dev, port->cdat.table); port->cdat.table = NULL; port->cdat.length = 0; - ret = -EIO; - goto error; + return -EIO; } - return; -error: - dev_err(dev, "CDAT data read error (%d)\n", ret); + return 0; +} + +void read_cdat_data(struct cxl_port *port) +{ + int retries = 5; + int rc; + + while (retries--) { + rc = __read_cdat_data(port); + if (!rc) + break; + dev_err(&port->dev, + "CDAT data read error rc=%d (retries %d)\n", + rc, retries); + } } EXPORT_SYMBOL_NS_GPL(read_cdat_data, CXL);