Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

development/chipset/rtl8822bu #25

Open
wants to merge 3 commits into
base: development/chipset/rtl8822bu
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 4 additions & 5 deletions mac.c
Original file line number Diff line number Diff line change
Expand Up @@ -924,24 +924,23 @@ static void __rtw_mac_flush_prio_queue(struct rtw_dev *rtwdev,
const struct rtw_prioq_addr *addr;
bool wsize;
u16 avail_page, rsvd_page;
int i;
unsigned long wait_end;

if (prio_queue >= RTW_DMA_MAPPING_MAX)
return;

addr = &chip->prioq_addrs->prio[prio_queue];
wsize = chip->prioq_addrs->wsize;

/* check if all of the reserved pages are available for 100 msecs */
for (i = 0; i < 5; i++) {
/* check if all of the reserved pages are available for 1000 msecs */
wait_end = jiffies + msecs_to_jiffies(1000);
for (; time_before(jiffies, wait_end); msleep(20)) {
rsvd_page = wsize ? rtw_read16(rtwdev, addr->rsvd) :
rtw_read8(rtwdev, addr->rsvd);
avail_page = wsize ? rtw_read16(rtwdev, addr->avail) :
rtw_read8(rtwdev, addr->avail);
if (rsvd_page == avail_page)
return;

msleep(20);
}

/* priority queue is still not empty, throw a warning,
Expand Down
23 changes: 20 additions & 3 deletions usb.c
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,15 @@ static int rtw_usb_ctrl_atomic(struct rtw_dev *rtwdev,
__u8 req_type, __u16 value, __u16 index,
void *databuf, __u16 size)
{
struct rtw_usb *rtwusb = (struct rtw_usb *)rtwdev->priv;
struct usb_ctrlrequest *dr = NULL;
struct rtw_usb_ctrlcb_t *ctx = NULL;
struct urb *urb = NULL;
bool done;
int ret = -ENOMEM;

if (rtwusb->usb_removed)
return -ENODEV;
ctx = kmalloc(sizeof(*ctx), GFP_ATOMIC);
if (!ctx)
goto out;
Expand All @@ -102,7 +105,11 @@ static int rtw_usb_ctrl_atomic(struct rtw_dev *rtwdev,
usb_fill_control_urb(urb, dev, pipe, (unsigned char *)dr, databuf, size,
rtw_usb_ctrl_atomic_cb, ctx);
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (unlikely(ret)) {
if (unlikely(ret == -ENODEV) || unlikely(ret == -ENOENT)) {
rtwusb->usb_removed = 1;
rtw_warn(rtwdev, "usb device removed");
goto err_free_urb;
} else if (unlikely(ret)) {
rtw_err(rtwdev, "failed to submit urb, ret=%d\n", ret);
goto err_free_urb;
}
Expand Down Expand Up @@ -628,6 +635,8 @@ static int rtw_usb_write_port(struct rtw_dev *rtwdev, u8 addr, u32 cnt,
unsigned int pipe;
int ret;

if (rtwusb->usb_removed)
return -ENODEV;
pipe = rtw_usb_get_pipe(rtwusb, addr);
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb)
Expand All @@ -636,7 +645,10 @@ static int rtw_usb_write_port(struct rtw_dev *rtwdev, u8 addr, u32 cnt,
usb_fill_bulk_urb(urb, usbd, pipe, skb->data, (int)cnt,
cb, context);
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (unlikely(ret))
if (unlikely(ret == -ENODEV) || unlikely(ret == -ENOENT)) {
rtwusb->usb_removed = 1;
rtw_warn(rtwdev, "usb device removed");
} else if (unlikely(ret))
rtw_err(rtwdev, "failed to submit write urb, ret=%d\n", ret);
usb_free_urb(urb);

Expand Down Expand Up @@ -1024,6 +1036,8 @@ static void rtw_usb_read_port(struct rtw_dev *rtwdev, u8 addr,
u32 len;
int ret;

if (rtwusb->usb_removed)
return;
urb = usb_alloc_urb(0, GFP_ATOMIC);
if (!urb)
return;
Expand All @@ -1048,7 +1062,10 @@ static void rtw_usb_read_port(struct rtw_dev *rtwdev, u8 addr,
rtw_usb_read_port_complete,
rxcb);
ret = usb_submit_urb(urb, GFP_ATOMIC);
if (ret)
if (unlikely(ret == -ENODEV) || unlikely(ret == -ENOENT)) {
rtwusb->usb_removed = 1;
rtw_warn(rtwdev, "usb device removed");
} else if (ret)
rtw_err(rtwdev, "failed to submit USB urb, ret=%d\n", ret);

usb_free_urb(urb);
Expand Down
1 change: 1 addition & 0 deletions usb.h
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ struct rtw_usb {
u8 queue_to_pipe[8];
u8 usb_speed;
u8 usb_txagg_num;
u8 usb_removed;

struct workqueue_struct *txwq, *rxwq;

Expand Down