Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp782255rwb; Tue, 29 Nov 2022 05:25:24 -0800 (PST) X-Google-Smtp-Source: AA0mqf4SFlTxw4j7cnr0yE1LqqGPbxcp64ybxNhaF/Gr6RBKMz0dmNkzMmf64gpAS2efoJvxVGpa X-Received: by 2002:a63:d143:0:b0:476:c8c5:ba85 with SMTP id c3-20020a63d143000000b00476c8c5ba85mr48626439pgj.182.1669728324624; Tue, 29 Nov 2022 05:25:24 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669728324; cv=none; d=google.com; s=arc-20160816; b=BQqMa+wHqA4J6IYB+hsiF5s59XMOiRmq4P3EWR1LFT8iyXz/uc/+qfZTXuqcGyiy9I /gAKwR4yUX/3y9bOB0AdDF7e7lRdkMN3h+pau6+MxHCHSDgsULUApAbtwI56VmysRPga mfGbdxVVnun4iTeRR0uXDrJTsZBWAw8/mBN5zMhonZx5XbQI1n3zMxeD8ldlbFSRLSZP Aqe/cjFU/SEtivDXe+dWvrMK6MUcoo+Vs3j/siKd2fmD0YSSJmrm4oWGOfKOLkhdTcqE l6U+RQQrXBQoduXuFBJMGaTfa70evdEm8xoehClD5eLsawGWRsT0H01GHwZ6ACjv63Hw zWmg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=HvX7af/N5/lzH6fxa5KjfS8FuhXQiZKgKoM6CluI66k=; b=Ir2jelW2OkzGFWiutBu4jrQpURAI0w6sQ5bz2hvdXBwLbtPKFVYoXuDoqeLDuMaTaK X4iD5ueGy85jJJjM3XvqD+DVj6ZhVnBcgmY4gc0Rl1uOWlH0RnYLtCwJ3LDF5WGeKDVq XM9RAyU9NYygEl9PH1McSGI3m/37K/Ne74xY4hYq+LA4/44iHZKJIv9rQ7zu9AMJsNCv /UhuAHjjzhVdFPAVfT4jXkAzMMEkkeQy0CW+Z/pQ16KBSck25PT75V2eINhrnRXsFdDS ROR8XFESz+dmH1jb+aiJFWgCMCQomOfhVk31v+6kqMY7aoUCGaQm3GmTLbnP1mnYDJlN hfMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=OSRPYwzS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id h19-20020a63f913000000b00476f92d5967si14695626pgi.877.2022.11.29.05.25.12; Tue, 29 Nov 2022 05:25:24 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@marvell.com header.s=pfpt0220 header.b=OSRPYwzS; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=REJECT dis=NONE) header.from=marvell.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230346AbiK2NKR (ORCPT + 85 others); Tue, 29 Nov 2022 08:10:17 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:50318 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232559AbiK2NJ7 (ORCPT ); Tue, 29 Nov 2022 08:09:59 -0500 Received: from mx0b-0016f401.pphosted.com (mx0a-0016f401.pphosted.com [67.231.148.174]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A37AE59170; Tue, 29 Nov 2022 05:09:58 -0800 (PST) Received: from pps.filterd (m0045849.ppops.net [127.0.0.1]) by mx0a-0016f401.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 2ATBxjWv029859; Tue, 29 Nov 2022 05:09:49 -0800 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=marvell.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding : content-type; s=pfpt0220; bh=HvX7af/N5/lzH6fxa5KjfS8FuhXQiZKgKoM6CluI66k=; b=OSRPYwzSbAtday5Gz04mKhUxFXCa3DZOUcaNRI2riTwoQwfwBXeqesRxDeQn/u6kisx8 Dtbrwq3iClySmA6IdcRco5uXDWS2CZG+bQ0mPiK0vG47pZEvPPes63Qbj605OFjLFpX1 J6dW2OLgZI1N78wC1oALItMgGjKDevQNW4skKmhhcxTbpc1QTdisK/cAAQSDdsLYUhj1 YWrDaCm2QgsAC11Y2gyf2+h4FJNvEHDNrDMuRrvteeoC8EZD1cL7ByV3aCW8NADQ3zrL hV0XbXyktqM7nnvHdh6NDTxltHCHFPN7R/sQgnKmTG5Iswn0rKFfaIbo1M/v/FLo7k/2 Qw== Received: from dc5-exch01.marvell.com ([199.233.59.181]) by mx0a-0016f401.pphosted.com (PPS) with ESMTPS id 3m5a509ysx-3 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-SHA384 bits=256 verify=NOT); Tue, 29 Nov 2022 05:09:49 -0800 Received: from DC5-EXCH01.marvell.com (10.69.176.38) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server (TLS) id 15.0.1497.2; Tue, 29 Nov 2022 05:09:40 -0800 Received: from maili.marvell.com (10.69.176.80) by DC5-EXCH01.marvell.com (10.69.176.38) with Microsoft SMTP Server id 15.0.1497.2 via Frontend Transport; Tue, 29 Nov 2022 05:09:40 -0800 Received: from sburla-PowerEdge-T630.caveonetworks.com (unknown [10.106.27.217]) by maili.marvell.com (Postfix) with ESMTP id 2135F3F7088; Tue, 29 Nov 2022 05:09:40 -0800 (PST) From: Veerasenareddy Burru To: , , , , , CC: , Veerasenareddy Burru , "David S. Miller" , Eric Dumazet , Jakub Kicinski , Paolo Abeni Subject: [PATCH net-next v2 1/9] octeon_ep: defer probe if firmware not ready Date: Tue, 29 Nov 2022 05:09:24 -0800 Message-ID: <20221129130933.25231-2-vburru@marvell.com> X-Mailer: git-send-email 2.36.0 In-Reply-To: <20221129130933.25231-1-vburru@marvell.com> References: <20221129130933.25231-1-vburru@marvell.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Proofpoint-ORIG-GUID: RzQePv3nI0UFPPUqDJLlzl1ydkXCAPiR X-Proofpoint-GUID: RzQePv3nI0UFPPUqDJLlzl1ydkXCAPiR X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.219,Aquarius:18.0.895,Hydra:6.0.545,FMLib:17.11.122.1 definitions=2022-11-29_08,2022-11-29_01,2022-06-22_01 X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_NONE, SPF_NONE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Defer probe if firmware is not ready for device usage. Signed-off-by: Veerasenareddy Burru Signed-off-by: Abhijit Ayarekar Signed-off-by: Satananda Burla --- v1 -> v2: * was scheduling workqueue task to wait for firmware ready, to probe/initialize the device. * now, removed the workqueue task; the probe returns EPROBE_DEFER, if firmware is not ready. * removed device status oct->status, as it is not required with the modified implementation. .../ethernet/marvell/octeon_ep/octep_main.c | 26 +++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c index 5a898fb88e37..aa7d0ced9807 100644 --- a/drivers/net/ethernet/marvell/octeon_ep/octep_main.c +++ b/drivers/net/ethernet/marvell/octeon_ep/octep_main.c @@ -1017,6 +1017,25 @@ static void octep_device_cleanup(struct octep_device *oct) oct->conf = NULL; } +static u8 get_fw_ready_status(struct pci_dev *pdev) +{ + u32 pos = 0; + u16 vsec_id; + u8 status; + + while ((pos = pci_find_next_ext_capability(pdev, pos, + PCI_EXT_CAP_ID_VNDR))) { + pci_read_config_word(pdev, pos + 4, &vsec_id); +#define FW_STATUS_VSEC_ID 0xA3 + if (vsec_id == FW_STATUS_VSEC_ID) { + pci_read_config_byte(pdev, (pos + 8), &status); + dev_info(&pdev->dev, "Firmware ready %u\n", status); + return status; + } + } + return 0; +} + /** * octep_probe() - Octeon PCI device probe handler. * @@ -1053,6 +1072,13 @@ static int octep_probe(struct pci_dev *pdev, const struct pci_device_id *ent) pci_enable_pcie_error_reporting(pdev); pci_set_master(pdev); +#define FW_STATUS_READY 1 + if (get_fw_ready_status(pdev) != FW_STATUS_READY) { + dev_notice(&pdev->dev, "Firmware not ready; defer probe.\n"); + err = -EPROBE_DEFER; + goto err_alloc_netdev; + } + netdev = alloc_etherdev_mq(sizeof(struct octep_device), OCTEP_MAX_QUEUES); if (!netdev) { -- 2.36.0