diff mbox series

[07/12] bnxt: Read VPD with pci_vpd_alloc()

Message ID 62522a24-f39a-2b35-1577-1fbb41695bed@gmail.com (mailing list archive)
State Rejected
Delegated to: Netdev Maintainers
Headers show
Series [01/12] sfc: falcon: Read VPD with pci_vpd_alloc() | expand

Commit Message

Heiner Kallweit Aug. 22, 2021, 1:55 p.m. UTC
Use pci_vpd_alloc() to dynamically allocate a properly sized buffer and
read the full VPD data into it.

This simplifies the code, and we no longer have to make assumptions about
VPD size.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 13 ++++---------
 1 file changed, 4 insertions(+), 9 deletions(-)

Comments

kernel test robot Aug. 22, 2021, 6:39 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/5658a697843355ac5fbf26ae3b7c57dd0d794238
        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 5658a697843355ac5fbf26ae3b7c57dd0d794238
        # 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/broadcom/bnxt/bnxt.c: In function 'bnxt_request_irq':
   drivers/net/ethernet/broadcom/bnxt/bnxt.c:9000:16: warning: variable 'j' set but not used [-Wunused-but-set-variable]
    9000 |         int i, j, rc = 0;
         |                ^
   drivers/net/ethernet/broadcom/bnxt/bnxt.c: In function 'bnxt_vpd_read_info':
   drivers/net/ethernet/broadcom/bnxt/bnxt.c:12987:20: error: implicit declaration of function 'pci_vpd_alloc'; did you mean 'pci_pool_alloc'? [-Werror=implicit-function-declaration]
   12987 |         vpd_data = pci_vpd_alloc(pdev, &vpd_size);
         |                    ^~~~~~~~~~~~~
         |                    pci_pool_alloc
>> drivers/net/ethernet/broadcom/bnxt/bnxt.c:12987:18: warning: assignment to 'u8 *' {aka 'unsigned char *'} from 'int' makes pointer from integer without a cast [-Wint-conversion]
   12987 |         vpd_data = pci_vpd_alloc(pdev, &vpd_size);
         |                  ^
   cc1: some warnings being treated as errors


vim +12987 drivers/net/ethernet/broadcom/bnxt/bnxt.c

 12979	
 12980	static void bnxt_vpd_read_info(struct bnxt *bp)
 12981	{
 12982		struct pci_dev *pdev = bp->pdev;
 12983		int i, len, pos, ro_size, size;
 12984		unsigned int vpd_size;
 12985		u8 *vpd_data;
 12986	
 12987		vpd_data = pci_vpd_alloc(pdev, &vpd_size);
 12988		if (IS_ERR(vpd_data)) {
 12989			pci_warn(pdev, "Unable to read VPD\n");
 12990			return;
 12991		}
 12992	
 12993		i = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA);
 12994		if (i < 0) {
 12995			netdev_err(bp->dev, "VPD READ-Only not found\n");
 12996			goto exit;
 12997		}
 12998	
 12999		ro_size = pci_vpd_lrdt_size(&vpd_data[i]);
 13000		i += PCI_VPD_LRDT_TAG_SIZE;
 13001		if (i + ro_size > vpd_size)
 13002			goto exit;
 13003	
 13004		pos = pci_vpd_find_info_keyword(vpd_data, i, ro_size,
 13005						PCI_VPD_RO_KEYWORD_PARTNO);
 13006		if (pos < 0)
 13007			goto read_sn;
 13008	
 13009		len = pci_vpd_info_field_size(&vpd_data[pos]);
 13010		pos += PCI_VPD_INFO_FLD_HDR_SIZE;
 13011		if (len + pos > vpd_size)
 13012			goto read_sn;
 13013	
 13014		size = min(len, BNXT_VPD_FLD_LEN - 1);
 13015		memcpy(bp->board_partno, &vpd_data[pos], size);
 13016	
 13017	read_sn:
 13018		pos = pci_vpd_find_info_keyword(vpd_data, i, ro_size,
 13019						PCI_VPD_RO_KEYWORD_SERIALNO);
 13020		if (pos < 0)
 13021			goto exit;
 13022	
 13023		len = pci_vpd_info_field_size(&vpd_data[pos]);
 13024		pos += PCI_VPD_INFO_FLD_HDR_SIZE;
 13025		if (len + pos > vpd_size)
 13026			goto exit;
 13027	
 13028		size = min(len, BNXT_VPD_FLD_LEN - 1);
 13029		memcpy(bp->board_serialno, &vpd_data[pos], size);
 13030	exit:
 13031		kfree(vpd_data);
 13032	}
 13033	

---
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/broadcom/bnxt/bnxt.c b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 893bdaf03..00a9b7126 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -13171,22 +13171,17 @@  static int bnxt_init_mac_addr(struct bnxt *bp)
 	return rc;
 }
 
-#define BNXT_VPD_LEN	512
 static void bnxt_vpd_read_info(struct bnxt *bp)
 {
 	struct pci_dev *pdev = bp->pdev;
 	int i, len, pos, ro_size, size;
-	ssize_t vpd_size;
+	unsigned int vpd_size;
 	u8 *vpd_data;
 
-	vpd_data = kmalloc(BNXT_VPD_LEN, GFP_KERNEL);
-	if (!vpd_data)
+	vpd_data = pci_vpd_alloc(pdev, &vpd_size);
+	if (IS_ERR(vpd_data)) {
+		pci_warn(pdev, "Unable to read VPD\n");
 		return;
-
-	vpd_size = pci_read_vpd(pdev, 0, BNXT_VPD_LEN, vpd_data);
-	if (vpd_size <= 0) {
-		netdev_err(bp->dev, "Unable to read VPD\n");
-		goto exit;
 	}
 
 	i = pci_vpd_find_tag(vpd_data, vpd_size, PCI_VPD_LRDT_RO_DATA);