Received: by 2002:a05:7412:2a8a:b0:fc:a2b0:25d7 with SMTP id u10csp515532rdh; Wed, 7 Feb 2024 11:13:26 -0800 (PST) X-Google-Smtp-Source: AGHT+IGbbq93gyXHZgyVCNyGAFhGy1t0Rv6nw/J8d3IBuEz/+woHvKv8WwAXvVNZ5cdKQZlibRHH X-Received: by 2002:a17:906:6b0b:b0:a38:45d:f90e with SMTP id q11-20020a1709066b0b00b00a38045df90emr5149947ejr.24.1707333206218; Wed, 07 Feb 2024 11:13:26 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707333206; cv=pass; d=google.com; s=arc-20160816; b=biUR0JWbUSHjncYbinPFgcZlU9WgsVLpbIRP+fcnWsfhQm9JkGI3Wj2NTscM9WhWmr /tYMj4wO1A2nwrNaCBOXxpUQGZpAp2FAOQL87O4pd8AY21ZvciR/OAJ8cCP/U7iWh4+/ wsxPyyp5p/RSz0/rWMNSkcJfhLozpfly66xEmBpnv7L4QTZkhlVJ/Z9weBGL8UH4JI7F szTg4D4QVTewwSpjNvDkLfLdh8t9e/dINlJUT6YnPp+EeNycs2A272yjzb26Rrg/pU0+ 7jbEQw5YyVlRDDTTGnLu1ArP6I9d+K7eTVXDZkAIuue5cWaFDEGBelZs1AnLq1Q9WdpH Ektg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from; bh=NkzCj1C9RS91pDWtSiNflWNO5GQHt4XTbriWZhu3bwk=; fh=fk+yJW0nh7WXs/jO+hPz38wSTjti7xIY7GypCdx1IEI=; b=0lmj7HSRZfrUMzPba5/GP76ku2TSNevofo99un2zNV/cwiizuUR/GN5wvSozsZcdzI ro3taJQql7d7jfS51rn5wx8qmrV7FzyxGGSFqNyUuVaILeLrrPXbRDLNWkQY+ArduU5K oTNtJkQA6ltkaOjjIl/fcFEqgurji5o723lrqL6CsfqeG1vfPHXE8+i5RGTYQ++5WDYP ApL/99zrA70OcLGGsYnNhMha3Pj8ca1pc6UeYkisLVkE5uyE02E1fgFVogwWoKhc/mr0 kNjgNAVSTcTTSSoY7Jl1U5db5HHlWGomKMIx4ofd2uLKImxZOmbstSwcFDC+JHRVqGCr 1hlA==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-wireless+bounces-3307-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3307-linux.lists.archive=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVqHcGXwe95WyKgykZqka8w7TB75UzqznnZEE09RpWEiDs+R28T1Y3bAPuHk21eUZjDKhT0GCFs9IWeBVcwJ3xboyMqNRTnEDpXzcLviA== Return-Path: Received: from am.mirrors.kernel.org (am.mirrors.kernel.org. [2604:1380:4601:e00::3]) by mx.google.com with ESMTPS id gv16-20020a170906f11000b00a386805be63si1127471ejb.1041.2024.02.07.11.13.26 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 11:13:26 -0800 (PST) Received-SPF: pass (google.com: domain of linux-wireless+bounces-3307-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; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-wireless+bounces-3307-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:4601:e00::3 as permitted sender) smtp.mailfrom="linux-wireless+bounces-3307-linux.lists.archive=gmail.com@vger.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 EEA741F2484A for ; Wed, 7 Feb 2024 19:13:25 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 93D2885C7A; Wed, 7 Feb 2024 19:13:00 +0000 (UTC) X-Original-To: linux-wireless@vger.kernel.org Received: from cloudserver094114.home.pl (cloudserver094114.home.pl [79.96.170.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id E69C4823B9; Wed, 7 Feb 2024 19:12:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=79.96.170.134 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707333180; cv=none; b=tjZ+vMJq9yDxHBH6G5lolc5qLQwNIwi+RV1E7dsj1Sg8N71JbTnte9DAEwnhZQ+chm5wszjxn0Oyk8KBu2AiSTDoYgQfn+sS3gssEXOHWBd/f4tvGIsqRUGrwPovJZCVRg6KWTZuRtMR+qDBmKinkCn2101YNgfVXRhq2pu6LQY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707333180; c=relaxed/simple; bh=AB6u5fg2dweFTMD5jMbAqYepGoUI5YM7pGFRXWYMAfY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=N15Hskrnu/aKA+cnsIj0avxPbECiXRzCYLjx7uXysOJ276Kuwy85OyM7MQ0rov/mjPK5UprsDMUrjTD3uB83dgJTOsfxwH8riwT/+o7bNX+aznL7D/vMyqGKkh7aXOCNu4PIxic/mI5mvgU6SDmDo7A6P3SDlZv3RKnm4C01hRM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net; spf=pass smtp.mailfrom=rjwysocki.net; arc=none smtp.client-ip=79.96.170.134 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=rjwysocki.net Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=rjwysocki.net Received: from localhost (127.0.0.1) (HELO v370.home.net.pl) by /usr/run/smtp (/usr/run/postfix/private/idea_relay_lmtp) via UNIX with SMTP (IdeaSmtpServer 5.4.0) id cc3e3f799ac74844; Wed, 7 Feb 2024 20:12:48 +0100 Received: from kreacher.localnet (unknown [195.136.19.94]) (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) (No client certificate requested) by cloudserver094114.home.pl (Postfix) with ESMTPSA id 261B2669B2E; Wed, 7 Feb 2024 20:12:48 +0100 (CET) From: "Rafael J. Wysocki" To: Linux PM Cc: Gregory Greenman , Miri Korenblit , Kalle Valo , Johannes Berg , linux-wireless@vger.kernel.org, LKML , Daniel Lezcano , Stanislaw Gruszka Subject: [PATCH v1 3/3] iwlwifi: mvm: Use for_each_thermal_trip() for walking trip points Date: Wed, 07 Feb 2024 20:12:38 +0100 Message-ID: <2270733.iZASKD2KPV@kreacher> In-Reply-To: <1892445.tdWV9SEqCh@kreacher> References: <1892445.tdWV9SEqCh@kreacher> Precedence: bulk X-Mailing-List: linux-wireless@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 7Bit Content-Type: text/plain; charset="UTF-8" X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrtddvgdduudekucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepledprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehgrhgvghhorhihrdhgrhgvvghnmhgrnhesihhnthgvlhdrtghomhdprhgtphhtthhopehmihhrihgrmhdrrhgrtghhvghlrdhkohhrvghnsghlihhtsehinhhtvghlrdgtohhmpdhrtghpthhtohepkhhvrghloheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohep jhhohhgrnhhnvghsrdgsvghrghesihhnthgvlhdrtghomhdprhgtphhtthhopehlihhnuhigqdifihhrvghlvghsshesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=9 Fuz1=9 Fuz2=9 From: Rafael J. Wysocki The code walking trip points in iwl_mvm_send_temp_report_ths_cmd() reads the trip table passed to thermal_zone_device_register_with_trips() in order to get the current trip temperatures, but this is not guaranteed to work in the future, because the thermal zone will store trip points information internally. For this reason, make iwl_mvm_send_temp_report_ths_cmd() use for_each_thermal_trip() as appropriate for walking trip points in a given thermal zone. No intentional functional impact, but it is requisite for future thermal core improvements. Signed-off-by: Rafael J. Wysocki --- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 40 +++++++++++++++++----------- 1 file changed, 25 insertions(+), 15 deletions(-) Index: linux-pm/drivers/net/wireless/intel/iwlwifi/mvm/tt.c =================================================================== --- linux-pm.orig/drivers/net/wireless/intel/iwlwifi/mvm/tt.c +++ linux-pm/drivers/net/wireless/intel/iwlwifi/mvm/tt.c @@ -555,6 +555,22 @@ static int compare_temps(const void *a, return ((s16)le16_to_cpu(*(__le16 *)a) - (s16)le16_to_cpu(*(__le16 *)b)); } + +struct iwl_trip_walk_data { + __le16 *thresholds; + int count; +}; + +static int iwl_trip_temp_cb(struct thermal_trip *trip, void *arg) +{ + struct iwl_trip_walk_data *twd = arg; + + if (trip->temperature == THERMAL_TEMP_INVALID) + return 0; + + twd->thresholds[twd->count++] = cpu_to_le16((s16)(trip->temperature / 1000)); + return 0; +} #endif int iwl_mvm_send_temp_report_ths_cmd(struct iwl_mvm *mvm) @@ -562,31 +578,25 @@ int iwl_mvm_send_temp_report_ths_cmd(str struct temp_report_ths_cmd cmd = {0}; int ret; #ifdef CONFIG_THERMAL - int i, idx = 0; + struct iwl_trip_walk_data twd = { .thresholds = cmd.thresholds, .count = 0 }; lockdep_assert_held(&mvm->mutex); if (!mvm->tz_device.tzone) goto send; - /* The driver holds array of temperature trips that are unsorted - * and uncompressed, the FW should get it compressed and sorted + /* + * The thermal core holds an array of temperature trips that are + * unsorted and uncompressed, the FW should get it compressed and + * sorted. */ /* compress trips to cmd array, remove uninitialized values*/ - for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) { - if (mvm->tz_device.trips[i].temperature != THERMAL_TEMP_INVALID) { - cmd.thresholds[idx++] = - cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000)); - } - } - cmd.num_temps = cpu_to_le32(idx); - - if (!idx) - goto send; + for_each_thermal_trip(mvm->tz_device.tzone, iwl_trip_temp_cb, &twd); - /*sort cmd array*/ - sort(cmd.thresholds, idx, sizeof(s16), compare_temps, NULL); + cmd.num_temps = cpu_to_le32(twd.count); + if (twd.count) + sort(cmd.thresholds, twd.count, sizeof(s16), compare_temps, NULL); send: #endif