Modified to push the events to the zio buffer even if the user is not reading

Signed-off-by: Samuel Iglesias Gonsálvez's avatarSamuel Iglesias Gonsalvez <siglesias@igalia.com>
parent f6e36321
#LINUX ?= /lib/modules/$(shell uname -r)/build
LINUX ?= ../../kernel-3.5
ZIO ?= $(HOME)/devel/cern/zio
SPEC_SW ?= $(HOME)/devel/cern/spec-sw
LINUX ?= /lib/modules/$(shell uname -r)/build
#LINUX ?= ../../kernel-3.5
ZIO ?= $(HOME)/dependencies/zio
SPEC_SW ?= $(HOME)/dependencies/spec-sw
KBUILD_EXTRA_SYMBOLS := $(ZIO)/Module.symvers $(SPEC_SW)/kernel/Module.symvers
......
......@@ -17,7 +17,6 @@
#include <linux/wait.h>
#include <linux/sched.h>
#include <linux/atomic.h>
#include <linux/semaphore.h>
#include <linux/zio.h>
#include <linux/zio-trigger.h>
......@@ -154,16 +153,9 @@ static void tdc_fmc_irq_work(struct work_struct *work)
tdc->event[chan].dacapo_flag = dacapo_flag;
/* Copy the data and notify the readers (ZIO trigger) */
tdc->event[chan].data = *tmp_data;
/* XXX: Flag to avoid the ZIO trigger to read always the same element
* Until we change to a mutex or a data buffer bigger than one.
*/
tdc->event[chan].read = 0;
/* XXX: as it has only one element of data, maybe is better a mutex
* instead of semaphore!
*/
//up(&tdc->event[chan].lock);
rd_ptr = (rd_ptr + 1) % TDC_EVENT_BUFFER_SIZE;
//zio_fire_trigger(tdc->hwzdev->cset[chan].ti);
zio_fire_trigger(tdc->zdev->cset[chan].ti);
}
dma_out:
......@@ -238,7 +230,7 @@ int tdc_fmc_probe(struct fmc_device *dev)
{
struct spec_tdc *tdc;
struct spec_dev *spec;
int ret, i, dev_lun;
int ret, dev_lun;
char gateware_path[128];
if(strcmp(dev->carrier_name, "SPEC") != 0)
......@@ -272,8 +264,6 @@ int tdc_fmc_probe(struct fmc_device *dev)
tdc->gn412x_regs = spec->remap[2]; /* BAR 4 */
tdc->wr_pointer = 0;
for(i = 0; i < TDC_CHAN_NUMBER; i++)
sema_init(&tdc->event[i].lock, 0);
/* Setup the Gennum 412x local clock frequency */
tdc_fmc_gennum_setup_local_clock(tdc, 160);
/* Reset FPGA to load the firmware */
......
......@@ -219,7 +219,7 @@ static const struct zio_sysfs_operations tdc_zio_s_op = {
static struct zio_device tdc_tmpl = {
.owner = THIS_MODULE,
.preferred_trigger = "user",
.preferred_trigger = "tdc",
.s_op = &tdc_zio_s_op,
.cset = tdc_cset,
.n_cset = ARRAY_SIZE(tdc_cset),
......@@ -247,21 +247,6 @@ static int tdc_zio_raw_io(struct zio_cset *cset)
tdc = zdev->priv_d;
chan = cset->index;
/* Wait for data */
#if 0
if(down_interruptible(&tdc->event[chan].lock))
return -ERESTARTSYS;
#else
//mdelay(100);
#endif
/* Check if we have read this data before */
/* XXX: change it if we have more data or use a mutex */
#if 0
if (tdc->event[chan].read)
return -EAGAIN;
tdc->event[chan].read = 1;
#endif
/* Process the data */
ctrl = zio_get_ctrl(zio_chan->active_block);
ctrl->ssize = 1; /* one event */
......@@ -291,11 +276,20 @@ static struct zio_driver tdc_zdrv = {
.probe = tdc_zio_probe,
};
/* Copied from zio-sys.c. This works because ZIO only supports one children */
static int __tdc_match_child(struct device *dev, void *data)
{
// if (dev->type == &zobj_device_type)
return 1;
// return 0;
}
int tdc_zio_register_device(struct spec_tdc *tdc)
{
int err = 0;
struct pci_dev *pdev;
int dev_id;
struct device *dev;
tdc->hwzdev = zio_allocate_device();
if (IS_ERR(tdc->hwzdev))
......@@ -314,6 +308,14 @@ int tdc_zio_register_device(struct spec_tdc *tdc)
zio_free_device(tdc->hwzdev);
return err;
}
dev = device_find_child(&tdc->hwzdev->head.dev, NULL, __tdc_match_child);
if (!dev) {
pr_err("Child device not found!!\n");
return -ENODEV;
}
tdc->zdev = to_zio_dev(dev);
return 0;
}
......
......@@ -27,9 +27,7 @@ struct tdc_event {
struct tdc_event_buffer {
struct tdc_event data;
struct semaphore lock;
int dacapo_flag;
int read;
};
struct tdc_acam_cfg {
......
......@@ -154,9 +154,9 @@ int main(int argc, char **argv)
/* read from valid chan */
tdc_set_host_utc_time(b);
tdc_activate_all_channels(b);
tdc_set_active_channels(b, CHAN0 | CHAN1 | CHAN2 | CHAN3 | CHAN4);
tdc_set_active_channels(b, CHAN0);
tdc_set_time_threshold(b, 10);
tdc_set_timestamp_threshold(b, 100);
tdc_set_timestamp_threshold(b, 10);
tdc_start_acquisition(b);
for (i = 0; i <100; i++) {
/* this should be a blocking read */
......@@ -167,7 +167,7 @@ int main(int argc, char **argv)
} else {
printf("Error reading sample\n");
}
sleep(1);
// sleep(1);
}
tdc_stop_acquisition(b);
......
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