f7: Do not wait for write buffer to completely fill at Full Speed.

Now the buffer is 128kB, it takes ~150ms to fill it at FS.
This commit is contained in:
Keir Fraser
2020-05-04 13:30:05 +01:00
parent 93c5200a65
commit 12028bdffe
6 changed files with 12 additions and 5 deletions

View File

@@ -44,6 +44,9 @@ bool_t ep_tx_ready(uint8_t ep);
* REQUIRES: ep_tx_ready(@ep) == TRUE */
void usb_write(uint8_t ep, const void *buf, uint32_t len);
/* Is the USB enumerated at High Speed? */
bool_t usb_is_highspeed(void);
/*
* Local variables:
* mode: C

View File

@@ -615,10 +615,15 @@ static uint8_t floppy_write_prep(const struct gw_write_flux *wf)
static void floppy_write_wait_data(void)
{
bool_t write_finished;
unsigned int u_buf_threshold;
floppy_process_write_packet();
wdata_decode_flux();
/* We don't wait for the massive F7 u_buf[] to fill at Full Speed. */
u_buf_threshold = ((U_BUF_SZ > 16384) && !usb_is_highspeed())
? 16384 - 512 : U_BUF_SZ - 512;
/* Wait for DMA and input buffers to fill, or write stream to end. We must
* take care because, since we are not yet draining the DMA buffer, the
* write stream may end without us noticing and setting rw.write_finished.
@@ -627,7 +632,7 @@ static void floppy_write_wait_data(void)
? rw.write_finished
: (u_buf[U_MASK(u_prod-1)] == 0));
if (((dma.prod != (ARRAY_SIZE(dma.buf)-1))
|| ((uint32_t)(u_prod - u_cons) < (U_BUF_SZ - 512)))
|| ((uint32_t)(u_prod - u_cons) < u_buf_threshold))
&& !write_finished)
return;

View File

@@ -49,7 +49,7 @@ static bool_t handle_control_request(void)
memcpy(ep0.data, device_qualifier, ep0.data_len);
}
} else if ((type == DESC_CONFIGURATION) && (idx == 0)) {
if (hw_is_highspeed()) {
if (usb_is_highspeed()) {
ep0.data_len = config_hs_descriptor[2]; /* wTotalLength */
memcpy(ep0.data, config_hs_descriptor, ep0.data_len);
} else {

View File

@@ -83,7 +83,6 @@ void usb_setaddr(uint8_t addr);
void hw_usb_init(void);
void hw_usb_deinit(void);
bool_t hw_has_highspeed(void);
bool_t hw_is_highspeed(void);
#define WARN printk

View File

@@ -31,7 +31,7 @@ bool_t hw_has_highspeed(void)
return conf_iface == IFACE_HS_EMBEDDED;
}
bool_t hw_is_highspeed(void)
bool_t usb_is_highspeed(void)
{
return is_hs;
}

View File

@@ -27,7 +27,7 @@ bool_t hw_has_highspeed(void)
return FALSE;
}
bool_t hw_is_highspeed(void)
bool_t usb_is_highspeed(void)
{
return FALSE;
}