[dahdi-commits] tzafrir: linux/trunk r6641 - /linux/trunk/drivers/dahdi/xpp/
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Tue May 19 11:01:30 CDT 2009
Author: tzafrir
Date: Tue May 19 11:01:27 2009
New Revision: 6641
URL: http://svn.asterisk.org/svn-view/dahdi?view=rev&rev=6641
Log:
xpp: fix the Astribank state machine
This generally is a case that would not happen in the wild, though.
Modified:
linux/trunk/drivers/dahdi/xpp/card_global.c
linux/trunk/drivers/dahdi/xpp/xbus-core.c
linux/trunk/drivers/dahdi/xpp/xbus-core.h
linux/trunk/drivers/dahdi/xpp/xbus-pcm.c
linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c
linux/trunk/drivers/dahdi/xpp/xproto.c
linux/trunk/drivers/dahdi/xpp/xproto.h
Modified: linux/trunk/drivers/dahdi/xpp/card_global.c
URL: http://svn.asterisk.org/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/card_global.c?view=diff&rev=6641&r1=6640&r2=6641
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/card_global.c (original)
+++ linux/trunk/drivers/dahdi/xpp/card_global.c Tue May 19 11:01:27 2009
@@ -307,9 +307,8 @@
BUG_ON(!xpd);
xbus = xpd->xbus;
- if(XBUS_IS(xbus, DISCONNECTED)) {
- XBUS_DBG(GENERAL, xbus, "Dropped packet. In state %s.\n",
- xbus_statename(XBUS_STATE(xbus)));
+ if(!XBUS_FLAGS(xbus, CONNECTED)) {
+ XBUS_DBG(GENERAL, xbus, "Dropped packet. Disconnected.\n");
return -EBUSY;
}
strlcpy(buf, cmdline, MAX_PROC_WRITE); /* Save a copy */
Modified: linux/trunk/drivers/dahdi/xpp/xbus-core.c
URL: http://svn.asterisk.org/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-core.c?view=diff&rev=6641&r1=6640&r2=6641
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-core.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-core.c Tue May 19 11:01:27 2009
@@ -90,7 +90,6 @@
case XBUS_STATE_READY: return "READY";
case XBUS_STATE_DEACTIVATING: return "DEACTIVATING";
case XBUS_STATE_DEACTIVATED: return "DEACTIVATED";
- case XBUS_STATE_DISCONNECTED: return "DISCONNECTED";
case XBUS_STATE_FAIL: return "FAIL";
}
return NULL;
@@ -481,7 +480,7 @@
BUG_ON(!xbus);
BUG_ON(!xframe);
BUG_ON(xframe->xframe_magic != XFRAME_MAGIC);
- if(XBUS_IS(xbus, DISCONNECTED)) {
+ if(!XBUS_FLAGS(xbus, CONNECTED)) {
XBUS_ERR(xbus, "Dropped command before sending -- hardware deactivated.\n");
dump_xframe("Dropped", xbus, xframe, DBG_ANY);
FREE_SEND_XFRAME(xbus, xframe);
@@ -562,7 +561,7 @@
BUG_ON(xframe->xframe_magic != XFRAME_MAGIC);
- if(XBUS_IS(xbus, DISCONNECTED)) {
+ if(!XBUS_FLAGS(xbus, CONNECTED)) {
XBUS_ERR(xbus, "Dropped command before queueing -- hardware deactivated.\n");
ret = -ENODEV;
goto err;
@@ -627,7 +626,7 @@
if(rx_tasklet) {
xframe_enqueue_recv(xbus, xframe);
} else {
- if(likely(!XBUS_IS(xbus, DISCONNECTED)))
+ if(likely(XBUS_FLAGS(xbus, CONNECTED)))
xframe_receive(xbus, xframe);
else
FREE_RECV_XFRAME(xbus, xframe); /* return to receive_pool */
@@ -1103,6 +1102,22 @@
return NULL;
}
+bool xbus_setflags(xbus_t *xbus, int flagbit, bool on)
+{
+ unsigned long flags;
+
+ spin_lock_irqsave(&xbus->transport.state_lock, flags);
+ XBUS_DBG(DEVICES, xbus, "%s flag %d\n",
+ (on) ? "Set" : "Clear",
+ flagbit);
+ if(on)
+ set_bit(flagbit, &(xbus->transport.transport_flags));
+ else
+ clear_bit(flagbit, &(xbus->transport.transport_flags));
+ spin_unlock_irqrestore(&xbus->transport.state_lock, flags);
+ return 1;
+}
+
bool xbus_setstate(xbus_t *xbus, enum xbus_state newstate)
{
unsigned long flags;
@@ -1139,19 +1154,19 @@
state_flip = 1; /* We are good */
break;
case XBUS_STATE_DEACTIVATING:
-#if 0
- if(XBUS_IS(xbus, DEACTIVATED) || XBUS_IS(xbus, DISCONNECTED))
+ if(XBUS_IS(xbus, DEACTIVATING))
goto bad_state;
-#endif
+ if(XBUS_IS(xbus, DEACTIVATED))
+ goto bad_state;
break;
case XBUS_STATE_DEACTIVATED:
if(!XBUS_IS(xbus, DEACTIVATING))
goto bad_state;
break;
- case XBUS_STATE_DISCONNECTED:
- break;
case XBUS_STATE_FAIL:
- if(XBUS_IS(xbus, DEACTIVATING) || XBUS_IS(xbus, DEACTIVATED) || XBUS_IS(xbus, DISCONNECTED))
+ if(XBUS_IS(xbus, DEACTIVATING))
+ goto bad_state;
+ if(XBUS_IS(xbus, DEACTIVATED))
goto bad_state;
break;
default:
@@ -1212,11 +1227,12 @@
BUG_ON(!ops->xframe_send_cmd);
BUG_ON(!ops->alloc_xframe);
BUG_ON(!ops->free_xframe);
+ xbus_setflags(xbus, XBUS_FLAG_CONNECTED, 1);
xbus_activate(xbus);
return 0;
}
-void xbus_deactivate(xbus_t *xbus, bool is_disconnected)
+void xbus_deactivate(xbus_t *xbus)
{
BUG_ON(!xbus);
XBUS_INFO(xbus, "[%s] Deactivating\n", xbus->label);
@@ -1230,16 +1246,15 @@
xbus_setstate(xbus, XBUS_STATE_DEACTIVATED);
worker_reset(xbus->worker);
xbus_release_xpds(xbus);
- if(!is_disconnected)
- xbus_setstate(xbus, XBUS_STATE_IDLE);
elect_syncer("deactivate");
}
void xbus_disconnect(xbus_t *xbus)
{
+ BUG_ON(!xbus);
XBUS_INFO(xbus, "[%s] Disconnecting\n", xbus->label);
- BUG_ON(!xbus);
- xbus_deactivate(xbus, 1);
+ xbus_setflags(xbus, XBUS_FLAG_CONNECTED, 0);
+ xbus_deactivate(xbus);
xbus_command_queue_clean(xbus);
xbus_command_queue_waitempty(xbus);
tasklet_kill(&xbus->receive_tasklet);
@@ -1247,7 +1262,6 @@
xframe_queue_clear(&xbus->send_pool);
xframe_queue_clear(&xbus->receive_pool);
xframe_queue_clear(&xbus->pcm_tospan);
- xbus_setstate(xbus, XBUS_STATE_DISCONNECTED);
del_timer_sync(&xbus->command_timer);
transportops_put(xbus);
transport_destroy(xbus);
@@ -1481,7 +1495,7 @@
xbus->busname,
xbus->connector,
xbus->label,
- (!XBUS_IS(xbus, DISCONNECTED)) ? "connected" : "missing"
+ (XBUS_FLAGS(xbus, CONNECTED)) ? "connected" : "missing"
);
len += xbus_fill_proc_queue(page + len, &xbus->send_pool);
len += xbus_fill_proc_queue(page + len, &xbus->receive_pool);
@@ -1726,7 +1740,7 @@
xbus->busname,
xbus->connector,
xbus->label,
- (!XBUS_IS(xbus, DISCONNECTED)) ? "connected" : "missing"
+ (XBUS_FLAGS(xbus, CONNECTED)) ? "connected" : "missing"
);
}
}
@@ -1763,6 +1777,7 @@
spin_lock_init(&xbus->transport.state_lock);
spin_lock_init(&xbus->transport.lock);
atomic_set(&xbus->transport.transport_refcount, 0);
+ xbus_setflags(xbus, XBUS_FLAG_CONNECTED, 0);
init_waitqueue_head(&xbus->transport.transport_unused);
}
Modified: linux/trunk/drivers/dahdi/xpp/xbus-core.h
URL: http://svn.asterisk.org/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-core.h?view=diff&rev=6641&r1=6640&r2=6641
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-core.h (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-core.h Tue May 19 11:01:27 2009
@@ -94,7 +94,6 @@
XBUS_STATE_READY,
XBUS_STATE_DEACTIVATING,
XBUS_STATE_DEACTIVATED,
- XBUS_STATE_DISCONNECTED,
XBUS_STATE_FAIL,
};
@@ -106,6 +105,7 @@
struct device *transport_device;
ushort max_send_size;
enum xbus_state xbus_state;
+ unsigned long transport_flags;
spinlock_t state_lock;
atomic_t transport_refcount;
wait_queue_head_t transport_unused;
@@ -116,6 +116,9 @@
#define XBUS_STATE(xbus) ((xbus)->transport.xbus_state)
#define XBUS_IS(xbus, st) (XBUS_STATE(xbus) == XBUS_STATE_ ## st)
#define TRANSPORT_EXIST(xbus) ((xbus)->transport.ops != NULL)
+
+#define XBUS_FLAG_CONNECTED 0
+#define XBUS_FLAGS(xbus, flg) test_bit(XBUS_FLAG_ ## flg, &((xbus)->transport.transport_flags))
struct xbus_ops *transportops_get(xbus_t *xbus);
void transportops_put(xbus_t *xbus);
@@ -300,11 +303,12 @@
xpd_t *xpd_of(const xbus_t *xbus, int xpd_num);
xpd_t *xpd_byaddr(const xbus_t *xbus, uint unit, uint subunit);
bool xbus_setstate(xbus_t *xbus, enum xbus_state newstate);
+bool xbus_setflags(xbus_t *xbus, int flagbit, bool on);
xbus_t *xbus_new(struct xbus_ops *ops, ushort max_send_size, struct device *transport_device, void *priv);
void xbus_free(xbus_t *xbus);
int xbus_connect(xbus_t *xbus);
int xbus_activate(xbus_t *xbus);
-void xbus_deactivate(xbus_t *xbus, bool is_disconnected);
+void xbus_deactivate(xbus_t *xbus);
void xbus_disconnect(xbus_t *xbus);
void xbus_receive_xframe(xbus_t *xbus, xframe_t *xframe);
int xbus_process_worker(xbus_t *xbus);
Modified: linux/trunk/drivers/dahdi/xpp/xbus-pcm.c
URL: http://svn.asterisk.org/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-pcm.c?view=diff&rev=6641&r1=6640&r2=6641
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-pcm.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-pcm.c Tue May 19 11:01:27 2009
@@ -414,7 +414,7 @@
(e.g: wrong firmware version, etc).
*/
if(xbus->self_ticking) {
- if(XBUS_IS(xbus, DISCONNECTED)) {
+ if(!XBUS_FLAGS(xbus, CONNECTED)) {
XBUS_DBG(GENERAL, xbus,
"Dropped packet. Is shutting down.\n");
} else {
@@ -554,7 +554,7 @@
xbus_t *xbus = xbus_num(i);
if(!xbus)
continue;
- if(!XBUS_IS(xbus, DISCONNECTED) && xbus != new_syncer) {
+ if(XBUS_FLAGS(xbus, CONNECTED) && xbus != new_syncer) {
if(xbus->self_ticking)
xbus_request_sync(xbus, SYNC_MODE_PLL);
else
Modified: linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c
URL: http://svn.asterisk.org/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c?view=diff&rev=6641&r1=6640&r2=6641
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xbus-sysfs.c Tue May 19 11:01:27 2009
@@ -86,7 +86,7 @@
xbus = dev_to_xbus(dev);
XBUS_DBG(GENERAL, xbus, "%s\n", buf);
if(strncmp(buf, "stop", 4) == 0)
- xbus_deactivate(xbus, 0);
+ xbus_deactivate(xbus);
else if(XBUS_IS(xbus, IDLE) && strncmp(buf, "start", 5) == 0)
xbus_activate(xbus);
else {
@@ -104,7 +104,7 @@
int ret;
xbus = dev_to_xbus(dev);
- ret = snprintf(buf, PAGE_SIZE, "%s\n", (!XBUS_IS(xbus, DISCONNECTED))?"connected":"missing");
+ ret = snprintf(buf, PAGE_SIZE, "%s\n", (XBUS_FLAGS(xbus, CONNECTED))?"connected":"missing");
return ret;
}
@@ -392,7 +392,11 @@
BUG_ON(!dev);
xbus = dev_to_xbus(dev);
- if(!XBUS_IS(xbus, DISCONNECTED)) {
+ if(XBUS_FLAGS(xbus, CONNECTED)) {
+ XBUS_ERR(xbus, "Try to release CONNECTED device.\n");
+ BUG();
+ }
+ if(!XBUS_IS(xbus, IDLE) && !XBUS_IS(xbus, FAIL) && !XBUS_IS(xbus, DEACTIVATED)) {
XBUS_ERR(xbus, "Try to release in state %s\n",
xbus_statename(XBUS_STATE(xbus)));
BUG();
Modified: linux/trunk/drivers/dahdi/xpp/xproto.c
URL: http://svn.asterisk.org/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xproto.c?view=diff&rev=6641&r1=6640&r2=6641
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xproto.c (original)
+++ linux/trunk/drivers/dahdi/xpp/xproto.c Tue May 19 11:01:27 2009
@@ -266,7 +266,7 @@
FREE_RECV_XFRAME(xbus, xframe);
return -EPROTO;
}
- if(XBUS_IS(xbus, DISCONNECTED)) {
+ if(!XBUS_FLAGS(xbus, CONNECTED)) {
XBUS_DBG(GENERAL, xbus, "Dropped xframe. Is shutting down.\n");
return -ENODEV;
}
Modified: linux/trunk/drivers/dahdi/xpp/xproto.h
URL: http://svn.asterisk.org/svn-view/dahdi/linux/trunk/drivers/dahdi/xpp/xproto.h?view=diff&rev=6641&r1=6640&r2=6641
==============================================================================
--- linux/trunk/drivers/dahdi/xpp/xproto.h (original)
+++ linux/trunk/drivers/dahdi/xpp/xproto.h Tue May 19 11:01:27 2009
@@ -147,9 +147,9 @@
do { \
int pack_len = RPACKET_SIZE(card,op); \
\
- if(XBUS_IS(xbus, DISCONNECTED)) \
+ if(!XBUS_FLAGS(xbus, CONNECTED)) \
return -ENODEV; \
- (frm) = ALLOC_SEND_XFRAME(xbus); \
+ (frm) = ALLOC_SEND_XFRAME(xbus); \
if(!(frm)) \
return -ENOMEM; \
(p) = xframe_next_packet(frm, pack_len); \
More information about the dahdi-commits
mailing list