Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2222bcb7 authored by Clemens Ladisch's avatar Clemens Ladisch Committed by Stefan Richter
Browse files

firewire: core: do not use del_timer_sync() in interrupt context



Because we might be in interrupt context, replace del_timer_sync() with
del_timer().  If the timer is already running, we know that it will
clean up the transaction, so we do not need to do any further processing
in the normal transaction handler.

Many thanks to Yong Zhang for diagnosing this.

Reported-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
Signed-off-by: default avatarClemens Ladisch <clemens@ladisch.de>
Signed-off-by: default avatarStefan Richter <stefanr@s5r6.in-berlin.de>
parent 1bf145fe
Loading
Loading
Loading
Loading
+10 −3
Original line number Original line Diff line number Diff line
@@ -81,6 +81,10 @@ static int close_transaction(struct fw_transaction *transaction,
	spin_lock_irqsave(&card->lock, flags);
	spin_lock_irqsave(&card->lock, flags);
	list_for_each_entry(t, &card->transaction_list, link) {
	list_for_each_entry(t, &card->transaction_list, link) {
		if (t == transaction) {
		if (t == transaction) {
			if (!del_timer(&t->split_timeout_timer)) {
				spin_unlock_irqrestore(&card->lock, flags);
				goto timed_out;
			}
			list_del_init(&t->link);
			list_del_init(&t->link);
			card->tlabel_mask &= ~(1ULL << t->tlabel);
			card->tlabel_mask &= ~(1ULL << t->tlabel);
			break;
			break;
@@ -89,11 +93,11 @@ static int close_transaction(struct fw_transaction *transaction,
	spin_unlock_irqrestore(&card->lock, flags);
	spin_unlock_irqrestore(&card->lock, flags);


	if (&t->link != &card->transaction_list) {
	if (&t->link != &card->transaction_list) {
		del_timer_sync(&t->split_timeout_timer);
		t->callback(card, rcode, NULL, 0, t->callback_data);
		t->callback(card, rcode, NULL, 0, t->callback_data);
		return 0;
		return 0;
	}
	}


 timed_out:
	return -ENOENT;
	return -ENOENT;
}
}


@@ -921,6 +925,10 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
	spin_lock_irqsave(&card->lock, flags);
	spin_lock_irqsave(&card->lock, flags);
	list_for_each_entry(t, &card->transaction_list, link) {
	list_for_each_entry(t, &card->transaction_list, link) {
		if (t->node_id == source && t->tlabel == tlabel) {
		if (t->node_id == source && t->tlabel == tlabel) {
			if (!del_timer(&t->split_timeout_timer)) {
				spin_unlock_irqrestore(&card->lock, flags);
				goto timed_out;
			}
			list_del_init(&t->link);
			list_del_init(&t->link);
			card->tlabel_mask &= ~(1ULL << t->tlabel);
			card->tlabel_mask &= ~(1ULL << t->tlabel);
			break;
			break;
@@ -929,6 +937,7 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
	spin_unlock_irqrestore(&card->lock, flags);
	spin_unlock_irqrestore(&card->lock, flags);


	if (&t->link == &card->transaction_list) {
	if (&t->link == &card->transaction_list) {
 timed_out:
		fw_notify("Unsolicited response (source %x, tlabel %x)\n",
		fw_notify("Unsolicited response (source %x, tlabel %x)\n",
			  source, tlabel);
			  source, tlabel);
		return;
		return;
@@ -963,8 +972,6 @@ void fw_core_handle_response(struct fw_card *card, struct fw_packet *p)
		break;
		break;
	}
	}


	del_timer_sync(&t->split_timeout_timer);

	/*
	/*
	 * The response handler may be executed while the request handler
	 * The response handler may be executed while the request handler
	 * is still pending.  Cancel the request handler.
	 * is still pending.  Cancel the request handler.