Commit 985d9745 authored by Federico Vaga's avatar Federico Vaga

kernel: limit kfifo size

Signed-off-by: Federico Vaga's avatarFederico Vaga <federico.vaga@cern.ch>
parent 816acbfd
......@@ -137,6 +137,7 @@ struct ft_channel_state {
between pulses */
struct kfifo fifo;
uint32_t fifo_len;
};
/* Main TDC device context */
......
......@@ -43,19 +43,19 @@ static int ft_show_sdb;
module_param_named(show_sdb, ft_show_sdb, int, 0444);
MODULE_PARM_DESC(verbose, "Print a dump of the gateware's SDB tree.");
static int ft_buffer_size = 8192;
static int ft_buffer_size = 64;
module_param_named(buffer_size, ft_buffer_size, int, 0444);
MODULE_PARM_DESC(verbose,
"Number of timestamps in each channel's software FIFO buffer.");
"Number of timestamps in each channel's software FIFO buffer (It must be a power of 2).");
static int ft_init_channel(struct fmctdc_dev *ft, int channel)
{
struct ft_channel_state *st = &ft->channels[channel - 1];
st->expected_edge = 1;
st->fifo_len = ft_buffer_size;
return kfifo_alloc(&st->fifo,
sizeof(struct ft_wr_timestamp) * ft_buffer_size,
sizeof(struct ft_wr_timestamp) * st->fifo_len,
GFP_KERNEL);
}
......
......@@ -213,6 +213,11 @@ static inline void process_timestamp(struct fmctdc_dev *ft,
/* Put the timestamp in the FIFO */
kfifo_in_spinlocked(&st->fifo, &ts,
sizeof(struct ft_wr_timestamp), &ft->lock);
if (st->fifo_len <= kfifo_len(&st->fifo) / sizeof(struct ft_wr_timestamp)) {
kfifo_out_spinlocked(&st->fifo, &ts,
sizeof(struct ft_wr_timestamp),
&ft->lock);
}
}
/* Wait for the next raising edge */
......
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