All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14
@ 2022-04-14 16:15 Tony Nguyen
  2022-04-14 16:15 ` [PATCH net 1/4] ice: xsk: check if Rx ring was filled up to the end Tony Nguyen
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Tony Nguyen @ 2022-04-14 16:15 UTC (permalink / raw)
  To: davem, kuba, pabeni; +Cc: Tony Nguyen, netdev

This series contains updates to ice driver only.

Maciej adjusts implementation in __ice_alloc_rx_bufs_zc() for when
ice_fill_rx_descs() does not return the entire buffer request and fixes a
return value for !CONFIG_NET_SWITCHDEV configuration which was preventing
VF creation.

Wojciech prevents eswitch transmit when VFs are being removed which was
causing NULL pointer dereference.

Jianglei Nie fixes a memory leak on error path of getting OROM data.

The following are changes since commit 2df3fc4a84e917a422935cc5bae18f43f9955d31:
  net: bcmgenet: Revert "Use stronger register read/writes to assure ordering"
and are available in the git repository at:
  git://git.kernel.org/pub/scm/linux/kernel/git/tnguy/net-queue 100GbE

Jianglei Nie (1):
  ice: Fix memory leak in ice_get_orom_civd_data()

Maciej Fijalkowski (2):
  ice: xsk: check if Rx ring was filled up to the end
  ice: allow creating VFs for !CONFIG_NET_SWITCHDEV

Wojciech Drewek (1):
  ice: fix crash in switchdev mode

 drivers/net/ethernet/intel/ice/ice_eswitch.c | 3 ++-
 drivers/net/ethernet/intel/ice/ice_eswitch.h | 2 +-
 drivers/net/ethernet/intel/ice/ice_nvm.c     | 1 +
 drivers/net/ethernet/intel/ice/ice_xsk.c     | 7 ++++++-
 4 files changed, 10 insertions(+), 3 deletions(-)

-- 
2.31.1


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

* [PATCH net 1/4] ice: xsk: check if Rx ring was filled up to the end
  2022-04-14 16:15 [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14 Tony Nguyen
@ 2022-04-14 16:15 ` Tony Nguyen
  2022-04-14 16:15 ` [PATCH net 2/4] ice: allow creating VFs for !CONFIG_NET_SWITCHDEV Tony Nguyen
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tony Nguyen @ 2022-04-14 16:15 UTC (permalink / raw)
  To: davem, kuba, pabeni
  Cc: Maciej Fijalkowski, netdev, anthony.l.nguyen, magnus.karlsson,
	ast, daniel, hawk, john.fastabend, bpf, Shwetha Nagaraju

From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

__ice_alloc_rx_bufs_zc() checks if a number of the descriptors to be
allocated would cause the ring wrap. In that case, driver will issue two
calls to xsk_buff_alloc_batch() - one that will fill the ring up to the
end and the second one that will start with filling descriptors from the
beginning of the ring.

ice_fill_rx_descs() is a wrapper for taking care of what
xsk_buff_alloc_batch() gave back to the driver. It works in a best
effort approach, so for example when driver asks for 64 buffers,
ice_fill_rx_descs() could assign only 32. Such case needs to be checked
when ring is being filled up to the end, because in that situation ntu
might not reached the end of the ring.

Fix the ring wrap by checking if nb_buffs_extra has the expected value.
If not, bump ntu and go directly to tail update.

Fixes: 3876ff525de7 ("ice: xsk: Handle SW XDP ring wrap and bump tail more often")
Signed-off-by: Magnus Karlsson <magnus.karlsson@intel.com>
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Tested-by: Shwetha Nagaraju <Shwetha.nagaraju@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_xsk.c | 7 ++++++-
 1 file changed, 6 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_xsk.c b/drivers/net/ethernet/intel/ice/ice_xsk.c
index 866ee4df9671..9dd38f667059 100644
--- a/drivers/net/ethernet/intel/ice/ice_xsk.c
+++ b/drivers/net/ethernet/intel/ice/ice_xsk.c
@@ -415,8 +415,8 @@ static u16 ice_fill_rx_descs(struct xsk_buff_pool *pool, struct xdp_buff **xdp,
  */
 static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)
 {
+	u32 nb_buffs_extra = 0, nb_buffs = 0;
 	union ice_32b_rx_flex_desc *rx_desc;
-	u32 nb_buffs_extra = 0, nb_buffs;
 	u16 ntu = rx_ring->next_to_use;
 	u16 total_count = count;
 	struct xdp_buff **xdp;
@@ -428,6 +428,10 @@ static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)
 		nb_buffs_extra = ice_fill_rx_descs(rx_ring->xsk_pool, xdp,
 						   rx_desc,
 						   rx_ring->count - ntu);
+		if (nb_buffs_extra != rx_ring->count - ntu) {
+			ntu += nb_buffs_extra;
+			goto exit;
+		}
 		rx_desc = ICE_RX_DESC(rx_ring, 0);
 		xdp = ice_xdp_buf(rx_ring, 0);
 		ntu = 0;
@@ -441,6 +445,7 @@ static bool __ice_alloc_rx_bufs_zc(struct ice_rx_ring *rx_ring, u16 count)
 	if (ntu == rx_ring->count)
 		ntu = 0;
 
+exit:
 	if (rx_ring->next_to_use != ntu)
 		ice_release_rx_desc(rx_ring, ntu);
 
-- 
2.31.1


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

* [PATCH net 2/4] ice: allow creating VFs for !CONFIG_NET_SWITCHDEV
  2022-04-14 16:15 [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14 Tony Nguyen
  2022-04-14 16:15 ` [PATCH net 1/4] ice: xsk: check if Rx ring was filled up to the end Tony Nguyen
@ 2022-04-14 16:15 ` Tony Nguyen
  2022-04-14 16:15 ` [PATCH net 3/4] ice: fix crash in switchdev mode Tony Nguyen
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Tony Nguyen @ 2022-04-14 16:15 UTC (permalink / raw)
  To: davem, kuba, pabeni
  Cc: Maciej Fijalkowski, netdev, anthony.l.nguyen, Grzegorz Nitka,
	Michal Swiatkowski, Konrad Jankowski

From: Maciej Fijalkowski <maciej.fijalkowski@intel.com>

Currently for !CONFIG_NET_SWITCHDEV kernel builds it is not possible to
create VFs properly as call to ice_eswitch_configure() returns
-EOPNOTSUPP for us. This is because CONFIG_ICE_SWITCHDEV depends on
CONFIG_NET_SWITCHDEV.

Change the ice_eswitch_configure() implementation for
!CONFIG_ICE_SWITCHDEV to return 0 instead -EOPNOTSUPP and let
ice_ena_vfs() finish its work properly.

CC: Grzegorz Nitka <grzegorz.nitka@intel.com>
Fixes: 1a1c40df2e80 ("ice: set and release switchdev environment")
Signed-off-by: Maciej Fijalkowski <maciej.fijalkowski@intel.com>
Signed-off-by: Michal Swiatkowski <michal.swiatkowski@intel.com>
Tested-by: Konrad Jankowski <konrad0.jankowski@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_eswitch.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.h b/drivers/net/ethernet/intel/ice/ice_eswitch.h
index bd58d9d2e565..6a413331572b 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.h
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.h
@@ -52,7 +52,7 @@ static inline void ice_eswitch_update_repr(struct ice_vsi *vsi) { }
 
 static inline int ice_eswitch_configure(struct ice_pf *pf)
 {
-	return -EOPNOTSUPP;
+	return 0;
 }
 
 static inline int ice_eswitch_rebuild(struct ice_pf *pf)
-- 
2.31.1


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

* [PATCH net 3/4] ice: fix crash in switchdev mode
  2022-04-14 16:15 [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14 Tony Nguyen
  2022-04-14 16:15 ` [PATCH net 1/4] ice: xsk: check if Rx ring was filled up to the end Tony Nguyen
  2022-04-14 16:15 ` [PATCH net 2/4] ice: allow creating VFs for !CONFIG_NET_SWITCHDEV Tony Nguyen
@ 2022-04-14 16:15 ` Tony Nguyen
  2022-04-14 16:15 ` [PATCH net 4/4] ice: Fix memory leak in ice_get_orom_civd_data() Tony Nguyen
  2022-04-15 10:40 ` [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14 patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Tony Nguyen @ 2022-04-14 16:15 UTC (permalink / raw)
  To: davem, kuba, pabeni
  Cc: Wojciech Drewek, netdev, anthony.l.nguyen, Marcin Szycik,
	Michal Swiatkowski, Sandeep Penigalapati

From: Wojciech Drewek <wojciech.drewek@intel.com>

Below steps end up with crash:
- modprobe ice
- devlink dev eswitch set $PF1_PCI mode switchdev
- echo 64 > /sys/class/net/$PF1/device/sriov_numvfs
- rmmod ice

Calling ice_eswitch_port_start_xmit while the process of removing
VFs is in progress ends up with NULL pointer dereference.
That's because PR netdev is not released but some resources
are already freed. Fix it by checking if ICE_VF_DIS bit is set.

Call trace:
[ 1379.595146] BUG: kernel NULL pointer dereference, address: 0000000000000040
[ 1379.595284] #PF: supervisor read access in kernel mode
[ 1379.595410] #PF: error_code(0x0000) - not-present page
[ 1379.595535] PGD 0 P4D 0
[ 1379.595657] Oops: 0000 [#1] PREEMPT SMP PTI
[ 1379.595783] CPU: 4 PID: 974 Comm: NetworkManager Kdump: loaded Tainted: G           OE     5.17.0-rc8_mrq_dev-queue+ #12
[ 1379.595926] Hardware name: Intel Corporation S1200SP/S1200SP, BIOS S1200SP.86B.03.01.0042.013020190050 01/30/2019
[ 1379.596063] RIP: 0010:ice_eswitch_port_start_xmit+0x46/0xd0 [ice]
[ 1379.596292] Code: c7 c8 09 00 00 e8 9a c9 fc ff 84 c0 0f 85 82 00 00 00 4c 89 e7 e8 ca 70 fe ff 48 8b 7d 58 48 89 c3 48 85 ff 75 5e 48 8b 53 20 <8b> 42 40 85 c0 74 78 8d 48 01 f0 0f b1 4a 40 75 f2 0f b6 95 84 00
[ 1379.596456] RSP: 0018:ffffaba0c0d7bad0 EFLAGS: 00010246
[ 1379.596584] RAX: ffff969c14c71680 RBX: ffff969c14c71680 RCX: 000100107a0f0000
[ 1379.596715] RDX: 0000000000000000 RSI: ffff969b9d631000 RDI: 0000000000000000
[ 1379.596846] RBP: ffff969c07b46500 R08: ffff969becfca8ac R09: 0000000000000001
[ 1379.596977] R10: 0000000000000004 R11: ffffaba0c0d7bbec R12: ffff969b9d631000
[ 1379.597106] R13: ffffffffc08357a0 R14: ffff969c07b46500 R15: ffff969b9d631000
[ 1379.597237] FS:  00007f72c0e25c80(0000) GS:ffff969f13500000(0000) knlGS:0000000000000000
[ 1379.597414] CS:  0010 DS: 0000 ES: 0000 CR0: 0000000080050033
[ 1379.597562] CR2: 0000000000000040 CR3: 000000012b316006 CR4: 00000000003706e0
[ 1379.597713] DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
[ 1379.597863] DR3: 0000000000000000 DR6: 00000000fffe0ff0 DR7: 0000000000000400
[ 1379.598015] Call Trace:
[ 1379.598153]  <TASK>
[ 1379.598294]  dev_hard_start_xmit+0xd9/0x220
[ 1379.598444]  sch_direct_xmit+0x8a/0x340
[ 1379.598592]  __dev_queue_xmit+0xa3c/0xd30
[ 1379.598739]  ? packet_parse_headers+0xb4/0xf0
[ 1379.598890]  packet_sendmsg+0xa15/0x1620
[ 1379.599038]  ? __check_object_size+0x46/0x140
[ 1379.599186]  sock_sendmsg+0x5e/0x60
[ 1379.599330]  ____sys_sendmsg+0x22c/0x270
[ 1379.599474]  ? import_iovec+0x17/0x20
[ 1379.599622]  ? sendmsg_copy_msghdr+0x59/0x90
[ 1379.599771]  ___sys_sendmsg+0x81/0xc0
[ 1379.599917]  ? __pollwait+0xd0/0xd0
[ 1379.600061]  ? preempt_count_add+0x68/0xa0
[ 1379.600210]  ? _raw_write_lock_irq+0x1a/0x40
[ 1379.600369]  ? ep_done_scan+0xc9/0x110
[ 1379.600494]  ? _raw_spin_unlock_irqrestore+0x25/0x40
[ 1379.600622]  ? preempt_count_add+0x68/0xa0
[ 1379.600747]  ? _raw_spin_lock_irq+0x1a/0x40
[ 1379.600899]  ? __fget_light+0x8f/0x110
[ 1379.601024]  __sys_sendmsg+0x49/0x80
[ 1379.601148]  ? release_ds_buffers+0x50/0xe0
[ 1379.601274]  do_syscall_64+0x3b/0x90
[ 1379.601399]  entry_SYSCALL_64_after_hwframe+0x44/0xae
[ 1379.601525] RIP: 0033:0x7f72c1e2e35d

Fixes: f5396b8a663f ("ice: switchdev slow path")
Signed-off-by: Wojciech Drewek <wojciech.drewek@intel.com>
Reported-by: Marcin Szycik <marcin.szycik@linux.intel.com>
Reviewed-by: Michal Swiatkowski <michal.swiatkowski@linux.intel.com>
Tested-by: Sandeep Penigalapati <sandeep.penigalapati@intel.com>
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_eswitch.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/intel/ice/ice_eswitch.c b/drivers/net/ethernet/intel/ice/ice_eswitch.c
index 9a84d746a6c4..6a463b242c7d 100644
--- a/drivers/net/ethernet/intel/ice/ice_eswitch.c
+++ b/drivers/net/ethernet/intel/ice/ice_eswitch.c
@@ -361,7 +361,8 @@ ice_eswitch_port_start_xmit(struct sk_buff *skb, struct net_device *netdev)
 	np = netdev_priv(netdev);
 	vsi = np->vsi;
 
-	if (ice_is_reset_in_progress(vsi->back->state))
+	if (ice_is_reset_in_progress(vsi->back->state) ||
+	    test_bit(ICE_VF_DIS, vsi->back->state))
 		return NETDEV_TX_BUSY;
 
 	repr = ice_netdev_to_repr(netdev);
-- 
2.31.1


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

* [PATCH net 4/4] ice: Fix memory leak in ice_get_orom_civd_data()
  2022-04-14 16:15 [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14 Tony Nguyen
                   ` (2 preceding siblings ...)
  2022-04-14 16:15 ` [PATCH net 3/4] ice: fix crash in switchdev mode Tony Nguyen
@ 2022-04-14 16:15 ` Tony Nguyen
  2022-04-15 10:40 ` [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14 patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: Tony Nguyen @ 2022-04-14 16:15 UTC (permalink / raw)
  To: davem, kuba, pabeni; +Cc: Jianglei Nie, netdev, anthony.l.nguyen, Gurucharan

From: Jianglei Nie <niejianglei2021@163.com>

A memory chunk was allocated for orom_data in ice_get_orom_civd_data()
by vzmalloc(). But when ice_read_flash_module() fails, the allocated
memory is not freed, which will lead to a memory leak.

We can fix it by freeing the orom_data when ce_read_flash_module() fails.

Fixes: af18d8866c80 ("ice: reduce time to read Option ROM CIVD data")
Signed-off-by: Jianglei Nie <niejianglei2021@163.com>
Tested-by: Gurucharan <gurucharanx.g@intel.com> (A Contingent worker at Intel)
Signed-off-by: Tony Nguyen <anthony.l.nguyen@intel.com>
---
 drivers/net/ethernet/intel/ice/ice_nvm.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/net/ethernet/intel/ice/ice_nvm.c b/drivers/net/ethernet/intel/ice/ice_nvm.c
index 4eb0599714f4..13cdb5ea594d 100644
--- a/drivers/net/ethernet/intel/ice/ice_nvm.c
+++ b/drivers/net/ethernet/intel/ice/ice_nvm.c
@@ -641,6 +641,7 @@ ice_get_orom_civd_data(struct ice_hw *hw, enum ice_bank_select bank,
 	status = ice_read_flash_module(hw, bank, ICE_SR_1ST_OROM_BANK_PTR, 0,
 				       orom_data, hw->flash.banks.orom_size);
 	if (status) {
+		vfree(orom_data);
 		ice_debug(hw, ICE_DBG_NVM, "Unable to read Option ROM data\n");
 		return status;
 	}
-- 
2.31.1


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

* Re: [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14
  2022-04-14 16:15 [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14 Tony Nguyen
                   ` (3 preceding siblings ...)
  2022-04-14 16:15 ` [PATCH net 4/4] ice: Fix memory leak in ice_get_orom_civd_data() Tony Nguyen
@ 2022-04-15 10:40 ` patchwork-bot+netdevbpf
  4 siblings, 0 replies; 6+ messages in thread
From: patchwork-bot+netdevbpf @ 2022-04-15 10:40 UTC (permalink / raw)
  To: Tony Nguyen; +Cc: davem, kuba, pabeni, netdev

Hello:

This series was applied to netdev/net.git (master)
by Tony Nguyen <anthony.l.nguyen@intel.com>:

On Thu, 14 Apr 2022 09:15:18 -0700 you wrote:
> This series contains updates to ice driver only.
> 
> Maciej adjusts implementation in __ice_alloc_rx_bufs_zc() for when
> ice_fill_rx_descs() does not return the entire buffer request and fixes a
> return value for !CONFIG_NET_SWITCHDEV configuration which was preventing
> VF creation.
> 
> [...]

Here is the summary with links:
  - [net,1/4] ice: xsk: check if Rx ring was filled up to the end
    https://git.kernel.org/netdev/net/c/d1fc4c6feac1
  - [net,2/4] ice: allow creating VFs for !CONFIG_NET_SWITCHDEV
    https://git.kernel.org/netdev/net/c/aacca7a83b97
  - [net,3/4] ice: fix crash in switchdev mode
    https://git.kernel.org/netdev/net/c/d201665147ae
  - [net,4/4] ice: Fix memory leak in ice_get_orom_civd_data()
    https://git.kernel.org/netdev/net/c/7c8881b77908

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2022-04-15 10:40 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-04-14 16:15 [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14 Tony Nguyen
2022-04-14 16:15 ` [PATCH net 1/4] ice: xsk: check if Rx ring was filled up to the end Tony Nguyen
2022-04-14 16:15 ` [PATCH net 2/4] ice: allow creating VFs for !CONFIG_NET_SWITCHDEV Tony Nguyen
2022-04-14 16:15 ` [PATCH net 3/4] ice: fix crash in switchdev mode Tony Nguyen
2022-04-14 16:15 ` [PATCH net 4/4] ice: Fix memory leak in ice_get_orom_civd_data() Tony Nguyen
2022-04-15 10:40 ` [PATCH net 0/4][pull request] Intel Wired LAN Driver Updates 2022-04-14 patchwork-bot+netdevbpf

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.