[svn-commits] tzafrir: branch linux/tzafrir/sysfs r8767 - /linux/team/tzafrir/sysfs/drivers...
SVN commits to the Digium repositories
svn-commits at lists.digium.com
Mon Jun 14 15:49:52 CDT 2010
Author: tzafrir
Date: Mon Jun 14 15:49:49 2010
New Revision: 8767
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8767
Log:
Safety against unplug/plug same PRI-AB
* Asterisk does not release D-Channel on removal events:
- As a result, we cannot destroy those XPD's and XBUS's when unplugged.
- On repluging, the XBUS identified as new AB and very bad things happen.
* The fix is to block dbus_activate() if we have an XBUS with same LABEL.
* When asterisk is closed and the old, NOHW, AB is released, we can trigger
the new AB activation via:
echo start > /sys/bus/astribanks/devices/xbus-.../xbus_state
Modified:
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_global.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.h
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_global.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_global.c?view=diff&rev=8767&r1=8766&r2=8767
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_global.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_global.c Mon Jun 14 15:49:49 2010
@@ -431,6 +431,8 @@
DBG(DEVICES, "NO XBUS\n");
return -EINVAL;
}
+ if (xbus_check_unique(xbus))
+ return -EBUSY;
XFRAME_NEW_CMD(xframe, pack, xbus, GLOBAL, AB_REQUEST, 0);
RPACKET_FIELD(pack, GLOBAL, AB_REQUEST, rev) = XPP_PROTOCOL_VERSION;
RPACKET_FIELD(pack, GLOBAL, AB_REQUEST, reserved) = 0;
@@ -610,6 +612,8 @@
goto proto_err;
}
XBUS_INFO(xbus, "DESCRIPTOR: %d cards, protocol revision %d\n", count_units, rev);
+ if (xbus_check_unique(xbus))
+ return -EBUSY;
xbus->revision = rev;
if(!worker) {
XBUS_ERR(xbus, "missing worker\n");
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.c?view=diff&rev=8767&r1=8766&r2=8767
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.c Mon Jun 14 15:49:49 2010
@@ -80,6 +80,50 @@
static struct xbus_desc {
xbus_t *xbus;
} xbuses_array[MAX_BUSES];
+
+static xbus_t *xbus_byhwid(const char *hwid)
+{
+ int i;
+ xbus_t *xbus;
+
+ for (i = 0; i < ARRAY_SIZE(xbuses_array); i++) {
+ xbus = xbuses_array[i].xbus;
+ if (xbus && strcmp(hwid, xbus->label) == 0)
+ return xbus;
+ }
+ return NULL;
+}
+
+
+/* If an Astribank disconnected and then reconnected, we prefer not to
+ fully initialize it
+ */
+int xbus_check_unique(xbus_t *xbus)
+{
+ xbus_t *xbus_old;
+
+ if (!xbus)
+ return -ENOENT;
+ if (!xbus->label) {
+ XBUS_NOTICE(xbus, "Astribank without a Label: Bad.\n");
+ return 0;
+ }
+
+ XBUS_DBG(DEVICES, xbus, "Checking LABEL='%s'\n", xbus->label);
+ xbus_old = xbus_byhwid(xbus->label);
+ if (xbus_old && xbus_old != xbus) {
+ XBUS_NOTICE(xbus_old,
+ /* FIXME: rephrase message to hint this is a
+ reconnecting AB */
+ "Duplicate LABEL='%s'. Leave %s unused. refcount_xbus=%d\n",
+ xbus_old->label,
+ xbus->busname,
+ refcount_xbus(xbus_old));
+ return -EBUSY;
+ }
+
+ return 0;
+}
const char *xbus_statename(enum xbus_state st)
{
@@ -1200,6 +1244,8 @@
int xbus_activate(xbus_t *xbus)
{
XBUS_INFO(xbus, "[%s] Activating\n", xbus->label);
+ if (xbus_check_unique(xbus))
+ return -EBUSY;
xpp_drift_init(xbus);
xbus_set_command_timer(xbus, 1);
xframe_queue_disable(&xbus->command_queue, 0);
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.h?view=diff&rev=8767&r1=8766&r2=8767
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.h (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.h Mon Jun 14 15:49:49 2010
@@ -302,6 +302,7 @@
xpd_t *xpd_of(const xbus_t *xbus, int xpd_num);
xpd_t *xpd_byaddr(const xbus_t *xbus, uint unit, uint subunit);
+int xbus_check_unique(xbus_t *xbus);
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);
More information about the svn-commits
mailing list