diff mbox series

[01/12] sfc: falcon: Read VPD with pci_vpd_alloc()

Message ID 2a8d069e-9516-50d8-6520-2614222c8f5f@gmail.com (mailing list archive)
State Accepted
Delegated to: Bjorn Helgaas
Headers show
Series PCI/VPD: Convert more users to the new VPD API functions | expand

Commit Message

Heiner Kallweit Aug. 22, 2021, 1:48 p.m. UTC
This is the same as 5119e20facfa "sfc: Read VPD with pci_vpd_alloc()",
just for the falcon chip version.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/sfc/falcon/efx.c | 30 +++++++++++++--------------
 1 file changed, 14 insertions(+), 16 deletions(-)

Comments

kernel test robot Aug. 22, 2021, 4:25 p.m. UTC | #1
Hi Heiner,

I love your patch! Perhaps something to improve:

[auto build test WARNING on scsi/for-next]
[also build test WARNING on pci/next mkp-scsi/for-next linus/master v5.14-rc6 next-20210820]
[If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]

url:    https://github.com/0day-ci/linux/commits/Heiner-Kallweit/PCI-VPD-Convert-more-users-to-the-new-VPD-API-functions/20210822-220229
base:   https://git.kernel.org/pub/scm/linux/kernel/git/jejb/scsi.git for-next
config: xtensa-allyesconfig (attached as .config)
compiler: xtensa-linux-gcc (GCC) 11.2.0
reproduce (this is a W=1 build):
        wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # https://github.com/0day-ci/linux/commit/f04e3b53e818526cc8b869af3804e375c0a48abf
        git remote add linux-review https://github.com/0day-ci/linux
        git fetch --no-tags linux-review Heiner-Kallweit/PCI-VPD-Convert-more-users-to-the-new-VPD-API-functions/20210822-220229
        git checkout f04e3b53e818526cc8b869af3804e375c0a48abf
        # save the attached .config to linux build tree
        COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-11.2.0 make.cross ARCH=xtensa 

If you fix the issue, kindly add following tag as appropriate
Reported-by: kernel test robot <lkp@intel.com>

All warnings (new ones prefixed by >>):

   drivers/net/ethernet/sfc/falcon/efx.c: In function 'ef4_probe_vpd_strings':
   drivers/net/ethernet/sfc/falcon/efx.c:2792:20: error: implicit declaration of function 'pci_vpd_alloc'; did you mean 'pci_pool_alloc'? [-Werror=implicit-function-declaration]
    2792 |         vpd_data = pci_vpd_alloc(dev, &vpd_size);
         |                    ^~~~~~~~~~~~~
         |                    pci_pool_alloc
>> drivers/net/ethernet/sfc/falcon/efx.c:2792:18: warning: assignment to 'u8 *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
    2792 |         vpd_data = pci_vpd_alloc(dev, &vpd_size);
         |                  ^
   cc1: some warnings being treated as errors


vim +2792 drivers/net/ethernet/sfc/falcon/efx.c

  2781	
  2782	/* NIC VPD information
  2783	 * Called during probe to display the part number of the installed NIC.
  2784	 */
  2785	static void ef4_probe_vpd_strings(struct ef4_nic *efx)
  2786	{
  2787		struct pci_dev *dev = efx->pci_dev;
  2788		int ro_start, ro_size, i, j;
  2789		unsigned int vpd_size;
  2790		u8 *vpd_data;
  2791	
> 2792		vpd_data = pci_vpd_alloc(dev, &vpd_size);
  2793		if (IS_ERR(vpd_data)) {
  2794			pci_warn(dev, "Unable to read VPD\n");
  2795			return;
  2796		}
  2797	
  2798		/* Get the Read only section */
  2799		ro_start = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA);
  2800		if (ro_start < 0) {
  2801			netif_err(efx, drv, efx->net_dev, "VPD Read-only not found\n");
  2802			goto out;
  2803		}
  2804	
  2805		ro_size = pci_vpd_lrdt_size(&vpd_data[ro_start]);
  2806		j = ro_size;
  2807		i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
  2808		if (i + j > vpd_size)
  2809			j = vpd_size - i;
  2810	
  2811		/* Get the Part number */
  2812		i = pci_vpd_find_info_keyword(vpd_data, i, j, "PN");
  2813		if (i < 0) {
  2814			netif_err(efx, drv, efx->net_dev, "Part number not found\n");
  2815			goto out;
  2816		}
  2817	
  2818		j = pci_vpd_info_field_size(&vpd_data[i]);
  2819		i += PCI_VPD_INFO_FLD_HDR_SIZE;
  2820		if (i + j > vpd_size) {
  2821			netif_err(efx, drv, efx->net_dev, "Incomplete part number\n");
  2822			goto out;
  2823		}
  2824	
  2825		netif_info(efx, drv, efx->net_dev,
  2826			   "Part Number : %.*s\n", j, &vpd_data[i]);
  2827	
  2828		i = ro_start + PCI_VPD_LRDT_TAG_SIZE;
  2829		j = ro_size;
  2830		i = pci_vpd_find_info_keyword(vpd_data, i, j, "SN");
  2831		if (i < 0) {
  2832			netif_err(efx, drv, efx->net_dev, "Serial number not found\n");
  2833			goto out;
  2834		}
  2835	
  2836		j = pci_vpd_info_field_size(&vpd_data[i]);
  2837		i += PCI_VPD_INFO_FLD_HDR_SIZE;
  2838		if (i + j > vpd_size) {
  2839			netif_err(efx, drv, efx->net_dev, "Incomplete serial number\n");
  2840			goto out;
  2841		}
  2842	
  2843		efx->vpd_sn = kmalloc(j + 1, GFP_KERNEL);
  2844		if (!efx->vpd_sn)
  2845			goto out;
  2846	
  2847		snprintf(efx->vpd_sn, j + 1, "%s", &vpd_data[i]);
  2848	out:
  2849		kfree(vpd_data);
  2850	}
  2851	

---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all@lists.01.org
diff mbox series

Patch

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);
 }