From patchwork Wed Feb 7 19:09:15 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 198072 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2449765dyb; Wed, 7 Feb 2024 11:13:49 -0800 (PST) X-Google-Smtp-Source: AGHT+IEGv6AXFENjWe6riFLF7mcT9RxFZOt3JKZR7yNtQNAMcSFhYW8VWtk28DMccoKASU5cfmBd X-Received: by 2002:a05:622a:241:b0:42b:ff26:fad5 with SMTP id c1-20020a05622a024100b0042bff26fad5mr8542826qtx.35.1707333229225; Wed, 07 Feb 2024 11:13:49 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707333229; cv=pass; d=google.com; s=arc-20160816; b=SEePp4Ma8IIl4v6yE7mgkqTuv8WOPFZFJTG0HH7kNo3RAhdb6IiyuBiz190dhG/g4F 5tj4rQDPVMteOV+u4dBH6bD0jTQ2jw3oCQZ3gaKDQwmYTXAhYsz3FlVDBEk5k3GvE1z2 EFh9h7PcYw7fuf1PRdSlDHqtY1bTbO7I4L2a8OiFyqCvSe7YrovWnj3tzReXtzVNwOz/ S1zx5r52ww9q/jPLvnpZZyeVJwvu9hHLZfcw+j8Q+LxK06rpCtBLxz4Eh8Nqd6eHid11 jXaD/JjFhfJ3FS5aJDM482YWFAvbxCs90yH/IyX1jibMopyGgGbmjM12CJVdcQ6kTmvH 9f9g== 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=DF8le9HDpq93p2777y4UQBN8RGND8Kbv97g3pP965Fs=; fh=T+JPKUDUpAa/zu5ft1k6Scfgz0pcQWSbKYkHHXfALKs=; b=n1unB0KeaaDegQXxfzeTCq5p10GNru/1MU74NjltInKkhZw/hMQDX1RIl6nF9CcgsU IXZRBR2wcLtD1Puy++GPc850CLCVyKaWCmePeqxaWy4U2WwfipdKDwmW9Y8PdwZ+xFXG v+q75UiHGTzDYvK36wwU2YkDl5jbcPdgo/Z3KTmnYUIOEzLYO+wrBkJQBnGAPMJ7hzb7 KD+WO9VJH36jjAGgsLmND7LklstWNJjD1y3+wnnbSBZ7DQjZvdpHrdBg4eJwC/2AH37L Mp8wUi9hskPyU3Ap1u4+9j0qbDU1ASq6MltV2f1ANwiSc2bKPhYAuSt+xqgOaqJT96IQ 7u0w==; 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-kernel+bounces-56975-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56975-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCVoK2VeDZU7RamSVBd0oqgDY324woGHFF94N5vH7F+kQ36/GOfoje7ApsutnQMOy54Lf4zaWqp6EM9FfINrO3PMt+S3Bw== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id p16-20020a05622a00d000b0042c25e7363csi1757849qtw.167.2024.02.07.11.13.49 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 11:13:49 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56975-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-56975-ouuuleilei=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56975-ouuuleilei=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 ny.mirrors.kernel.org (Postfix) with ESMTPS id 0A7FA1C247F8 for ; Wed, 7 Feb 2024 19:13:49 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id C89D8126F03; Wed, 7 Feb 2024 19:13:01 +0000 (UTC) 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 E5D7C84FB3; Wed, 7 Feb 2024 19:12:57 +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=McAEyYxFXwRlWcukFvjLKwnNZwZ4108bF0CqGiFEyABZns+eZTzbMemdYoO/LSs76JVeVXyPv2tOYMVeSo5I+wDYL9ocR++7YHXGd3z4GwBHW5imHzLxL2p/HPa6ifUgau1n7V21fH197njSVv0iSMm4+uo4pu3edtpJiAjvBYQ= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707333180; c=relaxed/simple; bh=IKdzAuASVSS/yKCccM5Mg8xdrg02liH8JpWtvz0XBq8=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Xl4HbFblep3004a7pyJcpCCX5YZVrfFhz6vJAZmuflWe/2LKwlfcyFKClf48k+rADLe0XOqTF3jlpZoyGwstN2V2zgM9YSSnh5JSLEXoR0p7cVUUa1ZJlG8wm3K7S6p+NnL+t6nDfuvPhcquiJbL75YQk2vmMXotJPIMQd/50bI= 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 e8e8c8c4c6c01498; Wed, 7 Feb 2024 20:12:50 +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 DD008669B2E; Wed, 7 Feb 2024 20:12:49 +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 1/3] iwlwifi: mvm: Drop unused fw_trips_index[] from iwl_mvm_thermal_device Date: Wed, 07 Feb 2024 20:09:15 +0100 Message-ID: <13461881.uLZWGnKmhe@kreacher> In-Reply-To: <1892445.tdWV9SEqCh@kreacher> References: <1892445.tdWV9SEqCh@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrtddvgdduudelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepledprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehgrhgvghhorhihrdhgrhgvvghnmhgrnhesihhnthgvlhdrtghomhdprhgtphhtthhopehmihhrihgrmhdrrhgrtghhvghlrdhkohhrvghnsghlihhtsehinhhtvghlrdgtohhmpdhrtghpthhtohepkhhvrghloheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohep jhhohhgrnhhnvghsrdgsvghrghesihhnthgvlhdrtghomhdprhgtphhtthhopehlihhnuhigqdifihhrvghlvghsshesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=9 Fuz1=9 Fuz2=9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790268648017626346 X-GMAIL-MSGID: 1790268648017626346 From: Rafael J. Wysocki The fw_trips_index[] array in struct iwl_mvm_thermal_device is only populated, but never read, so drop it. Note that the iwl_mvm_send_temp_report_ths_cmd() code populating fw_trips_index[] is questionable, because it accesses a trips table of a thermal zone directly, which is not guaranteed to work in the future. No functional impact. Signed-off-by: Rafael J. Wysocki --- drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 2 -- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 13 +------------ 2 files changed, 1 insertion(+), 14 deletions(-) Index: linux-pm/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h =================================================================== --- linux-pm.orig/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +++ linux-pm/drivers/net/wireless/intel/iwlwifi/mvm/mvm.h @@ -539,12 +539,10 @@ struct iwl_mvm_tt_mgmt { /** *struct iwl_mvm_thermal_device - thermal zone related data * @temp_trips: temperature thresholds for report - * @fw_trips_index: keep indexes to original array - temp_trips * @tzone: thermal zone device data */ struct iwl_mvm_thermal_device { struct thermal_trip trips[IWL_MAX_DTS_TRIPS]; - u8 fw_trips_index[IWL_MAX_DTS_TRIPS]; struct thermal_zone_device *tzone; }; 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 @@ -562,7 +562,7 @@ int iwl_mvm_send_temp_report_ths_cmd(str struct temp_report_ths_cmd cmd = {0}; int ret; #ifdef CONFIG_THERMAL - int i, j, idx = 0; + int i, idx = 0; lockdep_assert_held(&mvm->mutex); @@ -588,17 +588,6 @@ int iwl_mvm_send_temp_report_ths_cmd(str /*sort cmd array*/ sort(cmd.thresholds, idx, sizeof(s16), compare_temps, NULL); - /* we should save the indexes of trips because we sort - * and compress the orginal array - */ - for (i = 0; i < idx; i++) { - for (j = 0; j < IWL_MAX_DTS_TRIPS; j++) { - if ((int)(le16_to_cpu(cmd.thresholds[i]) * 1000) == - mvm->tz_device.trips[j].temperature) - mvm->tz_device.fw_trips_index[i] = j; - } - } - send: #endif ret = iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(PHY_OPS_GROUP, From patchwork Wed Feb 7 19:10:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 198071 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2449623dyb; Wed, 7 Feb 2024 11:13:34 -0800 (PST) X-Google-Smtp-Source: AGHT+IFUc7mmOSy1+g9vNQNWRe55t7Iz0hjbjG8qDcinvSVrrMOFXen2jw6SDMaoUhvu008HqPV4 X-Received: by 2002:a05:6358:1a82:b0:179:2af:2e29 with SMTP id gm2-20020a0563581a8200b0017902af2e29mr2834886rwb.20.1707333214386; Wed, 07 Feb 2024 11:13:34 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707333214; cv=pass; d=google.com; s=arc-20160816; b=ejOEI8MNDgx+3MEmGT9MlIa40/sI/YpiVyByaF1ZlaBj9okgRsFkmboA7ZbDb2PLTW iBWeILV5eKKK0VjW14YtXGK0srUpv5rgZutzb0SWuV6CxJY4pF/RjSwJJZacULe9TsFq alcb5RjNaTZbO2Jc/qIuw3BCLIjyj1b+BUfVZs9gemWjiI0Gt7Rgz2rbU2LZM9ownqcV Uoc/gP9R0wxEUzU7a2tt/UEg1ivEjtRvmVzuO+BmsxKj8LcHHQVeEhEY7juKdu7pDHbr bdltomf2FmJqCpKeCeR5oiddKV8D5VYfyM/IvrSYjqRUoqVLl4Cl3HVEG/4CB+vYvKfY dIhA== 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=YxohlTFSuP3eg3oGl5XyJM9akbGsF+KuK1HuCJKYwho=; fh=MpGkFcnMviJhnmia5ZdIbdW6a15rkuQlf/iG6Wlt4n0=; b=cvQvWmUb4sR64GmuweFDkjMRgVxowi9GuLkZdgG4SVNUk/S301nDTL6xzT/wx0CwNX KK0xf9LRy69PctC1217yg/nuk3fta/f+RRiGKjQeA+4PS0DdEhu4I/FMH+eA2HIgkC1N SjN7jePIDnFdT+DZrAa8KKRp40IONd+uk/lBczzEUQM93tDzBc7rI0GsLu3hhM1dJ27D av3oNLxXSiUWI9pn3HEpnVJZw63oBbyUyJiWDdILY7FSM6Heg1PakUfwD/9r4SbeI91A cbVnsYwKPtxBdTmyAZjqu+rkNpwRxS7a7nmJhrglqrjxgXRxJbqOoFVVgnJl6GWUAcQF P4rA==; 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-kernel+bounces-56974-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56974-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCWmKvNEgctjqUL2LAqJLSABHY6xvx/YREG9vGKPuUE4jIGftMgSWPfAnCsH029yHyh5JIDaEGECSR+8RcxydIT6OzTd6Q== Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id b16-20020a056a000cd000b006e03db87d98si2352213pfv.105.2024.02.07.11.13.34 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 11:13:34 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56974-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-56974-ouuuleilei=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56974-ouuuleilei=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 sv.mirrors.kernel.org (Postfix) with ESMTPS id E9A282887E7 for ; Wed, 7 Feb 2024 19:13:33 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E4E578614F; Wed, 7 Feb 2024 19:13:00 +0000 (UTC) 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 E6A098527E; 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=1707333179; cv=none; b=dKvqtX9rSfgcABKAag3KNL77Wa+KNrfWvp5fz3aeBhkxaHsS/8WjHraziVMHFf8Qj9oywtOKQYIbWWs7AMCJnvnFxL+cWoPFkUiQ+7ZHNsei1ysOsHGpdmPeT8PO/xIP9Rn/nohsEIL+qiRE3+1HS1zMUCrGyhkKCdJR/HyqLiY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707333179; c=relaxed/simple; bh=fEDNq2Er6z2Bo4ZvoiSYDuSkdI3VFvkzx+dgMfUNyCE=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=Ve/8hlHrDdVcwFTYCindN6/eSI/tGJVXqvQ+xvMt6vEyVUkXj7Xk1+zIL8mcQKmxiWAhMM4tyrSdyY6J3DmFo4NL0xR5Ap2XWl5Fa3zjxFs4z1PdOl/UZWYdy5/TRc3GAg4RKJ2pMkiRSt00xUSoEIXoWQVx+GuPgYXwLACdnoc= 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 527089a773aed57e; Wed, 7 Feb 2024 20:12:49 +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 0173A669B2E; 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 2/3] iwlwifi: mvm: Populate trip table before registering thermal zone Date: Wed, 07 Feb 2024 20:10:24 +0100 Message-ID: <8346768.T7Z3S40VBb@kreacher> In-Reply-To: <1892445.tdWV9SEqCh@kreacher> References: <1892445.tdWV9SEqCh@kreacher> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-CLIENT-IP: 195.136.19.94 X-CLIENT-HOSTNAME: 195.136.19.94 X-VADE-SPAMSTATE: clean X-VADE-SPAMCAUSE: gggruggvucftvghtrhhoucdtuddrgedvledrtddvgdduudelucetufdoteggodetrfdotffvucfrrhhofhhilhgvmecujffqoffgrffnpdggtffipffknecuuegrihhlohhuthemucduhedtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenucfjughrpefhvfevufffkfgjfhgggfgtsehtufertddttdejnecuhfhrohhmpedftfgrfhgrvghlucflrdcuhgihshhotghkihdfuceorhhjfiesrhhjfiihshhotghkihdrnhgvtheqnecuggftrfgrthhtvghrnhepvdffueeitdfgvddtudegueejtdffteetgeefkeffvdeftddttdeuhfegfedvjefhnecukfhppeduleehrddufeeirdduledrleegnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehinhgvthepudelhedrudefiedrudelrdelgedphhgvlhhopehkrhgvrggthhgvrhdrlhhotggrlhhnvghtpdhmrghilhhfrhhomhepfdftrghfrggvlhculfdrucghhihsohgtkhhifdcuoehrjhifsehrjhifhihsohgtkhhirdhnvghtqedpnhgspghrtghpthhtohepledprhgtphhtthhopehlihhnuhigqdhpmhesvhhgvghrrdhkvghrnhgvlhdrohhrghdprhgtphhtthhopehgrhgvghhorhihrdhgrhgvvghnmhgrnhesihhnthgvlhdrtghomhdprhgtphhtthhopehmihhrihgrmhdrrhgrtghhvghlrdhkohhrvghnsghlihhtsehinhhtvghlrdgtohhmpdhrtghpthhtohepkhhvrghloheskhgvrhhnvghlrdhorhhgpdhrtghpthhtohep jhhohhgrnhhnvghsrdgsvghrghesihhnthgvlhdrtghomhdprhgtphhtthhopehlihhnuhigqdifihhrvghlvghsshesvhhgvghrrdhkvghrnhgvlhdrohhrgh X-DCC--Metrics: v370.home.net.pl 1024; Body=9 Fuz1=9 Fuz2=9 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790268632720650106 X-GMAIL-MSGID: 1790268632720650106 From: Rafael J. Wysocki The trip table in iwl_mvm_thermal_zone_register() is populated after passing it to thermal_zone_device_register_with_trips(), so it may be accessed (for instance, via sysfs) before it is ready. To prevent that from happening, modify the function to populate the trip table before calling thermal_zone_device_register_with_trips(). Also make the code use THERMAL_TEMP_INVALID as the "invalid temperature" value which is also meaningful for the core. Signed-off-by: Rafael J. Wysocki --- drivers/net/wireless/intel/iwlwifi/mvm/tt.c | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 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 @@ -575,7 +575,7 @@ int iwl_mvm_send_temp_report_ths_cmd(str /* compress trips to cmd array, remove uninitialized values*/ for (i = 0; i < IWL_MAX_DTS_TRIPS; i++) { - if (mvm->tz_device.trips[i].temperature != INT_MIN) { + if (mvm->tz_device.trips[i].temperature != THERMAL_TEMP_INVALID) { cmd.thresholds[idx++] = cpu_to_le16((s16)(mvm->tz_device.trips[i].temperature / 1000)); } @@ -675,6 +675,14 @@ static void iwl_mvm_thermal_zone_registe BUILD_BUG_ON(ARRAY_SIZE(name) >= THERMAL_NAME_LENGTH); sprintf(name, "iwlwifi_%u", atomic_inc_return(&counter) & 0xFF); + /* + * 0 is a valid temperature, + * so initialize the array with S16_MIN which invalid temperature + */ + for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) { + mvm->tz_device.trips[i].temperature = THERMAL_TEMP_INVALID; + mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE; + } mvm->tz_device.tzone = thermal_zone_device_register_with_trips(name, mvm->tz_device.trips, IWL_MAX_DTS_TRIPS, @@ -693,15 +701,6 @@ static void iwl_mvm_thermal_zone_registe if (ret) { IWL_DEBUG_TEMP(mvm, "Failed to enable thermal zone\n"); thermal_zone_device_unregister(mvm->tz_device.tzone); - return; - } - - /* 0 is a valid temperature, - * so initialize the array with S16_MIN which invalid temperature - */ - for (i = 0 ; i < IWL_MAX_DTS_TRIPS; i++) { - mvm->tz_device.trips[i].temperature = INT_MIN; - mvm->tz_device.trips[i].type = THERMAL_TRIP_PASSIVE; } } From patchwork Wed Feb 7 19:12:38 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Rafael J. Wysocki" X-Patchwork-Id: 198073 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7301:168b:b0:106:860b:bbdd with SMTP id ma11csp2449886dyb; Wed, 7 Feb 2024 11:14:01 -0800 (PST) X-Google-Smtp-Source: AGHT+IFJCHpqc4avGvzMj1tbfEf5OE2LqDIawMhkmBp2mXlZAUeIHV+96uIS/GYVFQa5l4SesBnV X-Received: by 2002:a17:90a:cb0f:b0:296:3daf:8245 with SMTP id z15-20020a17090acb0f00b002963daf8245mr3435372pjt.19.1707333241632; Wed, 07 Feb 2024 11:14:01 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707333241; cv=pass; d=google.com; s=arc-20160816; b=F2ifRMOYBL++slnYpNT5LuZvM1lq476z2v/o81sAEEGXw6kII0iVTla7s3ZD51eJM0 sAilknTCVDU48QzBCQWktXKGxx0T7DgvBlduj1LDA1Lz+XTPsZRw+/SThPeMUmVOc4uN weo2GKifk5e+ZUTaL4PokbtcjKE76c68msdX7fAnke35ZttgxTLT7HAbyAHqSQPqhoj1 eQGs3LmQbuGy6HbOUYEdBSnzZweqnRg6IGky4Ngq106Jz366Fomn1t8uN0ZEfBNeBvbk Gi4BcXu3Agc0maD7EvSKia/ppSfnh+9fzlNFJmL8qMr3Y7JyBQv8KprvSsY2wXUWojuy BK+A== 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=9bBBArznAvJnwqHJVpYHSfbBkmp3sdFaYyhlkpxJ1XU=; b=sSRiyGwmAbrVm6Sz6RyMghOlc2fLIgUzXSbVlBeDvmpsloJYjnD1GovvKeXws3VVvF cvg8gezoHA0mKbzNxwfoMTTfHg6XSURxGyCh1Q4/gHW6AX890WNRt22c91jfaVy6O+iY Sr6wYbit2VUfQQDOTuiNQk2BKoBNy4qcmYZgvn3lHStgj55T2qPWjyCudZ2t0Hf4qpW9 1DM1hfXuJD8+P6/wWDivzJaST2vUpDX7lIcx2opwKBZwCe8Ih+BMF55SBGQyz3nP8CmC hEtNG0ndQuei3zV2NnSj7yGKVczgRTr7sgcHVxZNTiHfUjLxIs4sPiI/XoC4ezUouqEE PbYQ==; 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-kernel+bounces-56976-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56976-ouuuleilei=gmail.com@vger.kernel.org" X-Forwarded-Encrypted: i=2; AJvYcCXuTnw6R3Acuk4jyQZq8AS0vGNCX6xkt2O/fq2TemVLs49/GEl5kaj+pKgCbYQjUSe9aHXmczf32yVioaYn1JJvL01BmA== Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [2604:1380:40f1:3f00::1]) by mx.google.com with ESMTPS id gd2-20020a17090b0fc200b002965d9cda3esi2224016pjb.163.2024.02.07.11.14.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 07 Feb 2024 11:14:01 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-56976-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) client-ip=2604:1380:40f1:3f00::1; Authentication-Results: mx.google.com; arc=pass (i=1 spf=pass spfdomain=rjwysocki.net); spf=pass (google.com: domain of linux-kernel+bounces-56976-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:40f1:3f00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-56976-ouuuleilei=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 sy.mirrors.kernel.org (Postfix) with ESMTPS id 7EA91B21AF6 for ; Wed, 7 Feb 2024 19:14:00 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 621A5126F37; Wed, 7 Feb 2024 19:13:02 +0000 (UTC) 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-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 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 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790268661336066584 X-GMAIL-MSGID: 1790268661336066584 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