All of lore.kernel.org
 help / color / mirror / Atom feed
From: Hans Ulli Kroll <linux@ulli-kroll.de>
To: Sascha Hauer <s.hauer@pengutronix.de>, linux-wireless@vger.kernel.org
Cc: Neo Jou <neojou@gmail.com>, Ping-Ke Shih <pkshih@realtek.com>,
	Yan-Hsuan Chuang <tony0620emma@gmail.com>,
	Kalle Valo <kvalo@kernel.org>,
	netdev@vger.kernel.org, linux-kernel@vger.kernel.org,
	Martin Blumenstingl <martin.blumenstingl@googlemail.com>,
	kernel@pengutronix.de, Johannes Berg <johannes@sipsolutions.net>,
	neo_jou <neo_jou@realtek.com>
Subject: Re: [PATCH 06/10] rtw88: Add common USB chip support
Date: Mon, 23 May 2022 06:07:22 +0200	[thread overview]
Message-ID: <9766817fae774b24372edb09666c0bab6ebf40b4.camel@ulli-kroll.de> (raw)
In-Reply-To: <20220518082318.3898514-7-s.hauer@pengutronix.de>

On Wed, 2022-05-18 at 10:23 +0200, Sascha Hauer wrote:
> Add the common bits and pieces to add USB support to the RTW88 driver.
> This is based on https://github.com/ulli-kroll/rtw88-usb.git which
> itself is first written by Neo Jou.
> 

Neo Jou borrowed the usb logic from rtlwifi.
This was (maybe) also in the early stages of the vendor driver.

Newer ones doesn't use async write for register access.

In short it looks like this.
The extra "time consume" is added between v5.2.4 and v5.3.1

static int __rtw_usb_vendor_request(struct usb_device *udev, unsigned int pipe,
				    u8 request, u8 requesttype, u16 val, u16 index,
				    void *buf, size_t len)
{
	int i, ret;

	for (i = 0; i < MAX_USBCTRL_VENDORREQ_TIMES; i++) {
		ret = usb_control_msg(udev, pipe, request, requesttype, val,
				      index, buf, len, RTW_USBCTRL_MSG_TIMEOUT);

		if (ret <= 0)
			return ret;
	}

	if (val <= 0xff ||
	    (val >= 0x1000 && val <= 0x10ff)) {
		/* add a write to consume time on device */

		unsigned int t_pipe = usb_sndctrlpipe(udev, 0);/* write_out */
		u8 t_reqtype =  RTW_USB_CMD_WRITE;
		u8 t_len = 1;
		u8 t_req = RTW_USB_CMD_REQ;
		u16 t_reg = 0x4e0;	/* unknown reg on device */
		u16 t_index = 0;

		ret = usb_control_msg(udev, t_pipe, t_req, t_reqtype,
				      t_reg, t_index, buf, t_len,
				      RTW_USBCTRL_MSG_TIMEOUT);

		if (ret != 1)
			return ret;
	}


	return ret;
}

static int rtw_vendor_request(struct rtw_usb *rtwusb, unsigned int pipe,
			      u8 request, u8 requesttype, u16 val, u16 index,
			      void *buf, size_t len)
{
	struct usb_device *udev = rtwusb->udev;
	int ret;

	mutex_lock(&rtwusb->usb_ctrl_mtx);
	ret = __rtw_usb_vendor_request(udev, pipe, request, requesttype,
				       val, index, buf, len);
	mutex_unlock(&rtwusb->usb_ctrl_mtx);

	return ret;
}


Hans Ulli

  parent reply	other threads:[~2022-05-23  4:16 UTC|newest]

Thread overview: 43+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-05-18  8:23 [PATCH 00/10] RTW88: Add support for USB variants Sascha Hauer
2022-05-18  8:23 ` [PATCH 01/10] rtw88: Call rtw_fw_beacon_filter_config() with rtwdev->mutex held Sascha Hauer
2022-05-18  8:23 ` [PATCH 02/10] rtw88: Drop rf_lock Sascha Hauer
2022-05-20  3:49   ` Pkshih
2022-05-20  6:54     ` s.hauer
2022-05-18  8:23 ` [PATCH 03/10] rtw88: Drop h2c.lock Sascha Hauer
2022-05-18  8:23 ` [PATCH 04/10] rtw88: Drop coex mutex Sascha Hauer
2022-05-18  8:23 ` [PATCH 05/10] rtw88: Do not access registers while atomic Sascha Hauer
2022-05-20  6:06   ` Pkshih
2022-05-20  7:07     ` s.hauer
2022-05-20 17:32   ` Larry Finger
2022-05-18  8:23 ` [PATCH 06/10] rtw88: Add common USB chip support Sascha Hauer
2022-05-18  8:32   ` Sascha Hauer
2022-05-18  8:34     ` Johannes Berg
2022-05-19 13:58       ` Sascha Hauer
2022-05-20  7:39   ` Pkshih
2022-05-20  8:51     ` s.hauer
2022-05-20  9:23       ` Pkshih
2022-05-20 18:33   ` Larry Finger
2022-05-23  4:07   ` Hans Ulli Kroll [this message]
2022-05-18  8:23 ` [PATCH 07/10] rtw88: Add rtw8723du chipset support Sascha Hauer
2022-05-18 16:55   ` kernel test robot
2022-05-20  7:47   ` Pkshih
2022-05-20  8:16     ` s.hauer
2022-05-30  6:34   ` Icenowy Zheng
2022-05-18  8:23 ` [PATCH 08/10] rtw88: Add rtw8821cu " Sascha Hauer
2022-05-20  7:56   ` Pkshih
2022-05-18  8:23 ` [PATCH 09/10] rtw88: Add rtw8822bu " Sascha Hauer
2022-05-20  7:58   ` Pkshih
2022-05-23 11:56   ` Rin Cat (鈴猫)
2022-05-23 12:34     ` Sascha Hauer
2022-05-18  8:23 ` [PATCH 10/10] rtw88: Add rtw8822cu " Sascha Hauer
2022-05-20  8:03   ` Pkshih
2022-05-20  8:56     ` s.hauer
2022-05-23  4:07 ` [PATCH 00/10] RTW88: Add support for USB variants Hans Ulli Kroll
2022-05-23  6:53   ` Sascha Hauer
2022-05-23 11:39     ` Ping-Ke Shih
2022-05-24  6:54       ` s.hauer
2022-05-23 10:13   ` Sascha Hauer
2022-05-30  9:25 ` Kalle Valo
2022-05-30  9:52   ` Sascha Hauer
2022-05-30 10:07     ` Kalle Valo
2022-05-30 10:16       ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=9766817fae774b24372edb09666c0bab6ebf40b4.camel@ulli-kroll.de \
    --to=linux@ulli-kroll.de \
    --cc=johannes@sipsolutions.net \
    --cc=kernel@pengutronix.de \
    --cc=kvalo@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-wireless@vger.kernel.org \
    --cc=martin.blumenstingl@googlemail.com \
    --cc=neo_jou@realtek.com \
    --cc=neojou@gmail.com \
    --cc=netdev@vger.kernel.org \
    --cc=pkshih@realtek.com \
    --cc=s.hauer@pengutronix.de \
    --cc=tony0620emma@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.