diff options
| author | Johannes Demel <johannes.demel@ettus.com> | 2013-11-05 13:56:00 -0800 | 
|---|---|---|
| committer | Johannes Demel <johannes.demel@ettus.com> | 2013-11-19 12:33:22 -0800 | 
| commit | 25660c5c9e83e352e10d9fe9feb115d40a322353 (patch) | |
| tree | 41d9fd9d97a7ebb04664d2cb0a7afd314b479e1f /host/lib/usrp/b200 | |
| parent | 45a780cc858dd84e4883139ad2121aeb222d2d8e (diff) | |
| download | uhd-25660c5c9e83e352e10d9fe9feb115d40a322353.tar.gz uhd-25660c5c9e83e352e10d9fe9feb115d40a322353.tar.bz2 uhd-25660c5c9e83e352e10d9fe9feb115d40a322353.zip | |
b200/dtor-stall: fixed bug that stalled b200 on shutdown.
Diffstat (limited to 'host/lib/usrp/b200')
| -rw-r--r-- | host/lib/usrp/b200/b200_impl.cpp | 4 | ||||
| -rw-r--r-- | host/lib/usrp/b200/b200_impl.hpp | 4 | ||||
| -rw-r--r-- | host/lib/usrp/b200/b200_io_impl.cpp | 27 | 
3 files changed, 26 insertions, 9 deletions
| diff --git a/host/lib/usrp/b200/b200_impl.cpp b/host/lib/usrp/b200/b200_impl.cpp index 0da388b93..66ab813c2 100644 --- a/host/lib/usrp/b200/b200_impl.cpp +++ b/host/lib/usrp/b200/b200_impl.cpp @@ -252,7 +252,7 @@ b200_impl::b200_impl(const device_addr_t &device_addr)      ////////////////////////////////////////////////////////////////////      _async_task_data.reset(new AsyncTaskData());      _async_task_data->async_md.reset(new async_md_type(1000/*messages deep*/)); -    _async_task = uhd::task::make(boost::bind(&b200_impl::handle_async_task, this, _ctrl_transport, _async_task_data)); +    _async_task = uhd::msg_task::make(boost::bind(&b200_impl::handle_async_task, this, _ctrl_transport, _async_task_data));      ////////////////////////////////////////////////////////////////////      // Local control endpoint @@ -474,7 +474,7 @@ b200_impl::b200_impl(const device_addr_t &device_addr)  b200_impl::~b200_impl(void)  { -    UHD_SAFE_CALL +	UHD_SAFE_CALL      (          _async_task.reset();      ) diff --git a/host/lib/usrp/b200/b200_impl.hpp b/host/lib/usrp/b200/b200_impl.hpp index eced4a539..59a047e01 100644 --- a/host/lib/usrp/b200/b200_impl.hpp +++ b/host/lib/usrp/b200/b200_impl.hpp @@ -120,7 +120,7 @@ struct b200_impl : public uhd::device      boost::weak_ptr<uhd::tx_streamer> _tx_streamer;      //async ctrl + msgs -    uhd::task::sptr _async_task; +    uhd::msg_task::sptr _async_task;      typedef uhd::transport::bounded_buffer<uhd::async_metadata_t> async_md_type;      struct AsyncTaskData      { @@ -130,7 +130,7 @@ struct b200_impl : public uhd::device          b200_uart::sptr gpsdo_uart;      };      boost::shared_ptr<AsyncTaskData> _async_task_data; -    void handle_async_task(uhd::transport::zero_copy_if::sptr, boost::shared_ptr<AsyncTaskData>); +    boost::optional<uhd::msg_task::msg_type_t> handle_async_task(uhd::transport::zero_copy_if::sptr, boost::shared_ptr<AsyncTaskData>);      void register_loopback_self_test(uhd::wb_iface::sptr iface);      void codec_loopback_self_test(uhd::wb_iface::sptr iface); diff --git a/host/lib/usrp/b200/b200_io_impl.cpp b/host/lib/usrp/b200/b200_io_impl.cpp index d643ef855..069b8ff58 100644 --- a/host/lib/usrp/b200/b200_io_impl.cpp +++ b/host/lib/usrp/b200/b200_io_impl.cpp @@ -139,13 +139,24 @@ bool b200_impl::recv_async_msg(      return _async_task_data->async_md->pop_with_timed_wait(async_metadata, timeout);  } -void b200_impl::handle_async_task( +/* + * This method is constantly called in a msg_task loop. + * Incoming messages are dispatched in to the hosts radio_ctrl_cores. + * The radio_ctrl_core queues are accessed via a weak_ptr to them, stored in AsyncTaskData. + * During shutdown the radio_ctrl_core dtor's are called. + * An empty peek32(0) is sent out to flush pending async messages. + * The response to those messages can't be delivered to the ctrl_core queues anymore + * because the shared pointer corresponding to the weak_ptrs is no longer valid. + * Those stranded messages are put into a dump_queue implemented in msg_task. + * A radio_ctrl_core can search for missing messages there. + */ +boost::optional<uhd::msg_task::msg_type_t> b200_impl::handle_async_task(      uhd::transport::zero_copy_if::sptr xport,      boost::shared_ptr<AsyncTaskData> data  )  { -    managed_recv_buffer::sptr buff = xport->get_recv_buff(); -    if (not buff or buff->size() < 8) return; +	managed_recv_buffer::sptr buff = xport->get_recv_buff(); +    if (not buff or buff->size() < 8) return NULL;      const boost::uint32_t sid = uhd::wtohx(buff->cast<const boost::uint32_t *>()[1]);      switch (sid)      { @@ -155,11 +166,16 @@ void b200_impl::handle_async_task(      case B200_RESP1_MSG_SID:      case B200_LOCAL_RESP_SID:      { -        radio_ctrl_core_3000::sptr ctrl; +    	radio_ctrl_core_3000::sptr ctrl;          if (sid == B200_RESP0_MSG_SID) ctrl = data->radio_ctrl[0].lock();          if (sid == B200_RESP1_MSG_SID) ctrl = data->radio_ctrl[1].lock();          if (sid == B200_LOCAL_RESP_SID) ctrl = data->local_ctrl.lock(); -        if (ctrl) ctrl->push_response(buff->cast<const boost::uint32_t *>()); +        if (ctrl){ +        	ctrl->push_response(buff->cast<const boost::uint32_t *>()); +        } +        else{ +            return std::make_pair(sid, uhd::msg_task::buff_to_vector(buff->cast<boost::uint8_t *>(), buff->size() ) ); +        }          break;      } @@ -204,6 +220,7 @@ void b200_impl::handle_async_task(      default:          UHD_MSG(error) << "Got a ctrl packet with unknown SID " << sid << std::endl;      } +    return NULL;  }  /*********************************************************************** | 
