Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp3337656ybb; Mon, 6 Apr 2020 07:04:09 -0700 (PDT) X-Google-Smtp-Source: APiQypLHc1WQVyDa2FAVujcCXalYcdD66rPicTW6jqQd3P7S0uvS63Amo++Pzcqc4crzNHQ0NC3N X-Received: by 2002:aca:a883:: with SMTP id r125mr12501718oie.10.1586181849148; Mon, 06 Apr 2020 07:04:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586181849; cv=none; d=google.com; s=arc-20160816; b=GOUq9lowN1OhQ93ydf3OJzO/557Vi2kDOH4rahiT5hqd3QCSZ5nFXzXvaRwCTbQSx9 cmXtRB9cH7Xc7Cm/eXH5ewOBOGYsuHosN7IEZvdZW5m5/h+W6biWuS+n1GVxMlK/x3Zy NckGbjZeGI9c4cD1T9J9ujOcgR0kOlG5uZlfT3odB5lRJWckYtRtJWKBDw+eygnIICxv KQ4WIKKu29pDQL+SLeNQDZOFcDSkNI3jaF7FTx8G0/V2sYNygqIZ90qjBS9ZxIM6Jvzo kHQtvKGMMP7lmZzckrr0aQLAwdDWPFE/S8AmIhMZ9I3htUN12D9eGIL648uo3Lbobt2j lOYA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:user-agent:message-id :in-reply-to:date:references:subject:cc:to:from:dmarc-filter :dkim-signature; bh=ddRHNrTYuHRZ9Qp05MVsdiWN86Gi1Yd/jbkzWd681IA=; b=VpoDxKZT6fIfbeXiK+wwMrD0+65jD58WdQJ5q1IEJo2Gh/0RCtgfkguNAB4VbJXR0e Zpcevr9I1CrmzAFGtybDfnvoyOPkloygv09oD8ItsVJlX3RHv2kauW2H3IfTrhmCtqRl LpQdQPwkztzdemFg/XXWbvHLsTKdtOm51yZIyDPLyoClTxz0QTqeDlOzkRG2xCiUGChY 3tRksb1p7uXrNmwV5CXa3oPM912lGVR9lXRtprBiL3ZUxp7PSP7ytOLjKcLmy+HyIpNk H3ptiApB4nCaTIgKbPT89REBFq6pXogAmvRrDoeqDJdvzJaJF0KOzMQHTPnGpysqY+mv UxbA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=XI16osb7; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h25si7806592ooa.9.2020.04.06.07.03.53; Mon, 06 Apr 2020 07:04:09 -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; dkim=fail header.i=@mg.codeaurora.org header.s=smtp header.b=XI16osb7; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728569AbgDFODO (ORCPT + 99 others); Mon, 6 Apr 2020 10:03:14 -0400 Received: from mail26.static.mailgun.info ([104.130.122.26]:56283 "EHLO mail26.static.mailgun.info" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726436AbgDFODO (ORCPT ); Mon, 6 Apr 2020 10:03:14 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1586181793; h=Content-Type: MIME-Version: Message-ID: In-Reply-To: Date: References: Subject: Cc: To: From: Sender; bh=ddRHNrTYuHRZ9Qp05MVsdiWN86Gi1Yd/jbkzWd681IA=; b=XI16osb7s2AfVebSEw38+RbBgPt8LmZq3ab2EDaKjUu1I/hoA4FHKhR7bLnETk/o+5rPz2ga brWF9EVaIHXx4aBpZCmVYBLiGP7OMMrBsTCTGjHNUBifxNLl5krQ8DKjInA5MSmPUZRayqbR fxeSj+wtHkvZbTtWxhv0Q7mgtXo= X-Mailgun-Sending-Ip: 104.130.122.26 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by mxa.mailgun.org with ESMTP id 5e8b369a.7fc899cd3998-smtp-out-n02; Mon, 06 Apr 2020 14:03:06 -0000 (UTC) Received: by smtp.codeaurora.org (Postfix, from userid 1001) id 50DCBC43636; Mon, 6 Apr 2020 14:03:05 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-1.0 required=2.0 tests=ALL_TRUSTED,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.0 Received: from potku.adurom.net (88-114-240-156.elisa-laajakaista.fi [88.114.240.156]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: kvalo) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0FBE0C433D2; Mon, 6 Apr 2020 14:03:02 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0FBE0C433D2 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=none smtp.mailfrom=kvalo@codeaurora.org From: Kalle Valo To: Kai-Heng Feng Cc: Tony Chuang , "David S. Miller" , "open list\:REALTEK WIRELESS DRIVER \(rtw88\)" , "open list\:NETWORKING DRIVERS" , open list Subject: Re: [PATCH] rtw88: Add delay on polling h2c command status bit 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> Date: Mon, 06 Apr 2020 17:03:00 +0300 In-Reply-To: <83B3A3D8-833A-42BE-9EB0-59C95B349B01@canonical.com> (Kai-Heng Feng's message of "Mon, 6 Apr 2020 21:35:29 +0800") Message-ID: <87k12syanf.fsf@kamboji.qca.qualcomm.com> User-Agent: Gnus/5.13 (Gnus v5.13) Emacs/24.5 (gnu/linux) MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org 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. -- https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches