[dahdi-commits] tzafrir: branch linux/tzafrir/sysfs r8910 - in /linux/team/tzafrir/sysfs: ./ ...
SVN commits to the DAHDI project
dahdi-commits at lists.digium.com
Tue Jul 13 13:56:33 CDT 2010
Author: tzafrir
Date: Tue Jul 13 13:56:29 2010
New Revision: 8910
URL: http://svnview.digium.com/svn/dahdi?view=rev&rev=8910
Log:
Merged revisions 8904-8905,8909 via svnmerge from
https://origsvn.digium.com/svn/dahdi/linux/trunk
........
r8904 | tzafrir | 2010-07-13 19:28:37 +0300 (Tue, 13 Jul 2010) | 7 lines
Create /sys/devices/astribanks:
* Astribank devices now reside under their own top-level device.
* The USB device is still used as the 'transport'.
* This means the astribanks parents are NOT the USB devices.
* As a result, even after a USB disconnect, we have valid sysfs representation.
........
r8905 | tzafrir | 2010-07-13 20:25:06 +0300 (Tue, 13 Jul 2010) | 5 lines
prevent handling of duplicate Astribanks
Don't let AB which are unplugged/replugged create duplicate XBUS's (if
asterisk don't close the original channels).
........
r8909 | tzafrir | 2010-07-13 21:35:20 +0300 (Tue, 13 Jul 2010) | 7 lines
PRI Astribanks always sync AB (and independent)
* PRI devices always get SYNC-AB (never PLL, not even for NT)
* Fix Timing priority calculation accordingly.
* On PRI layer1 changes, elect_syncer() is called, so we have
re-election.
........
Modified:
linux/team/tzafrir/sysfs/ (props changed)
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_bri.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxo.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxs.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_pri.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.h
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.h
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-sysfs.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp_dahdi.c
linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xproto.h
Propchange: linux/team/tzafrir/sysfs/
------------------------------------------------------------------------------
automerge = YES
Propchange: linux/team/tzafrir/sysfs/
------------------------------------------------------------------------------
--- svnmerge-integrated (original)
+++ svnmerge-integrated Tue Jul 13 13:56:29 2010
@@ -1,1 +1,1 @@
-/linux/trunk:1-8902
+/linux/trunk:1-8909
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_bri.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_bri.c?view=diff&rev=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_bri.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_bri.c Tue Jul 13 13:56:29 2010
@@ -1671,6 +1671,7 @@
.card_pcm_recompute = BRI_card_pcm_recompute,
.card_pcm_fromspan = BRI_card_pcm_fromspan,
.card_pcm_tospan = BRI_card_pcm_tospan,
+ .card_timing_priority = generic_timing_priority,
.card_ioctl = BRI_card_ioctl,
.card_open = BRI_card_open,
.card_close = BRI_card_close,
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxo.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxo.c?view=diff&rev=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxo.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxo.c Tue Jul 13 13:56:29 2010
@@ -1133,6 +1133,7 @@
.card_pcm_recompute = generic_card_pcm_recompute,
.card_pcm_fromspan = generic_card_pcm_fromspan,
.card_pcm_tospan = generic_card_pcm_tospan,
+ .card_timing_priority = generic_timing_priority,
.card_ioctl = FXO_card_ioctl,
.card_open = FXO_card_open,
.card_register_reply = FXO_card_register_reply,
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxs.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxs.c?view=diff&rev=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxs.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_fxs.c Tue Jul 13 13:56:29 2010
@@ -1409,6 +1409,7 @@
.card_pcm_recompute = generic_card_pcm_recompute,
.card_pcm_fromspan = generic_card_pcm_fromspan,
.card_pcm_tospan = generic_card_pcm_tospan,
+ .card_timing_priority = generic_timing_priority,
.card_open = FXS_card_open,
.card_close = FXS_card_close,
.card_ioctl = FXS_card_ioctl,
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_pri.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_pri.c?view=diff&rev=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_pri.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/card_pri.c Tue Jul 13 13:56:29 2010
@@ -1193,6 +1193,7 @@
return NULL;
}
#endif
+ xbus->sync_mode_default = SYNC_MODE_AB;
return xpd;
}
@@ -1825,6 +1826,18 @@
}
XPD_COUNTER(xpd, PCM_READ)++;
spin_unlock_irqrestore(&xpd->lock, flags);
+}
+
+int PRI_timing_priority(xbus_t *xbus, xpd_t *xpd)
+{
+ struct PRI_priv_data *priv;
+
+ priv = xpd->priv;
+ BUG_ON(!priv);
+ if (priv->layer1_up)
+ return xpd->timing_priority;
+ XPD_DBG(SYNC, xpd, "No timing priority (no layer1)\n");
+ return -ENOENT;
}
/*---------------- PRI: HOST COMMANDS -------------------------------------*/
@@ -1917,6 +1930,7 @@
send_idlebits(xpd, 1);
}
xpd->span.alarms = alarms;
+ elect_syncer("LAYER1");
dahdi_alarm_notify(&xpd->span);
set_clocking(xpd);
}
@@ -2140,6 +2154,7 @@
.card_pcm_recompute = PRI_card_pcm_recompute,
.card_pcm_fromspan = PRI_card_pcm_fromspan,
.card_pcm_tospan = PRI_card_pcm_tospan,
+ .card_timing_priority = PRI_timing_priority,
.card_ioctl = PRI_card_ioctl,
.card_close = PRI_card_close,
.card_register_reply = PRI_card_register_reply,
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=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.c Tue Jul 13 13:56:29 2010
@@ -1485,6 +1485,7 @@
worker_init(xbus);
atomic_set(&xbus->num_xpds, 0);
xbus->sync_mode = SYNC_MODE_NONE;
+ xbus->sync_mode_default = SYNC_MODE_PLL;
err = xbus_sysfs_create(xbus);
if(err) {
XBUS_ERR(xbus, "SYSFS creation failed: %d\n", err);
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=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.h (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-core.h Tue Jul 13 13:56:29 2010
@@ -194,6 +194,8 @@
bool self_ticking;
enum sync_mode sync_mode;
+ /* Managed by low-level drivers: */
+ enum sync_mode sync_mode_default;
struct timer_list command_timer;
unsigned int xbus_frag_count;
struct xframe_queue pcm_tospan;
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.c?view=diff&rev=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.c Tue Jul 13 13:56:29 2010
@@ -56,6 +56,7 @@
*/
static struct xpp_ticker *ref_ticker = NULL;
static spinlock_t ref_ticker_lock = SPIN_LOCK_UNLOCKED;
+static spinlock_t elect_syncer_lock = SPIN_LOCK_UNLOCKED;
static bool force_dahdi_sync = 0; /* from /sys/bus/astribanks/drivers/xppdrv/sync */
static xbus_t *global_ticker;
static struct xpp_ticker global_ticks_series;
@@ -305,17 +306,17 @@
return sync_mode_names[mode];
}
+/*
+ * Caller must aquire/release the 'ref_ticker_lock' spinlock
+ */
static void xpp_set_syncer(xbus_t *xbus, bool on)
{
- unsigned long flags;
-
- spin_lock_irqsave(&ref_ticker_lock, flags);
if(!xbus) { /* Special case, no more syncers */
DBG(SYNC, "No more syncers\n");
syncer = NULL;
if(ref_ticker != &dahdi_ticker)
ref_ticker = NULL;
- goto out;
+ return;
}
if(syncer != xbus && on) {
XBUS_DBG(SYNC, xbus, "New syncer\n");
@@ -329,8 +330,6 @@
XBUS_DBG(SYNC, xbus, "ignore %s (current syncer: %s)\n",
(on)?"ON":"OFF",
(syncer) ? syncer->busname : "NO-SYNC");
-out:
- spin_unlock_irqrestore(&ref_ticker_lock, flags);
}
static void xbus_command_timer(unsigned long param)
@@ -369,11 +368,14 @@
void got_new_syncer(xbus_t *xbus, enum sync_mode mode, int drift)
{
unsigned long flags;
+ unsigned long flags2;
spin_lock_irqsave(&xbus->lock, flags);
+ spin_lock_irqsave(&ref_ticker_lock, flags2);
xbus->sync_adjustment = (signed char)drift;
if(xbus->sync_mode == mode) {
- /* XBUS_DBG(SYNC, xbus, "Already in mode '%s'. Ignored\n", sync_mode_name(mode)); */
+ XBUS_DBG(SYNC, xbus, "Already in mode '%s'. Ignored\n",
+ sync_mode_name(mode));
goto out;
}
XBUS_DBG(SYNC, xbus, "Mode %s (%d), drift=%d (pcm_rx_counter=%d)\n",
@@ -402,15 +404,32 @@
XBUS_ERR(xbus, "%s: unknown mode=0x%X\n", __FUNCTION__, mode);
}
out:
+ spin_unlock_irqrestore(&ref_ticker_lock, flags2);
spin_unlock_irqrestore(&xbus->lock, flags);
}
void xbus_request_sync(xbus_t *xbus, enum sync_mode mode)
{
+ unsigned long flags;
+
BUG_ON(!xbus);
XBUS_DBG(SYNC, xbus, "sent request (mode=%d)\n", mode);
CALL_PROTO(GLOBAL, SYNC_SOURCE, xbus, NULL, mode, 0);
if(mode == SYNC_MODE_NONE) {
+ /*
+ * We must deselect the syncer *now* and not wait for the
+ * reply from the AB. Otherwise, a disconnect of the syncing
+ * AB would result in a corrupted 'syncer'.
+ */
+ spin_lock_irqsave(&ref_ticker_lock, flags);
+ xpp_set_syncer(xbus, 0);
+ spin_unlock_irqrestore(&ref_ticker_lock, flags);
+ /*
+ * We must activate timer now since the commands go to
+ * the command queue, and we should maintain something to
+ * "tick" meanwhile until the AB get these commands and
+ * start being "self_ticking".
+ */
xbus_set_command_timer(xbus, 1);
}
}
@@ -559,6 +578,7 @@
force_dahdi_sync = 0;
ref_ticker = &new_syncer->ticker;
xbus_drift_clear(new_syncer); /* Clean new data */
+ xpp_set_syncer(new_syncer, 1);
xbus_request_sync(new_syncer, SYNC_MODE_AB);
} else if(force_dahdi_sync) {
ref_ticker = &dahdi_ticker;
@@ -574,7 +594,8 @@
continue;
if(XBUS_FLAGS(xbus, CONNECTED) && xbus != new_syncer) {
if(xbus->self_ticking)
- xbus_request_sync(xbus, SYNC_MODE_PLL);
+ xbus_request_sync(xbus,
+ xbus->sync_mode_default);
else
XBUS_DBG(SYNC, xbus, "Not self_ticking yet. Ignore\n");
}
@@ -588,7 +609,9 @@
uint timing_priority = INT_MAX;
xpd_t *best_xpd = NULL;
xbus_t *the_xbus = NULL;
-
+ unsigned long flags;
+
+ spin_lock_irqsave(&elect_syncer_lock, flags);
for(i = 0; i < MAX_BUSES; i++) {
xbus_t *xbus = xbus_num(i);
if(!xbus)
@@ -598,11 +621,19 @@
the_xbus = xbus; /* First candidate */
for(j = 0; j < MAX_XPDS; j++) {
xpd_t *xpd = xpd_of(xbus, j);
+ int prio;
if(!xpd || !xpd->card_present)
continue;
- if(xpd->timing_priority > 0 && xpd->timing_priority < timing_priority) {
- timing_priority = xpd->timing_priority;
+ prio = CALL_XMETHOD(card_timing_priority,
+ xbus, xpd);
+ if (prio < 0) {
+ DBG(SYNC, "%s/%s: skip sync\n",
+ xbus->busname, xpd->xpdname);
+ continue;
+ }
+ if (prio > 0 && prio < timing_priority) {
+ timing_priority = prio;
best_xpd = xpd;
}
}
@@ -614,12 +645,17 @@
} else if(the_xbus) {
XBUS_DBG(SYNC, the_xbus, "%s: elected\n", msg);
} else {
+ unsigned long flags;
+
DBG(SYNC, "%s: No more syncers\n", msg);
+ spin_lock_irqsave(&ref_ticker_lock, flags);
xpp_set_syncer(NULL, 0);
+ spin_unlock_irqrestore(&ref_ticker_lock, flags);
the_xbus = NULL;
}
if(the_xbus != syncer)
update_sync_master(the_xbus, force_dahdi_sync);
+ spin_unlock_irqrestore(&elect_syncer_lock, flags);
}
/*
@@ -960,6 +996,11 @@
out:
FREE_RECV_XFRAME(xbus, xframe);
return ret;
+}
+
+int generic_timing_priority(xbus_t *xbus, xpd_t *xpd)
+{
+ return xpd->timing_priority;
}
static void xbus_tick(xbus_t *xbus)
@@ -1290,6 +1331,7 @@
EXPORT_SYMBOL(generic_card_pcm_recompute);
EXPORT_SYMBOL(generic_card_pcm_tospan);
EXPORT_SYMBOL(generic_card_pcm_fromspan);
+EXPORT_SYMBOL(generic_timing_priority);
#ifdef DEBUG_PCMTX
EXPORT_SYMBOL(pcmtx);
EXPORT_SYMBOL(pcmtx_chan);
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.h?view=diff&rev=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.h (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-pcm.h Tue Jul 13 13:56:29 2010
@@ -108,6 +108,7 @@
void generic_card_pcm_recompute(xbus_t *xbus, xpd_t *xpd, xpp_line_t pcm_mask);
void generic_card_pcm_fromspan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
void generic_card_pcm_tospan(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
+int generic_timing_priority(xbus_t *xbus, xpd_t *xpd);
void fill_beep(u_char *buf, int num, int duration);
const char *sync_mode_name(enum sync_mode mode);
void xbus_set_command_timer(xbus_t *xbus, bool on);
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-sysfs.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-sysfs.c?view=diff&rev=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-sysfs.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xbus-sysfs.c Tue Jul 13 13:56:29 2010
@@ -440,6 +440,16 @@
XBUS_INFO(xbus, "[%s] Astribank Release\n", xbus->label);
xbus_free(xbus);
}
+
+static void toplevel_release(struct device *dev)
+{
+ NOTICE("%s\n", __func__);
+}
+
+static struct device toplevel_device = {
+ .release = toplevel_release,
+ /* No Parent */
+};
static struct bus_type toplevel_bus_type = {
.name = "astribanks",
@@ -815,12 +825,19 @@
int xbus_sysfs_transport_create(xbus_t *xbus)
{
struct device *astribank;
+ struct device *transport_device;
int ret = 0;
BUG_ON(!xbus);
XBUS_DBG(DEVICES, xbus, "\n");
astribank = &xbus->astribank;
- ret = sysfs_create_link(&astribank->kobj, &astribank->parent->kobj,
+ BUG_ON(!astribank);
+ transport_device = xbus->transport.transport_device;
+ if (!transport_device) {
+ XBUS_ERR(xbus, "%s: Missing transport_device\n", __func__);
+ return -ENODEV;
+ }
+ ret = sysfs_create_link(&astribank->kobj, &transport_device->kobj,
"transport");
if (ret < 0) {
XBUS_ERR(xbus, "%s: sysfs_create_link failed: %d\n",
@@ -853,7 +870,7 @@
astribank = &xbus->astribank;
XBUS_DBG(DEVICES, xbus, "\n");
astribank->bus = &toplevel_bus_type;
- astribank->parent = xbus->transport.transport_device;
+ astribank->parent = &toplevel_device;
dev_set_name(astribank, "xbus-%02d", xbus->num);
dev_set_drvdata(astribank, xbus);
astribank->release = astribank_release;
@@ -870,6 +887,12 @@
int ret;
DBG(DEVICES, "SYSFS\n");
+ dev_set_name(&toplevel_device, "astribanks");
+ ret = device_register(&toplevel_device);
+ if (ret) {
+ ERR("%s: toplevel device_register failed: %d\n", __func__, ret);
+ goto failed_toplevel;
+ }
if((ret = bus_register(&toplevel_bus_type)) < 0) {
ERR("%s: bus_register(%s) failed. Error number %d",
__FUNCTION__, toplevel_bus_type.name, ret);
@@ -891,6 +914,8 @@
failed_xpp_driver:
bus_unregister(&toplevel_bus_type);
failed_bus:
+ device_unregister(&toplevel_device);
+failed_toplevel:
return ret;
}
@@ -900,6 +925,7 @@
bus_unregister(&xpd_type);
driver_unregister(&xpp_driver);
bus_unregister(&toplevel_bus_type);
+ device_unregister(&toplevel_device);
}
EXPORT_SYMBOL(xpd_driver_register);
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp_dahdi.c
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp_dahdi.c?view=diff&rev=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp_dahdi.c (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xpp_dahdi.c Tue Jul 13 13:56:29 2010
@@ -130,7 +130,7 @@
xpd_t *xpd;
xpd = kref_to_xpd(kref);
- XPD_NOTICE(xpd, "%s\n", __func__);
+ XPD_DBG(DEVICES, xpd, "%s\n", __func__);
xpd_device_unregister(xpd);
}
Modified: linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xproto.h
URL: http://svnview.digium.com/svn/dahdi/linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xproto.h?view=diff&rev=8910&r1=8909&r2=8910
==============================================================================
--- linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xproto.h (original)
+++ linux/team/tzafrir/sysfs/drivers/dahdi/xpp/xproto.h Tue Jul 13 13:56:29 2010
@@ -226,6 +226,7 @@
void (*card_pcm_recompute)(xbus_t *xbus, xpd_t *xpd, xpp_line_t pcm_mask);
void (*card_pcm_fromspan)(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
void (*card_pcm_tospan)(xbus_t *xbus, xpd_t *xpd, xpacket_t *pack);
+ int (*card_timing_priority)(xbus_t *xbus, xpd_t *xpd);
int (*card_dahdi_preregistration)(xpd_t *xpd, bool on);
int (*card_dahdi_postregistration)(xpd_t *xpd, bool on);
int (*card_hooksig)(xbus_t *xbus, xpd_t *xpd, int pos, enum dahdi_txsig txsig);
More information about the dahdi-commits
mailing list