Received: by 2002:a05:6358:d09b:b0:dc:cd0c:909e with SMTP id jc27csp114380rwb; Wed, 30 Nov 2022 23:07:45 -0800 (PST) X-Google-Smtp-Source: AA0mqf6nOjIE2qxV/8zYcj9x8iLxTxZUEbxdhAbVgPq9cZNwYF763uyTBDDQSCe5EV++RdjAOpvb X-Received: by 2002:a62:6406:0:b0:576:51c:e539 with SMTP id y6-20020a626406000000b00576051ce539mr4126676pfb.6.1669878465710; Wed, 30 Nov 2022 23:07:45 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1669878465; cv=none; d=google.com; s=arc-20160816; b=mzTNvj6cABD1OyyGjWmsvHsQu7M4IW4mo76GjjEDt0ld25/6dmZieM5u6jVUWU6N/V dvQbiBoFxmP88anCid2BSlN+bYLx4MTGhyK4wla3UELEbXbKIMmWiKkGN556KbfLlaXB Gvhr8G7p2Ojd9GEshSHO2LTBspPlJV7nFrjE26TdqUZX/vFPY8Wqc5UfLfi9dISRcqB1 l7nsno1J+3YNmk4NAHtDNLTO8w/KQP9DrpmObaWitH4lhbmA05WTLjMQf0Xhjo4cP15z 4f7/FYh5SjNgKpCTIcQKzP1Aam8gFtavOdQHSRkQ2AZGykXi4E//TgSxbrl0PSkRTEZB hDAw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :message-id:references:in-reply-to:user-agent:subject:cc:to:from :date:dkim-signature; bh=zplU/keWgUhDPc5p2G5eKUobwqeXLRQhaljOW0vQhGw=; b=CWYfWNUjBSBVx+9N1UG9NsALuHWfRHwn59Xz7GCT+/zxmK8dLMtLmD2e03TMN88EJA PHHxsUH7E6zFIbdr1Zv4kUe8YcCu6RVGUopfA0mMpyNTOJ2UXlDJLh9nfqtGcaMJFhz3 md0PohWxSHapVSb61NTn0DDNMz3JbENVlHRa+jq37B2QCOe/7SlG5okG1+oxwDuYMFdc wxHgBSuhndnaFuf0oyPO9pPgqPyMB3prFXEpOyCo5seiSx8ZTvBjGmiF/EC4nMH3kZfc qwjSmi1ija4TJnPLLcFyXow3Y6XZMr0hYtjBybv+3om0xcbEieNFu47FblGTDVjWou7f 6wRA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nmr6EadO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id j62-20020a638041000000b004639c67961dsi3658413pgd.268.2022.11.30.23.07.34; Wed, 30 Nov 2022 23:07:45 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=Nmr6EadO; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229708AbiLAGVe (ORCPT + 83 others); Thu, 1 Dec 2022 01:21:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:59276 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229503AbiLAGVb (ORCPT ); Thu, 1 Dec 2022 01:21:31 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CC08FAB001; Wed, 30 Nov 2022 22:21:30 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 5874061E8F; Thu, 1 Dec 2022 06:21:30 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id CC4F8C433D6; Thu, 1 Dec 2022 06:21:28 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1669875689; bh=1TShYY6JkDucSJo1cjYSsWtnGpEz8gTWzbxvY/gsAVc=; h=Date:From:To:CC:Subject:In-Reply-To:References:From; b=Nmr6EadOg/rHV11uZ4icZPKLjWkG9u5exEWuXjcet49ziPi6lKPVIKjGUOYp6CcWx Y12Z/NwkhsvhLIEHSbtm15Y2RB65kw6eZsRUaz2Phq9LxaG7FxUh1g9l8+F7qBS+HD CGeOtlLQauyAR3MBwsA3p8GfaCD9Z9dbk/yh4BUovT3UVpuVYIqfDFshlSc0Qsgaat xX1b8CE466ljiqmJHjjcrMiKQTkwBAH9gx4pQ3hDXQLOp5daBTG65U9wqGD+K0uJkf MbDMzGCSBHmedPkE/bR2v0ikovVSHk5K7DiOGBkIqQXcHADL1iSgVygFDQE1SThq5o Rv80Q+9vzjyTA== Date: Thu, 01 Dec 2022 06:21:25 +0000 From: Conor Dooley To: Walker Chen , Conor Dooley CC: linux-riscv@lists.infradead.org, linux-pm@vger.kernel.org, devicetree@vger.kernel.org, Rob Herring , Krzysztof Kozlowski , "Rafael J . Wysocki" , linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 3/4] soc: starfive: Add StarFive JH71XX pmu driver User-Agent: K-9 Mail for Android In-Reply-To: References: <20221118133216.17037-1-walker.chen@starfivetech.com> <20221118133216.17037-4-walker.chen@starfivetech.com> <95b05ac3-31a9-50dc-8eeb-eb3a9f883a6b@starfivetech.com> Message-ID: <42D09618-DB39-4A8B-9327-4C6CC9DA2000@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS autolearn=ham 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-kernel@vger.kernel.org Hey Walker, Apologies for my formatting here=2E=20 On 1 December 2022 03:56:27 GMT, Walker Chen wrote: >On 2022/11/25 19:17, Conor Dooley wrote: >> On Fri, Nov 25, 2022 at 06:04:59PM +0800, Walker Chen wrote: >>> On 2022/11/19 8:24, Conor Dooley wrote: >>> > On Fri, Nov 18, 2022 at 09:32:15PM +0800, Walker Chen wrote: >>=20 >>> >> +void starfive_pmu_hw_event_turn_off(u32 mask) >>> >> +{ >>> >> + pmu_writel(mask, HW_EVENT_TURN_OFF_MASK); >>> >> +} >>> >> +EXPORT_SYMBOL(starfive_pmu_hw_event_turn_off); >>> >=20 >>> > Where are the users for these exports? Also, should they be exported= as >>> > GPL? >>> >=20 >>> > Either way, what is the point of the extra layer of abstraction here >>> > around the writel()? >>>=20 >>> The two export functions are only prepared for GPU module=2E But accor= dint to >>> the latest information, it seems that there is no open source plan fo= r GPU=2E=20 >>> So the two functions will be drop in next version of patch=2E >>=20 >> That's a shame! > >Need to comply with certain commercial terms=2E > >>=20 >>> >> +static int starfive_pmu_get_state(struct starfive_power_dev *pmd, = bool *is_on) >>> >> +{ >>> >> + struct starfive_pmu *pmu =3D pmd->power; >>> >> + >>> >> + if (!pmd->mask) { >>> >> + *is_on =3D false; >>> >> + return -EINVAL; >>> >> + } >>> >> + >>> >> + *is_on =3D __raw_readl(pmu->base + CURR_POWER_MODE) & pmd->mask; >>> >=20 >>> > Is there a specific reason that you are using the __raw variants her= e >>> > (and elsewhere) in the driver? >>>=20 >>> Will use unified function '__raw_readl' and '__raw_writel' >>=20 >> No no, I want to know *why* you are using the __raw accessors here=2E M= y >> understanding was that __raw variants are unbarriered & unordered with >> respect to other io accesses=2E >>=20 >> I do notice that the bcm driver you mentioned uses the __raw variants, >> but only __raw variants - whereas you use readl() which is ordered and >> barriered & __raw_readl()=2E >>=20 >> Is there a reason why you would not use readl() or readl_relaxed()? > >Your question led me to deeply understand the usage of these io accessors= =2E >__raw_readl / __raw_writel denotes native byte order, no memory barrier= =2E >readl / writel do guarantee the byte order with barrier, ensure that prev= ious writes are done=2E >Seem that non-raw accessors are more safe=2E Yeah, if there's no good reason to use these "raw" versions then please u= se readl/readl_relaxed=2E >> No worries, looking forward to getting my board :) >>=20 >Have you purchased a VisionFive 2 board online? =20 I have :)