From patchwork Sun Aug 22 13:48:33 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Heiner Kallweit X-Patchwork-Id: 501487 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-14.2 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS,USER_AGENT_SANE_1 autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8C5C4C4320A for ; Sun, 22 Aug 2021 14:01:25 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5FC6D6126A for ; Sun, 22 Aug 2021 14:01:25 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232428AbhHVOCF (ORCPT ); Sun, 22 Aug 2021 10:02:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40216 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230495AbhHVOCE (ORCPT ); Sun, 22 Aug 2021 10:02:04 -0400 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0FE21C061575; Sun, 22 Aug 2021 07:01:23 -0700 (PDT) Received: by mail-wr1-x432.google.com with SMTP id d26so1625241wrc.0; Sun, 22 Aug 2021 07:01:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=subject:from:to:cc:references:message-id:date:user-agent :mime-version:in-reply-to:content-language:content-transfer-encoding; bh=Euz0E6isscBYyFQ42pM4Z2EOYe57hCAo87czLinH3tQ=; b=Ku7NYMjn9nIwgb2ynMqcuTcWBtHsvWS2W57WhgpdY7Z4cL+aUN2DyL3RcNwP9ZKoLP ibLcGD0I/IRefzks/kJyucgsHGK9S2R7cFW3jiW2uU44uXOulsd76cmwk7CyF+rILsTN ONHjh3vcoQmrwMl9tJ4YoEZJt4qJr5/Hzv48lYjX8vhmIZojU1F0hkFTXV231HJmcaMj 1CcH28LUJdpqvOxvC/ZhkJVj+au958joOU4vUS0PFAhPiPaLGxaQYyrgoe+tbKmT0GUA 9eB1RnZEjXfBmnzh9cLfkGM+TyEf06yczr9N3SSq4R7GEazFqS5fCc/lEtlcoasH7Uyf vRKw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:subject:from:to:cc:references:message-id:date :user-agent:mime-version:in-reply-to:content-language :content-transfer-encoding; bh=Euz0E6isscBYyFQ42pM4Z2EOYe57hCAo87czLinH3tQ=; b=lf4nr76hQ6ufSzwBAPDdUJI/j9SZOtdBBcLGKcOJl0IpPC+cW2MK6ILctwprpZnaSy aRP1Aa2WQt1U20UvqIRxd3tRkifnt554FzkD+LczqmZJTmXVWcWyus3f2sOpte54fh23 j8a5eSYpHZ5OLald1S2w9NQc30jiR2HiheC5MMlTpt4ALKK2ACS65baNgJZ4wFXhnIf9 5kn+XeOkeNVQf0QSAmNxbFdfQSM03bRzb5Lou2pa2CxuM+YlV6tCkPUZhwFftck5pM0R dGqth4s+qsM/UNnzAzOQaIb73VQPCWcH0mMhctkcS7di+dp2jVlPrOT9pNAVM2Ppy1So v0pA== X-Gm-Message-State: AOAM533rwLq3wcuLiNVU9ejFnCvoR4Y4clInvTFN8NgGdbhd3txgme7C 92gWX8UzM9f9CrFsqFdFsbCvNBseJyBTEw== X-Google-Smtp-Source: ABdhPJxsxqZLYUrdIsPO90PZWWoJEriPEnNBkC+1jahdkQlcQTd45SQhdMkwHyALbQl9HWEmfTsHlA== X-Received: by 2002:a5d:6381:: with SMTP id p1mr9133141wru.310.1629640881263; Sun, 22 Aug 2021 07:01:21 -0700 (PDT) Received: from ?IPv6:2003:ea:8f08:4500:fc53:5e22:f926:c43b? (p200300ea8f084500fc535e22f926c43b.dip0.t-ipconnect.de. [2003:ea:8f08:4500:fc53:5e22:f926:c43b]) by smtp.googlemail.com with ESMTPSA id w14sm11818452wrt.23.2021.08.22.07.01.20 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Sun, 22 Aug 2021 07:01:20 -0700 (PDT) Subject: [PATCH 01/12] sfc: falcon: Read VPD with pci_vpd_alloc() From: Heiner Kallweit To: Bjorn Helgaas , Edward Cree , Martin Habets , Jakub Kicinski , David Miller Cc: "linux-pci@vger.kernel.org" , SCSI development list , "netdev@vger.kernel.org" References: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Message-ID: <2a8d069e-9516-50d8-6520-2614222c8f5f@gmail.com> Date: Sun, 22 Aug 2021 15:48:33 +0200 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:78.0) Gecko/20100101 Thunderbird/78.13.0 MIME-Version: 1.0 In-Reply-To: <1ca29408-7bc7-4da5-59c7-87893c9e0442@gmail.com> Content-Language: en-US Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org This is the same as 5119e20facfa "sfc: Read VPD with pci_vpd_alloc()", just for the falcon chip version. Signed-off-by: Heiner Kallweit --- drivers/net/ethernet/sfc/falcon/efx.c | 30 +++++++++++++-------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/drivers/net/ethernet/sfc/falcon/efx.c b/drivers/net/ethernet/sfc/falcon/efx.c index c177ea0f3..5ab1e863d 100644 --- a/drivers/net/ethernet/sfc/falcon/efx.c +++ b/drivers/net/ethernet/sfc/falcon/efx.c @@ -2780,22 +2780,18 @@ static void ef4_pci_remove(struct pci_dev *pci_dev) }; /* NIC VPD information - * Called during probe to display the part number of the - * installed NIC. VPD is potentially very large but this should - * always appear within the first 512 bytes. + * Called during probe to display the part number of the installed NIC. */ -#define SFC_VPD_LEN 512 static void ef4_probe_vpd_strings(struct ef4_nic *efx) { struct pci_dev *dev = efx->pci_dev; - char vpd_data[SFC_VPD_LEN]; - ssize_t vpd_size; int ro_start, ro_size, i, j; + unsigned int vpd_size; + u8 *vpd_data; - /* Get the vpd data from the device */ - vpd_size = pci_read_vpd(dev, 0, sizeof(vpd_data), vpd_data); - if (vpd_size <= 0) { - netif_err(efx, drv, efx->net_dev, "Unable to read VPD\n"); + vpd_data = pci_vpd_alloc(dev, &vpd_size); + if (IS_ERR(vpd_data)) { + pci_warn(dev, "Unable to read VPD\n"); return; } @@ -2803,7 +2799,7 @@ static void ef4_probe_vpd_strings(struct ef4_nic *efx) ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA); if (ro_start < 0) { netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n"); - return; + goto out; } ro_size = pci_vpd_lrdt_size(&vpd_data[ro_start]); @@ -2816,14 +2812,14 @@ static void ef4_probe_vpd_strings(struct ef4_nic *efx) i = pci_vpd_find_info_keyword(vpd_data, i, j, "PN"); if (i < 0) { netif_err(efx, drv, efx->net_dev, "Part number not found\n"); - return; + goto out; } j = pci_vpd_info_field_size(&vpd_data[i]); i += PCI_VPD_INFO_FLD_HDR_SIZE; if (i + j > vpd_size) { netif_err(efx, drv, efx->net_dev, "Incomplete part number\n"); - return; + goto out; } netif_info(efx, drv, efx->net_dev, @@ -2834,21 +2830,23 @@ static void ef4_probe_vpd_strings(struct ef4_nic *efx) i = pci_vpd_find_info_keyword(vpd_data, i, j, "SN"); if (i < 0) { netif_err(efx, drv, efx->net_dev, "Serial number not found\n"); - return; + goto out; } j = pci_vpd_info_field_size(&vpd_data[i]); i += PCI_VPD_INFO_FLD_HDR_SIZE; if (i + j > vpd_size) { netif_err(efx, drv, efx->net_dev, "Incomplete serial number\n"); - return; + goto out; } efx->vpd_sn = kmalloc(j + 1, GFP_KERNEL); if (!efx->vpd_sn) - return; + goto out; snprintf(efx->vpd_sn, j + 1, "%s", &vpd_data[i]); +out: + kfree(vpd_data); }