Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4100244ybb; Tue, 7 Apr 2020 00:21:36 -0700 (PDT) X-Google-Smtp-Source: APiQypJx6vc97NZrZdsO1Y7gP/dtE5jm8iLBPp8jFpKOxU5L13X75iMSbjfNwiaDmAsvQ2/7/TDk X-Received: by 2002:aca:f346:: with SMTP id r67mr685368oih.39.1586244095968; Tue, 07 Apr 2020 00:21:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586244095; cv=none; d=google.com; s=arc-20160816; b=u398HSw8C5ns1/lKnLP1ThhyUjpWr54srwRBXaR7KaAtaX/2D7vEEu64Q4PafOkxKU F13uAC1eh5jxd0T6GN3yHWlLaKn9db9C6apPNc1blMOYUqJWMZB4+Me9xf6iWDxE2cI7 F5p+BY46MEwKtCKiCGDdE6RTLOfrlnT3CvaKOQaXo6TnBu6wttOd3kvpKg90+hr6tgoC PFR5AsCxsaqQEQvWmM/KnGHxtA77rRXuDIX/sBxrXEs+1Iiw0g6vl86uAB6+G5pnBL2a jLKoD2NLMQOfm7wwVPrrOp3LKHnHREi2tYqnuMiioJ6B4XIGTzP7DsTZTtk/PBcK+hnR kHZw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:references:message-id :content-transfer-encoding:cc:date:in-reply-to:from:subject :mime-version; bh=XHQTL6mMRo/kdbQ3KX3IDWAsZlERGVWROttreQ+5WP0=; b=Xtk5WQv29cpvbPuQ6A4e1g2esg7zZfAby4UIUfU25I/pMsDcgXNbCa+8IE3F1B+FFt 4w3GDFNoxmX0X2+NZbXNY1S+4QQ2olMuTW41m/iu3/pBBt1qLbvfQMxlSmVZvVAFMfJs Wr+NAwdmfT3bmq3tTBmRFXHomrcjnAo7OTwvhzXFQhw98YJStYbrDsgvncBeIRLfnt3v w7pRyIalu+eddT5+PqBJl6upI4Oy6qGGbF1rNCiyCSCP9WiUaYrZrvwa/w6v1aF1EdwQ BONpwn9qJJCCysU7DdQM05F/i8JZLKymlrxPZwInMPXeJTKICaB4Ev8rt+6si71DgW9K avRA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id f46si881969otf.146.2020.04.07.00.21.23; Tue, 07 Apr 2020 00:21:35 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=canonical.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727705AbgDGHUk convert rfc822-to-8bit (ORCPT + 99 others); Tue, 7 Apr 2020 03:20:40 -0400 Received: from youngberry.canonical.com ([91.189.89.112]:36738 "EHLO youngberry.canonical.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727173AbgDGHUk (ORCPT ); Tue, 7 Apr 2020 03:20:40 -0400 Received: from mail-pf1-f200.google.com ([209.85.210.200]) by youngberry.canonical.com with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.86_2) (envelope-from ) id 1jLiXF-0001cm-V9 for linux-kernel@vger.kernel.org; Tue, 07 Apr 2020 07:20:38 +0000 Received: by mail-pf1-f200.google.com with SMTP id s8so1744487pfd.23 for ; Tue, 07 Apr 2020 00:20:37 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:subject:from:in-reply-to:date:cc :content-transfer-encoding:message-id:references:to; bh=D9wpwa0NndfexX1TCjkujJJlqtFXso1cUg7215eV4lg=; b=pu7C8gbkyDtTt9AHAyZQIICccT+CZQF8N8xJoUnTIgGGx7jvEM/ohiCNPNuNsNG1Qg kp5cz1HxsfB3Ax2PqvQD/rZXBmq17/T0pPou+P6ap8jI8d7GBfDaLRIDc7iNLeGBAGgS 6h5WzPBBOd7zyb/JkLs+KI2RYmvW+sVEPIIzkJmCDlBke7iOkYNrrBYgMFki9Z37owSx iURhQuvhCFjYBemZ9FesnxoTkLG2apizaNeiqJm2eGRjuJ9sTrnZ2RyxjRf2zBriarzn wL4cI/zYO3POEoCEferAgMRC6cjpaMEb8HpxJfsS2pFKoRNWt/Us4oyIzjiO/CAX+xv2 SEYA== X-Gm-Message-State: AGi0PuZEWPHbWqGuxKHSBNl6KxDFw1w2DSzpzyYWMovw6MShsbuSa4H+ k5W+53TlxcLJKhdvUjMNMXp22c9n9jIP3zDlUUVpQ8l4CBYw5EuPCoBzNA+L9a4FqabKIzMo+gh MqkA4LYJ1t/h8Nh16MVX2IwMyhw2SxFrEdpmcMOzkqA== X-Received: by 2002:a63:8442:: with SMTP id k63mr728454pgd.11.1586244036554; Tue, 07 Apr 2020 00:20:36 -0700 (PDT) X-Received: by 2002:a63:8442:: with SMTP id k63mr728433pgd.11.1586244036201; Tue, 07 Apr 2020 00:20:36 -0700 (PDT) Received: from [192.168.1.208] (220-133-187-190.HINET-IP.hinet.net. [220.133.187.190]) by smtp.gmail.com with ESMTPSA id w138sm13528050pff.145.2020.04.07.00.20.34 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 07 Apr 2020 00:20:35 -0700 (PDT) Content-Type: text/plain; charset=us-ascii Mime-Version: 1.0 (Mac OS X Mail 13.4 \(3608.80.23.2.2\)) Subject: Re: [PATCH] rtw88: Add delay on polling h2c command status bit From: Kai-Heng Feng In-Reply-To: <87k12syanf.fsf@kamboji.qca.qualcomm.com> Date: Tue, 7 Apr 2020 15:20:33 +0800 Cc: Tony Chuang , "David S. Miller" , "open list:REALTEK WIRELESS DRIVER (rtw88)" , "open list:NETWORKING DRIVERS" , open list Content-Transfer-Encoding: 8BIT Message-Id: References: <20200406093623.3980-1-kai.heng.feng@canonical.com> <87v9mczu4h.fsf@kamboji.qca.qualcomm.com> <94EAAF7E-66C5-40E2-B6A9-0787CB13A3A9@canonical.com> <87zhboycfr.fsf@kamboji.qca.qualcomm.com> <83B3A3D8-833A-42BE-9EB0-59C95B349B01@canonical.com> <87k12syanf.fsf@kamboji.qca.qualcomm.com> To: Kalle Valo X-Mailer: Apple Mail (2.3608.80.23.2.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org > On Apr 6, 2020, at 22:03, Kalle Valo wrote: > > Kai-Heng Feng writes: > >>> On Apr 6, 2020, at 21:24, Kalle Valo wrote: >>> >>> Kai-Heng Feng writes: >>> >>>>> On Apr 6, 2020, at 20:17, Kalle Valo wrote: >>>>> >>>>> Kai-Heng Feng writes: >>>>> >>>>>> --- a/drivers/net/wireless/realtek/rtw88/hci.h >>>>>> +++ b/drivers/net/wireless/realtek/rtw88/hci.h >>>>>> @@ -253,6 +253,10 @@ rtw_write8_mask(struct rtw_dev *rtwdev, u32 >>>>>> addr, u32 mask, u8 data) >>>>>> rtw_write8(rtwdev, addr, set); >>>>>> } >>>>>> >>>>>> +#define rr8(addr) rtw_read8(rtwdev, addr) >>>>>> +#define rr16(addr) rtw_read16(rtwdev, addr) >>>>>> +#define rr32(addr) rtw_read32(rtwdev, addr) >>>>> >>>>> For me these macros reduce code readability, not improve anything. They >>>>> hide the use of rtwdev variable, which is evil, and a name like rr8() is >>>>> just way too vague. Please keep the original function names as is. >>>> >>>> The inspiration is from another driver. >>>> readx_poll_timeout macro only takes one argument for the op. >>>> Some other drivers have their own poll_timeout implementation, >>>> and I guess it makes sense to make one specific for rtw88. >>> >>> I'm not even understanding the problem you are tying to fix with these >>> macros. The upstream philosopyhy is to have the source code readable and >>> maintainable, not to use minimal number of characters. There's a reason >>> why we don't name our functions a(), b(), c() and so on. >> >> The current h2c polling doesn't have delay between each interval, so >> the polling is too fast and the following logic considers it's a >> timeout. >> The readx_poll_timeout() macro provides a generic mechanism to setup >> an interval delay and timeout which is what we need here. >> However readx_poll_timeout only accepts one parameter which usually is >> memory address, while we need to pass both rtwdev and address. >> >> So if hiding rtwdev is evil, we can roll our own variant of >> readx_poll_timeout() to make the polling readable. > > Can't you do: > > ret = read_poll_timeout(rtw_read8, box_state, > !((box_state >> box) & 0x1), 100, > 3000, false, rtw_dev, REG_HMETFR); > > No ugly macros needed and it should function the same. But I did not > test this in any way, so no idea if it even compiles. Yes that will do. Didn't notice the recently added macro. Will send v2. Kai-Heng > > -- > https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches