Received: by 2002:a05:7412:b995:b0:f9:9502:5bb8 with SMTP id it21csp4674451rdb; Fri, 29 Dec 2023 09:22:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEIB+1HAGWHeLSMKKP3TbzYQndD8atFpWso1F5H7vBp1gVBQnwD2iHH8yX7CJdPgVlPHl+l X-Received: by 2002:a50:9e0e:0:b0:554:32ec:eada with SMTP id z14-20020a509e0e000000b0055432eceadamr9896632ede.18.1703870569397; Fri, 29 Dec 2023 09:22:49 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1703870569; cv=none; d=google.com; s=arc-20160816; b=Xnd7/+5tbPolDCOMa475PzUb2VfbA3O+hPT8CoR0VX4+YJxwBz0flQ6/YsgirxOzo3 gB/P0rV/vCGe9U8kHMEZ4S004x+l9UxeqnmapzohRo4tD+wtUXrrBxdrTNm2TZzyH2Ek RcDY32ghF6V0tvJBVCMdDpMS+MeTw5+5vTqAhyavbXLKFAjUDR0FSiyzRexpR7/7s3EO 481pWfVMEWJzHYmU7jmn7qSep3gbc9RUZ4zBNOsayhklwjKC9BPbXbF2HQlYAymNvNsS +pqPGSNuGHqLYdN+ukIHZPsJsk1VTKDc1r2k6m+eYcIZpbltEh4gczBlM+iz9b9iKj7S ZopQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:list-unsubscribe:list-subscribe :list-id:precedence; bh=3zXsDSVyjkOlIslVUejAQip3X8oIGu+vcHizvG4w/TU=; fh=7Jleww2JHVkQTdwzF/6p9dzhxSth5cWh+avroIJ7GmE=; b=m452eF9D2grioMIbo+haQUBHW2eY/p5CaLcTkMeIkqKNsdZq9Iup8TfJ/KQpdqhV+4 lZBMHexryOX3RchzYVyujBm9ecTIAPDy0NrbYZ1+wdpKikoiJWcuSwsYvGUi4c1U1aaa TxcXjoBRQRzbKLXb/bvpi4u1/jVr9G/i0BneYk0Li+iMulGVDdB/1XZqDIFmtMlJXpM4 NDRsD7oUanytrwdL1h3F/k3LdnwNsp/e+s/X6Bmb4lPNGtU/QOHFOlHgDSIVe5ymz91e 27ffy6ldD0JpAj1Qjsp2HQxQN5jLNux2q3Cr8MvAPUvW/PEjzpSCHQVLCscVyOKmPR+b SB4A== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13180-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13180-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id x20-20020a50d614000000b005533935f0d9si8223889edi.407.2023.12.29.09.22.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 29 Dec 2023 09:22:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-13180-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) client-ip=2604:1380:4601:e00::3; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel+bounces-13180-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-kernel+bounces-13180-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by am.mirrors.kernel.org (Postfix) with ESMTPS id BB3B31F22487 for ; Fri, 29 Dec 2023 17:22:48 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B9E6512B84; Fri, 29 Dec 2023 17:22:39 +0000 (UTC) X-Original-To: linux-kernel@vger.kernel.org Received: from mail-ot1-f44.google.com (mail-ot1-f44.google.com [209.85.210.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D001E12E40; Fri, 29 Dec 2023 17:22:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dmarc=fail (p=none dis=none) header.from=kernel.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-ot1-f44.google.com with SMTP id 46e09a7af769-6dbca8c6eeeso1488300a34.1; Fri, 29 Dec 2023 09:22:37 -0800 (PST) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1703870557; x=1704475357; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=3zXsDSVyjkOlIslVUejAQip3X8oIGu+vcHizvG4w/TU=; b=wpSfowfKYZMiboymg7TjPTcqnmTVhZg2QGtAJzHppcWjICWMTdQGIVybjV0Gh9G3Ce 2POMvqWpH1iyDbzwibV+KOffGY5ot2y+jExPJSNifPkAtKymL5nNuggl1aRnbi5VRalx PrqSpExcKyMhflIi55tX9KN892RVyBHFM5FiXCzVAewbF/hBKj8J71lo3XatZKZYVTBB e61771YmUsYxodxDRrDvXo5QQVvwstEvHsb7xXEAuqJ9NZmcCcxRY+kBMF92moxFBkvu irmV78vjcBL6vgka4w740zqEdsL00byX9cHJrDSTk4svxtun2bDq1Qy6/oAFm7+v7k3l jD7g== X-Gm-Message-State: AOJu0YzgCIkPGdtrNnsunaSLxc6fwwHkKa+npqQi8c9bAicghPTlU3oE dEPJGmkO2jmdxqXELEmZui5sI+oTv+i350ASp5s= X-Received: by 2002:a05:6820:358:b0:593:fbd5:10aa with SMTP id m24-20020a056820035800b00593fbd510aamr17645813ooe.1.1703870556822; Fri, 29 Dec 2023 09:22:36 -0800 (PST) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 References: <20231227062940.10780-1-ricardo.neri-calderon@linux.intel.com> <20231227062940.10780-2-ricardo.neri-calderon@linux.intel.com> In-Reply-To: <20231227062940.10780-2-ricardo.neri-calderon@linux.intel.com> From: "Rafael J. Wysocki" Date: Fri, 29 Dec 2023 18:22:25 +0100 Message-ID: Subject: Re: [PATCH 1/4] thermal: intel: hfi: Refactor enabling code into helper functions To: Ricardo Neri Cc: "Rafael J. Wysocki" , Chen Yu , Len Brown , Srinivas Pandruvada , Stanislaw Gruszka , Zhang Rui , Zhao Liu , linux-pm@vger.kernel.org, linux-kernel@vger.kernel.org, Zhao Liu Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable On Wed, Dec 27, 2023 at 7:28=E2=80=AFAM Ricardo Neri wrote: > > In preparation to add a suspend notifier, wrap the logic to enable HFI an= d > program its memory buffer into helper functions. Both the CPU hotplug > callback and the suspend notifier will use it. No functional impact? > Cc: Chen Yu > Cc: Len Brown > Cc: Srinivas Pandruvada > Cc: Stanislaw Gruszka > Cc: Zhang Rui > Cc: Zhao Liu > Cc: linux-pm@vger.kernel.org > Cc: stable@vger.kernel.org Please don't CC stable@vger on patch submissions, although you may add a Cc: stable tag without actually CCing it for my information, but in that case please add a full tag including the earliest stable series the patch is intended to apply to. > Signed-off-by: Ricardo Neri > --- > drivers/thermal/intel/intel_hfi.c | 46 +++++++++++++++++-------------- > 1 file changed, 25 insertions(+), 21 deletions(-) > > diff --git a/drivers/thermal/intel/intel_hfi.c b/drivers/thermal/intel/in= tel_hfi.c > index c69db6c90869..87ac7b196981 100644 > --- a/drivers/thermal/intel/intel_hfi.c > +++ b/drivers/thermal/intel/intel_hfi.c > @@ -347,6 +347,25 @@ static void init_hfi_instance(struct hfi_instance *h= fi_instance) > hfi_instance->data =3D hfi_instance->hdr + hfi_features.hdr_size; > } > > +static void hfi_enable(void) > +{ > + u64 msr_val; > + > + rdmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); > + msr_val |=3D HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT; > + wrmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); > +} > + > +static void hfi_set_hw_table(struct hfi_instance *hfi_instance) > +{ > + phys_addr_t hw_table_pa; > + u64 msr_val; > + > + hw_table_pa =3D virt_to_phys(hfi_instance->hw_table); > + msr_val =3D hw_table_pa | HW_FEEDBACK_PTR_VALID_BIT; > + wrmsrl(MSR_IA32_HW_FEEDBACK_PTR, msr_val); > +} > + > /** > * intel_hfi_online() - Enable HFI on @cpu > * @cpu: CPU in which the HFI will be enabled > @@ -364,8 +383,6 @@ void intel_hfi_online(unsigned int cpu) > { > struct hfi_instance *hfi_instance; > struct hfi_cpu_info *info; > - phys_addr_t hw_table_pa; > - u64 msr_val; > u16 die_id; > > /* Nothing to do if hfi_instances are missing. */ > @@ -403,14 +420,16 @@ void intel_hfi_online(unsigned int cpu) > /* > * Hardware is programmed with the physical address of the first = page > * frame of the table. Hence, the allocated memory must be page-a= ligned. > + * > + * Some processors do not forget the initial address of the HFI t= able > + * even after having been reprogrammed. Keep using the same pages= . Do > + * not free them. This comment change does not seem to belong to this patch. I guess it needs to go to one of the subsequent patches? > */ > hfi_instance->hw_table =3D alloc_pages_exact(hfi_features.nr_tabl= e_pages, > GFP_KERNEL | __GFP_ZER= O); > if (!hfi_instance->hw_table) > goto unlock; > > - hw_table_pa =3D virt_to_phys(hfi_instance->hw_table); > - > /* > * Allocate memory to keep a local copy of the table that > * hardware generates. > @@ -420,16 +439,6 @@ void intel_hfi_online(unsigned int cpu) > if (!hfi_instance->local_table) > goto free_hw_table; > > - /* > - * Program the address of the feedback table of this die/package.= On > - * some processors, hardware remembers the old address of the HFI= table > - * even after having been reprogrammed and re-enabled. Thus, do n= ot free > - * the pages allocated for the table or reprogram the hardware wi= th a > - * new base address. Namely, program the hardware only once. > - */ > - msr_val =3D hw_table_pa | HW_FEEDBACK_PTR_VALID_BIT; > - wrmsrl(MSR_IA32_HW_FEEDBACK_PTR, msr_val); > - > init_hfi_instance(hfi_instance); > > INIT_DELAYED_WORK(&hfi_instance->update_work, hfi_update_work_fn)= ; > @@ -438,13 +447,8 @@ void intel_hfi_online(unsigned int cpu) > > cpumask_set_cpu(cpu, hfi_instance->cpus); > > - /* > - * Enable the hardware feedback interface and never disable it. S= ee > - * comment on programming the address of the table. > - */ > - rdmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); > - msr_val |=3D HW_FEEDBACK_CONFIG_HFI_ENABLE_BIT; > - wrmsrl(MSR_IA32_HW_FEEDBACK_CONFIG, msr_val); > + hfi_set_hw_table(hfi_instance); > + hfi_enable(); > > unlock: > mutex_unlock(&hfi_instance_lock); > --