I put together this patch which reduces the number of consecutive write packets sent at startup. In my testing system it reduced it from 22 to 2. However, I only spent about 2 minutes testing it, just a handful of startups.
-- >8 -- >From 5bf2780aff4b4af183ec54f1fbcd3f0a3b0408c7 Mon Sep 17 00:00:00 2001 From: Jeff Epler <[email protected]> Date: Sun, 20 Sep 2015 15:28:30 -0500 Subject: [PATCH] WIP hm2_eth: batch writes from hm2_force_write --- src/hal/drivers/mesa-hostmot2/hm2_eth.c | 2 +- src/hal/drivers/mesa-hostmot2/hostmot2-lowlevel.h | 2 ++ src/hal/drivers/mesa-hostmot2/hostmot2.c | 4 ++++ 3 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/hal/drivers/mesa-hostmot2/hm2_eth.c b/src/hal/drivers/mesa-hostmot2/hm2_eth.c index e57f14e..b1a3e80 100644 --- a/src/hal/drivers/mesa-hostmot2/hm2_eth.c +++ b/src/hal/drivers/mesa-hostmot2/hm2_eth.c @@ -523,7 +523,7 @@ static int hm2_eth_enqueue_read(hm2_lowlevel_io_t *this, rtapi_u32 addr, void *b static int hm2_eth_enqueue_write(hm2_lowlevel_io_t *this, rtapi_u32 addr, void *buffer, int size); static int hm2_eth_write(hm2_lowlevel_io_t *this, rtapi_u32 addr, void *buffer, int size) { - if(rtapi_task_self() >= 0) + if(rtapi_task_self() >= 0 || this->queue_writes) return hm2_eth_enqueue_write(this, addr, buffer, size); int send; diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2-lowlevel.h b/src/hal/drivers/mesa-hostmot2/hostmot2-lowlevel.h index 3df443c..81e40fd 100644 --- a/src/hal/drivers/mesa-hostmot2/hostmot2-lowlevel.h +++ b/src/hal/drivers/mesa-hostmot2/hostmot2-lowlevel.h @@ -144,6 +144,8 @@ struct hm2_lowlevel_io_struct { // if TRUE, the hostmot2 driver will export those three functions and also read_gpio() and write_gpio() int threadsafe; + // if TRUE, queue writes for a subsequent call to ->send_queued_writes() + int queue_writes; void *private; // for the low-level driver to hang their struct on }; diff --git a/src/hal/drivers/mesa-hostmot2/hostmot2.c b/src/hal/drivers/mesa-hostmot2/hostmot2.c index 3acb34d..57365a8 100644 --- a/src/hal/drivers/mesa-hostmot2/hostmot2.c +++ b/src/hal/drivers/mesa-hostmot2/hostmot2.c @@ -1655,6 +1655,7 @@ void rtapi_app_exit(void) { // this pushes our idea of what things are like into the FPGA's poor little mind void hm2_force_write(hostmot2_t *hm2) { + hm2->llio->queue_writes = 1; hm2_watchdog_force_write(hm2); hm2_ioport_force_write(hm2); hm2_encoder_force_write(hm2); @@ -1664,5 +1665,8 @@ void hm2_force_write(hostmot2_t *hm2) { hm2_sserial_force_write(hm2); hm2_bspi_force_write(hm2); hm2_dpll_force_write(hm2); + + hm2->llio->queue_writes = 0; + if(hm2->llio->send_queued_writes) hm2->llio->send_queued_writes(hm2->llio); } -- 1.7.10.4 ------------------------------------------------------------------------------ _______________________________________________ Emc-users mailing list [email protected] https://lists.sourceforge.net/lists/listinfo/emc-users
