Commit 0429f237 authored by David S. Miller's avatar David S. Miller

Merge branch 's390-qeth-fixes'

Julian Wiedmann says:

====================
s390/qeth: fixes 2019-02-04

please apply the following four fixes to -net.

Patch 1 takes care of a common resource leak in various error paths, while the
second patch fixes a misordered kfree when cleaning up after an error.
The other two patches ensure that there's no stale work dangling on workqueues
when the qeth device has already been offlined and/or removed.
====================
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents c1f7e029 c0a2e4d1
...@@ -22,6 +22,7 @@ ...@@ -22,6 +22,7 @@
#include <linux/hashtable.h> #include <linux/hashtable.h>
#include <linux/ip.h> #include <linux/ip.h>
#include <linux/refcount.h> #include <linux/refcount.h>
#include <linux/workqueue.h>
#include <net/ipv6.h> #include <net/ipv6.h>
#include <net/if_inet6.h> #include <net/if_inet6.h>
...@@ -789,6 +790,7 @@ struct qeth_card { ...@@ -789,6 +790,7 @@ struct qeth_card {
struct qeth_seqno seqno; struct qeth_seqno seqno;
struct qeth_card_options options; struct qeth_card_options options;
struct workqueue_struct *event_wq;
wait_queue_head_t wait_q; wait_queue_head_t wait_q;
spinlock_t mclock; spinlock_t mclock;
unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)]; unsigned long active_vlans[BITS_TO_LONGS(VLAN_N_VID)];
...@@ -962,7 +964,6 @@ extern const struct attribute_group *qeth_osn_attr_groups[]; ...@@ -962,7 +964,6 @@ extern const struct attribute_group *qeth_osn_attr_groups[];
extern const struct attribute_group qeth_device_attr_group; extern const struct attribute_group qeth_device_attr_group;
extern const struct attribute_group qeth_device_blkt_group; extern const struct attribute_group qeth_device_blkt_group;
extern const struct device_type qeth_generic_devtype; extern const struct device_type qeth_generic_devtype;
extern struct workqueue_struct *qeth_wq;
int qeth_card_hw_is_reachable(struct qeth_card *); int qeth_card_hw_is_reachable(struct qeth_card *);
const char *qeth_get_cardname_short(struct qeth_card *); const char *qeth_get_cardname_short(struct qeth_card *);
......
...@@ -74,8 +74,7 @@ static void qeth_notify_skbs(struct qeth_qdio_out_q *queue, ...@@ -74,8 +74,7 @@ static void qeth_notify_skbs(struct qeth_qdio_out_q *queue,
static void qeth_release_skbs(struct qeth_qdio_out_buffer *buf); static void qeth_release_skbs(struct qeth_qdio_out_buffer *buf);
static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *, int); static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *, int);
struct workqueue_struct *qeth_wq; static struct workqueue_struct *qeth_wq;
EXPORT_SYMBOL_GPL(qeth_wq);
int qeth_card_hw_is_reachable(struct qeth_card *card) int qeth_card_hw_is_reachable(struct qeth_card *card)
{ {
...@@ -566,6 +565,7 @@ static int __qeth_issue_next_read(struct qeth_card *card) ...@@ -566,6 +565,7 @@ static int __qeth_issue_next_read(struct qeth_card *card)
QETH_DBF_MESSAGE(2, "error %i on device %x when starting next read ccw!\n", QETH_DBF_MESSAGE(2, "error %i on device %x when starting next read ccw!\n",
rc, CARD_DEVID(card)); rc, CARD_DEVID(card));
atomic_set(&channel->irq_pending, 0); atomic_set(&channel->irq_pending, 0);
qeth_release_buffer(channel, iob);
card->read_or_write_problem = 1; card->read_or_write_problem = 1;
qeth_schedule_recovery(card); qeth_schedule_recovery(card);
wake_up(&card->wait_q); wake_up(&card->wait_q);
...@@ -1127,6 +1127,8 @@ static void qeth_irq(struct ccw_device *cdev, unsigned long intparm, ...@@ -1127,6 +1127,8 @@ static void qeth_irq(struct ccw_device *cdev, unsigned long intparm,
rc = qeth_get_problem(card, cdev, irb); rc = qeth_get_problem(card, cdev, irb);
if (rc) { if (rc) {
card->read_or_write_problem = 1; card->read_or_write_problem = 1;
if (iob)
qeth_release_buffer(iob->channel, iob);
qeth_clear_ipacmd_list(card); qeth_clear_ipacmd_list(card);
qeth_schedule_recovery(card); qeth_schedule_recovery(card);
goto out; goto out;
...@@ -1466,6 +1468,10 @@ static struct qeth_card *qeth_alloc_card(struct ccwgroup_device *gdev) ...@@ -1466,6 +1468,10 @@ static struct qeth_card *qeth_alloc_card(struct ccwgroup_device *gdev)
CARD_RDEV(card) = gdev->cdev[0]; CARD_RDEV(card) = gdev->cdev[0];
CARD_WDEV(card) = gdev->cdev[1]; CARD_WDEV(card) = gdev->cdev[1];
CARD_DDEV(card) = gdev->cdev[2]; CARD_DDEV(card) = gdev->cdev[2];
card->event_wq = alloc_ordered_workqueue("%s", 0, dev_name(&gdev->dev));
if (!card->event_wq)
goto out_wq;
if (qeth_setup_channel(&card->read, true)) if (qeth_setup_channel(&card->read, true))
goto out_ip; goto out_ip;
if (qeth_setup_channel(&card->write, true)) if (qeth_setup_channel(&card->write, true))
...@@ -1481,6 +1487,8 @@ static struct qeth_card *qeth_alloc_card(struct ccwgroup_device *gdev) ...@@ -1481,6 +1487,8 @@ static struct qeth_card *qeth_alloc_card(struct ccwgroup_device *gdev)
out_channel: out_channel:
qeth_clean_channel(&card->read); qeth_clean_channel(&card->read);
out_ip: out_ip:
destroy_workqueue(card->event_wq);
out_wq:
dev_set_drvdata(&gdev->dev, NULL); dev_set_drvdata(&gdev->dev, NULL);
kfree(card); kfree(card);
out: out:
...@@ -1809,6 +1817,7 @@ static int qeth_idx_activate_get_answer(struct qeth_card *card, ...@@ -1809,6 +1817,7 @@ static int qeth_idx_activate_get_answer(struct qeth_card *card,
QETH_DBF_MESSAGE(2, "Error2 in activating channel rc=%d\n", rc); QETH_DBF_MESSAGE(2, "Error2 in activating channel rc=%d\n", rc);
QETH_DBF_TEXT_(SETUP, 2, "2err%d", rc); QETH_DBF_TEXT_(SETUP, 2, "2err%d", rc);
atomic_set(&channel->irq_pending, 0); atomic_set(&channel->irq_pending, 0);
qeth_release_buffer(channel, iob);
wake_up(&card->wait_q); wake_up(&card->wait_q);
return rc; return rc;
} }
...@@ -1878,6 +1887,7 @@ static int qeth_idx_activate_channel(struct qeth_card *card, ...@@ -1878,6 +1887,7 @@ static int qeth_idx_activate_channel(struct qeth_card *card,
rc); rc);
QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc); QETH_DBF_TEXT_(SETUP, 2, "1err%d", rc);
atomic_set(&channel->irq_pending, 0); atomic_set(&channel->irq_pending, 0);
qeth_release_buffer(channel, iob);
wake_up(&card->wait_q); wake_up(&card->wait_q);
return rc; return rc;
} }
...@@ -2058,6 +2068,7 @@ int qeth_send_control_data(struct qeth_card *card, int len, ...@@ -2058,6 +2068,7 @@ int qeth_send_control_data(struct qeth_card *card, int len,
} }
reply = qeth_alloc_reply(card); reply = qeth_alloc_reply(card);
if (!reply) { if (!reply) {
qeth_release_buffer(channel, iob);
return -ENOMEM; return -ENOMEM;
} }
reply->callback = reply_cb; reply->callback = reply_cb;
...@@ -2389,11 +2400,12 @@ static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *q, int bidx) ...@@ -2389,11 +2400,12 @@ static int qeth_init_qdio_out_buf(struct qeth_qdio_out_q *q, int bidx)
return 0; return 0;
} }
static void qeth_free_qdio_out_buf(struct qeth_qdio_out_q *q) static void qeth_free_output_queue(struct qeth_qdio_out_q *q)
{ {
if (!q) if (!q)
return; return;
qeth_clear_outq_buffers(q, 1);
qdio_free_buffers(q->qdio_bufs, QDIO_MAX_BUFFERS_PER_Q); qdio_free_buffers(q->qdio_bufs, QDIO_MAX_BUFFERS_PER_Q);
kfree(q); kfree(q);
} }
...@@ -2467,10 +2479,8 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card) ...@@ -2467,10 +2479,8 @@ static int qeth_alloc_qdio_buffers(struct qeth_card *card)
card->qdio.out_qs[i]->bufs[j] = NULL; card->qdio.out_qs[i]->bufs[j] = NULL;
} }
out_freeoutq: out_freeoutq:
while (i > 0) { while (i > 0)
qeth_free_qdio_out_buf(card->qdio.out_qs[--i]); qeth_free_output_queue(card->qdio.out_qs[--i]);
qeth_clear_outq_buffers(card->qdio.out_qs[i], 1);
}
kfree(card->qdio.out_qs); kfree(card->qdio.out_qs);
card->qdio.out_qs = NULL; card->qdio.out_qs = NULL;
out_freepool: out_freepool:
...@@ -2503,10 +2513,8 @@ static void qeth_free_qdio_buffers(struct qeth_card *card) ...@@ -2503,10 +2513,8 @@ static void qeth_free_qdio_buffers(struct qeth_card *card)
qeth_free_buffer_pool(card); qeth_free_buffer_pool(card);
/* free outbound qdio_qs */ /* free outbound qdio_qs */
if (card->qdio.out_qs) { if (card->qdio.out_qs) {
for (i = 0; i < card->qdio.no_out_queues; ++i) { for (i = 0; i < card->qdio.no_out_queues; i++)
qeth_clear_outq_buffers(card->qdio.out_qs[i], 1); qeth_free_output_queue(card->qdio.out_qs[i]);
qeth_free_qdio_out_buf(card->qdio.out_qs[i]);
}
kfree(card->qdio.out_qs); kfree(card->qdio.out_qs);
card->qdio.out_qs = NULL; card->qdio.out_qs = NULL;
} }
...@@ -5028,6 +5036,7 @@ static void qeth_core_free_card(struct qeth_card *card) ...@@ -5028,6 +5036,7 @@ static void qeth_core_free_card(struct qeth_card *card)
qeth_clean_channel(&card->read); qeth_clean_channel(&card->read);
qeth_clean_channel(&card->write); qeth_clean_channel(&card->write);
qeth_clean_channel(&card->data); qeth_clean_channel(&card->data);
destroy_workqueue(card->event_wq);
qeth_free_qdio_buffers(card); qeth_free_qdio_buffers(card);
unregister_service_level(&card->qeth_service_level); unregister_service_level(&card->qeth_service_level);
dev_set_drvdata(&card->gdev->dev, NULL); dev_set_drvdata(&card->gdev->dev, NULL);
......
...@@ -369,6 +369,8 @@ static void qeth_l2_stop_card(struct qeth_card *card, int recovery_mode) ...@@ -369,6 +369,8 @@ static void qeth_l2_stop_card(struct qeth_card *card, int recovery_mode)
qeth_clear_cmd_buffers(&card->read); qeth_clear_cmd_buffers(&card->read);
qeth_clear_cmd_buffers(&card->write); qeth_clear_cmd_buffers(&card->write);
} }
flush_workqueue(card->event_wq);
} }
static int qeth_l2_process_inbound_buffer(struct qeth_card *card, static int qeth_l2_process_inbound_buffer(struct qeth_card *card,
...@@ -801,6 +803,8 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev) ...@@ -801,6 +803,8 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)
if (cgdev->state == CCWGROUP_ONLINE) if (cgdev->state == CCWGROUP_ONLINE)
qeth_l2_set_offline(cgdev); qeth_l2_set_offline(cgdev);
cancel_work_sync(&card->close_dev_work);
if (qeth_netdev_is_registered(card->dev)) if (qeth_netdev_is_registered(card->dev))
unregister_netdev(card->dev); unregister_netdev(card->dev);
} }
...@@ -1434,7 +1438,7 @@ static void qeth_bridge_state_change(struct qeth_card *card, ...@@ -1434,7 +1438,7 @@ static void qeth_bridge_state_change(struct qeth_card *card,
data->card = card; data->card = card;
memcpy(&data->qports, qports, memcpy(&data->qports, qports,
sizeof(struct qeth_sbp_state_change) + extrasize); sizeof(struct qeth_sbp_state_change) + extrasize);
queue_work(qeth_wq, &data->worker); queue_work(card->event_wq, &data->worker);
} }
struct qeth_bridge_host_data { struct qeth_bridge_host_data {
...@@ -1506,7 +1510,7 @@ static void qeth_bridge_host_event(struct qeth_card *card, ...@@ -1506,7 +1510,7 @@ static void qeth_bridge_host_event(struct qeth_card *card,
data->card = card; data->card = card;
memcpy(&data->hostevs, hostevs, memcpy(&data->hostevs, hostevs,
sizeof(struct qeth_ipacmd_addr_change) + extrasize); sizeof(struct qeth_ipacmd_addr_change) + extrasize);
queue_work(qeth_wq, &data->worker); queue_work(card->event_wq, &data->worker);
} }
/* SETBRIDGEPORT support; sending commands */ /* SETBRIDGEPORT support; sending commands */
......
...@@ -1433,6 +1433,8 @@ static void qeth_l3_stop_card(struct qeth_card *card, int recovery_mode) ...@@ -1433,6 +1433,8 @@ static void qeth_l3_stop_card(struct qeth_card *card, int recovery_mode)
qeth_clear_cmd_buffers(&card->read); qeth_clear_cmd_buffers(&card->read);
qeth_clear_cmd_buffers(&card->write); qeth_clear_cmd_buffers(&card->write);
} }
flush_workqueue(card->event_wq);
} }
/* /*
...@@ -2338,6 +2340,7 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev) ...@@ -2338,6 +2340,7 @@ static void qeth_l3_remove_device(struct ccwgroup_device *cgdev)
if (cgdev->state == CCWGROUP_ONLINE) if (cgdev->state == CCWGROUP_ONLINE)
qeth_l3_set_offline(cgdev); qeth_l3_set_offline(cgdev);
cancel_work_sync(&card->close_dev_work);
if (qeth_netdev_is_registered(card->dev)) if (qeth_netdev_is_registered(card->dev))
unregister_netdev(card->dev); unregister_netdev(card->dev);
qeth_l3_clear_ip_htable(card, 0); qeth_l3_clear_ip_htable(card, 0);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment