Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp6181386pxb; Mon, 8 Nov 2021 04:36:22 -0800 (PST) X-Google-Smtp-Source: ABdhPJzYcdLJLRuepGOdXUwKY+MFIThWdzrD8o550eDLx8yJCU0pguN12RY7EXJhnIM+c3Km2X4k X-Received: by 2002:a17:906:82c5:: with SMTP id a5mr37128490ejy.127.1636374981993; Mon, 08 Nov 2021 04:36:21 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636374981; cv=none; d=google.com; s=arc-20160816; b=zArdQ1E9D6A5LhDzlxI+GjTVWtyakAB4DEHoEjgln8EhDG32wc2qh0L/Pp+sWtyroA MvxE0YLTMQybjebXftT6WNtzt3YI1eLzcXzIovu+kK04gwM4TQcDHbC3tLPbEV9rvyXr rjdN5COsfoSGFoQPLOfy+lDH2rAsG36D8vEAEKe1eO1oxl9yp1RvaKCfC5/GUHbeRC57 lxRgJaJuCnTf4SB9qXH3vbBgYgT+NDLsFQiszxA9aVHM337n5opNfJHk2jZeaxZLr1/u Yb0/xUFK8XGlEPnWWY7ToSS5z2qsCRxbE6/4S74Zoj3i96gAle+3D8SBOh/tol+1uZqm Rldg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=5NFnfqo73VmZa9KdPDtUR2AdqfLCRkiEPb4pbj86ui0=; b=0VVfUVQsRmWGm9bSCO2FvW69wf+LFBfocUwSECo9C/V9kzXVu4vlZJjrROrRht8Zhn mbQO1jdU7hgQNT+Iqx76he5I4yU9RB26suVR9zLqk0H7oBPgDohEPGAfPI+zBbB+vK57 fdXD+rqDHSgeb6OlyWigHysl99eO8Azk98Dwp+w1bmcVcAktGoPdH7CEUkAsD8D8pe1x s4EcU9T3VM0seTyyc6eXLLAywo2cmeYnjdpH4PDonElPfNu9kixNy5tqoYyv8zZ8M0Au WdLe3ZzCni21ijazQbH9mtHIp9vc4g/ze4Qzq4TJ73B11FYkbqwhGjWRhMc21sQFleQ3 rdJQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="dK/FD8/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 2si25305699ejl.511.2021.11.08.04.35.56; Mon, 08 Nov 2021 04:36:21 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@infradead.org header.s=desiato.20200630 header.b="dK/FD8/1"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238126AbhKHIuv (ORCPT + 99 others); Mon, 8 Nov 2021 03:50:51 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:47648 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229988AbhKHIuu (ORCPT ); Mon, 8 Nov 2021 03:50:50 -0500 Received: from desiato.infradead.org (desiato.infradead.org [IPv6:2001:8b0:10b:1:d65d:64ff:fe57:4e05]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 89C7EC061570; Mon, 8 Nov 2021 00:48:06 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=desiato.20200630; h=In-Reply-To:Content-Type:MIME-Version: References:Message-ID:Subject:Cc:To:From:Date:Sender:Reply-To: Content-Transfer-Encoding:Content-ID:Content-Description; bh=5NFnfqo73VmZa9KdPDtUR2AdqfLCRkiEPb4pbj86ui0=; b=dK/FD8/1D5AbzQUvYeuURUX7N+ eALUIE8ff+2lsAqGOl2JGKcmAUDzXqinHQcDViR3VU0ACxuRwFfiM1L0CMQUHQW/l94PC13ssk+hb YBMwE7KwTFaYlEDKidSi2np4r00RFLym3d5sRCVk9/IMXy1rcuYSOcidlvonyO1hnOLMY4Wp9KnAF tS6D7Zsc72rn95JAduzEoyI3Cmudn2zftMAqSOp2M8y+Hng1LOfDaH+CR8KvooRTeaLctT/URJ7zz zA+2IO3TLT9+RQgUCdJr+tBnvU09XXK8RHRa/ll8F0Lqhbp8ojIe56XtsOVR9zjBxJ0xhO/yL7/SQ 9aretSnA==; Received: from j217100.upc-j.chello.nl ([24.132.217.100] helo=noisy.programming.kicks-ass.net) by desiato.infradead.org with esmtpsa (Exim 4.94.2 #2 (Red Hat Linux)) id 1mk0Jp-00Er30-8q; Mon, 08 Nov 2021 08:47:57 +0000 Received: from hirez.programming.kicks-ass.net (hirez.programming.kicks-ass.net [192.168.1.225]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (Client did not present a certificate) by noisy.programming.kicks-ass.net (Postfix) with ESMTPS id 378E230022C; Mon, 8 Nov 2021 09:47:56 +0100 (CET) Received: by hirez.programming.kicks-ass.net (Postfix, from userid 1000) id 8975D2671B8AC; Mon, 8 Nov 2021 09:47:54 +0100 (CET) Date: Mon, 8 Nov 2021 09:47:54 +0100 From: Peter Zijlstra To: Ricardo Neri Cc: "Rafael J. Wysocki" , Daniel Lezcano , linux-pm@vger.kernel.org, x86@kernel.org, linux-doc@vger.kernel.org, Len Brown , Srinivas Pandruvada , Aubrey Li , Amit Kucheria , Andi Kleen , Tim Chen , "Ravi V. Shankar" , Ricardo Neri , linux-kernel@vger.kernel.org Subject: Re: [PATCH 3/7] thermal: intel: hfi: Minimally initialize the Hardware Feedback Interface Message-ID: References: <20211106013312.26698-1-ricardo.neri-calderon@linux.intel.com> <20211106013312.26698-4-ricardo.neri-calderon@linux.intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20211106013312.26698-4-ricardo.neri-calderon@linux.intel.com> Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Fri, Nov 05, 2021 at 06:33:08PM -0700, Ricardo Neri wrote: > +static __init int hfi_parse_features(void) > +{ > + unsigned int nr_capabilities, reg; > + > + /* > + * If we are here we know that CPUID_HFI_LEAF exists. Parse the > + * supported capabilities and the size of the HFI table. > + */ > + reg = cpuid_edx(CPUID_HFI_LEAF); > + > + hfi_features.capabilities = reg & HFI_CAPABILITIES_MASK; > + if (!(hfi_features.capabilities & HFI_CAPABILITIES_PERFORMANCE)) { > + pr_err("Performance reporting not supported! Not using HFI\n"); > + return -ENODEV; > + } > + > + /* The number of 4KB pages required by the table */ > + hfi_features.nr_table_pages = ((reg & CPUID_HFI_TABLE_SIZE_MASK) >> > + CPUID_HFI_TABLE_SIZE_SHIFT) + 1; > + > +/* Hardware Feedback Interface Enumeration */ > +#define CPUID_HFI_LEAF 6 > +#define CPUID_HFI_CAP_MASK 0xff > +#define CPUID_HFI_TABLE_SIZE_MASK 0x0f00 > +#define CPUID_HFI_TABLE_SIZE_SHIFT 8 > +#define CPUID_HFI_CPU_INDEX_MASK 0xffff0000 Also, *if* you're going to do something like this, then at least write out the masks in full so you can easily see how they relate. The above is crap. > +#define CPUID_HFI_CPU_INDEX_SHIFT 16 > + > +/* Hardware Feedback Interface Pointer */ > +#define HFI_PTR_VALID_BIT BIT(0) > +#define HFI_PTR_ADDR_SHIFT 12 > + > +/* Hardware Feedback Interface Configuration */ > +#define HFI_CONFIG_ENABLE_BIT BIT(0) > + > +/* Hardware Feedback Interface Capabilities */ > +#define HFI_CAPABILITIES_MASK 0xff > +#define HFI_CAPABILITIES_NR 8 > +#define HFI_CAPABILITIES_PERFORMANCE BIT(0) > +#define HFI_CAPABILITIES_ENERGY_EFF BIT(1) So personally I prefer a bitfield union a-la cpuid10_eax, cpuid10_ebx cpuid10_edx etc.. Barring that, the above can also be written more concise using FIELD_GET() from bitfields. union cpuid6_edx { struct { unsigned int capabilities : 8; unsigned int table_size : 4; unsigned int __reserved : 4; unsigned int cpu_index : 16; }; unsigned int full; };