* [PATCH 0/5] ibmveth: various fixes
@ 2006-10-03 17:24 Santiago Leon
2006-10-03 17:24 ` [PATCH 1/5] ibmveth: Harden driver initilisation Santiago Leon
` (4 more replies)
0 siblings, 5 replies; 7+ messages in thread
From: Santiago Leon @ 2006-10-03 17:24 UTC (permalink / raw)
To: netdev, Jeff Garzik; +Cc: Santiago Leon
Hi Jeff,
Can you apply the following patches (hopefully for 2.6.19)? They are the hardening of the initialization for kexec, adding netpoll, and some small fixes for bugs that people have been running into.
Thanks,
--
Santiago A. Leon
Power Linux Development
IBM Linux Technology Center
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 1/5] ibmveth: Harden driver initilisation
2006-10-03 17:24 [PATCH 0/5] ibmveth: various fixes Santiago Leon
@ 2006-10-03 17:24 ` Santiago Leon
2006-10-05 10:43 ` Jeff Garzik
2006-10-03 17:24 ` [PATCH 2/5] ibmveth: Add netpoll function Santiago Leon
` (3 subsequent siblings)
4 siblings, 1 reply; 7+ messages in thread
From: Santiago Leon @ 2006-10-03 17:24 UTC (permalink / raw)
To: netdev, Jeff Garzik; +Cc: Santiago Leon
From: Michael Ellerman <michael@ellerman.id.au>
Hi Jeff,
This patch has been floating around for a while now, Santi originally sent it in March: http://www.spinics.net/lists/netdev/msg00471.html
You replied saying you thought it was "bonkers", I think I explained why it wasn't, perhaps you disagree.
I'm resending it now in the hope you can either give us more info on your objections, or merge it.
After a kexec the ibmveth driver will fail when trying to register with the Hypervisor because the previous kernel has not unregistered.
So if the registration fails, we unregister and then try again.
We don't unconditionally unregister, because we don't want to disturb the regular code path for 99% of users.
Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
Acked-by: Anton Blanchard <anton@samba.org>
Signed-off-by: Santiago Leon <santil@us.ibm.com>
---
drivers/net/ibmveth.c | 32 ++++++++++++++++++++++++++------
1 file changed, 26 insertions(+), 6 deletions(-)
diff -urNp a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
--- a/drivers/net/ibmveth.c 2006-07-12 10:45:09.787235496 -0500
+++ b/drivers/net/ibmveth.c 2006-07-12 10:43:20.655186616 -0500
@@ -437,6 +437,31 @@ static void ibmveth_cleanup(struct ibmve
&adapter->rx_buff_pool[i]);
}
+static int ibmveth_register_logical_lan(struct ibmveth_adapter *adapter,
+ union ibmveth_buf_desc rxq_desc, u64 mac_address)
+{
+ int rc, try_again = 1;
+
+ /* After a kexec the adapter will still be open, so our attempt to
+ * open it will fail. So if we get a failure we free the adapter and
+ * try again, but only once. */
+retry:
+ rc = h_register_logical_lan(adapter->vdev->unit_address,
+ adapter->buffer_list_dma, rxq_desc.desc,
+ adapter->filter_list_dma, mac_address);
+
+ if (rc != H_SUCCESS && try_again) {
+ do {
+ rc = h_free_logical_lan(adapter->vdev->unit_address);
+ } while (H_IS_LONG_BUSY(rc) || (rc == H_BUSY));
+
+ try_again = 0;
+ goto retry;
+ }
+
+ return rc;
+}
+
static int ibmveth_open(struct net_device *netdev)
{
struct ibmveth_adapter *adapter = netdev->priv;
@@ -502,12 +527,7 @@ static int ibmveth_open(struct net_devic
ibmveth_debug_printk("filter list @ 0x%p\n", adapter->filter_list_addr);
ibmveth_debug_printk("receive q @ 0x%p\n", adapter->rx_queue.queue_addr);
-
- lpar_rc = h_register_logical_lan(adapter->vdev->unit_address,
- adapter->buffer_list_dma,
- rxq_desc.desc,
- adapter->filter_list_dma,
- mac_address);
+ lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
if(lpar_rc != H_SUCCESS) {
ibmveth_error_printk("h_register_logical_lan failed with %ld\n", lpar_rc);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 2/5] ibmveth: Add netpoll function
2006-10-03 17:24 [PATCH 0/5] ibmveth: various fixes Santiago Leon
2006-10-03 17:24 ` [PATCH 1/5] ibmveth: Harden driver initilisation Santiago Leon
@ 2006-10-03 17:24 ` Santiago Leon
2006-10-03 17:24 ` [PATCH 3/5] ibmveth: kdump interrupt fix Santiago Leon
` (2 subsequent siblings)
4 siblings, 0 replies; 7+ messages in thread
From: Santiago Leon @ 2006-10-03 17:24 UTC (permalink / raw)
To: netdev, Jeff Garzik; +Cc: Santiago Leon
From: Santiago Leon <santil@us.ibm.com>
This patch adds the net poll controller function to ibmveth to support netconsole and netdump.
Signed-off-by: Santiago Leon <santil@us.ibm.com>
---
drivers/net/ibmveth.c | 11 +++++++++++
1 file changed, 11 insertions(+)
diff -urNp a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
--- a/drivers/net/ibmveth.c 2006-07-12 11:07:41.940202928 -0500
+++ b/drivers/net/ibmveth.c 2006-07-12 11:09:45.344207680 -0500
@@ -925,6 +925,14 @@ static int ibmveth_change_mtu(struct net
return -EINVAL;
}
+#ifdef CONFIG_NET_POLL_CONTROLLER
+static void ibmveth_poll_controller(struct net_device *dev)
+{
+ ibmveth_replenish_task(dev->priv);
+ ibmveth_interrupt(dev->irq, dev, NULL);
+}
+#endif
+
static int __devinit ibmveth_probe(struct vio_dev *dev, const struct vio_device_id *id)
{
int rc, i;
@@ -997,6 +1005,9 @@ static int __devinit ibmveth_probe(struc
netdev->ethtool_ops = &netdev_ethtool_ops;
netdev->change_mtu = ibmveth_change_mtu;
SET_NETDEV_DEV(netdev, &dev->dev);
+#ifdef CONFIG_NET_POLL_CONTROLLER
+ netdev->poll_controller = ibmveth_poll_controller;
+#endif
netdev->features |= NETIF_F_LLTX;
spin_lock_init(&adapter->stats_lock);
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 3/5] ibmveth: kdump interrupt fix
2006-10-03 17:24 [PATCH 0/5] ibmveth: various fixes Santiago Leon
2006-10-03 17:24 ` [PATCH 1/5] ibmveth: Harden driver initilisation Santiago Leon
2006-10-03 17:24 ` [PATCH 2/5] ibmveth: Add netpoll function Santiago Leon
@ 2006-10-03 17:24 ` Santiago Leon
2006-10-03 17:24 ` [PATCH 4/5] ibmveth: rename proc entry name Santiago Leon
2006-10-03 17:24 ` [PATCH 5/5] ibmveth: fix int rollover panic Santiago Leon
4 siblings, 0 replies; 7+ messages in thread
From: Santiago Leon @ 2006-10-03 17:24 UTC (permalink / raw)
To: netdev, Jeff Garzik; +Cc: Santiago Leon
From: Santiago Leon <santil@us.ibm.com>
This patch fixes a race that panics the kernel when opening the device after a kdump. Without this patch there is a window where the hypervisor can send an interrupt before all the structures for the kdump ibmveth module are ready (because the hypervisor is not aware that the partition crashed and that the virtual driver is reloading). We close this window by disabling the interrupts before registering the adapter to the hypervisor.
This patch depends on the "ibmveth: Harden driver initilisation" patch.
Signed-off-by: Santiago Leon <santil@us.ibm.com>
---
drivers/net/ibmveth.c | 2 ++
1 file changed, 2 insertions(+)
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -527,6 +527,8 @@ static int ibmveth_open(struct net_devic
ibmveth_debug_printk("filter list @ 0x%p\n", adapter->filter_list_addr);
ibmveth_debug_printk("receive q @ 0x%p\n", adapter->rx_queue.queue_addr);
+ h_vio_signal(adapter->vdev->unit_address, VIO_IRQ_DISABLE);
+
lpar_rc = ibmveth_register_logical_lan(adapter, rxq_desc, mac_address);
if(lpar_rc != H_SUCCESS) {
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 4/5] ibmveth: rename proc entry name
2006-10-03 17:24 [PATCH 0/5] ibmveth: various fixes Santiago Leon
` (2 preceding siblings ...)
2006-10-03 17:24 ` [PATCH 3/5] ibmveth: kdump interrupt fix Santiago Leon
@ 2006-10-03 17:24 ` Santiago Leon
2006-10-03 17:24 ` [PATCH 5/5] ibmveth: fix int rollover panic Santiago Leon
4 siblings, 0 replies; 7+ messages in thread
From: Santiago Leon @ 2006-10-03 17:24 UTC (permalink / raw)
To: netdev, Jeff Garzik; +Cc: Santiago Leon
From: Santiago Leon <santil@us.ibm.com>
This patch changes the name of the proc file for each ibmveth adapter from the network device name to the slot number in the virtual bus.
The proc file is created when the device is probed, so a change in the name of the device will not be reflected in the name of the proc file giving problems when identifying and removing the adapter. The slot number is a property that does not change through the life of the adapter so we use that instead.
Signed-off-by: Santiago Leon <santil@us.ibm.com>
---
drivers/net/ibmveth.c | 8 ++++++--
1 file changed, 6 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -1165,7 +1165,9 @@ static void ibmveth_proc_register_adapte
{
struct proc_dir_entry *entry;
if (ibmveth_proc_dir) {
- entry = create_proc_entry(adapter->netdev->name, S_IFREG, ibmveth_proc_dir);
+ char u_addr[10];
+ sprintf(u_addr, "%x", adapter->vdev->unit_address);
+ entry = create_proc_entry(u_addr, S_IFREG, ibmveth_proc_dir);
if (!entry) {
ibmveth_error_printk("Cannot create adapter proc entry");
} else {
@@ -1180,7 +1182,9 @@ static void ibmveth_proc_register_adapte
static void ibmveth_proc_unregister_adapter(struct ibmveth_adapter *adapter)
{
if (ibmveth_proc_dir) {
- remove_proc_entry(adapter->netdev->name, ibmveth_proc_dir);
+ char u_addr[10];
+ sprintf(u_addr, "%x", adapter->vdev->unit_address);
+ remove_proc_entry(u_addr, ibmveth_proc_dir);
}
}
^ permalink raw reply [flat|nested] 7+ messages in thread
* [PATCH 5/5] ibmveth: fix int rollover panic
2006-10-03 17:24 [PATCH 0/5] ibmveth: various fixes Santiago Leon
` (3 preceding siblings ...)
2006-10-03 17:24 ` [PATCH 4/5] ibmveth: rename proc entry name Santiago Leon
@ 2006-10-03 17:24 ` Santiago Leon
4 siblings, 0 replies; 7+ messages in thread
From: Santiago Leon @ 2006-10-03 17:24 UTC (permalink / raw)
To: netdev, Jeff Garzik; +Cc: Santiago Leon
From: Santiago Leon <santil@us.ibm.com>
This patch fixes a nasty bug that has been sitting there since the very first versions of the driver, but is generating a panic because we changed the number of 2K buffers for 2.6.16.
The consumer_index and producer_index are u32's that get incremented on every buffer emptied and replenished respectively. We use the {producer,consumer}_index mod'ed with the size of the pool to pick out an entry in the free_map. The problem happens when the u32 rolls over and the number of the buffers in the pool is not a perfect divisor of 2^32. i.e. if the number of 2K buffers is 0x300, before the consumer_index rolls over, our index to the free map = 0xffffffff mod 0x300 = 0xff. The next time a buffer is emptied, we want the index to the free map to be 0x100, but 0x0 mod 0x300 is 0x0.
This patch assigns the mod'ed result back to the consumer and producer indexes so that they never roll over. The second chunk of the patch covers the unlikely case where the consumer_index has just been reset to 0x0 and the hypervisor is not able to accept that buffer.
Signed-off-by: Santiago Leon <santil@us.ibm.com>
---
drivers/net/ibmveth.c | 7 ++++++-
1 file changed, 6 insertions(+), 1 deletion(-)
diff --git a/drivers/net/ibmveth.c b/drivers/net/ibmveth.c
--- a/drivers/net/ibmveth.c
+++ b/drivers/net/ibmveth.c
@@ -213,6 +213,7 @@ static void ibmveth_replenish_buffer_poo
}
free_index = pool->consumer_index++ % pool->size;
+ pool->consumer_index = free_index;
index = pool->free_map[free_index];
ibmveth_assert(index != IBM_VETH_INVALID_MAP);
@@ -238,7 +239,10 @@ static void ibmveth_replenish_buffer_poo
if(lpar_rc != H_SUCCESS) {
pool->free_map[free_index] = index;
pool->skbuff[index] = NULL;
- pool->consumer_index--;
+ if (pool->consumer_index == 0)
+ pool->consumer_index = pool->size - 1;
+ else
+ pool->consumer_index--;
dma_unmap_single(&adapter->vdev->dev,
pool->dma_addr[index], pool->buff_size,
DMA_FROM_DEVICE);
@@ -326,6 +330,7 @@ static void ibmveth_remove_buffer_from_p
DMA_FROM_DEVICE);
free_index = adapter->rx_buff_pool[pool].producer_index++ % adapter->rx_buff_pool[pool].size;
+ adapter->rx_buff_pool[pool].producer_index = free_index;
adapter->rx_buff_pool[pool].free_map[free_index] = index;
mb();
^ permalink raw reply [flat|nested] 7+ messages in thread
* Re: [PATCH 1/5] ibmveth: Harden driver initilisation
2006-10-03 17:24 ` [PATCH 1/5] ibmveth: Harden driver initilisation Santiago Leon
@ 2006-10-05 10:43 ` Jeff Garzik
0 siblings, 0 replies; 7+ messages in thread
From: Jeff Garzik @ 2006-10-05 10:43 UTC (permalink / raw)
To: Santiago Leon; +Cc: netdev
applied 1-5 to #upstream-fixes
^ permalink raw reply [flat|nested] 7+ messages in thread
end of thread, other threads:[~2006-10-05 10:43 UTC | newest]
Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-10-03 17:24 [PATCH 0/5] ibmveth: various fixes Santiago Leon
2006-10-03 17:24 ` [PATCH 1/5] ibmveth: Harden driver initilisation Santiago Leon
2006-10-05 10:43 ` Jeff Garzik
2006-10-03 17:24 ` [PATCH 2/5] ibmveth: Add netpoll function Santiago Leon
2006-10-03 17:24 ` [PATCH 3/5] ibmveth: kdump interrupt fix Santiago Leon
2006-10-03 17:24 ` [PATCH 4/5] ibmveth: rename proc entry name Santiago Leon
2006-10-03 17:24 ` [PATCH 5/5] ibmveth: fix int rollover panic Santiago Leon
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).