lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite for Android: free password hash cracker in your pocket
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <9766817fae774b24372edb09666c0bab6ebf40b4.camel@ulli-kroll.de>
Date:   Mon, 23 May 2022 06:07:22 +0200
From:   Hans Ulli Kroll <linux@...i-kroll.de>
To:     Sascha Hauer <s.hauer@...gutronix.de>,
        linux-wireless@...r.kernel.org
Cc:     Neo Jou <neojou@...il.com>, Ping-Ke Shih <pkshih@...ltek.com>,
        Yan-Hsuan Chuang <tony0620emma@...il.com>,
        Kalle Valo <kvalo@...nel.org>, netdev@...r.kernel.org,
        linux-kernel@...r.kernel.org,
        Martin Blumenstingl <martin.blumenstingl@...glemail.com>,
        kernel@...gutronix.de, Johannes Berg <johannes@...solutions.net>,
        neo_jou <neo_jou@...ltek.com>
Subject: Re: [PATCH 06/10] rtw88: Add common USB chip support

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

Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ