Changeset c4e84ed6 in mainline for uspace/drv/bus/usb/usbhub/usbhub.h


Ignore:
Timestamp:
2018-01-16T03:45:38Z (7 years ago)
Author:
Ondřej Hlavatý <aearsis@…>
Branches:
lfn, master, serial, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
Children:
c952abc4
Parents:
d2c3dcd
git-author:
Ondřej Hlavatý <aearsis@…> (2018-01-15 20:49:15)
git-committer:
Ondřej Hlavatý <aearsis@…> (2018-01-16 03:45:38)
Message:

usbhub: rewrite port handling

The state space of a usb hub port is a bit more complex than what was
there originally. Got rid of the active operations counting, and
replaced that with finite state machine. Fixes a lot of race conditions
and lack of synchronization when connect and disconnect events come very
fast.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/drv/bus/usb/usbhub/usbhub.h

    rd2c3dcd rc4e84ed6  
    5050
    5151#include "port.h"
     52#include "status.h"
    5253
    5354/** Information about attached hub. */
     
    6162        /** Data polling handle. */
    6263        usb_polling_t polling;
    63         /** Number of pending operations on the mutex to prevent shooting
    64          * ourselves in the foot.
    65          * When the hub is disconnected but we are in the middle of some
    66          * operation, we cannot destroy this structure right away because
    67          * the pending operation might use it.
    68          */
    69         size_t pending_ops_count;
    70         /** Guard for pending_ops_count. */
    71         fibril_mutex_t pending_ops_mutex;
    72         /** Condition variable for pending_ops_count. */
    73         fibril_condvar_t pending_ops_cv;
    7464        /** Pointer to usbhub function. */
    7565        ddf_fun_t *hub_fun;
    76         /** Status indicator */
    77         volatile bool running;
     66        /** Device communication pipe. */
     67        usb_pipe_t *control_pipe;
    7868        /** Hub supports port power switching. */
    7969        bool power_switched;
     
    8474extern const usb_endpoint_description_t hub_status_change_endpoint_description;
    8575
    86 extern int usb_hub_device_add(usb_device_t *);
    87 extern int usb_hub_device_remove(usb_device_t *);
    88 extern int usb_hub_device_gone(usb_device_t *);
     76int usb_hub_device_add(usb_device_t *);
     77int usb_hub_device_remove(usb_device_t *);
     78int usb_hub_device_gone(usb_device_t *);
    8979
    90 extern bool hub_port_changes_callback(usb_device_t *, uint8_t *, size_t,
    91     void *);
     80int usb_hub_get_port_status(const usb_hub_dev_t *, size_t, usb_port_status_t *);
     81int usb_hub_set_port_feature(const usb_hub_dev_t *, size_t, usb_hub_class_feature_t);
     82int usb_hub_clear_port_feature(const usb_hub_dev_t *, size_t, usb_hub_class_feature_t);
     83
     84bool hub_port_changes_callback(usb_device_t *, uint8_t *, size_t, void *);
    9285
    9386#endif
Note: See TracChangeset for help on using the changeset viewer.