* [PATCH net-next] vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev
@ 2013-03-06 17:46 Bhavesh Davda
2013-03-06 20:38 ` David Miller
2013-03-06 22:04 ` Bhavesh Davda
0 siblings, 2 replies; 6+ messages in thread
From: Bhavesh Davda @ 2013-03-06 17:46 UTC (permalink / raw)
To: davem, netdev, linux-kernel
Cc: pv-drivers, Bhavesh Davda, Shreyas N Bhatewara
Linux is free to call ethtool ops as soon as a netdev exists when probe
finishes. However, we only allocate vmxnet3 tx/rx queues and initialize the
rx_buf_per_pkt field in struct vmxnet3_adapter when the interface is
opened (UP).
Signed-off-by: Bhavesh Davda <bhavesh@vmware.com>
Signed-off-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
---
drivers/net/vmxnet3/vmxnet3_drv.c | 3 ++-
drivers/net/vmxnet3/vmxnet3_ethtool.c | 6 ++++++
drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
3 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 4aad350..bfc5898 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2922,7 +2922,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
(int)num_online_cpus());
else
#endif
- num_rx_queues = 1;
+ num_rx_queues = 1;
num_rx_queues = rounddown_pow_of_two(num_rx_queues);
if (enable_mq)
@@ -2958,6 +2958,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
adapter->num_rx_queues = num_rx_queues;
adapter->num_tx_queues = num_tx_queues;
+ adapter->rx_buf_per_pkt = 1;
size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues;
size += sizeof(struct Vmxnet3_RxQueueDesc) * adapter->num_rx_queues;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index a0feb17..0a4fc9e 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -472,6 +472,12 @@ vmxnet3_set_ringparam(struct net_device *netdev,
VMXNET3_RX_RING_MAX_SIZE)
return -EINVAL;
+ /* if adapter not yet initialized, do nothing */
+ if (adapter->rx_buf_per_pkt == 0) {
+ netdev_info(netdev,
+ "adapter not completely initialized, ring size cannot be changed yet\n");
+ return -EOPNOTSUPP;
+ }
/* round it up to a multiple of VMXNET3_RING_SIZE_ALIGN */
new_tx_ring_size = (param->tx_pending + VMXNET3_RING_SIZE_MASK) &
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index 3198384..3541814 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -70,10 +70,10 @@
/*
* Version numbers
*/
-#define VMXNET3_DRIVER_VERSION_STRING "1.1.29.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING "1.1.30.0-k"
/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM 0x01011D00
+#define VMXNET3_DRIVER_VERSION_NUM 0x01011E00
#if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev
2013-03-06 17:46 [PATCH net-next] vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev Bhavesh Davda
@ 2013-03-06 20:38 ` David Miller
2013-03-06 22:00 ` Bhavesh Davda
2013-03-06 22:04 ` Bhavesh Davda
1 sibling, 1 reply; 6+ messages in thread
From: David Miller @ 2013-03-06 20:38 UTC (permalink / raw)
To: bhavesh; +Cc: netdev, linux-kernel, pv-drivers, sbhatewara
From: Bhavesh Davda <bhavesh@vmware.com>
Date: Wed, 6 Mar 2013 09:46:24 -0800
> Linux is free to call ethtool ops as soon as a netdev exists when probe
> finishes. However, we only allocate vmxnet3 tx/rx queues and initialize the
> rx_buf_per_pkt field in struct vmxnet3_adapter when the interface is
> opened (UP).
>
> Signed-off-by: Bhavesh Davda <bhavesh@vmware.com>
> Signed-off-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
> ---
> drivers/net/vmxnet3/vmxnet3_drv.c | 3 ++-
> drivers/net/vmxnet3/vmxnet3_ethtool.c | 6 ++++++
> drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
> 3 files changed, 10 insertions(+), 3 deletions(-)
>
> diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
> index 4aad350..bfc5898 100644
> --- a/drivers/net/vmxnet3/vmxnet3_drv.c
> +++ b/drivers/net/vmxnet3/vmxnet3_drv.c
> @@ -2922,7 +2922,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
> (int)num_online_cpus());
> else
> #endif
> - num_rx_queues = 1;
> + num_rx_queues = 1;
Why are you un-indenting this else branch? Please don't do that.
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev
2013-03-06 20:38 ` David Miller
@ 2013-03-06 22:00 ` Bhavesh Davda
0 siblings, 0 replies; 6+ messages in thread
From: Bhavesh Davda @ 2013-03-06 22:00 UTC (permalink / raw)
To: David Miller; +Cc: netdev, linux-kernel, pv-drivers, sbhatewara
> > ---
> > drivers/net/vmxnet3/vmxnet3_drv.c | 3 ++-
> > drivers/net/vmxnet3/vmxnet3_ethtool.c | 6 ++++++
> > drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
> > 3 files changed, 10 insertions(+), 3 deletions(-)
> >
> > diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c
> > b/drivers/net/vmxnet3/vmxnet3_drv.c
> > index 4aad350..bfc5898 100644
> > --- a/drivers/net/vmxnet3/vmxnet3_drv.c
> > +++ b/drivers/net/vmxnet3/vmxnet3_drv.c
> > @@ -2922,7 +2922,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
> > (int)num_online_cpus());
> > else
> > #endif
> > - num_rx_queues = 1;
> > + num_rx_queues = 1;
>
> Why are you un-indenting this else branch? Please don't do that
>
Just to annoy you :) [Sorry, couldn't resist.]
I'm sorry I didn't notice I was breaking the indent of the else branch. For some reason checkpatch didn't complain.
While at it, I'm also changing the netdev_info to netdev_err in vmxnet3_ethtool.c.
You didn't explicitly ask for it, so I wasn't sure if I should repost the patch. I'm going to repost it any way and leave it up to you on which patch you want to apply.
Thanks.
- Bhavesh
^ permalink raw reply [flat|nested] 6+ messages in thread
* [PATCH net-next] vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev
2013-03-06 17:46 [PATCH net-next] vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev Bhavesh Davda
2013-03-06 20:38 ` David Miller
@ 2013-03-06 22:04 ` Bhavesh Davda
2013-03-06 22:09 ` David Miller
2013-03-07 21:11 ` David Miller
1 sibling, 2 replies; 6+ messages in thread
From: Bhavesh Davda @ 2013-03-06 22:04 UTC (permalink / raw)
To: davem, netdev, linux-kernel
Cc: pv-drivers, Bhavesh Davda, Shreyas N Bhatewara
Linux is free to call ethtool ops as soon as a netdev exists when probe
finishes. However, we only allocate vmxnet3 tx/rx queues and initialize the
rx_buf_per_pkt field in struct vmxnet3_adapter when the interface is
opened (UP).
Signed-off-by: Bhavesh Davda <bhavesh@vmware.com>
Signed-off-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
---
drivers/net/vmxnet3/vmxnet3_drv.c | 1 +
drivers/net/vmxnet3/vmxnet3_ethtool.c | 6 ++++++
drivers/net/vmxnet3/vmxnet3_int.h | 4 ++--
3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 4aad350..eae7a03 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -2958,6 +2958,7 @@ vmxnet3_probe_device(struct pci_dev *pdev,
adapter->num_rx_queues = num_rx_queues;
adapter->num_tx_queues = num_tx_queues;
+ adapter->rx_buf_per_pkt = 1;
size = sizeof(struct Vmxnet3_TxQueueDesc) * adapter->num_tx_queues;
size += sizeof(struct Vmxnet3_RxQueueDesc) * adapter->num_rx_queues;
diff --git a/drivers/net/vmxnet3/vmxnet3_ethtool.c b/drivers/net/vmxnet3/vmxnet3_ethtool.c
index a0feb17..63a1243 100644
--- a/drivers/net/vmxnet3/vmxnet3_ethtool.c
+++ b/drivers/net/vmxnet3/vmxnet3_ethtool.c
@@ -472,6 +472,12 @@ vmxnet3_set_ringparam(struct net_device *netdev,
VMXNET3_RX_RING_MAX_SIZE)
return -EINVAL;
+ /* if adapter not yet initialized, do nothing */
+ if (adapter->rx_buf_per_pkt == 0) {
+ netdev_err(netdev, "adapter not completely initialized, "
+ "ring size cannot be changed yet\n");
+ return -EOPNOTSUPP;
+ }
/* round it up to a multiple of VMXNET3_RING_SIZE_ALIGN */
new_tx_ring_size = (param->tx_pending + VMXNET3_RING_SIZE_MASK) &
diff --git a/drivers/net/vmxnet3/vmxnet3_int.h b/drivers/net/vmxnet3/vmxnet3_int.h
index 3198384..3541814 100644
--- a/drivers/net/vmxnet3/vmxnet3_int.h
+++ b/drivers/net/vmxnet3/vmxnet3_int.h
@@ -70,10 +70,10 @@
/*
* Version numbers
*/
-#define VMXNET3_DRIVER_VERSION_STRING "1.1.29.0-k"
+#define VMXNET3_DRIVER_VERSION_STRING "1.1.30.0-k"
/* a 32-bit int, each byte encode a verion number in VMXNET3_DRIVER_VERSION */
-#define VMXNET3_DRIVER_VERSION_NUM 0x01011D00
+#define VMXNET3_DRIVER_VERSION_NUM 0x01011E00
#if defined(CONFIG_PCI_MSI)
/* RSS only makes sense if MSI-X is supported. */
--
1.7.1
^ permalink raw reply related [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev
2013-03-06 22:04 ` Bhavesh Davda
@ 2013-03-06 22:09 ` David Miller
2013-03-07 21:11 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2013-03-06 22:09 UTC (permalink / raw)
To: bhavesh; +Cc: netdev, linux-kernel, pv-drivers, sbhatewara
From: Bhavesh Davda <bhavesh@vmware.com>
Date: Wed, 6 Mar 2013 14:04:53 -0800
> Linux is free to call ethtool ops as soon as a netdev exists when probe
> finishes. However, we only allocate vmxnet3 tx/rx queues and initialize the
> rx_buf_per_pkt field in struct vmxnet3_adapter when the interface is
> opened (UP).
>
> Signed-off-by: Bhavesh Davda <bhavesh@vmware.com>
> Signed-off-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
Maybe this is more appropriate for 'net' rather than 'net-next'?
^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH net-next] vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev
2013-03-06 22:04 ` Bhavesh Davda
2013-03-06 22:09 ` David Miller
@ 2013-03-07 21:11 ` David Miller
1 sibling, 0 replies; 6+ messages in thread
From: David Miller @ 2013-03-07 21:11 UTC (permalink / raw)
To: bhavesh; +Cc: netdev, linux-kernel, pv-drivers, sbhatewara
From: Bhavesh Davda <bhavesh@vmware.com>
Date: Wed, 6 Mar 2013 14:04:53 -0800
> Linux is free to call ethtool ops as soon as a netdev exists when probe
> finishes. However, we only allocate vmxnet3 tx/rx queues and initialize the
> rx_buf_per_pkt field in struct vmxnet3_adapter when the interface is
> opened (UP).
>
> Signed-off-by: Bhavesh Davda <bhavesh@vmware.com>
> Signed-off-by: Shreyas N Bhatewara <sbhatewara@vmware.com>
As discussed yesterday, I'm applying this to 'net', thanks.
^ permalink raw reply [flat|nested] 6+ messages in thread
end of thread, other threads:[~2013-03-07 21:11 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2013-03-06 17:46 [PATCH net-next] vmxnet3: prevent div-by-zero panic when ring resizing uninitialized dev Bhavesh Davda
2013-03-06 20:38 ` David Miller
2013-03-06 22:00 ` Bhavesh Davda
2013-03-06 22:04 ` Bhavesh Davda
2013-03-06 22:09 ` David Miller
2013-03-07 21:11 ` David Miller
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.