All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any()
@ 2021-09-10  6:20 Heiner Kallweit
  2021-09-10  6:22 ` [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any() Heiner Kallweit
                   ` (5 more replies)
  0 siblings, 6 replies; 16+ messages in thread
From: Heiner Kallweit @ 2021-09-10  6:20 UTC (permalink / raw)
  To: Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju
  Cc: linux-pci, netdev

In certain cases we need a variant of pci_read_vpd()/pci_write_vpd() that
does not check against dev->vpd.len. Such cases are:
- reading VPD if dev->vpd.len isn't set yet (in pci_vpd_size())
- devices that map non-VPD information to arbitrary places in VPD address
  space (example: Chelsio T3 EEPROM write-protect flag)
Therefore add function variants that check against PCI_VPD_MAX_SIZE only.

Make the cxgb3 driver the first user of the new functions.

Preferably this series should go through the PCI tree.

Heiner Kallweit (5):
  PCI/VPD: Add pci_read/write_vpd_any()
  PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size()
  cxgb3: Remove t3_seeprom_read and use VPD API
  cxgb3: Use VPD API in t3_seeprom_wp()
  cxgb3: Remove seeprom_write and user VPD API

 drivers/net/ethernet/chelsio/cxgb3/common.h   |  2 -
 .../net/ethernet/chelsio/cxgb3/cxgb3_main.c   | 38 +++----
 drivers/net/ethernet/chelsio/cxgb3/t3_hw.c    | 98 +++----------------
 drivers/pci/vpd.c                             | 79 ++++++++++-----
 include/linux/pci.h                           |  2 +
 5 files changed, 83 insertions(+), 136 deletions(-)

-- 
2.33.0


^ permalink raw reply	[flat|nested] 16+ messages in thread

* [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any()
  2021-09-10  6:20 [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Heiner Kallweit
@ 2021-09-10  6:22 ` Heiner Kallweit
  2021-10-12 18:59   ` Qian Cai
  2021-09-10  6:22 ` [PATCH 2/5] PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size() Heiner Kallweit
                   ` (4 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Heiner Kallweit @ 2021-09-10  6:22 UTC (permalink / raw)
  To: Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju
  Cc: linux-pci, netdev

In certain cases we need a variant of pci_read_vpd()/pci_write_vpd() that
does not check against dev->vpd.len. Such cases are:
- reading VPD if dev->vpd.len isn't set yet (in pci_vpd_size())
- devices that map non-VPD information to arbitrary places in VPD address
  space (example: Chelsio T3 EEPROM write-protect flag)
Therefore add function variants that check against PCI_VPD_MAX_SIZE only.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/pci/vpd.c   | 72 +++++++++++++++++++++++++++++++--------------
 include/linux/pci.h |  2 ++
 2 files changed, 52 insertions(+), 22 deletions(-)

diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
index 25557b272..286cad2a6 100644
--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -138,9 +138,10 @@ static int pci_vpd_wait(struct pci_dev *dev, bool set)
 }
 
 static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
-			    void *arg)
+			    void *arg, bool check_size)
 {
 	struct pci_vpd *vpd = &dev->vpd;
+	unsigned int max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
 	int ret = 0;
 	loff_t end = pos + count;
 	u8 *buf = arg;
@@ -151,11 +152,11 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
 	if (pos < 0)
 		return -EINVAL;
 
-	if (pos > vpd->len)
+	if (pos >= max_len)
 		return 0;
 
-	if (end > vpd->len) {
-		end = vpd->len;
+	if (end > max_len) {
+		end = max_len;
 		count = end - pos;
 	}
 
@@ -199,9 +200,10 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
 }
 
 static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
-			     const void *arg)
+			     const void *arg, bool check_size)
 {
 	struct pci_vpd *vpd = &dev->vpd;
+	unsigned int max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
 	const u8 *buf = arg;
 	loff_t end = pos + count;
 	int ret = 0;
@@ -212,7 +214,7 @@ static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
 	if (pos < 0 || (pos & 3) || (count & 3))
 		return -EINVAL;
 
-	if (end > vpd->len)
+	if (end > max_len)
 		return -EINVAL;
 
 	if (mutex_lock_killable(&vpd->lock))
@@ -365,6 +367,24 @@ static int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
 	return -ENOENT;
 }
 
+static ssize_t __pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf,
+			      bool check_size)
+{
+	ssize_t ret;
+
+	if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
+		dev = pci_get_func0_dev(dev);
+		if (!dev)
+			return -ENODEV;
+
+		ret = pci_vpd_read(dev, pos, count, buf, check_size);
+		pci_dev_put(dev);
+		return ret;
+	}
+
+	return pci_vpd_read(dev, pos, count, buf, check_size);
+}
+
 /**
  * pci_read_vpd - Read one entry from Vital Product Data
  * @dev:	PCI device struct
@@ -373,6 +393,20 @@ static int pci_vpd_find_info_keyword(const u8 *buf, unsigned int off,
  * @buf:	pointer to where to store result
  */
 ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf)
+{
+	return __pci_read_vpd(dev, pos, count, buf, true);
+}
+EXPORT_SYMBOL(pci_read_vpd);
+
+/* Same, but allow to access any address */
+ssize_t pci_read_vpd_any(struct pci_dev *dev, loff_t pos, size_t count, void *buf)
+{
+	return __pci_read_vpd(dev, pos, count, buf, false);
+}
+EXPORT_SYMBOL(pci_read_vpd_any);
+
+static ssize_t __pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count,
+			       const void *buf, bool check_size)
 {
 	ssize_t ret;
 
@@ -381,14 +415,13 @@ ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf)
 		if (!dev)
 			return -ENODEV;
 
-		ret = pci_vpd_read(dev, pos, count, buf);
+		ret = pci_vpd_write(dev, pos, count, buf, check_size);
 		pci_dev_put(dev);
 		return ret;
 	}
 
-	return pci_vpd_read(dev, pos, count, buf);
+	return pci_vpd_write(dev, pos, count, buf, check_size);
 }
-EXPORT_SYMBOL(pci_read_vpd);
 
 /**
  * pci_write_vpd - Write entry to Vital Product Data
@@ -399,22 +432,17 @@ EXPORT_SYMBOL(pci_read_vpd);
  */
 ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf)
 {
-	ssize_t ret;
-
-	if (dev->dev_flags & PCI_DEV_FLAGS_VPD_REF_F0) {
-		dev = pci_get_func0_dev(dev);
-		if (!dev)
-			return -ENODEV;
-
-		ret = pci_vpd_write(dev, pos, count, buf);
-		pci_dev_put(dev);
-		return ret;
-	}
-
-	return pci_vpd_write(dev, pos, count, buf);
+	return __pci_write_vpd(dev, pos, count, buf, true);
 }
 EXPORT_SYMBOL(pci_write_vpd);
 
+/* Same, but allow to access any address */
+ssize_t pci_write_vpd_any(struct pci_dev *dev, loff_t pos, size_t count, const void *buf)
+{
+	return __pci_write_vpd(dev, pos, count, buf, false);
+}
+EXPORT_SYMBOL(pci_write_vpd_any);
+
 int pci_vpd_find_ro_info_keyword(const void *buf, unsigned int len,
 				 const char *kw, unsigned int *size)
 {
diff --git a/include/linux/pci.h b/include/linux/pci.h
index cd8aa6fce..9649bd9e4 100644
--- a/include/linux/pci.h
+++ b/include/linux/pci.h
@@ -1350,6 +1350,8 @@ void pci_unlock_rescan_remove(void);
 /* Vital Product Data routines */
 ssize_t pci_read_vpd(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
 ssize_t pci_write_vpd(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
+ssize_t pci_read_vpd_any(struct pci_dev *dev, loff_t pos, size_t count, void *buf);
+ssize_t pci_write_vpd_any(struct pci_dev *dev, loff_t pos, size_t count, const void *buf);
 
 /* Helper functions for low-level code (drivers/pci/setup-[bus,res].c) */
 resource_size_t pcibios_retrieve_fw_addr(struct pci_dev *dev, int idx);
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 2/5] PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size()
  2021-09-10  6:20 [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Heiner Kallweit
  2021-09-10  6:22 ` [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any() Heiner Kallweit
@ 2021-09-10  6:22 ` Heiner Kallweit
  2021-10-27 11:01   ` Jon Hunter
  2021-09-10  6:24 ` [PATCH 3/5] cxgb3: Remove t3_seeprom_read and use VPD API Heiner Kallweit
                   ` (3 subsequent siblings)
  5 siblings, 1 reply; 16+ messages in thread
From: Heiner Kallweit @ 2021-09-10  6:22 UTC (permalink / raw)
  To: Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju
  Cc: linux-pci, netdev

Use new function pci_read_vpd_any() to simplify the code.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/pci/vpd.c | 7 ++-----
 1 file changed, 2 insertions(+), 5 deletions(-)

diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
index 286cad2a6..517789205 100644
--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -57,10 +57,7 @@ static size_t pci_vpd_size(struct pci_dev *dev)
 	size_t off = 0, size;
 	unsigned char tag, header[1+2];	/* 1 byte tag, 2 bytes length */
 
-	/* Otherwise the following reads would fail. */
-	dev->vpd.len = PCI_VPD_MAX_SIZE;
-
-	while (pci_read_vpd(dev, off, 1, header) == 1) {
+	while (pci_read_vpd_any(dev, off, 1, header) == 1) {
 		size = 0;
 
 		if (off == 0 && (header[0] == 0x00 || header[0] == 0xff))
@@ -68,7 +65,7 @@ static size_t pci_vpd_size(struct pci_dev *dev)
 
 		if (header[0] & PCI_VPD_LRDT) {
 			/* Large Resource Data Type Tag */
-			if (pci_read_vpd(dev, off + 1, 2, &header[1]) != 2) {
+			if (pci_read_vpd_any(dev, off + 1, 2, &header[1]) != 2) {
 				pci_warn(dev, "failed VPD read at offset %zu\n",
 					 off + 1);
 				return off ?: PCI_VPD_SZ_INVALID;
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 3/5] cxgb3: Remove t3_seeprom_read and use VPD API
  2021-09-10  6:20 [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Heiner Kallweit
  2021-09-10  6:22 ` [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any() Heiner Kallweit
  2021-09-10  6:22 ` [PATCH 2/5] PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size() Heiner Kallweit
@ 2021-09-10  6:24 ` Heiner Kallweit
  2021-09-10  6:25 ` [PATCH 4/5] cxgb3: Use VPD API in t3_seeprom_wp() Heiner Kallweit
                   ` (2 subsequent siblings)
  5 siblings, 0 replies; 16+ messages in thread
From: Heiner Kallweit @ 2021-09-10  6:24 UTC (permalink / raw)
  To: Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju
  Cc: linux-pci, netdev

Using the VPD API allows to simplify the code and completely get rid
of t3_seeprom_read(). Note that we don't have to use pci_read_vpd_any()
here because a VPD quirk sets dev->vpd.len to the full EEPROM size.

Tested with a T320 card.

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/chelsio/cxgb3/common.h   |  1 -
 .../net/ethernet/chelsio/cxgb3/cxgb3_main.c   | 27 ++++------
 drivers/net/ethernet/chelsio/cxgb3/t3_hw.c    | 54 +++----------------
 3 files changed, 18 insertions(+), 64 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/common.h b/drivers/net/ethernet/chelsio/cxgb3/common.h
index b706f2fbe..56312f9ed 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/common.h
+++ b/drivers/net/ethernet/chelsio/cxgb3/common.h
@@ -676,7 +676,6 @@ void t3_link_changed(struct adapter *adapter, int port_id);
 void t3_link_fault(struct adapter *adapter, int port_id);
 int t3_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc);
 const struct adapter_info *t3_get_adapter_info(unsigned int board_id);
-int t3_seeprom_read(struct adapter *adapter, u32 addr, __le32 *data);
 int t3_seeprom_write(struct adapter *adapter, u32 addr, __le32 data);
 int t3_seeprom_wp(struct adapter *adapter, int enable);
 int t3_get_tp_version(struct adapter *adapter, u32 *vers);
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index 38e47703f..d73339682 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -2036,20 +2036,16 @@ static int get_eeprom(struct net_device *dev, struct ethtool_eeprom *e,
 {
 	struct port_info *pi = netdev_priv(dev);
 	struct adapter *adapter = pi->adapter;
-	int i, err = 0;
-
-	u8 *buf = kmalloc(EEPROMSIZE, GFP_KERNEL);
-	if (!buf)
-		return -ENOMEM;
+	int cnt;
 
 	e->magic = EEPROM_MAGIC;
-	for (i = e->offset & ~3; !err && i < e->offset + e->len; i += 4)
-		err = t3_seeprom_read(adapter, i, (__le32 *) & buf[i]);
+	cnt = pci_read_vpd(adapter->pdev, e->offset, e->len, data);
+	if (cnt < 0)
+		return cnt;
 
-	if (!err)
-		memcpy(data, buf + e->offset, e->len);
-	kfree(buf);
-	return err;
+	e->len = cnt;
+
+	return 0;
 }
 
 static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
@@ -2072,12 +2068,9 @@ static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
 		buf = kmalloc(aligned_len, GFP_KERNEL);
 		if (!buf)
 			return -ENOMEM;
-		err = t3_seeprom_read(adapter, aligned_offset, (__le32 *) buf);
-		if (!err && aligned_len > 4)
-			err = t3_seeprom_read(adapter,
-					      aligned_offset + aligned_len - 4,
-					      (__le32 *) & buf[aligned_len - 4]);
-		if (err)
+		err = pci_read_vpd(adapter->pdev, aligned_offset, aligned_len,
+				   buf);
+		if (err < 0)
 			goto out;
 		memcpy(buf + (eeprom->offset & 3), data, eeprom->len);
 	} else
diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
index 7ff31d102..4ecf40b02 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
@@ -599,42 +599,6 @@ struct t3_vpd {
 #define EEPROM_STAT_ADDR  0x4000
 #define VPD_BASE          0xc00
 
-/**
- *	t3_seeprom_read - read a VPD EEPROM location
- *	@adapter: adapter to read
- *	@addr: EEPROM address
- *	@data: where to store the read data
- *
- *	Read a 32-bit word from a location in VPD EEPROM using the card's PCI
- *	VPD ROM capability.  A zero is written to the flag bit when the
- *	address is written to the control register.  The hardware device will
- *	set the flag to 1 when 4 bytes have been read into the data register.
- */
-int t3_seeprom_read(struct adapter *adapter, u32 addr, __le32 *data)
-{
-	u16 val;
-	int attempts = EEPROM_MAX_POLL;
-	u32 v;
-	unsigned int base = adapter->params.pci.vpd_cap_addr;
-
-	if ((addr >= EEPROMSIZE && addr != EEPROM_STAT_ADDR) || (addr & 3))
-		return -EINVAL;
-
-	pci_write_config_word(adapter->pdev, base + PCI_VPD_ADDR, addr);
-	do {
-		udelay(10);
-		pci_read_config_word(adapter->pdev, base + PCI_VPD_ADDR, &val);
-	} while (!(val & PCI_VPD_ADDR_F) && --attempts);
-
-	if (!(val & PCI_VPD_ADDR_F)) {
-		CH_ERR(adapter, "reading EEPROM address 0x%x failed\n", addr);
-		return -EIO;
-	}
-	pci_read_config_dword(adapter->pdev, base + PCI_VPD_DATA, &v);
-	*data = cpu_to_le32(v);
-	return 0;
-}
-
 /**
  *	t3_seeprom_write - write a VPD EEPROM location
  *	@adapter: adapter to write
@@ -708,24 +672,22 @@ static int vpdstrtou16(char *s, u8 len, unsigned int base, u16 *val)
  */
 static int get_vpd_params(struct adapter *adapter, struct vpd_params *p)
 {
-	int i, addr, ret;
 	struct t3_vpd vpd;
+	u8 base_val = 0;
+	int addr, ret;
 
 	/*
 	 * Card information is normally at VPD_BASE but some early cards had
 	 * it at 0.
 	 */
-	ret = t3_seeprom_read(adapter, VPD_BASE, (__le32 *)&vpd);
-	if (ret)
+	ret = pci_read_vpd(adapter->pdev, VPD_BASE, 1, &base_val);
+	if (ret < 0)
 		return ret;
-	addr = vpd.id_tag == 0x82 ? VPD_BASE : 0;
+	addr = base_val == PCI_VPD_LRDT_ID_STRING ? VPD_BASE : 0;
 
-	for (i = 0; i < sizeof(vpd); i += 4) {
-		ret = t3_seeprom_read(adapter, addr + i,
-				      (__le32 *)((u8 *)&vpd + i));
-		if (ret)
-			return ret;
-	}
+	ret = pci_read_vpd(adapter->pdev, addr, sizeof(vpd), &vpd);
+	if (ret < 0)
+		return ret;
 
 	ret = vpdstrtouint(vpd.cclk_data, vpd.cclk_len, 10, &p->cclk);
 	if (ret)
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 4/5] cxgb3: Use VPD API in t3_seeprom_wp()
  2021-09-10  6:20 [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Heiner Kallweit
                   ` (2 preceding siblings ...)
  2021-09-10  6:24 ` [PATCH 3/5] cxgb3: Remove t3_seeprom_read and use VPD API Heiner Kallweit
@ 2021-09-10  6:25 ` Heiner Kallweit
  2021-09-10  6:27 ` [PATCH 5/5] cxgb3: Remove seeprom_write and use VPD API Heiner Kallweit
  2021-10-08 22:53 ` [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Bjorn Helgaas
  5 siblings, 0 replies; 16+ messages in thread
From: Heiner Kallweit @ 2021-09-10  6:25 UTC (permalink / raw)
  To: Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju
  Cc: linux-pci, netdev

Use standard VPD API to replace t3_seeprom_write(), this prepares for
removing this function. Chelsio T3 maps the EEPROM write protect flag
to an arbitrary place in VPD address space, therefore we have to use
pci_write_vpd_any().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/chelsio/cxgb3/t3_hw.c | 9 ++++++++-
 1 file changed, 8 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
index 4ecf40b02..ec4b49ebe 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
@@ -642,7 +642,14 @@ int t3_seeprom_write(struct adapter *adapter, u32 addr, __le32 data)
  */
 int t3_seeprom_wp(struct adapter *adapter, int enable)
 {
-	return t3_seeprom_write(adapter, EEPROM_STAT_ADDR, enable ? 0xc : 0);
+	u32 data = enable ? 0xc : 0;
+	int ret;
+
+	/* EEPROM_STAT_ADDR is outside VPD area, use pci_write_vpd_any() */
+	ret = pci_write_vpd_any(adapter->pdev, EEPROM_STAT_ADDR, sizeof(u32),
+				&data);
+
+	return ret < 0 ? ret : 0;
 }
 
 static int vpdstrtouint(char *s, u8 len, unsigned int base, unsigned int *val)
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* [PATCH 5/5] cxgb3: Remove seeprom_write and use VPD API
  2021-09-10  6:20 [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Heiner Kallweit
                   ` (3 preceding siblings ...)
  2021-09-10  6:25 ` [PATCH 4/5] cxgb3: Use VPD API in t3_seeprom_wp() Heiner Kallweit
@ 2021-09-10  6:27 ` Heiner Kallweit
  2021-10-08 22:53 ` [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Bjorn Helgaas
  5 siblings, 0 replies; 16+ messages in thread
From: Heiner Kallweit @ 2021-09-10  6:27 UTC (permalink / raw)
  To: Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju
  Cc: linux-pci, netdev

Using the VPD API allows to simplify the code and completely get
rid of t3_seeprom_write().

Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
---
 drivers/net/ethernet/chelsio/cxgb3/common.h   |  1 -
 .../net/ethernet/chelsio/cxgb3/cxgb3_main.c   | 11 ++----
 drivers/net/ethernet/chelsio/cxgb3/t3_hw.c    | 35 -------------------
 3 files changed, 3 insertions(+), 44 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb3/common.h b/drivers/net/ethernet/chelsio/cxgb3/common.h
index 56312f9ed..d115ec932 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/common.h
+++ b/drivers/net/ethernet/chelsio/cxgb3/common.h
@@ -676,7 +676,6 @@ void t3_link_changed(struct adapter *adapter, int port_id);
 void t3_link_fault(struct adapter *adapter, int port_id);
 int t3_link_start(struct cphy *phy, struct cmac *mac, struct link_config *lc);
 const struct adapter_info *t3_get_adapter_info(unsigned int board_id);
-int t3_seeprom_write(struct adapter *adapter, u32 addr, __le32 data);
 int t3_seeprom_wp(struct adapter *adapter, int enable);
 int t3_get_tp_version(struct adapter *adapter, u32 *vers);
 int t3_check_tpsram_version(struct adapter *adapter);
diff --git a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
index d73339682..e185f5f24 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/cxgb3_main.c
@@ -2054,7 +2054,6 @@ static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
 	struct port_info *pi = netdev_priv(dev);
 	struct adapter *adapter = pi->adapter;
 	u32 aligned_offset, aligned_len;
-	__le32 *p;
 	u8 *buf;
 	int err;
 
@@ -2080,17 +2079,13 @@ static int set_eeprom(struct net_device *dev, struct ethtool_eeprom *eeprom,
 	if (err)
 		goto out;
 
-	for (p = (__le32 *) buf; !err && aligned_len; aligned_len -= 4, p++) {
-		err = t3_seeprom_write(adapter, aligned_offset, *p);
-		aligned_offset += 4;
-	}
-
-	if (!err)
+	err = pci_write_vpd(adapter->pdev, aligned_offset, aligned_len, buf);
+	if (err >= 0)
 		err = t3_seeprom_wp(adapter, 1);
 out:
 	if (buf != data)
 		kfree(buf);
-	return err;
+	return err < 0 ? err : 0;
 }
 
 static void get_wol(struct net_device *dev, struct ethtool_wolinfo *wol)
diff --git a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
index ec4b49ebe..cb85c2f21 100644
--- a/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb3/t3_hw.c
@@ -595,44 +595,9 @@ struct t3_vpd {
 	u32 pad;		/* for multiple-of-4 sizing and alignment */
 };
 
-#define EEPROM_MAX_POLL   40
 #define EEPROM_STAT_ADDR  0x4000
 #define VPD_BASE          0xc00
 
-/**
- *	t3_seeprom_write - write a VPD EEPROM location
- *	@adapter: adapter to write
- *	@addr: EEPROM address
- *	@data: value to write
- *
- *	Write a 32-bit word to a location in VPD EEPROM using the card's PCI
- *	VPD ROM capability.
- */
-int t3_seeprom_write(struct adapter *adapter, u32 addr, __le32 data)
-{
-	u16 val;
-	int attempts = EEPROM_MAX_POLL;
-	unsigned int base = adapter->params.pci.vpd_cap_addr;
-
-	if ((addr >= EEPROMSIZE && addr != EEPROM_STAT_ADDR) || (addr & 3))
-		return -EINVAL;
-
-	pci_write_config_dword(adapter->pdev, base + PCI_VPD_DATA,
-			       le32_to_cpu(data));
-	pci_write_config_word(adapter->pdev,base + PCI_VPD_ADDR,
-			      addr | PCI_VPD_ADDR_F);
-	do {
-		msleep(1);
-		pci_read_config_word(adapter->pdev, base + PCI_VPD_ADDR, &val);
-	} while ((val & PCI_VPD_ADDR_F) && --attempts);
-
-	if (val & PCI_VPD_ADDR_F) {
-		CH_ERR(adapter, "write to EEPROM address 0x%x failed\n", addr);
-		return -EIO;
-	}
-	return 0;
-}
-
 /**
  *	t3_seeprom_wp - enable/disable EEPROM write protection
  *	@adapter: the adapter
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any()
  2021-09-10  6:20 [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Heiner Kallweit
                   ` (4 preceding siblings ...)
  2021-09-10  6:27 ` [PATCH 5/5] cxgb3: Remove seeprom_write and use VPD API Heiner Kallweit
@ 2021-10-08 22:53 ` Bjorn Helgaas
  2021-10-08 23:42   ` Jakub Kicinski
  5 siblings, 1 reply; 16+ messages in thread
From: Bjorn Helgaas @ 2021-10-08 22:53 UTC (permalink / raw)
  To: Heiner Kallweit
  Cc: Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju,
	linux-pci, netdev

On Fri, Sep 10, 2021 at 08:20:23AM +0200, Heiner Kallweit wrote:
> In certain cases we need a variant of pci_read_vpd()/pci_write_vpd() that
> does not check against dev->vpd.len. Such cases are:
> - reading VPD if dev->vpd.len isn't set yet (in pci_vpd_size())
> - devices that map non-VPD information to arbitrary places in VPD address
>   space (example: Chelsio T3 EEPROM write-protect flag)
> Therefore add function variants that check against PCI_VPD_MAX_SIZE only.
> 
> Make the cxgb3 driver the first user of the new functions.
> 
> Preferably this series should go through the PCI tree.
> 
> Heiner Kallweit (5):
>   PCI/VPD: Add pci_read/write_vpd_any()
>   PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size()
>   cxgb3: Remove t3_seeprom_read and use VPD API
>   cxgb3: Use VPD API in t3_seeprom_wp()
>   cxgb3: Remove seeprom_write and user VPD API

Tentatively applied to pci/vpd for v5.16.

Ideally would like reviewed-by and ack for the cxgb3 parts from Raju,
Jakub, David.

>  drivers/net/ethernet/chelsio/cxgb3/common.h   |  2 -
>  .../net/ethernet/chelsio/cxgb3/cxgb3_main.c   | 38 +++----
>  drivers/net/ethernet/chelsio/cxgb3/t3_hw.c    | 98 +++----------------
>  drivers/pci/vpd.c                             | 79 ++++++++++-----
>  include/linux/pci.h                           |  2 +
>  5 files changed, 83 insertions(+), 136 deletions(-)
> 
> -- 
> 2.33.0
> 

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any()
  2021-10-08 22:53 ` [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Bjorn Helgaas
@ 2021-10-08 23:42   ` Jakub Kicinski
  2021-10-11 20:43     ` Bjorn Helgaas
  0 siblings, 1 reply; 16+ messages in thread
From: Jakub Kicinski @ 2021-10-08 23:42 UTC (permalink / raw)
  To: Bjorn Helgaas
  Cc: Heiner Kallweit, Bjorn Helgaas, David Miller, Raju Rangoju,
	linux-pci, netdev

On Fri, 8 Oct 2021 17:53:40 -0500 Bjorn Helgaas wrote:
> Ideally would like reviewed-by and ack for the cxgb3 parts from Raju,
> Jakub, David.

Raju's ack would be best, there isn't much networking there, 
but certainly no objection for you merging the changes:

Acked-by: Jakub Kicinski <kuba@kernel.org>

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any()
  2021-10-08 23:42   ` Jakub Kicinski
@ 2021-10-11 20:43     ` Bjorn Helgaas
  0 siblings, 0 replies; 16+ messages in thread
From: Bjorn Helgaas @ 2021-10-11 20:43 UTC (permalink / raw)
  To: Jakub Kicinski
  Cc: Heiner Kallweit, Bjorn Helgaas, David Miller, Raju Rangoju,
	linux-pci, netdev

On Fri, Oct 08, 2021 at 04:42:49PM -0700, Jakub Kicinski wrote:
> On Fri, 8 Oct 2021 17:53:40 -0500 Bjorn Helgaas wrote:
> > Ideally would like reviewed-by and ack for the cxgb3 parts from Raju,
> > Jakub, David.
> 
> Raju's ack would be best, there isn't much networking there, 
> but certainly no objection for you merging the changes:
> 
> Acked-by: Jakub Kicinski <kuba@kernel.org>

Thanks, added your ack.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any()
  2021-09-10  6:22 ` [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any() Heiner Kallweit
@ 2021-10-12 18:59   ` Qian Cai
  2021-10-12 20:26     ` Heiner Kallweit
  0 siblings, 1 reply; 16+ messages in thread
From: Qian Cai @ 2021-10-12 18:59 UTC (permalink / raw)
  To: Heiner Kallweit, Bjorn Helgaas, Jakub Kicinski, David Miller,
	Raju Rangoju
  Cc: linux-pci, netdev



On 9/10/2021 2:22 AM, Heiner Kallweit wrote:
> In certain cases we need a variant of pci_read_vpd()/pci_write_vpd() that
> does not check against dev->vpd.len. Such cases are:
> - reading VPD if dev->vpd.len isn't set yet (in pci_vpd_size())
> - devices that map non-VPD information to arbitrary places in VPD address
>   space (example: Chelsio T3 EEPROM write-protect flag)
> Therefore add function variants that check against PCI_VPD_MAX_SIZE only.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com
Reverting this series fixed a hang or stack overflow while reading things like,

/sys/devices/pci0000:00/0000:00:00.0/0000:01:00.0/vpd

[  125.797082] Insufficient stack space to handle exception!
[  125.797091] ESR: 0x96000047 -- DABT (current EL)
[  125.797095] FAR: 0xffff80002433ffc0
[  125.797096] Task stack:     [0xffff800024340000..0xffff800024350000]
[  125.797099] IRQ stack:      [0xffff8000101c0000..0xffff8000101d0000]
[  125.797102] Overflow stack: [0xffff009b675b02b0..0xffff009b675b12b0]
[  125.797106] CPU: 14 PID: 1550 Comm: lsbug Not tainted 5.15.0-rc5-next-20211012 #143
[  125.797110] Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
[  125.797114] pstate: 10000005 (nzcV daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  125.797118] pc : pci_vpd_size+0xc/0x1f8
[  125.797128] lr : pci_vpd_read+0x2ec/0x420
[  125.797132] sp : ffff800024340060
[  125.797133] x29: ffff800024340060 x28: ffff00001a54cbcc x27: 0000000000000000
[  125.797142] x26: ffff800024340210 x25: 0000000000000004 x24: 1fffe000034a9979
[  125.797148] x23: ffff00001a54cbc8 x22: ffff00001a54cb38 x21: 0000000000008000
[  125.797153] x20: 1fffe000034a9979 x19: ffff00001a54c000 x18: 0000000000000000
[  125.797158] x17: 0000000000000000 x16: 0000000000000000 x15: dfff800000000000
[  125.797163] x14: ffff800019ab0560 x13: 1fffe00110f9272f x12: ffff60010e945be1
[  125.797168] x11: 1fffe0010e945be0 x10: 1ffff00004868022 x9 : ffff800010d1a38c
[  125.797174] x8 : ffff700004868022 x7 : dfff800000000000 x6 : 0000000000000000
[  125.797179] x5 : ffff000887c93540 x4 : 0000000000000000 x3 : ffff800024340210
[  125.797184] x2 : 0000000000000001 x1 : 0000000000000003 x0 : ffff00001a54c000
[  125.797190] Kernel panic - not syncing: kernel stack overflow
[  125.797193] CPU: 14 PID: 1550 Comm: lsbug Not tainted 5.15.0-rc5-next-20211012 #143
[  125.797197] Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
[  125.797199] Call trace:
[  125.797201]  dump_backtrace+0x0/0x3b8
[  125.797208]  show_stack+0x20/0x30
[  125.797212]  dump_stack_lvl+0x8c/0xb8
[  125.797216]  dump_stack+0x1c/0x38
[  125.797219]  panic+0x2b0/0x538
[  125.797224]  add_taint+0x0/0xe8
[  125.797229]  panic_bad_stack+0x1e4/0x230
[  125.797233]  handle_bad_stack+0x38/0x50
[  125.797237]  __bad_stack+0x88/0x8c
[  125.797241]  pci_vpd_size+0xc/0x1f8
[  125.797244]  __pci_read_vpd+0x114/0x158
[  125.797247]  pci_vpd_size+0xa0/0x1f8
[  125.797251]  pci_vpd_read+0x2ec/0x420
[  125.797254]  __pci_read_vpd+0x114/0x158
[  125.797258]  pci_vpd_size+0xa0/0x1f8
[  125.797261]  pci_vpd_read+0x2ec/0x420
...
[  125.798534]  __pci_read_vpd+0x114/0x158
[  125.798538]  pci_vpd_size+0xa0/0x1f8
[  125.798541]  pci_vpd_read+0x2ec/0x420
[  125.798545]  __pci_read_vpd+0x114/0x158
__pci_read_vpd at /usr/src/linux-next/drivers/pci/vpd.c:398
[  125.798548]  vpd_read+0x28/0x38
vpd_read at /usr/src/linux-next/drivers/pci/vpd.c:276
[  125.798551]  sysfs_kf_bin_read+0x120/0x218
[  125.798556]  kernfs_fop_read_iter+0x244/0x4a8
[  125.798559]  new_sync_read+0x2bc/0x4e8
[  125.798564]  vfs_read+0x18c/0x390
[  125.798567]  ksys_read+0xf8/0x1e0
[  125.798570]  __arm64_sys_read+0x74/0xa8
[  125.798574]  invoke_syscall.constprop.0+0xdc/0x1d8
[  125.798578]  do_el0_svc+0xe4/0x298
[  125.798582]  el0_svc+0x64/0x130
[  125.798586]  el0t_64_sync_handler+0xb0/0xb8
[  125.798590]  el0t_64_sync+0x180/0x184
[  125.798598] ------------[ cut here ]------------
[  125.798600] WARNING: CPU: -32 PID: 1550 at include/linux/cpumask.h:108 smp_send_stop+0x4a4/0x5e8
[  125.798607] Modules linked in: loop cppc_cpufreq efivarfs ip_tables x_tables ext4 mbcache jbd2 dm_mod igb i2c_algo_bit nvme mlx5_core i2c_core nvme_core firmware_class
[  125.798632] CPU: 791961908 PID: 1550 Comm: lsbug Not tainted 5.15.0-rc5-next-20211012 #143
[  125.798637] Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
[  125.798639] pstate: a00003c5 (NzCv DAIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
[  125.798643] pc : smp_send_stop+0x4a4/0x5e8
[  125.798647] lr : panic+0x2b8/0x538
[  125.798650] sp : ffff009b675b0c70
[  125.798652] x29: ffff009b675b0c70 x28: ffff000887c92ec0 x27: 0000000000000000
[  125.798658] x26: 0000000000000025 x25: ffff809b55bf0000 x24: ffff800011eeb4d0
[  125.798663] x23: ffff800011426680 x22: ffff800019393000 x21: ffff800019dfa000
[  125.798668] x20: 00000000ffffffe0 x19: ffff8000119c0000 x18: 0000000000000000
[  125.798673] x17: 0000000000000000 x16: 0000000000000002 x15: 0000000000000000
[  125.798678] x14: 0000000000000000 x13: 000000000000000f x12: ffff7000023ef669
[  125.798683] x11: 1ffff000023ef668 x10: ffff7000023ef668 x9 : ffff80001133f2cc
[  125.798688] x8 : 0000000000000003 x7 : 0000000000000001 x6 : ffff800011f7b340
[  125.798693] x5 : 1fffe0136ceb619e x4 : 0000000041b58ab3 x3 : 1fffe0136ceb6000
[  125.798698] x2 : 1ffff000023dd69a x1 : 0000000000000000 x0 : 0000000000000020
[  125.798704] Call trace:
[  125.798705]  smp_send_stop+0x4a4/0x5e8
[  125.798709]  panic+0x2b8/0x538
[  125.798713]  add_taint+0x0/0xe8
[  125.798717]  panic_bad_stack+0x1e4/0x230
[  125.798720]  handle_bad_stack+0x38/0x50
[  125.798724]  __bad_stack+0x88/0x8c
[  125.798727]  pci_vpd_size+0xc/0x1f8
[  125.798731]  __pci_read_vpd+0x114/0x158
[  125.798734]  pci_vpd_size+0xa0/0x1f8
[  125.798738]  pci_vpd_read+0x2ec/0x420
[  125.798741]  __pci_read_vpd+0x114/0x158
[  125.798744]  pci_vpd_size+0xa0/0x1f8
[  125.798748]  pci_vpd_read+0x2ec/0x420  

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any()
  2021-10-12 18:59   ` Qian Cai
@ 2021-10-12 20:26     ` Heiner Kallweit
  2021-10-13 14:22       ` Qian Cai
  0 siblings, 1 reply; 16+ messages in thread
From: Heiner Kallweit @ 2021-10-12 20:26 UTC (permalink / raw)
  To: Qian Cai, Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju
  Cc: linux-pci, netdev

On 12.10.2021 20:59, Qian Cai wrote:
> 
> 
> On 9/10/2021 2:22 AM, Heiner Kallweit wrote:
>> In certain cases we need a variant of pci_read_vpd()/pci_write_vpd() that
>> does not check against dev->vpd.len. Such cases are:
>> - reading VPD if dev->vpd.len isn't set yet (in pci_vpd_size())
>> - devices that map non-VPD information to arbitrary places in VPD address
>>   space (example: Chelsio T3 EEPROM write-protect flag)
>> Therefore add function variants that check against PCI_VPD_MAX_SIZE only.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com
> Reverting this series fixed a hang or stack overflow while reading things like,
> 
> /sys/devices/pci0000:00/0000:00:00.0/0000:01:00.0/vpd
> 
> [  125.797082] Insufficient stack space to handle exception!
> [  125.797091] ESR: 0x96000047 -- DABT (current EL)
> [  125.797095] FAR: 0xffff80002433ffc0
> [  125.797096] Task stack:     [0xffff800024340000..0xffff800024350000]
> [  125.797099] IRQ stack:      [0xffff8000101c0000..0xffff8000101d0000]
> [  125.797102] Overflow stack: [0xffff009b675b02b0..0xffff009b675b12b0]
> [  125.797106] CPU: 14 PID: 1550 Comm: lsbug Not tainted 5.15.0-rc5-next-20211012 #143
> [  125.797110] Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
> [  125.797114] pstate: 10000005 (nzcV daif -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> [  125.797118] pc : pci_vpd_size+0xc/0x1f8
> [  125.797128] lr : pci_vpd_read+0x2ec/0x420
> [  125.797132] sp : ffff800024340060
> [  125.797133] x29: ffff800024340060 x28: ffff00001a54cbcc x27: 0000000000000000
> [  125.797142] x26: ffff800024340210 x25: 0000000000000004 x24: 1fffe000034a9979
> [  125.797148] x23: ffff00001a54cbc8 x22: ffff00001a54cb38 x21: 0000000000008000
> [  125.797153] x20: 1fffe000034a9979 x19: ffff00001a54c000 x18: 0000000000000000
> [  125.797158] x17: 0000000000000000 x16: 0000000000000000 x15: dfff800000000000
> [  125.797163] x14: ffff800019ab0560 x13: 1fffe00110f9272f x12: ffff60010e945be1
> [  125.797168] x11: 1fffe0010e945be0 x10: 1ffff00004868022 x9 : ffff800010d1a38c
> [  125.797174] x8 : ffff700004868022 x7 : dfff800000000000 x6 : 0000000000000000
> [  125.797179] x5 : ffff000887c93540 x4 : 0000000000000000 x3 : ffff800024340210
> [  125.797184] x2 : 0000000000000001 x1 : 0000000000000003 x0 : ffff00001a54c000
> [  125.797190] Kernel panic - not syncing: kernel stack overflow
> [  125.797193] CPU: 14 PID: 1550 Comm: lsbug Not tainted 5.15.0-rc5-next-20211012 #143
> [  125.797197] Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
> [  125.797199] Call trace:
> [  125.797201]  dump_backtrace+0x0/0x3b8
> [  125.797208]  show_stack+0x20/0x30
> [  125.797212]  dump_stack_lvl+0x8c/0xb8
> [  125.797216]  dump_stack+0x1c/0x38
> [  125.797219]  panic+0x2b0/0x538
> [  125.797224]  add_taint+0x0/0xe8
> [  125.797229]  panic_bad_stack+0x1e4/0x230
> [  125.797233]  handle_bad_stack+0x38/0x50
> [  125.797237]  __bad_stack+0x88/0x8c
> [  125.797241]  pci_vpd_size+0xc/0x1f8
> [  125.797244]  __pci_read_vpd+0x114/0x158
> [  125.797247]  pci_vpd_size+0xa0/0x1f8
> [  125.797251]  pci_vpd_read+0x2ec/0x420
> [  125.797254]  __pci_read_vpd+0x114/0x158
> [  125.797258]  pci_vpd_size+0xa0/0x1f8
> [  125.797261]  pci_vpd_read+0x2ec/0x420
> ...
> [  125.798534]  __pci_read_vpd+0x114/0x158
> [  125.798538]  pci_vpd_size+0xa0/0x1f8
> [  125.798541]  pci_vpd_read+0x2ec/0x420
> [  125.798545]  __pci_read_vpd+0x114/0x158
> __pci_read_vpd at /usr/src/linux-next/drivers/pci/vpd.c:398
> [  125.798548]  vpd_read+0x28/0x38
> vpd_read at /usr/src/linux-next/drivers/pci/vpd.c:276
> [  125.798551]  sysfs_kf_bin_read+0x120/0x218
> [  125.798556]  kernfs_fop_read_iter+0x244/0x4a8
> [  125.798559]  new_sync_read+0x2bc/0x4e8
> [  125.798564]  vfs_read+0x18c/0x390
> [  125.798567]  ksys_read+0xf8/0x1e0
> [  125.798570]  __arm64_sys_read+0x74/0xa8
> [  125.798574]  invoke_syscall.constprop.0+0xdc/0x1d8
> [  125.798578]  do_el0_svc+0xe4/0x298
> [  125.798582]  el0_svc+0x64/0x130
> [  125.798586]  el0t_64_sync_handler+0xb0/0xb8
> [  125.798590]  el0t_64_sync+0x180/0x184
> [  125.798598] ------------[ cut here ]------------
> [  125.798600] WARNING: CPU: -32 PID: 1550 at include/linux/cpumask.h:108 smp_send_stop+0x4a4/0x5e8
> [  125.798607] Modules linked in: loop cppc_cpufreq efivarfs ip_tables x_tables ext4 mbcache jbd2 dm_mod igb i2c_algo_bit nvme mlx5_core i2c_core nvme_core firmware_class
> [  125.798632] CPU: 791961908 PID: 1550 Comm: lsbug Not tainted 5.15.0-rc5-next-20211012 #143
> [  125.798637] Hardware name: MiTAC RAPTOR EV-883832-X3-0001/RAPTOR, BIOS 1.6 06/28/2020
> [  125.798639] pstate: a00003c5 (NzCv DAIF -PAN -UAO -TCO -DIT -SSBS BTYPE=--)
> [  125.798643] pc : smp_send_stop+0x4a4/0x5e8
> [  125.798647] lr : panic+0x2b8/0x538
> [  125.798650] sp : ffff009b675b0c70
> [  125.798652] x29: ffff009b675b0c70 x28: ffff000887c92ec0 x27: 0000000000000000
> [  125.798658] x26: 0000000000000025 x25: ffff809b55bf0000 x24: ffff800011eeb4d0
> [  125.798663] x23: ffff800011426680 x22: ffff800019393000 x21: ffff800019dfa000
> [  125.798668] x20: 00000000ffffffe0 x19: ffff8000119c0000 x18: 0000000000000000
> [  125.798673] x17: 0000000000000000 x16: 0000000000000002 x15: 0000000000000000
> [  125.798678] x14: 0000000000000000 x13: 000000000000000f x12: ffff7000023ef669
> [  125.798683] x11: 1ffff000023ef668 x10: ffff7000023ef668 x9 : ffff80001133f2cc
> [  125.798688] x8 : 0000000000000003 x7 : 0000000000000001 x6 : ffff800011f7b340
> [  125.798693] x5 : 1fffe0136ceb619e x4 : 0000000041b58ab3 x3 : 1fffe0136ceb6000
> [  125.798698] x2 : 1ffff000023dd69a x1 : 0000000000000000 x0 : 0000000000000020
> [  125.798704] Call trace:
> [  125.798705]  smp_send_stop+0x4a4/0x5e8
> [  125.798709]  panic+0x2b8/0x538
> [  125.798713]  add_taint+0x0/0xe8
> [  125.798717]  panic_bad_stack+0x1e4/0x230
> [  125.798720]  handle_bad_stack+0x38/0x50
> [  125.798724]  __bad_stack+0x88/0x8c
> [  125.798727]  pci_vpd_size+0xc/0x1f8
> [  125.798731]  __pci_read_vpd+0x114/0x158
> [  125.798734]  pci_vpd_size+0xa0/0x1f8
> [  125.798738]  pci_vpd_read+0x2ec/0x420
> [  125.798741]  __pci_read_vpd+0x114/0x158
> [  125.798744]  pci_vpd_size+0xa0/0x1f8
> [  125.798748]  pci_vpd_read+0x2ec/0x420  
> 

Thanks for the report! I could reproduce the issue, the following fixes
it for me. Could you please test whether it fixes the issue for you as well?
Thank you.


diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
index 5108bbd20..a4fc4d069 100644
--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -96,14 +96,14 @@ static size_t pci_vpd_size(struct pci_dev *dev)
 	return off ?: PCI_VPD_SZ_INVALID;
 }
 
-static bool pci_vpd_available(struct pci_dev *dev)
+static bool pci_vpd_available(struct pci_dev *dev, bool check_size)
 {
 	struct pci_vpd *vpd = &dev->vpd;
 
 	if (!vpd->cap)
 		return false;
 
-	if (vpd->len == 0) {
+	if (vpd->len == 0 && check_size) {
 		vpd->len = pci_vpd_size(dev);
 		if (vpd->len == PCI_VPD_SZ_INVALID) {
 			vpd->cap = 0;
@@ -156,17 +156,19 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
 			    void *arg, bool check_size)
 {
 	struct pci_vpd *vpd = &dev->vpd;
-	unsigned int max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
+	unsigned int max_len;
 	int ret = 0;
 	loff_t end = pos + count;
 	u8 *buf = arg;
 
-	if (!pci_vpd_available(dev))
+	if (!pci_vpd_available(dev, check_size))
 		return -ENODEV;
 
 	if (pos < 0)
 		return -EINVAL;
 
+	max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
+
 	if (pos >= max_len)
 		return 0;
 
@@ -218,17 +220,19 @@ static ssize_t pci_vpd_write(struct pci_dev *dev, loff_t pos, size_t count,
 			     const void *arg, bool check_size)
 {
 	struct pci_vpd *vpd = &dev->vpd;
-	unsigned int max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
+	unsigned int max_len;
 	const u8 *buf = arg;
 	loff_t end = pos + count;
 	int ret = 0;
 
-	if (!pci_vpd_available(dev))
+	if (!pci_vpd_available(dev, check_size))
 		return -ENODEV;
 
 	if (pos < 0 || (pos & 3) || (count & 3))
 		return -EINVAL;
 
+	max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
+
 	if (end > max_len)
 		return -EINVAL;
 
@@ -312,7 +316,7 @@ void *pci_vpd_alloc(struct pci_dev *dev, unsigned int *size)
 	void *buf;
 	int cnt;
 
-	if (!pci_vpd_available(dev))
+	if (!pci_vpd_available(dev, true))
 		return ERR_PTR(-ENODEV);
 
 	len = dev->vpd.len;
-- 
2.33.0



^ permalink raw reply related	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any()
  2021-10-12 20:26     ` Heiner Kallweit
@ 2021-10-13 14:22       ` Qian Cai
  2021-10-13 18:08         ` Heiner Kallweit
  0 siblings, 1 reply; 16+ messages in thread
From: Qian Cai @ 2021-10-13 14:22 UTC (permalink / raw)
  To: Heiner Kallweit, Bjorn Helgaas, Jakub Kicinski, David Miller,
	Raju Rangoju
  Cc: linux-pci, netdev



On 10/12/2021 4:26 PM, Heiner Kallweit wrote:
> Thanks for the report! I could reproduce the issue, the following fixes
> it for me. Could you please test whether it fixes the issue for you as well?

Yes, it works fine. BTW, in the original patch here:

--- a/drivers/pci/vpd.c
+++ b/drivers/pci/vpd.c
@@ -138,9 +138,10 @@ static int pci_vpd_wait(struct pci_dev *dev, bool set)
 }
 
 static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
-			    void *arg)
+			    void *arg, bool check_size)
 {
 	struct pci_vpd *vpd = &dev->vpd;
+	unsigned int max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
 	int ret = 0;
 	loff_t end = pos + count;
 	u8 *buf = arg;
@@ -151,11 +152,11 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
 	if (pos < 0)
 		return -EINVAL;
 
-	if (pos > vpd->len)
+	if (pos >= max_len)
 		return 0;

I am not sure if "pos >= max_len" is correct there, so just want to give you
a chance to double-check.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any()
  2021-10-13 14:22       ` Qian Cai
@ 2021-10-13 18:08         ` Heiner Kallweit
  0 siblings, 0 replies; 16+ messages in thread
From: Heiner Kallweit @ 2021-10-13 18:08 UTC (permalink / raw)
  To: Qian Cai, Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju
  Cc: linux-pci, netdev

On 13.10.2021 16:22, Qian Cai wrote:
> 
> 
> On 10/12/2021 4:26 PM, Heiner Kallweit wrote:
>> Thanks for the report! I could reproduce the issue, the following fixes
>> it for me. Could you please test whether it fixes the issue for you as well?
> 
> Yes, it works fine. BTW, in the original patch here:
> 
Thanks for testing!

> --- a/drivers/pci/vpd.c
> +++ b/drivers/pci/vpd.c
> @@ -138,9 +138,10 @@ static int pci_vpd_wait(struct pci_dev *dev, bool set)
>  }
>  
>  static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
> -			    void *arg)
> +			    void *arg, bool check_size)
>  {
>  	struct pci_vpd *vpd = &dev->vpd;
> +	unsigned int max_len = check_size ? vpd->len : PCI_VPD_MAX_SIZE;
>  	int ret = 0;
>  	loff_t end = pos + count;
>  	u8 *buf = arg;
> @@ -151,11 +152,11 @@ static ssize_t pci_vpd_read(struct pci_dev *dev, loff_t pos, size_t count,
>  	if (pos < 0)
>  		return -EINVAL;
>  
> -	if (pos > vpd->len)
> +	if (pos >= max_len)
>  		return 0;
> 
> I am not sure if "pos >= max_len" is correct there, so just want to give you
> a chance to double-check.
> 
This is intentional, but good catch.

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size()
  2021-09-10  6:22 ` [PATCH 2/5] PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size() Heiner Kallweit
@ 2021-10-27 11:01   ` Jon Hunter
  2021-10-27 11:32     ` Heiner Kallweit
  0 siblings, 1 reply; 16+ messages in thread
From: Jon Hunter @ 2021-10-27 11:01 UTC (permalink / raw)
  To: Heiner Kallweit, Bjorn Helgaas, Jakub Kicinski, David Miller,
	Raju Rangoju
  Cc: linux-pci, netdev, linux-tegra


On 10/09/2021 07:22, Heiner Kallweit wrote:
> Use new function pci_read_vpd_any() to simplify the code.
> 
> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
> ---
>   drivers/pci/vpd.c | 7 ++-----
>   1 file changed, 2 insertions(+), 5 deletions(-)
> 
> diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
> index 286cad2a6..517789205 100644
> --- a/drivers/pci/vpd.c
> +++ b/drivers/pci/vpd.c
> @@ -57,10 +57,7 @@ static size_t pci_vpd_size(struct pci_dev *dev)
>   	size_t off = 0, size;
>   	unsigned char tag, header[1+2];	/* 1 byte tag, 2 bytes length */
>   
> -	/* Otherwise the following reads would fail. */
> -	dev->vpd.len = PCI_VPD_MAX_SIZE;
> -
> -	while (pci_read_vpd(dev, off, 1, header) == 1) {
> +	while (pci_read_vpd_any(dev, off, 1, header) == 1) {
>   		size = 0;
>   
>   		if (off == 0 && (header[0] == 0x00 || header[0] == 0xff))
> @@ -68,7 +65,7 @@ static size_t pci_vpd_size(struct pci_dev *dev)
>   
>   		if (header[0] & PCI_VPD_LRDT) {
>   			/* Large Resource Data Type Tag */
> -			if (pci_read_vpd(dev, off + 1, 2, &header[1]) != 2) {
> +			if (pci_read_vpd_any(dev, off + 1, 2, &header[1]) != 2) {
>   				pci_warn(dev, "failed VPD read at offset %zu\n",
>   					 off + 1);
>   				return off ?: PCI_VPD_SZ_INVALID;
> 


This change is breaking a PCI test that we are running on Tegra124
Jetson TK1. The test is parsing the various PCI devices by running
'lspci -vvv' and for one device I am seeing a NULL pointer
dereference crash. Reverting this change or just adding the line
'dev->vpd.len = PCI_VPD_MAX_SIZE;' back fixes the problem.

I have taken a quick look but have not found why this is failing
so far. Let me know if you have any thoughts.

Cheers
Jon

[   56.577644] 8<--- cut here ---
[   56.580714] Unable to handle kernel NULL pointer dereference at virtual address 00000000
[   56.588836] pgd = da85f9ea
[   56.591545] [00000000] *pgd=00000000
[   56.595124] Internal error: Oops: 80000005 [#1] PREEMPT SMP ARM
[   56.601029] Modules linked in: nouveau drm_ttm_helper ttm tegra_soctherm
[   56.607725] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.0-rc2-00004-g7724d929fdde-dirty #5
[   56.616231] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
[   56.622482] PC is at 0x0
[   56.625007] LR is at rcu_core+0x368/0xc5c
[   56.629011] pc : [<00000000>]    lr : [<c01a3384>]    psr: 60000113
[   56.635261] sp : c1201dc8  ip : c35f4b80  fp : c1201df0
[   56.640472] r10: ffffe000  r9 : 00000007  r8 : c135d3a0
[   56.645683] r7 : 0000000a  r6 : c1204f0c  r5 : 00000008  r4 : 00000000
[   56.652193] r3 : c3c33850  r2 : 00000000  r1 : 00000000  r0 : c3c33850
[   56.658703] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
[   56.665821] Control: 10c5387d  Table: 82e0806a  DAC: 00000051
[   56.671551] Register r0 information: slab kmalloc-64 start c3c33840 pointer offset 16 size 64
[   56.680066] Register r1 information: NULL pointer
[   56.684759] Register r2 information: NULL pointer
[   56.689451] Register r3 information: slab kmalloc-64 start c3c33840 pointer offset 16 size 64
[   56.697964] Register r4 information: NULL pointer
[   56.702655] Register r5 information: non-paged memory
[   56.707693] Register r6 information: non-slab/vmalloc memory
[   56.713338] Register r7 information: non-paged memory
[   56.718375] Register r8 information: non-slab/vmalloc memory
[   56.724020] Register r9 information: non-paged memory
[   56.729057] Register r10 information: non-paged memory
[   56.734183] Register r11 information: non-slab/vmalloc memory
[   56.739914] Register r12 information: slab kmalloc-64 start c35f4b80 pointer offset 0 size 64
[   56.748428] Process swapper/0 (pid: 0, stack limit = 0x54fa894a)
[   56.754419] Stack: (0xc1201dc8 to 0xc1202000)
[   56.758762] 1dc0:                   ???????? ???????? ???????? ???????? ???????? ????????
[   56.766919] 1de0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.775076] 1e00: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.783232] 1e20: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.791389] 1e40: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.799545] 1e60: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.807701] 1e80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.815857] 1ea0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.824014] 1ec0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.832170] 1ee0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.840326] 1f00: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.848482] 1f20: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.856639] 1f40: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.864795] 1f60: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.872951] 1f80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.881108] 1fa0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.889264] 1fc0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.897420] 1fe0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.905580] [<c01a3384>] (rcu_core) from [<c0101358>] (__do_softirq+0x130/0x42c)
[   56.912966] [<c0101358>] (__do_softirq) from [<c012bcec>] (irq_exit+0xbc/0x100)
[   56.920262] [<c012bcec>] (irq_exit) from [<c0189388>] (handle_domain_irq+0x60/0x78)
[   56.927906] [<c0189388>] (handle_domain_irq) from [<c051445c>] (gic_handle_irq+0x7c/0x90)
[   56.936071] [<c051445c>] (gic_handle_irq) from [<c0100b7c>] (__irq_svc+0x5c/0x90)
[   56.943538] Exception stack(0xc1201ec0 to 0xc1201f08)
[   56.948574] 1ec0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.956731] 1ee0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
[   56.964888] 1f00: ???????? ????????
[   56.968364] [<c0100b7c>] (__irq_svc) from [<c0865fb8>] (cpuidle_enter_state+0x258/0x4c0)
[   56.976441] [<c0865fb8>] (cpuidle_enter_state) from [<c0866270>] (cpuidle_enter+0x3c/0x54)
[   56.984687] [<c0866270>] (cpuidle_enter) from [<c015c568>] (do_idle+0x200/0x27c)
[   56.992069] [<c015c568>] (do_idle) from [<c015c93c>] (cpu_startup_entry+0x18/0x1c)
[   56.999623] [<c015c93c>] (cpu_startup_entry) from [<c1100fa8>] (start_kernel+0x664/0x6b0)
[   57.007786] Code: bad PC value
[   57.010968] 8<--- cut here ---

-- 
nvpublic

^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size()
  2021-10-27 11:01   ` Jon Hunter
@ 2021-10-27 11:32     ` Heiner Kallweit
  2021-10-28  8:45       ` Jon Hunter
  0 siblings, 1 reply; 16+ messages in thread
From: Heiner Kallweit @ 2021-10-27 11:32 UTC (permalink / raw)
  To: Jon Hunter, Bjorn Helgaas, Jakub Kicinski, David Miller, Raju Rangoju
  Cc: linux-pci, netdev, linux-tegra

On 27.10.2021 13:01, Jon Hunter wrote:
> 
> On 10/09/2021 07:22, Heiner Kallweit wrote:
>> Use new function pci_read_vpd_any() to simplify the code.
>>
>> Signed-off-by: Heiner Kallweit <hkallweit1@gmail.com>
>> ---
>>   drivers/pci/vpd.c | 7 ++-----
>>   1 file changed, 2 insertions(+), 5 deletions(-)
>>
>> diff --git a/drivers/pci/vpd.c b/drivers/pci/vpd.c
>> index 286cad2a6..517789205 100644
>> --- a/drivers/pci/vpd.c
>> +++ b/drivers/pci/vpd.c
>> @@ -57,10 +57,7 @@ static size_t pci_vpd_size(struct pci_dev *dev)
>>       size_t off = 0, size;
>>       unsigned char tag, header[1+2];    /* 1 byte tag, 2 bytes length */
>>   -    /* Otherwise the following reads would fail. */
>> -    dev->vpd.len = PCI_VPD_MAX_SIZE;
>> -
>> -    while (pci_read_vpd(dev, off, 1, header) == 1) {
>> +    while (pci_read_vpd_any(dev, off, 1, header) == 1) {
>>           size = 0;
>>             if (off == 0 && (header[0] == 0x00 || header[0] == 0xff))
>> @@ -68,7 +65,7 @@ static size_t pci_vpd_size(struct pci_dev *dev)
>>             if (header[0] & PCI_VPD_LRDT) {
>>               /* Large Resource Data Type Tag */
>> -            if (pci_read_vpd(dev, off + 1, 2, &header[1]) != 2) {
>> +            if (pci_read_vpd_any(dev, off + 1, 2, &header[1]) != 2) {
>>                   pci_warn(dev, "failed VPD read at offset %zu\n",
>>                        off + 1);
>>                   return off ?: PCI_VPD_SZ_INVALID;
>>
> 
> 
> This change is breaking a PCI test that we are running on Tegra124
> Jetson TK1. The test is parsing the various PCI devices by running
> 'lspci -vvv' and for one device I am seeing a NULL pointer
> dereference crash. Reverting this change or just adding the line
> 'dev->vpd.len = PCI_VPD_MAX_SIZE;' back fixes the problem.
> 
> I have taken a quick look but have not found why this is failing
> so far. Let me know if you have any thoughts.
> 

There's a known issue with this change, the fix has just been applied to
linux-next. Can you please re-test with linux-next from today?

> Cheers
> Jon
> 

Heiner

> [   56.577644] 8<--- cut here ---
> [   56.580714] Unable to handle kernel NULL pointer dereference at virtual address 00000000
> [   56.588836] pgd = da85f9ea
> [   56.591545] [00000000] *pgd=00000000
> [   56.595124] Internal error: Oops: 80000005 [#1] PREEMPT SMP ARM
> [   56.601029] Modules linked in: nouveau drm_ttm_helper ttm tegra_soctherm
> [   56.607725] CPU: 0 PID: 0 Comm: swapper/0 Not tainted 5.15.0-rc2-00004-g7724d929fdde-dirty #5
> [   56.616231] Hardware name: NVIDIA Tegra SoC (Flattened Device Tree)
> [   56.622482] PC is at 0x0
> [   56.625007] LR is at rcu_core+0x368/0xc5c
> [   56.629011] pc : [<00000000>]    lr : [<c01a3384>]    psr: 60000113
> [   56.635261] sp : c1201dc8  ip : c35f4b80  fp : c1201df0
> [   56.640472] r10: ffffe000  r9 : 00000007  r8 : c135d3a0
> [   56.645683] r7 : 0000000a  r6 : c1204f0c  r5 : 00000008  r4 : 00000000
> [   56.652193] r3 : c3c33850  r2 : 00000000  r1 : 00000000  r0 : c3c33850
> [   56.658703] Flags: nZCv  IRQs on  FIQs on  Mode SVC_32  ISA ARM  Segment none
> [   56.665821] Control: 10c5387d  Table: 82e0806a  DAC: 00000051
> [   56.671551] Register r0 information: slab kmalloc-64 start c3c33840 pointer offset 16 size 64
> [   56.680066] Register r1 information: NULL pointer
> [   56.684759] Register r2 information: NULL pointer
> [   56.689451] Register r3 information: slab kmalloc-64 start c3c33840 pointer offset 16 size 64
> [   56.697964] Register r4 information: NULL pointer
> [   56.702655] Register r5 information: non-paged memory
> [   56.707693] Register r6 information: non-slab/vmalloc memory
> [   56.713338] Register r7 information: non-paged memory
> [   56.718375] Register r8 information: non-slab/vmalloc memory
> [   56.724020] Register r9 information: non-paged memory
> [   56.729057] Register r10 information: non-paged memory
> [   56.734183] Register r11 information: non-slab/vmalloc memory
> [   56.739914] Register r12 information: slab kmalloc-64 start c35f4b80 pointer offset 0 size 64
> [   56.748428] Process swapper/0 (pid: 0, stack limit = 0x54fa894a)
> [   56.754419] Stack: (0xc1201dc8 to 0xc1202000)
> [   56.758762] 1dc0:                   ???????? ???????? ???????? ???????? ???????? ????????
> [   56.766919] 1de0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.775076] 1e00: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.783232] 1e20: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.791389] 1e40: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.799545] 1e60: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.807701] 1e80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.815857] 1ea0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.824014] 1ec0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.832170] 1ee0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.840326] 1f00: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.848482] 1f20: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.856639] 1f40: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.864795] 1f60: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.872951] 1f80: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.881108] 1fa0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.889264] 1fc0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.897420] 1fe0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.905580] [<c01a3384>] (rcu_core) from [<c0101358>] (__do_softirq+0x130/0x42c)
> [   56.912966] [<c0101358>] (__do_softirq) from [<c012bcec>] (irq_exit+0xbc/0x100)
> [   56.920262] [<c012bcec>] (irq_exit) from [<c0189388>] (handle_domain_irq+0x60/0x78)
> [   56.927906] [<c0189388>] (handle_domain_irq) from [<c051445c>] (gic_handle_irq+0x7c/0x90)
> [   56.936071] [<c051445c>] (gic_handle_irq) from [<c0100b7c>] (__irq_svc+0x5c/0x90)
> [   56.943538] Exception stack(0xc1201ec0 to 0xc1201f08)
> [   56.948574] 1ec0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.956731] 1ee0: ???????? ???????? ???????? ???????? ???????? ???????? ???????? ????????
> [   56.964888] 1f00: ???????? ????????
> [   56.968364] [<c0100b7c>] (__irq_svc) from [<c0865fb8>] (cpuidle_enter_state+0x258/0x4c0)
> [   56.976441] [<c0865fb8>] (cpuidle_enter_state) from [<c0866270>] (cpuidle_enter+0x3c/0x54)
> [   56.984687] [<c0866270>] (cpuidle_enter) from [<c015c568>] (do_idle+0x200/0x27c)
> [   56.992069] [<c015c568>] (do_idle) from [<c015c93c>] (cpu_startup_entry+0x18/0x1c)
> [   56.999623] [<c015c93c>] (cpu_startup_entry) from [<c1100fa8>] (start_kernel+0x664/0x6b0)
> [   57.007786] Code: bad PC value
> [   57.010968] 8<--- cut here ---
> 


^ permalink raw reply	[flat|nested] 16+ messages in thread

* Re: [PATCH 2/5] PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size()
  2021-10-27 11:32     ` Heiner Kallweit
@ 2021-10-28  8:45       ` Jon Hunter
  0 siblings, 0 replies; 16+ messages in thread
From: Jon Hunter @ 2021-10-28  8:45 UTC (permalink / raw)
  To: Heiner Kallweit, Bjorn Helgaas, Jakub Kicinski, David Miller,
	Raju Rangoju
  Cc: linux-pci, netdev, linux-tegra


On 27/10/2021 12:32, Heiner Kallweit wrote:

...

>> This change is breaking a PCI test that we are running on Tegra124
>> Jetson TK1. The test is parsing the various PCI devices by running
>> 'lspci -vvv' and for one device I am seeing a NULL pointer
>> dereference crash. Reverting this change or just adding the line
>> 'dev->vpd.len = PCI_VPD_MAX_SIZE;' back fixes the problem.
>>
>> I have taken a quick look but have not found why this is failing
>> so far. Let me know if you have any thoughts.
>>
> 
> There's a known issue with this change, the fix has just been applied to
> linux-next. Can you please re-test with linux-next from today?


Thanks. Looking at yesterday's -next, I do see that it is now working again.

Cheers
Jon

-- 
nvpublic

^ permalink raw reply	[flat|nested] 16+ messages in thread

end of thread, other threads:[~2021-10-28  8:45 UTC | newest]

Thread overview: 16+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-09-10  6:20 [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Heiner Kallweit
2021-09-10  6:22 ` [PATCH 1/5] PCI/VPD: Add pci_read/write_vpd_any() Heiner Kallweit
2021-10-12 18:59   ` Qian Cai
2021-10-12 20:26     ` Heiner Kallweit
2021-10-13 14:22       ` Qian Cai
2021-10-13 18:08         ` Heiner Kallweit
2021-09-10  6:22 ` [PATCH 2/5] PCI/VPD: Use pci_read_vpd_any() in pci_vpd_size() Heiner Kallweit
2021-10-27 11:01   ` Jon Hunter
2021-10-27 11:32     ` Heiner Kallweit
2021-10-28  8:45       ` Jon Hunter
2021-09-10  6:24 ` [PATCH 3/5] cxgb3: Remove t3_seeprom_read and use VPD API Heiner Kallweit
2021-09-10  6:25 ` [PATCH 4/5] cxgb3: Use VPD API in t3_seeprom_wp() Heiner Kallweit
2021-09-10  6:27 ` [PATCH 5/5] cxgb3: Remove seeprom_write and use VPD API Heiner Kallweit
2021-10-08 22:53 ` [PATCH 0/5] PCI/VPD: Add and use pci_read/write_vpd_any() Bjorn Helgaas
2021-10-08 23:42   ` Jakub Kicinski
2021-10-11 20:43     ` Bjorn Helgaas

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.