Skip to content

Commit 5a87c50

Browse files
Leonid Ravichvinodkoul
authored andcommitted
dmaengine: ioat: removing duplicate code from timeout handler
moving duplicate code from timeout error handling to common function. Acked-by: Dave Jiang <[email protected]> Signed-off-by: Leonid Ravich <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Vinod Koul <[email protected]>
1 parent a6e2664 commit 5a87c50

File tree

1 file changed

+19
-26
lines changed

1 file changed

+19
-26
lines changed

drivers/dma/ioat/dma.c

Lines changed: 19 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -869,6 +869,23 @@ static void check_active(struct ioatdma_chan *ioat_chan)
869869
mod_timer(&ioat_chan->timer, jiffies + IDLE_TIMEOUT);
870870
}
871871

872+
static void ioat_reboot_chan(struct ioatdma_chan *ioat_chan)
873+
{
874+
spin_lock_bh(&ioat_chan->prep_lock);
875+
set_bit(IOAT_CHAN_DOWN, &ioat_chan->state);
876+
spin_unlock_bh(&ioat_chan->prep_lock);
877+
878+
ioat_abort_descs(ioat_chan);
879+
dev_warn(to_dev(ioat_chan), "Reset channel...\n");
880+
ioat_reset_hw(ioat_chan);
881+
dev_warn(to_dev(ioat_chan), "Restart channel...\n");
882+
ioat_restart_channel(ioat_chan);
883+
884+
spin_lock_bh(&ioat_chan->prep_lock);
885+
clear_bit(IOAT_CHAN_DOWN, &ioat_chan->state);
886+
spin_unlock_bh(&ioat_chan->prep_lock);
887+
}
888+
872889
void ioat_timer_event(struct timer_list *t)
873890
{
874891
struct ioatdma_chan *ioat_chan = from_timer(ioat_chan, t, timer);
@@ -891,19 +908,7 @@ void ioat_timer_event(struct timer_list *t)
891908

892909
if (test_bit(IOAT_RUN, &ioat_chan->state)) {
893910
spin_lock_bh(&ioat_chan->cleanup_lock);
894-
spin_lock_bh(&ioat_chan->prep_lock);
895-
set_bit(IOAT_CHAN_DOWN, &ioat_chan->state);
896-
spin_unlock_bh(&ioat_chan->prep_lock);
897-
898-
ioat_abort_descs(ioat_chan);
899-
dev_warn(to_dev(ioat_chan), "Reset channel...\n");
900-
ioat_reset_hw(ioat_chan);
901-
dev_warn(to_dev(ioat_chan), "Restart channel...\n");
902-
ioat_restart_channel(ioat_chan);
903-
904-
spin_lock_bh(&ioat_chan->prep_lock);
905-
clear_bit(IOAT_CHAN_DOWN, &ioat_chan->state);
906-
spin_unlock_bh(&ioat_chan->prep_lock);
911+
ioat_reboot_chan(ioat_chan);
907912
spin_unlock_bh(&ioat_chan->cleanup_lock);
908913
}
909914

@@ -939,19 +944,7 @@ void ioat_timer_event(struct timer_list *t)
939944
dev_dbg(to_dev(ioat_chan), "Active descriptors: %d\n",
940945
ioat_ring_active(ioat_chan));
941946

942-
spin_lock_bh(&ioat_chan->prep_lock);
943-
set_bit(IOAT_CHAN_DOWN, &ioat_chan->state);
944-
spin_unlock_bh(&ioat_chan->prep_lock);
945-
946-
ioat_abort_descs(ioat_chan);
947-
dev_warn(to_dev(ioat_chan), "Resetting channel...\n");
948-
ioat_reset_hw(ioat_chan);
949-
dev_warn(to_dev(ioat_chan), "Restarting channel...\n");
950-
ioat_restart_channel(ioat_chan);
951-
952-
spin_lock_bh(&ioat_chan->prep_lock);
953-
clear_bit(IOAT_CHAN_DOWN, &ioat_chan->state);
954-
spin_unlock_bh(&ioat_chan->prep_lock);
947+
ioat_reboot_chan(ioat_chan);
955948
spin_unlock_bh(&ioat_chan->cleanup_lock);
956949
return;
957950
} else

0 commit comments

Comments
 (0)