summaryrefslogtreecommitdiff
path: root/xpp/xproto.c
diff options
context:
space:
mode:
Diffstat (limited to 'xpp/xproto.c')
-rw-r--r--xpp/xproto.c38
1 files changed, 26 insertions, 12 deletions
diff --git a/xpp/xproto.c b/xpp/xproto.c
index 45ab125..89417b8 100644
--- a/xpp/xproto.c
+++ b/xpp/xproto.c
@@ -142,8 +142,12 @@ int packet_process(xbus_t *xbus, xpacket_t *pack)
BUG_ON(!pack);
if(!valid_xpd_addr(&XPACKET_ADDR(pack))) {
- if(printk_ratelimit())
+ if(printk_ratelimit()) {
+ XBUS_NOTICE(xbus, "%s: from %d%d: bad address.\n",
+ __FUNCTION__,
+ XPACKET_ADDR(pack).unit, XPACKET_ADDR(pack).subunit);
dump_packet("packet_process -- bad address", pack, print_dbg);
+ }
goto out;
}
op = XPACKET_OP(pack);
@@ -213,6 +217,10 @@ int xframe_receive(xbus_t *xbus, xframe_t *xframe)
struct timeval now;
int usec;
+ if(!down_read_trylock(&xbus->in_use)) {
+ XBUS_DBG(GENERAL, xbus, "Dropped xframe. Is in_use\n");
+ return -ENODEV;
+ }
p = xpacket_start = xframe->packets;
xframe_end = xpacket_start + XFRAME_LEN(xframe);
if(XFRAME_LEN(xframe) < RPACKET_HEADERSIZE) {
@@ -228,22 +236,27 @@ int xframe_receive(xbus_t *xbus, xframe_t *xframe)
* We want to check that xframes do not mix PCM and other commands
*/
is_pcm = XPACKET_IS_PCM((xpacket_t *)p);
- if(print_dbg & DBG_PCM) {
- static int rate_limit;
-
- if(is_pcm && ((rate_limit++ % 1003) == 0))
- dump_xframe("RX_XFRAME_PCM", xbus, xframe);
- }
+ if(is_pcm && (print_dbg & DBG_PCM))
+ dump_xframe("RX_XFRAME_PCM", xbus, xframe);
do {
pack = (xpacket_t *)p;
len = XPACKET_LEN(pack);
/* Sanity checks */
- if(unlikely(is_pcm && XPACKET_OP(pack) != XPROTO_NAME(GLOBAL,PCM_READ) && printk_ratelimit())) {
- XBUS_DBG(GENERAL, xbus, "Non-PCM packet within a PCM xframe\n");
- dump_xframe("In PCM xframe", xbus, xframe);
+ if(unlikely(is_pcm && XPACKET_OP(pack) != XPROTO_NAME(GLOBAL,PCM_READ))) {
+ static int rate_limit;
+
+ if((rate_limit++ % 1003) == 0) {
+ XBUS_DBG(GENERAL, xbus, "Non-PCM packet within a PCM xframe\n");
+ dump_xframe("In PCM xframe", xbus, xframe);
+ }
// goto bad_proto;
- } else if(unlikely(!is_pcm && XPACKET_OP(pack) == XPROTO_NAME(GLOBAL,PCM_READ) && printk_ratelimit())) {
- XBUS_DBG(GENERAL, xbus, "A PCM packet within a Non-PCM xframe\n");
+ } else if(unlikely(!is_pcm && XPACKET_OP(pack) == XPROTO_NAME(GLOBAL,PCM_READ))) {
+ static int rate_limit;
+
+ if((rate_limit++ % 1003) == 0) {
+ XBUS_DBG(GENERAL, xbus, "A PCM packet within a Non-PCM xframe\n");
+ dump_xframe("In Non-PCM xframe", xbus, xframe);
+ }
// goto bad_proto;
}
p += len;
@@ -270,6 +283,7 @@ out:
if(usec > xbus->max_rx_process)
xbus->max_rx_process = usec;
xbus->ops->xframe_free(xbus, xframe);
+ up_read(&xbus->in_use);
return ret;
bad_proto:
ret = -EPROTO;