Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in
Toggle navigation
F
FMC TDC 1ns 5cha - Software
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
Wiki
Wiki
image/svg+xml
Discourse
Discourse
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Commits
Issue Boards
Open sidebar
Projects
FMC TDC 1ns 5cha - Software
Commits
0cc06a63
Commit
0cc06a63
authored
Oct 07, 2014
by
Federico Vaga
Committed by
Federico Vaga
Jan 20, 2015
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
kernel: use kfifo instead of home-made fifo
Signed-off-by:
Federico Vaga
<
federico.vaga@cern.ch
>
parent
a814a6f0
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
21 additions
and
46 deletions
+21
-46
fmc-tdc.h
kernel/fmc-tdc.h
+2
-6
ft-core.c
kernel/ft-core.c
+7
-11
ft-irq.c
kernel/ft-irq.c
+12
-29
No files found.
kernel/fmc-tdc.h
View file @
0cc06a63
...
...
@@ -64,6 +64,7 @@ enum ft_command {
#include <linux/timer.h>
#include <linux/fmc.h>
#include <linux/version.h>
#include <linux/kfifo.h>
#define FT_USER_OFFSET_RANGE 1000000000
/* picoseconds */
...
...
@@ -114,11 +115,6 @@ struct ft_wr_timestamp {
int
channel
;
};
struct
ft_sw_fifo
{
unsigned
long
head
,
tail
,
count
,
size
;
struct
ft_wr_timestamp
*
t
;
};
struct
ft_channel_state
{
unsigned
long
flags
;
int
expected_edge
;
...
...
@@ -127,7 +123,7 @@ struct ft_channel_state {
int32_t
user_offset
;
struct
ft_wr_timestamp
prev_ts
;
struct
ft_sw_
fifo
fifo
;
struct
k
fifo
fifo
;
};
/* Main TDC device context */
...
...
kernel/ft-core.c
View file @
0cc06a63
...
...
@@ -22,6 +22,7 @@
#include <linux/init.h>
#include <linux/list.h>
#include <linux/io.h>
#include <linux/kfifo.h>
#include <linux/fmc.h>
#include <linux/fmc-sdb.h>
...
...
@@ -52,27 +53,22 @@ 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
.
size
=
ft_buffer_size
;
st
->
fifo
.
t
=
kmalloc
(
sizeof
(
struct
ft_wr_timestamp
)
*
st
->
fifo
.
size
,
GFP_KERNEL
);
if
(
!
st
->
fifo
.
t
)
return
-
ENOMEM
;
return
0
;
return
kfifo_alloc
(
&
st
->
fifo
,
sizeof
(
struct
ft_wr_timestamp
)
*
ft_buffer_size
,
GFP_KERNEL
);
}
static
void
ft_reset_channel
(
struct
fmctdc_dev
*
ft
,
int
channel
)
{
struct
ft_channel_state
*
st
=
&
ft
->
channels
[
channel
-
FT_CH_1
];
st
->
fifo
.
head
=
0
;
st
->
fifo
.
tail
=
0
;
st
->
fifo
.
count
=
0
;
st
->
cur_seq_id
=
0
;
st
->
expected_edge
=
1
;
clear_bit
(
FT_FLAG_CH_INPUT_READY
,
&
st
->
flags
);
ft_zio_kill_buffer
(
ft
,
channel
);
kfifo_reset
(
&
st
->
fifo
);
}
int
ft_enable_termination
(
struct
fmctdc_dev
*
ft
,
int
channel
,
int
enable
)
...
...
@@ -165,7 +161,7 @@ static void ft_channels_exit(struct fmctdc_dev *ft)
int
i
;
for
(
i
=
FT_CH_1
;
i
<=
FT_NUM_CHANNELS
;
i
++
)
kf
ree
(
ft
->
channels
[
i
-
1
].
fifo
.
t
);
kf
ifo_free
(
&
ft
->
channels
[
i
-
1
].
fifo
);
}
struct
ft_modlist
{
...
...
kernel/ft-irq.c
View file @
0cc06a63
...
...
@@ -20,6 +20,7 @@
#include <linux/bitops.h>
#include <linux/spinlock.h>
#include <linux/io.h>
#include <linux/kfifo.h>
#include <linux/zio.h>
#include <linux/zio-trigger.h>
...
...
@@ -58,24 +59,22 @@ int ft_read_sw_fifo(struct fmctdc_dev *ft, int channel,
struct
ft_wr_timestamp
ts
;
struct
ft_channel_state
*
st
;
unsigned
long
flags
;
int
ret
;
st
=
&
ft
->
channels
[
channel
-
1
];
if
(
!
chan
->
active_block
)
return
-
EAGAIN
;
if
(
!
st
->
fifo
.
count
)
ret
=
kfifo_out_spinlocked
(
&
st
->
fifo
,
&
ts
,
sizeof
(
struct
ft_wr_timestamp
),
&
ft
->
lock
);
if
(
!
ret
)
{
return
-
EAGAIN
;
/* Copy the sample to local storage */
spin_lock_irqsave
(
&
ft
->
lock
,
flags
);
ts
=
st
->
fifo
.
t
[
st
->
fifo
.
tail
];
st
->
fifo
.
tail
++
;
if
(
st
->
fifo
.
tail
==
st
->
fifo
.
size
)
st
->
fifo
.
tail
=
0
;
st
->
fifo
.
count
--
;
spin_unlock_irqrestore
(
&
ft
->
lock
,
flags
);
}
else
if
(
ret
<
sizeof
(
struct
ft_wr_timestamp
))
{
dev_err
(
&
ft
->
zdev
->
head
.
dev
,
"Somethig wrong with kfifo buffer
\n
"
);
return
-
EINVAL
;
}
/* Write the timestamp in the trigger, it will reach the control */
ti
->
tstamp
.
tv_sec
=
ts
.
seconds
;
...
...
@@ -107,23 +106,6 @@ int ft_read_sw_fifo(struct fmctdc_dev *ft, int channel,
return
0
;
}
static
inline
void
enqueue_timestamp
(
struct
fmctdc_dev
*
ft
,
int
channel
,
struct
ft_wr_timestamp
*
ts
)
{
struct
ft_sw_fifo
*
fifo
=
&
ft
->
channels
[
channel
-
1
].
fifo
;
unsigned
long
flags
;
/* fixme: consider independent locks for each channel. */
spin_lock_irqsave
(
&
ft
->
lock
,
flags
);
fifo
->
t
[
fifo
->
head
]
=
*
ts
;
fifo
->
head
=
(
fifo
->
head
+
1
)
%
fifo
->
size
;
if
(
fifo
->
count
<
fifo
->
size
)
fifo
->
count
++
;
else
fifo
->
tail
=
(
fifo
->
tail
+
1
)
%
fifo
->
size
;
spin_unlock_irqrestore
(
&
ft
->
lock
,
flags
);
}
static
inline
void
process_timestamp
(
struct
fmctdc_dev
*
ft
,
struct
ft_hw_timestamp
*
hwts
,
...
...
@@ -208,7 +190,8 @@ static inline void process_timestamp(struct fmctdc_dev *ft,
}
/* Put the timestamp in the FIFO */
enqueue_timestamp
(
ft
,
channel
,
&
ts
);
kfifo_in_spinlocked
(
&
st
->
fifo
,
&
ts
,
sizeof
(
struct
ft_wr_timestamp
),
&
ft
->
lock
);
}
/* Wait for the next raising edge */
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment