Skip to content
Snippets Groups Projects
Commit 5303eb90 authored by Wesley W. Terpstra's avatar Wesley W. Terpstra
Browse files

Added optional debug printk tracking of IO to the WB bridge

Fixed bugs in kernel etherbone:
  record_len was shadowed by redeclation
  wrote maximum of possible bytes instead of minimum
  added non-blocking IO support
parent bf61db73
Branches
Tags
No related merge requests found
......@@ -110,9 +110,18 @@ void wb_write(struct wishbone* wb, wb_addr_t addr, wb_data_t data)
}
switch (dev->width) {
case 4: iowrite32(data, window + (addr & WINDOW_LOW)); break;
case 2: iowrite16(data >> dev->shift, window + (addr & WINDOW_LOW) + dev->low_addr); break;
case 1: iowrite8 (data >> dev->shift, window + (addr & WINDOW_LOW) + dev->low_addr); break;
case 4:
if (unlikely(debug)) printk(KERN_ALERT PCIE_WB ": iowrite32(0x%x, 0x%x)\n", data, addr);
iowrite32(data, window + (addr & WINDOW_LOW));
break;
case 2:
if (unlikely(debug)) printk(KERN_ALERT PCIE_WB ": iowrite16(0x%x, 0x%x)\n", data >> dev->shift, addr + dev->low_addr);
iowrite16(data >> dev->shift, window + (addr & WINDOW_LOW) + dev->low_addr);
break;
case 1:
if (unlikely(debug)) printk(KERN_ALERT PCIE_WB ": iowrite8(0x%x, 0x%x)\n", data >> dev->shift, addr + dev->low_addr);
iowrite8 (data >> dev->shift, window + (addr & WINDOW_LOW) + dev->low_addr);
break;
}
}
......@@ -136,9 +145,15 @@ wb_data_t wb_read(struct wishbone* wb, wb_addr_t addr)
rmb(); // has to be executed before reading
switch (dev->width) {
case 4: return ((wb_data_t)ioread32(window + (addr & WINDOW_LOW)));
case 2: return ((wb_data_t)ioread16(window + (addr & WINDOW_LOW) + dev->low_addr)) << dev->shift;
case 1: return ((wb_data_t)ioread8 (window + (addr & WINDOW_LOW) + dev->low_addr)) << dev->shift;
case 4:
if (unlikely(debug)) printk(KERN_ALERT PCIE_WB ": ioread32(0x%x)\n", addr);
return ((wb_data_t)ioread32(window + (addr & WINDOW_LOW)));
case 2:
if (unlikely(debug)) printk(KERN_ALERT PCIE_WB ": ioread32(0x%x)\n", addr + dev->low_addr);
return ((wb_data_t)ioread16(window + (addr & WINDOW_LOW) + dev->low_addr)) << dev->shift;
case 1:
if (unlikely(debug)) printk(KERN_ALERT PCIE_WB ": ioread32(0x%x)\n", addr + dev->low_addr);
return ((wb_data_t)ioread8 (window + (addr & WINDOW_LOW) + dev->low_addr)) << dev->shift;
}
return 0;
}
......
......@@ -51,7 +51,7 @@ static void etherbone_process(struct etherbone_context* context)
{
struct wishbone *wb;
const struct wishbone_operations *wops;
unsigned int size, left, i, record_len = 0;
unsigned int size, left, i, record_len;
unsigned char *buf;
if (context->state == header) {
......@@ -77,7 +77,6 @@ static void etherbone_process(struct etherbone_context* context)
size = RING_PROC_LEN(context);
for (left = size; left >= 4; left -= record_len) {
unsigned int record_len;
unsigned char flags, be, wcount, rcount;
/* Determine record size */
......@@ -191,7 +190,7 @@ static ssize_t char_aio_read(struct kiocb *iocb, const struct iovec *iov, unsign
mutex_lock(&context->mutex);
ring_len = RING_READ_LEN(context);
len = max_t(unsigned int, ring_len, iov_len);
len = min_t(unsigned int, ring_len, iov_len);
/* How far till we must wrap? */
buf_len = sizeof(context->buf) - context->sent;
......@@ -210,6 +209,9 @@ static ssize_t char_aio_read(struct kiocb *iocb, const struct iovec *iov, unsign
mutex_unlock(&context->mutex);
if (len == 0 && (filep->f_flags & O_NONBLOCK) != 0)
return -EAGAIN;
return len;
}
......@@ -224,7 +226,7 @@ static ssize_t char_aio_write(struct kiocb *iocb, const struct iovec *iov, unsig
mutex_lock(&context->mutex);
ring_len = RING_WRITE_LEN(context);
len = max_t(unsigned int, ring_len, iov_len);
len = min_t(unsigned int, ring_len, iov_len);
/* How far till we must wrap? */
buf_len = sizeof(context->buf) - context->received;
......@@ -246,6 +248,9 @@ static ssize_t char_aio_write(struct kiocb *iocb, const struct iovec *iov, unsig
mutex_unlock(&context->mutex);
if (len == 0 && (filep->f_flags & O_NONBLOCK) != 0)
return -EAGAIN;
return len;
}
......
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