diff --git a/jtag/ChangeLog b/jtag/ChangeLog index 7584b6c1..5890e352 100644 --- a/jtag/ChangeLog +++ b/jtag/ChangeLog @@ -1,3 +1,10 @@ +2008-12-22 Arnim Laeuger + + * src/tap/usbconn/libftdi.c, src/tap/usbconn/libftd2xx.c, + include/usbconn/libftdx.h, src/tap/cable/ft2232.c: + increased MPSSE buffer size from 4k to 64k + mitigates performance decrease for mid-sized clock operations + 2008-12-21 Kolja Waschk * src/svf/svf.c: Fix 2456021 - SVF compare_tdo flaw diff --git a/jtag/include/usbconn/libftdx.h b/jtag/include/usbconn/libftdx.h index ba224ac1..97c77824 100644 --- a/jtag/include/usbconn/libftdx.h +++ b/jtag/include/usbconn/libftdx.h @@ -24,6 +24,7 @@ #define _USBCONN_LIBFTDX_H 1 #define FTDX_MAXSEND 4096 +#define FTDX_MAXSEND_MPSSE (64 * 1024) /* Maximum chunk to receive from ftdi/ftd2xx driver. Larger values might speed up comm, but there's an upper limit diff --git a/jtag/src/tap/cable/ft2232.c b/jtag/src/tap/cable/ft2232.c index e2630da6..583aaf26 100644 --- a/jtag/src/tap/cable/ft2232.c +++ b/jtag/src/tap/cable/ft2232.c @@ -931,8 +931,11 @@ ft2232_clock_schedule( cable_t *cable, int tms, int tdi, int n ) cx_cmd_queue( cmd_root, 0 ); while (n > 0) { - if (cx_cmd_space( cmd_root, 4096 ) < 3) + if (cx_cmd_space( cmd_root, FTDX_MAXSEND_MPSSE ) < 4) { + /* no space left for Clock Data plus Send Immediate + transfer queued commands to device and read receive data + to internal buffer */ cx_xfer( cmd_root, &imm_cmd, cable, COMPLETELY ); cx_cmd_queue( cmd_root, 0 ); } @@ -1054,6 +1057,10 @@ ft2232_transfer_schedule( cable_t *cable, int len, char *in, char *out ) /* reduce chunkbytes to the maximum amount we can receive in one step */ if (out && chunkbytes > FTDX_MAXRECV) chunkbytes = FTDX_MAXRECV; + /* reduce chunkbytes to the maximum amount that fits into one buffer + for performance reasons */ + if (chunkbytes > FTDX_MAXSEND_MPSSE - 4) + chunkbytes = FTDX_MAXSEND_MPSSE - 4; /* restrict chunkbytes to the maximum amount that can be transferred for one single operation */ if (chunkbytes > (1 << 16)) diff --git a/jtag/src/tap/usbconn/libftd2xx.c b/jtag/src/tap/usbconn/libftd2xx.c index 597bb23e..488de730 100644 --- a/jtag/src/tap/usbconn/libftd2xx.c +++ b/jtag/src/tap/usbconn/libftd2xx.c @@ -432,6 +432,9 @@ usbconn_ftd2xx_mpsse_open( usbconn_t *conn ) if (status == FT_OK) if ((status = FT_Purge( fc, FT_PURGE_RX )) != FT_OK) printf( _("%s(): Can't purge RX buffer.\n"), __FUNCTION__ ); + if (status == FT_OK) if ((status = FT_SetUSBParameters( fc, FTDX_MAXSEND_MPSSE, FTDX_MAXSEND_MPSSE )) != FT_OK) + printf( _("%s(): Can't set USB parameters.\n"), __FUNCTION__ ); + if (status == FT_OK) if ((status = FT_SetChars( fc, 0, 0, 0, 0 )) != FT_OK) printf( _("%s(): Can't set special characters.\n"), __FUNCTION__ ); diff --git a/jtag/src/tap/usbconn/libftdi.c b/jtag/src/tap/usbconn/libftdi.c index e254ab39..0f4efdfb 100644 --- a/jtag/src/tap/usbconn/libftdi.c +++ b/jtag/src/tap/usbconn/libftdi.c @@ -461,6 +461,11 @@ usbconn_ftdi_mpsse_open( usbconn_t *conn ) r = seq_reset( fc ); if (r >= 0) r = seq_purge( fc, 1, 0 ); + if (r >= 0) if ((r = ftdi_write_data_set_chunksize( fc, FTDX_MAXSEND_MPSSE )) < 0) + puts( ftdi_get_error_string( fc ) ); + if (r >= 0) if ((r = ftdi_read_data_set_chunksize( fc, FTDX_MAXSEND_MPSSE )) < 0) + puts( ftdi_get_error_string( fc ) ); + #ifdef LIBFTDI_UNIMPLEMENTED if (r >= 0) if ((r = ftdi_set_event_char( fc, 0, 0 )) < 0) puts( ftdi_get_error_string( fc ) );