Received: by 2002:a05:6602:18e:0:0:0:0 with SMTP id m14csp1648314ioo; Sun, 22 May 2022 22:58:31 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzMztrqqY4p3Jwgcwafu+xFZJzJlGa1SCO/DQOm1B2MlIR6uMQlmADalOyGVtDX1THpHEjS X-Received: by 2002:a17:902:ea82:b0:161:6088:bbde with SMTP id x2-20020a170902ea8200b001616088bbdemr21722059plb.50.1653285511287; Sun, 22 May 2022 22:58:31 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1653285511; cv=none; d=google.com; s=arc-20160816; b=ACHPFYjssdbK+6ZEtUJHfOsAOUjvuVcce/s1D6/fxLCRP4mSnL3EMG2g88GkUR4LhH S2dmXfxcqPshjiTijeDmmxQwj/fCFcxoH35cv5l4RBiGRa7Ta87ocq/sc5mUha7erZ9W 0Ev4EpKPheHb0cx2FouF54+tgUucJAWb8t/0BFIbQ5qxkxMvziK3GnTgGcXH8SNo8R30 HkMqueSic1lLm4jBNXUb+K/uQkmals1zxTZzfvL3gleBgIg0zvrVuRIklzsSN5u1hgpF uwmthNW6VsiXIE6dmwE7nDlmBNx12HzMM9kmFx2mRZBdcDOw+raHisHcUNaEcCjJjwZ7 yBQA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent :content-transfer-encoding:references:in-reply-to:date:cc:to:from :subject:message-id; bh=XBuYYKE5D8mB0VpZkS1Rr9x7bIIphCgE6YfMx9yAQfw=; b=CGnfVJV5YNdM88qUVZvMrb63W71DIWOttXvpXF0NTnufstJvq7caKHGBPzfAx7juUh VZXgfEiAQOSRVjkSS21RRXO3B2WA29HLl9kRslyBu5KFj4D69FRV41ilYCbayQSI9984 FzARSb6K+8DhCKLVdtN34YVigmGzHJzIIe2BZjBUTugNI+R3KsCs5Y6bADQuYwpwEUjZ DqOcaD6zCZ24Y2NVHKnk8eN5rg9bDYiqP+tNEhlK1o8wmK+Ug7PZEK13Rafm9xB2eAJ4 c/i039FsDQ0glE5urTxa3DhDT9em7sc3+wScnhqdA3w8RbY0kndUdg45NpCllEaiK7ha 4faQ== ARC-Authentication-Results: i=1; mx.google.com; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [23.128.96.19]) by mx.google.com with ESMTPS id f21-20020a63dc55000000b003f74c931d14si8945999pgj.586.2022.05.22.22.58.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sun, 22 May 2022 22:58:30 -0700 (PDT) Received-SPF: softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) client-ip=23.128.96.19; Authentication-Results: mx.google.com; spf=softfail (google.com: domain of transitioning linux-wireless-owner@vger.kernel.org does not designate 23.128.96.19 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id ABFD52ED46; Sun, 22 May 2022 22:53:56 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241304AbiEWEQR convert rfc822-to-8bit (ORCPT + 68 others); Mon, 23 May 2022 00:16:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36010 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229757AbiEWEQP (ORCPT ); Mon, 23 May 2022 00:16:15 -0400 Received: from mailproxy09.manitu.net (mailproxy09.manitu.net [217.11.48.32]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A2373627D; Sun, 22 May 2022 21:16:08 -0700 (PDT) Received: from [192.168.3.184] (cable-78-34-17-55.nc.de [78.34.17.55]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) (Authenticated sender: linux@ulli-kroll.de) by mailproxy09.manitu.net (Postfix) with ESMTPSA id 4B61212000F4; Mon, 23 May 2022 06:07:22 +0200 (CEST) Message-ID: <9766817fae774b24372edb09666c0bab6ebf40b4.camel@ulli-kroll.de> Subject: Re: [PATCH 06/10] rtw88: Add common USB chip support From: Hans Ulli Kroll To: Sascha Hauer , linux-wireless@vger.kernel.org Cc: Neo Jou , Ping-Ke Shih , Yan-Hsuan Chuang , Kalle Valo , netdev@vger.kernel.org, linux-kernel@vger.kernel.org, Martin Blumenstingl , kernel@pengutronix.de, Johannes Berg , neo_jou Date: Mon, 23 May 2022 06:07:22 +0200 In-Reply-To: <20220518082318.3898514-7-s.hauer@pengutronix.de> References: <20220518082318.3898514-1-s.hauer@pengutronix.de> <20220518082318.3898514-7-s.hauer@pengutronix.de> Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: 8BIT User-Agent: Evolution 3.44.1 MIME-Version: 1.0 X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org 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