s390/qeth: updates 2019-03-28
Subsystems (4)
cover s390/qeth: updates 2019-03-28
Hi Dave,
please apply the following patchset to net-next. This reworks the control IO code in qeth so that we no longer need to poll for cmd completion, and refactors the IDX setup code to also use this improved IO path.
Thanks,
Julian
Julian Wiedmann (10):
s390/qeth: defer RX modesetting
s390/qeth: remove locking for RX modeset cache s390/qeth: add wrapper for IP table access s390/qeth: defer IPv6 address notifier events s390/qeth: convert IP table spinlock to mutex s390/qeth: don't poll for cmd IO completion s390/qeth: clarify default cmd callback s390/qeth: let qeth_notify_reply() set the notify reason s390/qeth: use callback to finalize cmd s390/qeth: send IDX cmds via qeth_send_control_data()
drivers/s390/net/qeth_core.h | 21 +- drivers/s390/net/qeth_core_main.c | 567 +++++++++++++++++++------------------- drivers/s390/net/qeth_l2_main.c | 36 ++- drivers/s390/net/qeth_l3_main.c | 167 +++++++---- drivers/s390/net/qeth_l3_sys.c | 20 +- 5 files changed, 440 insertions(+), 371 deletions(-)
Signature · 1 line
2.16.4
PATCH 1/10 s390/qeth: defer RX modesetting
.ndo_set_rx_mode gets called in process context, but while holding the addr_list spinlock. Which means we currently can't sleep while re-programming the HW, and need to poll for IO completion. That's bad, in particular since receiving the cmd response can fail silently and we're then polling until the timeout hits.
As a first step towards eliminating the IO completion polling, run the RX modeset from a work element and only take the addr_list lock while updating the RX mode address cache.
--- drivers/s390/net/qeth_core.h | 1 + drivers/s390/net/qeth_l2_main.c | 22 +++++++++++++++++---- drivers/s390/net/qeth_l3_main.c | 42 ++++++++++++++++++++++++++++------------- 3 files changed, 48 insertions(+), 17 deletions(-)
drivers/s390/net/qeth_core.h +1 -0
@@ -780,6 +780,7 @@ struct qeth_card {DECLARE_HASHTABLE (mac_htable,4 );DECLARE_HASHTABLE (ip_htable,4 );DECLARE_HASHTABLE (ip_mc_htable,4 ); +struct work_struct rx_mode_work;struct work_struct kernel_thread_starter;spinlock_t thread_mask_lock;unsigned long thread_start_mask;
drivers/s390/net/qeth_l2_main.c +18 -4
@@ -149,7 +149,7 @@ static int qeth_l2_remove_mac(struct qeth_card *card, u8 *mac)return rc; } -static void qeth_l2_del_all_macs (struct qeth_card *card) +static void qeth_l2_drain_rx_mode_cache (struct qeth_card *card) {struct qeth_mac *mac;struct hlist_node *tmp;
@@ -292,8 +292,10 @@ static void qeth_l2_stop_card(struct qeth_card *card)qeth_set_allowed_threads (card,0 ,1 ); +cancel_work_sync (&card->rx_mode_work); +qeth_l2_drain_rx_mode_cache (card); +if (card->state ==CARD_STATE_SOFTSETUP ) { -qeth_l2_del_all_macs (card);qeth_clear_ipacmd_list (card); card->state =CARD_STATE_HARDSETUP ; }
@@ -515,9 +517,11 @@ static void qeth_l2_add_mac(struct qeth_card *card, struct netdev_hw_addr *ha)hash_add (card->mac_htable, &mac->hnode, mac_hash); } -static void qeth_l2_set_rx_mode (struct net_device *dev) +static void qeth_l2_rx_mode_work (struct work_struct *work) { -struct qeth_card *card = dev->ml_priv; + struct qeth_card *card = container_of(work, struct qeth_card, + rx_mode_work); +struct net_device *dev = card->dev;struct netdev_hw_addr *ha;struct qeth_mac *mac;struct hlist_node *tmp;
@@ -528,10 +532,12 @@ static void qeth_l2_set_rx_mode(struct net_device *dev)spin_lock_bh (&card->mclock); +netif_addr_lock_bh (dev);netdev_for_each_mc_addr (ha, dev)qeth_l2_add_mac (card, ha);netdev_for_each_uc_addr (ha, dev)qeth_l2_add_mac (card, ha); +netif_addr_unlock_bh (dev);hash_for_each_safe (card->mac_htable, i, tmp, mac, hnode) {switch (mac->disp_flag) {
@@ -653,6 +659,7 @@ static int qeth_l2_probe_device(struct ccwgroup_device *gdev) }hash_init (card->mac_htable); +INIT_WORK (&card->rx_mode_work, qeth_l2_rx_mode_work);return 0 ; }
@@ -673,6 +680,13 @@ static void qeth_l2_remove_device(struct ccwgroup_device *cgdev)unregister_netdev (card->dev); } +static void qeth_l2_set_rx_mode (struct net_device *dev) +{ +struct qeth_card *card = dev->ml_priv; + +schedule_work (&card->rx_mode_work); +} +static const struct net_device_ops qeth_l2_netdev_ops = { .ndo_open = qeth_open, .ndo_stop = qeth_stop,
drivers/s390/net/qeth_l3_main.c +29 -13
80 lines not on this page · raw message
Signature · 1 line
2.16.4
PATCH 2/10 s390/qeth: remove locking for RX modeset cache
In reply to Julian WiedmannThe L2 and L3 .ndo_set_rx_mode callbacks maintain an address cache to decide which addresses have changed since the last modeset.
When the card is set offline, qeth_l?_stop_card() drains this cache. This happens only after 1) the net_device has been detached, and
2) any pending RX modeset has completed. Consequently we can access the cache lock-free.
--- drivers/s390/net/qeth_core.h | 1 - drivers/s390/net/qeth_core_main.c | 1 - drivers/s390/net/qeth_l2_main.c | 6 ------ drivers/s390/net/qeth_l3_main.c | 6 ------ 4 files changed, 14 deletions(-)
drivers/s390/net/qeth_core.h +0 -1
@@ -775,7 +775,6 @@ struct qeth_card {struct workqueue_struct *event_wq;wait_queue_head_t wait_q; -spinlock_t mclock;unsigned long active_vlans[BITS_TO_LONGS (VLAN_N_VID )];DECLARE_HASHTABLE (mac_htable,4 );DECLARE_HASHTABLE (ip_htable,4 );
drivers/s390/net/qeth_core_main.c +0 -1
@@ -1409,7 +1409,6 @@ static void qeth_setup_card(struct qeth_card *card) card->info.type =CARD_RDEV (card)->id.driver_info; card->state =CARD_STATE_DOWN ; -spin_lock_init (&card->mclock);spin_lock_init (&card->lock);spin_lock_init (&card->ip_lock);spin_lock_init (&card->thread_mask_lock);
drivers/s390/net/qeth_l2_main.c +0 -6
@@ -155,12 +155,10 @@ static void qeth_l2_drain_rx_mode_cache(struct qeth_card *card)struct hlist_node *tmp;int i; -spin_lock_bh (&card->mclock);hash_for_each_safe (card->mac_htable, i, tmp, mac, hnode) {hash_del (&mac->hnode);kfree (mac); } -spin_unlock_bh (&card->mclock); }static int qeth_l2_get_cast_type (struct qeth_card *card,struct sk_buff *skb)
@@ -530,8 +528,6 @@ static void qeth_l2_rx_mode_work(struct work_struct *work)QETH_CARD_TEXT (card,3 ,"setmulti" ); -spin_lock_bh (&card->mclock); -netif_addr_lock_bh (dev);netdev_for_each_mc_addr (ha, dev)qeth_l2_add_mac (card, ha);
@@ -560,8 +556,6 @@ static void qeth_l2_rx_mode_work(struct work_struct *work) } } -spin_unlock_bh (&card->mclock); -if (qeth_adp_supported (card,IPA_SETADP_SET_PROMISC_MODE ))qeth_setadp_promisc_mode (card);else
drivers/s390/net/qeth_l3_main.c +0 -6
@@ -274,12 +274,10 @@ static void qeth_l3_drain_rx_mode_cache(struct qeth_card *card)struct hlist_node *tmp;int i; -spin_lock_bh (&card->mclock);hash_for_each_safe (card->ip_mc_htable, i, tmp, addr, hnode) {hash_del (&addr->hnode);kfree (addr); } -spin_unlock_bh (&card->mclock); }static void qeth_l3_clear_ip_htable (struct qeth_card *card,int recover)
@@ -1484,8 +1482,6 @@ static void qeth_l3_rx_mode_work(struct work_struct *work)QETH_CARD_TEXT (card,3 ,"setmulti" );if (!card->options.sniffer) { -spin_lock_bh (&card->mclock); -qeth_l3_add_multicast_ipv4 (card);qeth_l3_add_multicast_ipv6 (card);
@@ -1513,8 +1509,6 @@ static void qeth_l3_rx_mode_work(struct work_struct *work) } } -spin_unlock_bh (&card->mclock); -if (!qeth_adp_supported (card,IPA_SETADP_SET_PROMISC_MODE ))return ; }
Signature · 1 line
2.16.4
PATCH 3/10 s390/qeth: add wrapper for IP table access
In reply to Julian WiedmannExtract a little helper, so that high-level callers can manipulate the IP table without worrying about the locking. This will make it easier to convert the code to a different locking primitive later on.
--- drivers/s390/net/qeth_l3_main.c | 33 +++++++++++++++++---------------- 1 file changed, 17 insertions(+), 16 deletions(-)
drivers/s390/net/qeth_l3_main.c +17 -16
@@ -268,6 +268,18 @@ static int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *tmp_addr)return rc; } +static int qeth_l3_modify_ip (struct qeth_card *card,struct qeth_ipaddr *addr, +bool add) +{ +int rc; + +spin_lock_bh (&card->ip_lock); + rc = add ?qeth_l3_add_ip (card, addr) :qeth_l3_delete_ip (card, addr); +spin_unlock_bh (&card->ip_lock); + +return rc; +} +static void qeth_l3_drain_rx_mode_cache (struct qeth_card *card) {struct qeth_ipaddr *addr;
@@ -636,7 +648,6 @@ int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip, enum qeth_prot_versions proto) {struct qeth_ipaddr addr; -int rc;qeth_l3_init_ipaddr (&addr, type, proto);if (proto ==QETH_PROT_IPV4 )
@@ -644,16 +655,13 @@ int qeth_l3_modify_rxip_vipa(struct qeth_card *card, bool add, const u8 *ip,else memcpy (&addr.u.a6.addr, ip,16 ); -spin_lock_bh (&card->ip_lock); - rc = add ?qeth_l3_add_ip (card, &addr) :qeth_l3_delete_ip (card, &addr); -spin_unlock_bh (&card->ip_lock); -return rc; +return qeth_l3_modify_ip (card, &addr, add); }int qeth_l3_modify_hsuid (struct qeth_card *card,bool add) {struct qeth_ipaddr addr; -int rc, i; +unsigned int i;qeth_l3_init_ipaddr (&addr,QETH_IP_TYPE_NORMAL ,QETH_PROT_IPV6 ); addr.u.a6.addr.s6_addr[0 ] =0xfe ;
@@ -661,10 +669,7 @@ int qeth_l3_modify_hsuid(struct qeth_card *card, bool add)for (i =0 ; i <8 ; i++) addr.u.a6.addr.s6_addr[8 +i] = card->options.hsuid[i]; -spin_lock_bh (&card->ip_lock); - rc = add ?qeth_l3_add_ip (card, &addr) :qeth_l3_delete_ip (card, &addr); -spin_unlock_bh (&card->ip_lock); -return rc; +return qeth_l3_modify_ip (card, &addr, add); } static int qeth_l3_register_addr_entry(struct qeth_card *card,
@@ -2527,14 +2532,10 @@ static int qeth_l3_handle_ip_event(struct qeth_card *card, {switch (event) {case NETDEV_UP : -spin_lock_bh (&card->ip_lock); -qeth_l3_add_ip (card, addr); -spin_unlock_bh (&card->ip_lock); +qeth_l3_modify_ip (card, addr, true);return NOTIFY_OK ;case NETDEV_DOWN : -spin_lock_bh (&card->ip_lock); -qeth_l3_delete_ip (card, addr); -spin_unlock_bh (&card->ip_lock); +qeth_l3_modify_ip (card, addr, false);return NOTIFY_OK ;default :return NOTIFY_DONE ;
Signature · 1 line
2.16.4
PATCH 4/10 s390/qeth: defer IPv6 address notifier events
In reply to Julian WiedmannThe inet6addr_chain is atomic. So instead of starting the cmd IO for SETIP / DELIP straight from the notifier callback, run it from a workqueue. This is the last step towards removal of cmd IO completion polling.
--- drivers/s390/net/qeth_core.h | 1 + drivers/s390/net/qeth_core_main.c | 3 +- drivers/s390/net/qeth_l3_main.c | 60 +++++++++++++++++++++++++++++++++++---- 3 files changed, 57 insertions(+), 7 deletions(-)
drivers/s390/net/qeth_core.h +1 -0
@@ -774,6 +774,7 @@ struct qeth_card {struct qeth_card_options options;struct workqueue_struct *event_wq; +struct workqueue_struct *cmd_wq;wait_queue_head_t wait_q;unsigned long active_vlans[BITS_TO_LONGS (VLAN_N_VID )];DECLARE_HASHTABLE (mac_htable,4 );
drivers/s390/net/qeth_core_main.c +2 -1
@@ -1450,7 +1450,8 @@ static struct qeth_card *qeth_alloc_card(struct ccwgroup_device *gdev)CARD_WDEV (card) = gdev->cdev[1 ];CARD_DDEV (card) = gdev->cdev[2 ]; - card->event_wq =alloc_ordered_workqueue ("%s" ,0 ,dev_name (&gdev->dev)); + card->event_wq =alloc_ordered_workqueue ("%s_event" ,0 , +dev_name (&gdev->dev));if (!card->event_wq) goto out_wq;if (qeth_setup_channel (&card->read, true))
drivers/s390/net/qeth_l3_main.c +54 -6
97 lines not on this page · raw message
Signature · 1 line
2.16.4
PATCH 5/10 s390/qeth: convert IP table spinlock to mutex
In reply to Julian WiedmannAll users of the lock are running in process context now.
--- drivers/s390/net/qeth_core.h | 2 +- drivers/s390/net/qeth_core_main.c | 1 - drivers/s390/net/qeth_l3_main.c | 34 +++++++++++++++++----------------- drivers/s390/net/qeth_l3_sys.c | 20 ++++++++++---------- 4 files changed, 28 insertions(+), 29 deletions(-)
drivers/s390/net/qeth_core.h +1 -1
@@ -779,6 +779,7 @@ struct qeth_card {unsigned long active_vlans[BITS_TO_LONGS (VLAN_N_VID )];DECLARE_HASHTABLE (mac_htable,4 );DECLARE_HASHTABLE (ip_htable,4 ); +struct mutex ip_lock;DECLARE_HASHTABLE (ip_mc_htable,4 );struct work_struct rx_mode_work;struct work_struct kernel_thread_starter;
@@ -786,7 +787,6 @@ struct qeth_card {unsigned long thread_start_mask;unsigned long thread_allowed_mask;unsigned long thread_running_mask; -spinlock_t ip_lock;struct qeth_ipato ipato;struct list_head cmd_waiter_list;/* QDIO buffer handling */
drivers/s390/net/qeth_core_main.c +0 -1
@@ -1410,7 +1410,6 @@ static void qeth_setup_card(struct qeth_card *card) card->info.type =CARD_RDEV (card)->id.driver_info; card->state =CARD_STATE_DOWN ;spin_lock_init (&card->lock); -spin_lock_init (&card->ip_lock);spin_lock_init (&card->thread_mask_lock);mutex_init (&card->conf_mutex);mutex_init (&card->discipline_mutex);
drivers/s390/net/qeth_l3_main.c +17 -17
@@ -246,9 +246,9 @@ static int qeth_l3_add_ip(struct qeth_card *card, struct qeth_ipaddr *tmp_addr)*/ if (addr->proto ==QETH_PROT_IPV4 ) { addr->in_progress =1 ; -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock); rc =qeth_l3_register_addr_entry (card, addr); -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock); addr->in_progress =0 ; }else rc =qeth_l3_register_addr_entry (card, addr);
@@ -273,9 +273,9 @@ static int qeth_l3_modify_ip(struct qeth_card *card, struct qeth_ipaddr *addr, {int rc; -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock); rc = add ?qeth_l3_add_ip (card, addr) :qeth_l3_delete_ip (card, addr); -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock);return rc; }
@@ -300,7 +300,7 @@ static void qeth_l3_clear_ip_htable(struct qeth_card *card, int recover)QETH_CARD_TEXT (card,4 ,"clearip" ); -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);hash_for_each_safe (card->ip_htable, i, tmp, addr, hnode) {if (!recover) {
@@ -311,7 +311,7 @@ static void qeth_l3_clear_ip_htable(struct qeth_card *card, int recover) addr->disp_flag =QETH_DISP_ADDR_ADD ; } -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock); }static void qeth_l3_recover_ip (struct qeth_card *card)
@@ -323,15 +323,15 @@ static void qeth_l3_recover_ip(struct qeth_card *card)QETH_CARD_TEXT (card,4 ,"recovrip" ); -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);hash_for_each_safe (card->ip_htable, i, tmp, addr, hnode) {if (addr->disp_flag ==QETH_DISP_ADDR_ADD ) {if (addr->proto ==QETH_PROT_IPV4 ) { addr->in_progress =1 ; -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock); rc =qeth_l3_register_addr_entry (card, addr); -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock); addr->in_progress =0 ; }else rc =qeth_l3_register_addr_entry (card, addr);
@@ -347,8 +347,7 @@ static void qeth_l3_recover_ip(struct qeth_card *card) } } -spin_unlock_bh (&card->ip_lock); - +mutex_unlock (&card->ip_lock); } static int qeth_l3_setdelip_cb(struct qeth_card *card, struct qeth_reply *reply,
@@ -573,7 +572,7 @@ static void qeth_l3_clear_ipato_list(struct qeth_card *card) {struct qeth_ipato_entry *ipatoe, *tmp; -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);list_for_each_entry_safe (ipatoe, tmp, &card->ipato.entries, entry) {list_del (&ipatoe->entry);
@@ -581,7 +580,7 @@ static void qeth_l3_clear_ipato_list(struct qeth_card *card) }qeth_l3_update_ipato (card); -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock); } int qeth_l3_add_ipato_entry(struct qeth_card *card,
@@ -592,7 +591,7 @@ int qeth_l3_add_ipato_entry(struct qeth_card *card,QETH_CARD_TEXT (card,2 ,"addipato" ); -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);list_for_each_entry (ipatoe, &card->ipato.entries, entry) {if (ipatoe->proto != new->proto)
@@ -610,7 +609,7 @@ int qeth_l3_add_ipato_entry(struct qeth_card *card,qeth_l3_update_ipato (card); } -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock);return rc; }
@@ -624,7 +623,7 @@ int qeth_l3_del_ipato_entry(struct qeth_card *card,QETH_CARD_TEXT (card,2 ,"delipato" ); -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);list_for_each_entry_safe (ipatoe, tmp, &card->ipato.entries, entry) {if (ipatoe->proto != proto)
@@ -639,7 +638,7 @@ int qeth_l3_del_ipato_entry(struct qeth_card *card, } } -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock);return rc; }
@@ -2267,6 +2266,7 @@ static int qeth_l3_probe_device(struct ccwgroup_device *gdev)int rc;hash_init (card->ip_htable); +mutex_init (&card->ip_lock); card->cmd_wq =alloc_ordered_workqueue ("%s_cmd" ,0 ,dev_name (&gdev->dev));if (!card->cmd_wq)
drivers/s390/net/qeth_l3_sys.c +10 -10
@@ -367,9 +367,9 @@ static ssize_t qeth_l3_dev_ipato_enable_store(struct device *dev,if (card->ipato.enabled != enable) { card->ipato.enabled = enable; -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);qeth_l3_update_ipato (card); -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock); } out:mutex_unlock (&card->conf_mutex);
@@ -412,9 +412,9 @@ static ssize_t qeth_l3_dev_ipato_invert4_store(struct device *dev,if (card->ipato.invert4 != invert) { card->ipato.invert4 = invert; -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);qeth_l3_update_ipato (card); -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock); } out:mutex_unlock (&card->conf_mutex);
@@ -436,7 +436,7 @@ static ssize_t qeth_l3_dev_ipato_add_show(char *buf, struct qeth_card *card, entry_len = (proto ==QETH_PROT_IPV4 )?12 :40 ;/* add strlen for "/<mask>\n" */ entry_len += (proto ==QETH_PROT_IPV4 )?5 :6 ; -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);list_for_each_entry (ipatoe, &card->ipato.entries, entry) {if (ipatoe->proto != proto)continue ;
@@ -449,7 +449,7 @@ static ssize_t qeth_l3_dev_ipato_add_show(char *buf, struct qeth_card *card, i +=snprintf (buf + i,PAGE_SIZE - i,"%s/%i\n" , addr_str, ipatoe->mask_bits); } -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock); i +=snprintf (buf + i,PAGE_SIZE - i,"\n" );return i;
@@ -598,9 +598,9 @@ static ssize_t qeth_l3_dev_ipato_invert6_store(struct device *dev,if (card->ipato.invert6 != invert) { card->ipato.invert6 = invert; -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);qeth_l3_update_ipato (card); -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock); } out:mutex_unlock (&card->conf_mutex);
@@ -684,7 +684,7 @@ static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf, entry_len = (proto ==QETH_PROT_IPV4 )?12 :40 ; entry_len +=2 ;/* \n + terminator */ -spin_lock_bh (&card->ip_lock); +mutex_lock (&card->ip_lock);hash_for_each (card->ip_htable, i, ipaddr, hnode) {if (ipaddr->proto != proto || ipaddr->type != type)continue ;
@@ -698,7 +698,7 @@ static ssize_t qeth_l3_dev_ip_add_show(struct device *dev, char *buf, str_len +=snprintf (buf + str_len,PAGE_SIZE - str_len,"%s\n" , addr_str); } -spin_unlock_bh (&card->ip_lock); +mutex_unlock (&card->ip_lock); str_len +=snprintf (buf + str_len,PAGE_SIZE - str_len,"\n" );return str_len;
Signature · 1 line
2.16.4
PATCH 6/10 s390/qeth: don't poll for cmd IO completion
In reply to Julian WiedmannAll callers are running in process context now, so we can safely sleep in qeth_send_control_data() while waiting for a cmd to complete.
--- drivers/s390/net/qeth_core.h | 11 +++++-- drivers/s390/net/qeth_core_main.c | 60 ++++++++++++++++----------------------- drivers/s390/net/qeth_l2_main.c | 5 ++-- 3 files changed, 35 insertions(+), 41 deletions(-)
drivers/s390/net/qeth_core.h +9 -2
@@ -10,6 +10,7 @@#ifndef __QETH_CORE_H__#define __QETH_CORE_H__ +#include <linux/completion.h> #include <linux/if.h> #include <linux/if_arp.h> #include <linux/etherdevice.h>
@@ -21,6 +22,7 @@#include <linux/hashtable.h> #include <linux/ip.h> #include <linux/refcount.h> +#include <linux/wait.h> #include <linux/workqueue.h> #include <net/ipv6.h>
@@ -585,6 +587,7 @@ struct qeth_cmd_buffer {enum qeth_cmd_buffer_state state;struct qeth_channel *channel;struct qeth_reply *reply; +long timeout;unsigned char *data;void (*callback)(struct qeth_card *card,struct qeth_channel *channel,struct qeth_cmd_buffer *iob);
@@ -610,6 +613,11 @@ struct qeth_channel {int io_buf_no; }; +static inline bool qeth_trylock_channel (struct qeth_channel *channel) +{ +return atomic_cmpxchg (&channel->irq_pending,0 ,1 ) ==0 ; +} +/** * OSA card related definitions */
@@ -636,12 +644,11 @@ struct qeth_seqno {struct qeth_reply {struct list_head list; -wait_queue_head_t wait_q; +struct completion received;int (*callback)(struct qeth_card *,struct qeth_reply *,unsigned long );u32 seqno;unsigned long offset; -atomic_t received;int rc;void *param;refcount_t refcnt;
drivers/s390/net/qeth_core_main.c +24 -36
137 lines not on this page · raw message
drivers/s390/net/qeth_l2_main.c +2 -3
@@ -1050,13 +1050,12 @@ static int qeth_osn_send_control_data(struct qeth_card *card, int len,QETH_CARD_TEXT (card,5 ,"osndctrd" ); -wait_event (card->wait_q, -atomic_cmpxchg (&channel->irq_pending,0 ,1 ) ==0 ); +wait_event (card->wait_q,qeth_trylock_channel (channel));qeth_prepare_control_data (card, len, iob);QETH_CARD_TEXT (card,6 ,"osnoirqp" );spin_lock_irq (get_ccwdev_lock (channel->ccwdev)); rc =ccw_device_start_timeout (channel->ccwdev, channel->ccw, - (addr_t ) iob,0 ,0 ,QETH_IPA_TIMEOUT ); + (addr_t ) iob,0 ,0 , iob->timeout);spin_unlock_irq (get_ccwdev_lock (channel->ccwdev));if (rc) { QETH_DBF_MESSAGE(2, "qeth_osn_send_control_data: "
Signature · 1 line
2.16.4
PATCH 7/10 s390/qeth: clarify default cmd callback
In reply to Julian WiedmannCurrent code makes it look like qeth_send_control_data_cb() is some sort of default callback for all cmds. But in practice, it is only used for half of the cmd buffers we issue.
Reduce the confusion by only setting this callback for cmds that actually want it, and while at it give the callback a name that matches the established naming scheme.
--- drivers/s390/net/qeth_core_main.c | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-)
drivers/s390/net/qeth_core_main.c +9 -8
@@ -61,9 +61,9 @@ static struct kmem_cache *qeth_qdio_outbuf_cache;static struct device *qeth_core_root_dev;static struct lock_class_key qdio_out_skb_queue_key; -static void qeth_send_control_data_cb (struct qeth_card *card, -struct qeth_channel *channel, -struct qeth_cmd_buffer *iob); +static void qeth_issue_next_read_cb (struct qeth_card *card, +struct qeth_channel *channel, +struct qeth_cmd_buffer *iob);static struct qeth_cmd_buffer *qeth_get_buffer (struct qeth_channel *);static void qeth_free_buffer_pool (struct qeth_card *);static int qeth_qdio_establish (struct qeth_card *);
@@ -511,7 +511,9 @@ static int __qeth_issue_next_read(struct qeth_card *card) CARD_DEVID(card));return -ENOMEM ; } +qeth_setup_ccw (channel->ccw,CCW_CMD_READ ,QETH_BUFSIZE , iob->data); + iob->callback = qeth_issue_next_read_cb;QETH_CARD_TEXT (card,6 ,"noirqpnd" ); rc =ccw_device_start (channel->ccwdev, channel->ccw, (addr_t ) iob,0 ,0 );
@@ -721,7 +723,7 @@ void qeth_release_buffer(struct qeth_channel *channel,spin_lock_irqsave (&channel->iob_lock, flags); iob->state =BUF_STATE_FREE ; - iob->callback = qeth_send_control_data_cb; + iob->callback =NULL ;if (iob->reply) {qeth_put_reply (iob->reply); iob->reply =NULL ;
@@ -779,9 +781,9 @@ void qeth_clear_cmd_buffers(struct qeth_channel *channel) }EXPORT_SYMBOL_GPL (qeth_clear_cmd_buffers); -static void qeth_send_control_data_cb (struct qeth_card *card, -struct qeth_channel *channel, -struct qeth_cmd_buffer *iob) +static void qeth_issue_next_read_cb (struct qeth_card *card, +struct qeth_channel *channel, +struct qeth_cmd_buffer *iob) {struct qeth_ipa_cmd *cmd =NULL ;struct qeth_reply *reply =NULL ;
@@ -1272,7 +1274,6 @@ static int qeth_setup_channel(struct qeth_channel *channel, bool alloc_buffers)break ; channel->iob[cnt].state =BUF_STATE_FREE ; channel->iob[cnt].channel = channel; - channel->iob[cnt].callback = qeth_send_control_data_cb; }if (cnt <QETH_CMD_BUFFER_NO ) {qeth_clean_channel (channel);
Signature · 1 line
2.16.4
PATCH 8/10 s390/qeth: let qeth_notify_reply() set the notify reason
In reply to Julian WiedmannAs trivial cleanup before adding more users to qeth_notify_reply(), move the setup of reply->rc from the caller into the helper.
--- drivers/s390/net/qeth_core_main.c | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-)
drivers/s390/net/qeth_core_main.c +8 -14
@@ -577,8 +577,9 @@ static void qeth_dequeue_reply(struct qeth_card *card, struct qeth_reply *reply)spin_unlock_irq (&card->lock); } -static void qeth_notify_reply (struct qeth_reply *reply) +static void qeth_notify_reply (struct qeth_reply *reply,int reason) { + reply->rc = reason;complete (&reply->received); }
@@ -664,10 +665,8 @@ void qeth_clear_ipacmd_list(struct qeth_card *card)QETH_CARD_TEXT (card,4 ,"clipalst" );spin_lock_irqsave (&card->lock, flags); -list_for_each_entry (reply, &card->cmd_waiter_list, list) { - reply->rc = -EIO ; -qeth_notify_reply (reply); - } +list_for_each_entry (reply, &card->cmd_waiter_list, list) +qeth_notify_reply (reply, -EIO );spin_unlock_irqrestore (&card->lock, flags); }EXPORT_SYMBOL_GPL (qeth_clear_ipacmd_list);
@@ -744,10 +743,8 @@ static void qeth_cancel_cmd(struct qeth_cmd_buffer *iob, int rc) {struct qeth_reply *reply = iob->reply; -if (reply) { - reply->rc = rc; -qeth_notify_reply (reply); - } +if (reply) +qeth_notify_reply (reply, rc);qeth_release_buffer (iob->channel, iob); }
@@ -847,11 +844,8 @@ static void qeth_issue_next_read_cb(struct qeth_card *card, } } -if (rc <=0 ) { - reply->rc = rc; -qeth_notify_reply (reply); - } - +if (rc <=0 ) +qeth_notify_reply (reply, rc);qeth_put_reply (reply); out:
Signature · 1 line
2.16.4
PATCH 9/10 s390/qeth: use callback to finalize cmd
In reply to Julian WiedmannTo avoid concurrency issues, some parts of the cmd setup are delayed until qeth_send_control_data() holds the IO channel's irq_pending "lock". Rather than hard-coding those setup steps for each cmd type, have the cmd provide a callback. This will make it easier to also issue IDX commands via qeth_send_control_data().
--- drivers/s390/net/qeth_core.h | 4 +-- drivers/s390/net/qeth_core_main.c | 74 ++++++++++++++++++++++++--------------- drivers/s390/net/qeth_l2_main.c | 3 +- 3 files changed, 50 insertions(+), 31 deletions(-)
drivers/s390/net/qeth_core.h +2 -2
@@ -589,6 +589,8 @@ struct qeth_cmd_buffer {struct qeth_reply *reply;long timeout;unsigned char *data; +void (*finalize)(struct qeth_card *card,struct qeth_cmd_buffer *iob, +unsigned int length);void (*callback)(struct qeth_card *card,struct qeth_channel *channel,struct qeth_cmd_buffer *iob); };
@@ -991,8 +993,6 @@ void qeth_clear_qdio_buffers(struct qeth_card *);void qeth_setadp_promisc_mode (struct qeth_card *);int qeth_setadpparms_change_macaddr (struct qeth_card *);void qeth_tx_timeout (struct net_device *); -void qeth_prepare_control_data (struct qeth_card *,int , -struct qeth_cmd_buffer *);void qeth_release_buffer (struct qeth_channel *,struct qeth_cmd_buffer *);void qeth_prepare_ipa_cmd (struct qeth_card *card,struct qeth_cmd_buffer *iob,u16 cmd_length);
drivers/s390/net/qeth_core_main.c +46 -28
164 lines not on this page · raw message
drivers/s390/net/qeth_l2_main.c +2 -1
@@ -1051,7 +1051,8 @@ static int qeth_osn_send_control_data(struct qeth_card *card, int len,QETH_CARD_TEXT (card,5 ,"osndctrd" );wait_event (card->wait_q,qeth_trylock_channel (channel)); -qeth_prepare_control_data (card, len, iob); + iob->finalize (card, iob, len); +QETH_DBF_HEX (CTRL ,2 , iob->data,min (len,QETH_DBF_CTRL_LEN ));QETH_CARD_TEXT (card,6 ,"osnoirqp" );spin_lock_irq (get_ccwdev_lock (channel->ccwdev)); rc = ccw_device_start_timeout(channel->ccwdev, channel->ccw,
Signature · 1 line
2.16.4
PATCH 10/10 s390/qeth: send IDX cmds via qeth_send_control_data()
In reply to Julian WiedmannThis converts the IDX code to use qeth_send_control_data(), replacing a bunch of duplicated IO code and unbounded waits. It also allows the IDX sequence to benefit from the improved timeout & notify infrastructure, so that we can eliminate the DOWN -> ACTIVATING -> UP transition in the channel state machine.
The patch looks rather big, but most of it is a straight-forward conversion of the old IDX cmd setup & callbacks to the new model.
--- drivers/s390/net/qeth_core.h | 1 - drivers/s390/net/qeth_core_main.c | 417 +++++++++++++++++++------------------- 2 files changed, 206 insertions(+), 212 deletions(-)
drivers/s390/net/qeth_core.h +0 -1
@@ -540,7 +540,6 @@ struct qeth_qdio_info {enum qeth_channel_states {CH_STATE_UP ,CH_STATE_DOWN , -CH_STATE_ACTIVATING ,CH_STATE_HALTED ,CH_STATE_STOPPED ,CH_STATE_RCD ,
drivers/s390/net/qeth_core_main.c +206 -211
471 lines not on this page · raw message
Signature · 1 line
2.16.4
David Miller
maintainerFrom: Julian Wiedmann <[email protected]>
Date: Thu, 28 Mar 2019 16:39:18 +0100
Quoted 3 lines
please apply the following patchset to net-next. This reworks the control IO code in qeth so that we no longer need to poll for cmd completion, and refactors the IDX setup code to also use this improved IO path.
Series applied, thanks Julian.