Commit 1273a800 authored by Julian Wiedmann's avatar Julian Wiedmann Committed by David S. Miller

s390/qeth: remove qeth_wait_for_buffer()

The basic MPC initialization sequence is strictly sequential, and
waiting for an available cmd buffer should never be necessary.
So this change only affects the OSN path, where dangling waiters on an
unbounded wait_event() are not desirable. Switch to qeth_get_buffers(),
and let OSN callers deal with -ENOMEM.
Signed-off-by: default avatarJulian Wiedmann <jwi@linux.ibm.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 09ac887f
...@@ -998,7 +998,7 @@ void qeth_tx_timeout(struct net_device *); ...@@ -998,7 +998,7 @@ void qeth_tx_timeout(struct net_device *);
void qeth_release_buffer(struct qeth_channel *, 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, void qeth_prepare_ipa_cmd(struct qeth_card *card, struct qeth_cmd_buffer *iob,
u16 cmd_length); u16 cmd_length);
struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *); struct qeth_cmd_buffer *qeth_get_buffer(struct qeth_channel *channel);
int qeth_query_switch_attributes(struct qeth_card *card, int qeth_query_switch_attributes(struct qeth_card *card,
struct qeth_switch_info *sw_info); struct qeth_switch_info *sw_info);
int qeth_query_card_info(struct qeth_card *card, int qeth_query_card_info(struct qeth_card *card,
......
...@@ -65,7 +65,6 @@ static struct lock_class_key qdio_out_skb_queue_key; ...@@ -65,7 +65,6 @@ static struct lock_class_key qdio_out_skb_queue_key;
static void qeth_issue_next_read_cb(struct qeth_card *card, static void qeth_issue_next_read_cb(struct qeth_card *card,
struct qeth_channel *channel, struct qeth_channel *channel,
struct qeth_cmd_buffer *iob); 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 void qeth_free_buffer_pool(struct qeth_card *);
static int qeth_qdio_establish(struct qeth_card *); static int qeth_qdio_establish(struct qeth_card *);
static void qeth_free_qdio_queues(struct qeth_card *card); static void qeth_free_qdio_queues(struct qeth_card *card);
...@@ -746,7 +745,7 @@ static void qeth_cancel_cmd(struct qeth_cmd_buffer *iob, int rc) ...@@ -746,7 +745,7 @@ static void qeth_cancel_cmd(struct qeth_cmd_buffer *iob, int rc)
qeth_release_buffer(iob->channel, iob); qeth_release_buffer(iob->channel, iob);
} }
static struct qeth_cmd_buffer *qeth_get_buffer(struct qeth_channel *channel) struct qeth_cmd_buffer *qeth_get_buffer(struct qeth_channel *channel)
{ {
struct qeth_cmd_buffer *buffer = NULL; struct qeth_cmd_buffer *buffer = NULL;
unsigned long flags; unsigned long flags;
...@@ -756,15 +755,7 @@ static struct qeth_cmd_buffer *qeth_get_buffer(struct qeth_channel *channel) ...@@ -756,15 +755,7 @@ static struct qeth_cmd_buffer *qeth_get_buffer(struct qeth_channel *channel)
spin_unlock_irqrestore(&channel->iob_lock, flags); spin_unlock_irqrestore(&channel->iob_lock, flags);
return buffer; return buffer;
} }
EXPORT_SYMBOL_GPL(qeth_get_buffer);
struct qeth_cmd_buffer *qeth_wait_for_buffer(struct qeth_channel *channel)
{
struct qeth_cmd_buffer *buffer;
wait_event(channel->wait_q,
((buffer = qeth_get_buffer(channel)) != NULL));
return buffer;
}
EXPORT_SYMBOL_GPL(qeth_wait_for_buffer);
void qeth_clear_cmd_buffers(struct qeth_channel *channel) void qeth_clear_cmd_buffers(struct qeth_channel *channel)
{ {
...@@ -1794,6 +1785,16 @@ static void qeth_mpc_finalize_cmd(struct qeth_card *card, ...@@ -1794,6 +1785,16 @@ static void qeth_mpc_finalize_cmd(struct qeth_card *card,
iob->callback = qeth_release_buffer_cb; iob->callback = qeth_release_buffer_cb;
} }
static struct qeth_cmd_buffer *qeth_mpc_get_cmd_buffer(struct qeth_card *card)
{
struct qeth_cmd_buffer *iob;
iob = qeth_get_buffer(&card->write);
if (iob)
iob->finalize = qeth_mpc_finalize_cmd;
return iob;
}
/** /**
* qeth_send_control_data() - send control command to the card * qeth_send_control_data() - send control command to the card
* @card: qeth_card structure pointer * @card: qeth_card structure pointer
...@@ -2102,10 +2103,11 @@ static int qeth_cm_enable(struct qeth_card *card) ...@@ -2102,10 +2103,11 @@ static int qeth_cm_enable(struct qeth_card *card)
QETH_DBF_TEXT(SETUP, 2, "cmenable"); QETH_DBF_TEXT(SETUP, 2, "cmenable");
iob = qeth_wait_for_buffer(&card->write); iob = qeth_mpc_get_cmd_buffer(card);
iob->finalize = qeth_mpc_finalize_cmd; if (!iob)
memcpy(iob->data, CM_ENABLE, CM_ENABLE_SIZE); return -ENOMEM;
memcpy(iob->data, CM_ENABLE, CM_ENABLE_SIZE);
memcpy(QETH_CM_ENABLE_ISSUER_RM_TOKEN(iob->data), memcpy(QETH_CM_ENABLE_ISSUER_RM_TOKEN(iob->data),
&card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH); &card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH);
memcpy(QETH_CM_ENABLE_FILTER_TOKEN(iob->data), memcpy(QETH_CM_ENABLE_FILTER_TOKEN(iob->data),
...@@ -2137,10 +2139,11 @@ static int qeth_cm_setup(struct qeth_card *card) ...@@ -2137,10 +2139,11 @@ static int qeth_cm_setup(struct qeth_card *card)
QETH_DBF_TEXT(SETUP, 2, "cmsetup"); QETH_DBF_TEXT(SETUP, 2, "cmsetup");
iob = qeth_wait_for_buffer(&card->write); iob = qeth_mpc_get_cmd_buffer(card);
iob->finalize = qeth_mpc_finalize_cmd; if (!iob)
memcpy(iob->data, CM_SETUP, CM_SETUP_SIZE); return -ENOMEM;
memcpy(iob->data, CM_SETUP, CM_SETUP_SIZE);
memcpy(QETH_CM_SETUP_DEST_ADDR(iob->data), memcpy(QETH_CM_SETUP_DEST_ADDR(iob->data),
&card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH); &card->token.issuer_rm_r, QETH_MPC_TOKEN_LENGTH);
memcpy(QETH_CM_SETUP_CONNECTION_TOKEN(iob->data), memcpy(QETH_CM_SETUP_CONNECTION_TOKEN(iob->data),
...@@ -2256,10 +2259,11 @@ static int qeth_ulp_enable(struct qeth_card *card) ...@@ -2256,10 +2259,11 @@ static int qeth_ulp_enable(struct qeth_card *card)
/*FIXME: trace view callbacks*/ /*FIXME: trace view callbacks*/
QETH_DBF_TEXT(SETUP, 2, "ulpenabl"); QETH_DBF_TEXT(SETUP, 2, "ulpenabl");
iob = qeth_wait_for_buffer(&card->write); iob = qeth_mpc_get_cmd_buffer(card);
iob->finalize = qeth_mpc_finalize_cmd; if (!iob)
memcpy(iob->data, ULP_ENABLE, ULP_ENABLE_SIZE); return -ENOMEM;
memcpy(iob->data, ULP_ENABLE, ULP_ENABLE_SIZE);
*(QETH_ULP_ENABLE_LINKNUM(iob->data)) = (u8) card->dev->dev_port; *(QETH_ULP_ENABLE_LINKNUM(iob->data)) = (u8) card->dev->dev_port;
memcpy(QETH_ULP_ENABLE_PROT_TYPE(iob->data), &prot_type, 1); memcpy(QETH_ULP_ENABLE_PROT_TYPE(iob->data), &prot_type, 1);
memcpy(QETH_ULP_ENABLE_DEST_ADDR(iob->data), memcpy(QETH_ULP_ENABLE_DEST_ADDR(iob->data),
...@@ -2303,10 +2307,11 @@ static int qeth_ulp_setup(struct qeth_card *card) ...@@ -2303,10 +2307,11 @@ static int qeth_ulp_setup(struct qeth_card *card)
QETH_DBF_TEXT(SETUP, 2, "ulpsetup"); QETH_DBF_TEXT(SETUP, 2, "ulpsetup");
iob = qeth_wait_for_buffer(&card->write); iob = qeth_mpc_get_cmd_buffer(card);
iob->finalize = qeth_mpc_finalize_cmd; if (!iob)
memcpy(iob->data, ULP_SETUP, ULP_SETUP_SIZE); return -ENOMEM;
memcpy(iob->data, ULP_SETUP, ULP_SETUP_SIZE);
memcpy(QETH_ULP_SETUP_DEST_ADDR(iob->data), memcpy(QETH_ULP_SETUP_DEST_ADDR(iob->data),
&card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH); &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH);
memcpy(QETH_ULP_SETUP_CONNECTION_TOKEN(iob->data), memcpy(QETH_ULP_SETUP_CONNECTION_TOKEN(iob->data),
...@@ -2492,10 +2497,11 @@ static int qeth_dm_act(struct qeth_card *card) ...@@ -2492,10 +2497,11 @@ static int qeth_dm_act(struct qeth_card *card)
QETH_DBF_TEXT(SETUP, 2, "dmact"); QETH_DBF_TEXT(SETUP, 2, "dmact");
iob = qeth_wait_for_buffer(&card->write); iob = qeth_mpc_get_cmd_buffer(card);
iob->finalize = qeth_mpc_finalize_cmd; if (!iob)
memcpy(iob->data, DM_ACT, DM_ACT_SIZE); return -ENOMEM;
memcpy(iob->data, DM_ACT, DM_ACT_SIZE);
memcpy(QETH_DM_ACT_DEST_ADDR(iob->data), memcpy(QETH_DM_ACT_DEST_ADDR(iob->data),
&card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH); &card->token.cm_connection_r, QETH_MPC_TOKEN_LENGTH);
memcpy(QETH_DM_ACT_CONNECTION_TOKEN(iob->data), memcpy(QETH_DM_ACT_CONNECTION_TOKEN(iob->data),
......
...@@ -1084,7 +1084,10 @@ int qeth_osn_assist(struct net_device *dev, void *data, int data_len) ...@@ -1084,7 +1084,10 @@ int qeth_osn_assist(struct net_device *dev, void *data, int data_len)
QETH_CARD_TEXT(card, 2, "osnsdmc"); QETH_CARD_TEXT(card, 2, "osnsdmc");
if (!qeth_card_hw_is_reachable(card)) if (!qeth_card_hw_is_reachable(card))
return -ENODEV; return -ENODEV;
iob = qeth_wait_for_buffer(&card->write); iob = qeth_get_buffer(&card->write);
if (!iob)
return -ENOMEM;
qeth_prepare_ipa_cmd(card, iob, (u16) data_len); qeth_prepare_ipa_cmd(card, iob, (u16) data_len);
memcpy(__ipa_cmd(iob), data, data_len); memcpy(__ipa_cmd(iob), data, data_len);
return qeth_osn_send_ipa_cmd(card, iob); return qeth_osn_send_ipa_cmd(card, iob);
......
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