Skip to content

Commit 28bd204

Browse files
edmitardavem330
authored andcommitted
caif-hsi: Make inactivity timeout configurable.
CAIF HSI uses a timer for inactivity. Upon timeout HSI-wake signaling is initiated to allow power-down of the HSI block. Signed-off-by: Sjur Brændeland <sjur.brandeland@stericsson.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent ca63f8c commit 28bd204

2 files changed

Lines changed: 24 additions & 5 deletions

File tree

‎drivers/net/caif/caif_hsi.c‎

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,10 @@ MODULE_DESCRIPTION("CAIF HSI driver");
2929
#define PAD_POW2(x, pow) ((((x)&((pow)-1)) == 0) ? 0 :\
3030
(((pow)-((x)&((pow)-1)))))
3131

32+
static int inactivity_timeout = 1000;
33+
module_param(inactivity_timeout, int, S_IRUGO | S_IWUSR);
34+
MODULE_PARM_DESC(inactivity_timeout, "Inactivity timeout on HSI, ms.");
35+
3236
/*
3337
* HSI padding options.
3438
* Warning: must be a base of 2 (& operation used) and can not be zero !
@@ -98,7 +102,8 @@ static void cfhsi_abort_tx(struct cfhsi *cfhsi)
98102
}
99103
cfhsi->tx_state = CFHSI_TX_STATE_IDLE;
100104
if (!test_bit(CFHSI_SHUTDOWN, &cfhsi->bits))
101-
mod_timer(&cfhsi->timer, jiffies + CFHSI_INACTIVITY_TOUT);
105+
mod_timer(&cfhsi->timer,
106+
jiffies + cfhsi->inactivity_timeout);
102107
spin_unlock_bh(&cfhsi->lock);
103108
}
104109

@@ -312,7 +317,7 @@ static void cfhsi_tx_done(struct cfhsi *cfhsi)
312317
cfhsi->tx_state = CFHSI_TX_STATE_IDLE;
313318
/* Start inactivity timer. */
314319
mod_timer(&cfhsi->timer,
315-
jiffies + CFHSI_INACTIVITY_TOUT);
320+
jiffies + cfhsi->inactivity_timeout);
316321
spin_unlock_bh(&cfhsi->lock);
317322
goto done;
318323
}
@@ -534,7 +539,8 @@ static void cfhsi_rx_done(struct cfhsi *cfhsi)
534539

535540
/* Update inactivity timer if pending. */
536541
spin_lock_bh(&cfhsi->lock);
537-
mod_timer_pending(&cfhsi->timer, jiffies + CFHSI_INACTIVITY_TOUT);
542+
mod_timer_pending(&cfhsi->timer,
543+
jiffies + cfhsi->inactivity_timeout);
538544
spin_unlock_bh(&cfhsi->lock);
539545

540546
if (cfhsi->rx_state.state == CFHSI_RX_STATE_DESC) {
@@ -715,7 +721,7 @@ static void cfhsi_wake_up(struct work_struct *work)
715721
__func__);
716722
/* Start inactivity timer. */
717723
mod_timer(&cfhsi->timer,
718-
jiffies + CFHSI_INACTIVITY_TOUT);
724+
jiffies + cfhsi->inactivity_timeout);
719725
spin_unlock_bh(&cfhsi->lock);
720726
return;
721727
}
@@ -989,7 +995,19 @@ int cfhsi_probe(struct platform_device *pdev)
989995
goto err_alloc_rx;
990996
}
991997

992-
/* Initialize receive variables. */
998+
/* Pre-calculate inactivity timeout. */
999+
if (inactivity_timeout != -1) {
1000+
cfhsi->inactivity_timeout =
1001+
inactivity_timeout * HZ / 1000;
1002+
if (!cfhsi->inactivity_timeout)
1003+
cfhsi->inactivity_timeout = 1;
1004+
else if (cfhsi->inactivity_timeout > NEXT_TIMER_MAX_DELTA)
1005+
cfhsi->inactivity_timeout = NEXT_TIMER_MAX_DELTA;
1006+
} else {
1007+
cfhsi->inactivity_timeout = NEXT_TIMER_MAX_DELTA;
1008+
}
1009+
1010+
/* Initialize recieve vaiables. */
9931011
cfhsi->rx_ptr = cfhsi->rx_buf;
9941012
cfhsi->rx_len = CFHSI_DESC_SZ;
9951013

‎include/net/caif/caif_hsi.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -131,6 +131,7 @@ struct cfhsi {
131131
struct cfhsi_dev *dev;
132132
int tx_state;
133133
struct cfhsi_rx_state rx_state;
134+
unsigned long inactivity_timeout;
134135
int rx_len;
135136
u8 *rx_ptr;
136137
u8 *tx_buf;

0 commit comments

Comments
 (0)