xpp: stability fixes - xusb mutex

 * Replace old semaphore with mutex
 * Use this mutex for BOTH usb probe/disconnect

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: stability -- cleaner xpp_open/close

 * No need to use spinlock.
 * Just correctly use the atomic open_counter.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: stability -- better debug information

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: stability -- deadlock in waitfor_xpds()

waitfor_xpds xbus sysfs file should not take an xbus refcount:

* It is called from sysfs which maintain its own device refcount.
* If put_xbus() calls xbus_destroy() than down the call chain it will
  try to release an object that is held by sysfs.
* This will create a deadlock.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: stability -- better xbus shut down

* Maintain a "shutting_down" flag per-xbus
* Use it to prevent xbus dereferencing (via xbus_get()/xbus_put())
  during an xbus shutdown.
* Also, remove xbus from global array earlier.

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: demote some NOTICE() to DBG()

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
xpp: re-organize calls so worker_reset()

re-organize calls so worker_reset() isn't called twice
(was called from xbus_disconnect() and worker_destroy())

Signed-off-by: Tzafrir Cohen <tzafrir.cohen@xorcom.com>
wctc4xxp: Handle all known interrupts regardless of mask.

When switching to polling mode it was possible that we would mask off the
receive complete interrupt until the next timer fired. Now go ahead and handle
anything we know how to handle regardless of the current mask.

Also, no need to update the reg local anymore since it isn't used to ack any
interrupts. We now always ack all the interrupts first and inspect them all.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
wctc4xxp: Speed up the rate of polling.

The polling interval was not fast enough to keep the tx ring full on a loaded
card. This fixes a regression introduced in commits
ba05e31c8a786d7524fd1aed47feda27331606dd and
354d88cd418627285e86e77cceb9318e33f0348c.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
wctc4xxp: Fix the timestamp calculation for the RTP stream.

I do not have any evidence that this made a difference, but hopefully it will
clear things up for people in the future who might be wondering why the
timestamp does not increase with the number of samples actually sent.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
wctc4xxp: Service tx ring in interrupt handler.

This helps to keep the tx descriptor ring at max capacity when the system is
otherwise loaded. Now ready packets are moved from cmd_list to the transmit
descriptor ring directly in the interrupt handler and not when the deferred
function runs.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
wctc4xxp: Prevent exhausting memory in firmware.

If the host system sends to many packets to the DTE to process, the on-card
memory can be exhausted which will result in an out of memory alert. In commit
2ac233824705e2f5f1cf67b6b22459fa20e9aa4c, the driver will halt all communication
with the card and request a reload if any alert is received.

Now the driver will silently drop any "burst" traffic that was sent to the
transcoder as opposed to expecting the firmware to do it. There is currently a
limit of 640 samples (80ms of audio) in flight to the firmware at any one time
allowed.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>
Signed-off-by: Russ Meyerriecks <rmeyerriecks@digium.com>
wctc4xxp: Trivial fix typo that was preventing firmware load.

The interrupt handler was not schedulding the deferred processing routine when
there was packets to process. I did not test the actual master branch after
editing for checkpatch compliance. Sorry.

Signed-off-by: Shaun Ruffell <sruffell@digium.com>