Commit Graph

56 Commits

Author SHA1 Message Date
David Arcari 73087d2ade thermal: core: Allow thermal zones to tell the core to ignore them
JIRA: https://issues.redhat.com/browse/RHEL-61357
Conflicts: 3f3126515fbe ("wifi: iwlwifi: mvm: add mvm-specific guard") is
	   not in RHEL

commit e528be3c87be953b73e7826a2d7e4b837cbad39d
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Wed Jul 17 21:45:02 2024 +0200

    thermal: core: Allow thermal zones to tell the core to ignore them

    The iwlwifi wireless driver registers a thermal zone that is only needed
    when the network interface handled by it is up and it wants that thermal
    zone to be effectively ignored by the core otherwise.

    Before commit a8a261774466 ("thermal: core: Call monitor_thermal_zone()
    if zone temperature is invalid") that could be achieved by returning
    an error code from the thermal zone's .get_temp() callback because the
    core did not really handle errors returned by it almost at all.
    However, commit a8a261774466 made the core attempt to recover from the
    situation in which the temperature of a thermal zone cannot be
    determined due to errors returned by its .get_temp() and is always
    invalid from the core's perspective.

    That was done because there are thermal zones in which .get_temp()
    returns errors to start with due to some difficulties related to the
    initialization ordering, but then it will start to produce valid
    temperature values at one point.

    Unfortunately, the simple approach taken by commit a8a261774466,
    which is to poll the thermal zone periodically until its .get_temp()
    callback starts to return valid temperature values, is at odds with
    the special thermal zone in iwlwifi in which .get_temp() may always
    return an error because its network interface may always be down.  If
    that happens, every attempt to invoke the thermal zone's .get_temp()
    callback resulting in an error causes the thermal core to print a
    dev_warn() message to the kernel log which is super-noisy.

    To address this problem, make the core handle the case in which
    .get_temp() returns 0, but the temperature value returned by it
    is not actually valid, in a special way.  Namely, make the core
    completely ignore the invalid temperature value coming from
    .get_temp() in that case, which requires folding in
    update_temperature() into its caller and a few related changes.

    On the iwlwifi side, modify iwl_mvm_tzone_get_temp() to return 0
    and put THERMAL_TEMP_INVALID into the temperature return memory
    location instead of returning an error when the firmware is not
    running or it is not of the right type.

    Also, to clearly separate the handling of invalid temperature
    values from the thermal zone initialization, introduce a special
    THERMAL_TEMP_INIT value specifically for the latter purpose.

    Fixes: a8a261774466 ("thermal: core: Call monitor_thermal_zone() if zone temperature is invalid")
    Closes: https://lore.kernel.org/linux-pm/20240715044527.GA1544@sol.localdomain/
    Reported-by: Eric Biggers <ebiggers@kernel.org>
    Reported-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
    Link: https://bugzilla.kernel.org/show_bug.cgi?id=201761
    Tested-by: Oleksandr Natalenko <oleksandr@natalenko.name>
    Tested-by: Stefan Lippers-Hollmann <s.l-h@gmx.de>
    Cc: 6.10+ <stable@vger.kernel.org> # 6.10+
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://patch.msgid.link/4950004.31r3eYUQgx@rjwysocki.net
    [ rjw: Rebased on top of the current mainline ]
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-02-17 13:35:04 -05:00
David Arcari 70743da75c thermal: core: Eliminate writable trip points masks
JIRA: https://issues.redhat.com/browse/RHEL-61357
Conflicts: - moved thermal_zone_device_type to the correct location in
	     drivers/thermal/thermal_core.c
	   - out of order commits in drivers/acpi/thermal.c results
	     in minor difference
	   - Also dropped unsupported bits from:
	   	drivers/thermal/st/st_thermal.c
	        drivers/thermal/imx_thermal.c
	        drivers/thermal/da9062-thermal.c
	        drivers/platform/x86/acerhdf.c

commit 4a62d588a84e13c68017bd16bc9c2531a2cde08f
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Thu Feb 22 19:09:16 2024 +0100

    thermal: core: Eliminate writable trip points masks

    All of the thermal_zone_device_register_with_trips() callers pass zero
    writable trip points masks to it, so drop the mask argument from that
    function and update all of its callers accordingly.

    This also removes the artificial trip points per zone limit of 32,
    related to using writable trip points masks.

    No intentional functional impact.

    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-02-17 13:34:59 -05:00
David Arcari ec9187c619 wifi: iwlwifi: mvm: Set THERMAL_TRIP_FLAG_RW_TEMP directly
JIRA: https://issues.redhat.com/browse/RHEL-61357

commit 96c5330bf75839a31d6fdf953fade6e9fbf30bde
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Mon Feb 12 19:38:07 2024 +0100

    wifi: iwlwifi: mvm: Set THERMAL_TRIP_FLAG_RW_TEMP directly

    It is now possible to flag trip points with THERMAL_TRIP_FLAG_RW_TEMP
    to allow their temperature to be set from user space via sysfs instead
    of using a nonzero writable trips mask during thermal zone registration,
    so make the iwlwifi code do that.

    No intentional functional impact.

    Note that this change is requisite for dropping the mask argument from
    thermal_zone_device_register_with_trips() going forward.

    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Reviewed-by: Daniel Lezcano <daniel.lezcano@linaro.org>

Signed-off-by: David Arcari <darcari@redhat.com>
2025-02-17 13:34:59 -05:00
Jose Ignacio Tornos Martinez 15d99d1eba wifi: iwlwifi: support fast resume
JIRA: https://issues.redhat.com/browse/RHEL-50013

commit e8bb19c1d5906d2f31ae61853fea2a9abc71e951
Author: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Date:   Tue Jun 18 19:44:03 2024 +0300

    wifi: iwlwifi: support fast resume
    
    This will allow to suspend / resume the system without resetting the
    firmware. This will allow to reduce the resume time.
    In case the fast_resume fails, stop the device and bring it up from
    scratch.
    
    Raise the timeout for the D3_END notification since in some iterations,
    it took 240ms.
    
    Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://patch.msgid.link/20240618194245.03b8d2801044.I613d17c712de7a0d611cde4e14f37ebbe0c3c964@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:18:12 +01:00
Jose Ignacio Tornos Martinez 6c52684a71 wifi: iwlwifi: mvm: add mvm-specific guard
JIRA: https://issues.redhat.com/browse/RHEL-50013

Conflicts:
  - drivers/net/wireless/intel/iwlwifi/mvm/tt.c
    context diff because 0728c810873e1 was already applied.

commit 3f3126515fbee0e364f8218f6171c091d8e2555e
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Sun May 12 15:24:58 2024 +0300

    wifi: iwlwifi: mvm: add mvm-specific guard
    
    Add and use an mvm-specific guard for the mvm mutex.
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Link: https://msgid.link/20240512152312.7391425b3af2.I1b109f56753dd3f35602dd2c5cf6e1e35aee313d@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-10-29 08:17:47 +01:00
David Arcari ecf75b8822 thermal: trip: Pass trip pointer to .set_trip_temp() thermal zone callback
JIRA: https://issues.redhat.com/browse/RHEL-29349

commit 0728c810873e1a94e8b767f9809af940c9307d60
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Tue Jul 2 16:42:33 2024 +0200

    thermal: trip: Pass trip pointer to .set_trip_temp() thermal zone callback

    Out of several drivers implementing the .set_trip_temp() thermal zone
    operation, three don't actually use the trip ID argument passed to it,
    two call __thermal_zone_get_trip() to get a struct thermal_trip
    corresponding to the given trip ID, and the other use the trip ID as an
    index into their own data structures with the assumption that it will
    always match the ordering of entries in the trips table passed to the
    core during thermal zone registration, which is fragile and not really
    guaranteed.

    Even though the trip IDs used by the core are in fact their indices in the
    trips table passed to it by the thermal zone creator, that is purely a
    matter of convenience and should not be relied on for correctness.

    For this reason, modify trip_point_temp_store() to pass a (const) trip
    pointer to .set_trip_temp() and adjust the drivers implementing it
    accordingly.

    This helps to simplify the drivers invoking __thermal_zone_get_trip()
    from their .set_trip_temp() callback functions because they will not
    need to do it now and the other drivers can store their internal
    trip indices in the priv field in struct thermal_trip and their
    .set_trip_temp() callback functions can get those indices from there.

    The intel_quark_dts thermal driver can instead use the trip type to
    determine the requisite trip index.

    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
    Link: https://patch.msgid.link/8392906.T7Z3S40VBb@rjwysocki.net
    [ rjw: Add missing colon and 2 empty code lines ]
    [ rjw: Add missing change in imx_thermal.c and adjust the changelog ]
    [ rjw: Drop an unused local variable ]
    Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>

Signed-off-by: David Arcari <darcari@redhat.com>
2024-09-19 07:13:35 -04:00
Jose Ignacio Tornos Martinez 4c83438a7e iwlwifi: mvm: Use for_each_thermal_trip() for walking trip points
JIRA: https://issues.redhat.com/browse/RHEL-34696

commit 85af3310df34b0931daba8732d5b2c64a81c3b8d
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Wed Feb 7 20:12:38 2024 +0100

    iwlwifi: mvm: Use for_each_thermal_trip() for walking trip points
    
    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 <rafael.j.wysocki@intel.com>
    Acked-by: Miri Korenblit <Miriam.rachel.korenblit@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-06-17 09:19:17 +02:00
Jose Ignacio Tornos Martinez db8ae298e4 iwlwifi: mvm: Populate trip table before registering thermal zone
JIRA: https://issues.redhat.com/browse/RHEL-34696

commit 61d88437546f5f40b6411aac17c55d0298c7a19d
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Wed Feb 7 20:10:24 2024 +0100

    iwlwifi: mvm: Populate trip table before registering thermal zone
    
    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 <rafael.j.wysocki@intel.com>
    Acked-by: Miri Korenblit <Miriam.rachel.korenblit@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-06-17 09:19:17 +02:00
Jose Ignacio Tornos Martinez f36c59365f iwlwifi: mvm: Drop unused fw_trips_index[] from iwl_mvm_thermal_device
JIRA: https://issues.redhat.com/browse/RHEL-34696

commit 2e171a57c312cb732d633c5ccc51551588b7a855
Author: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Date:   Wed Feb 7 20:09:15 2024 +0100

    iwlwifi: mvm: Drop unused fw_trips_index[] from iwl_mvm_thermal_device
    
    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 <rafael.j.wysocki@intel.com>
    Acked-by: Miri Korenblit <Miriam.rachel.korenblit@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-06-17 09:19:17 +02:00
Jose Ignacio Tornos Martinez d94a359fa4 wifi: iwlwifi: drop NULL pointer check in iwl_mvm_tzone_set_trip_temp()
JIRA: https://issues.redhat.com/browse/RHEL-34696

commit cf912ca1a3c3d2e6fcacb6568e66f72cca05277d
Author: Dmitry Antipov <dmantipov@yandex.ru>
Date:   Tue Oct 3 12:20:46 2023 +0300

    wifi: iwlwifi: drop NULL pointer check in iwl_mvm_tzone_set_trip_temp()
    
    Since 'tz_device' is an in-place member of 'struct iwl_mvm', it can't
    be NULL and so relevant check may be dropped. Compile tested only.
    
    Found by Linux Verification Center (linuxtesting.org) with SVACE.
    
    Signed-off-by: Dmitry Antipov <dmantipov@yandex.ru>
    Acked-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20231003092048.24998-1-dmantipov@yandex.ru
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2024-06-17 09:18:22 +02:00
Mark Langsdorf 36b94a3dcd thermal/core: Use the thermal zone 'devdata' accessor in remaining drivers
JIRA: https://issues.redhat.com/browse/RHEL-26871

commit 3d4e1bad7804bee102bb1e992f2831e4c6658f88
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
Date: Fri, 03 Mar 2023 20:45:02 +0000

The thermal zone device structure is exposed to the different drivers
and obviously they access the internals while that should be
restricted to the core thermal code.

In order to self-encapsulate the thermal core code, we need to prevent
the drivers accessing directly the thermal zone structure and provide
accessor functions to deal with.

Use the devdata accessor introduced in the previous patch.

No functional changes intended.

Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Acked-by: Mark Brown <broonie@kernel.org>
Reviewed-by: Ido Schimmel <idosch@nvidia.com> #mlxsw
Acked-by: Gregory Greenman <gregory.greenman@intel.com> #iwlwifi
Acked-by: Sebastian Reichel <sebastian.reichel@collabora.com> #power_supply
Acked-by: Damien Le Moal <damien.lemoal@opensource.wdc.com> #ahci
Acked-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Rafael J. Wysocki <rafael.j.wysocki@intel.com>
Signed-off-by: Mark Langsdorf <mlangsdo@redhat.com>
2024-03-27 11:39:36 -04:00
Íñigo Huguet f563491464 wifi: iwlwifi: mvm: adjust SMPS for MLO
Bugzilla: https://bugzilla.redhat.com/2196821

commit 1a3e70391e55d12010073935e383629ab856528a
Author: Gregory Greenman <gregory.greenman@intel.com>
Date:   Tue Mar 28 10:59:01 2023 +0300

    wifi: iwlwifi: mvm: adjust SMPS for MLO
    
    Configure SMPS per-link. Add link_id parameter to
    iwl_mvm_update_smps() and refactor iwl_mvm_intf_dual_chain_req()
    since it has to handle all active links.
    
    Signed-off-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20230328104949.da6a19db562c.Ic88b02338c8973f2934439ac3ee77c7451bc0054@changeid
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2023-07-26 13:15:12 +02:00
Jose Ignacio Tornos Martinez f635230532 wifi: iwlwifi: Use generic thermal_zone_get_trip() function
Bugzilla: https://bugzilla.redhat.com/2178526

commit 3d2f20ad46f83b333025f5e8e4afc34be8f13c4c
Author: Daniel Lezcano <daniel.lezcano@linaro.org>
Date:   Fri Oct 14 09:32:50 2022 +0200

    wifi: iwlwifi: Use generic thermal_zone_get_trip() function
    
    The thermal framework gives the possibility to register the trip
    points with the thermal zone. When that is done, no get_trip_* ops are
    needed and they can be removed.
    
    The get_trip_temp, get_trip_hyst and get_trip_type are handled by the
    get_trip_point().
    
    The set_trip_temp() generic function does some checks which are no
    longer needed in the set_trip_point() ops.
    
    Convert ops content logic into generic trip points and register them
    with the thermal zone.
    
    Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
    Acked-by: Kalle Valo <kvalo@kernel.org>
    Acked-by: Gregory Greenman <gregory.greenman@intel.com>
    Link: https://lore.kernel.org/r/20221014073253.3719911-1-daniel.lezcano@linaro.org

Signed-off-by: Jose Ignacio Tornos Martinez <jtornosm@redhat.com>
2023-05-09 08:17:30 +02:00
Íñigo Huguet 6f64da8393 iwlwifi: mvm: add support for CT-KILL notification version 2
Bugzilla: https://bugzilla.redhat.com/2059999

commit 5c7fd9dc92e1e7b9096b8def9e32a1bc90af92b6
Author: Miri Korenblit <miriam.rachel.korenblit@intel.com>
Date:   Sat Jan 29 13:16:22 2022 +0200

    iwlwifi: mvm: add support for CT-KILL notification version 2
    
    A new version was added to the CT-KILL notification API.
    Add support for it.
    
    In addition, print the two fields that was added in this version.
    
    Signed-off-by: Miri Korenblit <miriam.rachel.korenblit@intel.com>
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/iwlwifi.20220129105618.b79be7a134e9.I7f5c67d79dd97bf5170492aab356ec983622d3b2@changeid
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-05-31 14:50:49 +02:00
Íñigo Huguet 3f71268946 iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
Bugzilla: https://bugzilla.redhat.com/2059999

commit 971cbe50e6362a69fb2ef2d20eca1432624452cc
Author: Johannes Berg <johannes.berg@intel.com>
Date:   Fri Jan 28 15:34:25 2022 +0200

    iwlwifi: make iwl_fw_lookup_cmd_ver() take a cmd_id
    
    Instead of taking the group/command separately, make the function
    take a combined command ID. In many cases, this allows us to pass
    an existing command ID (e.g. cmd.id), or introduce a new variable
    for it, so that we don't use the command ID twice.
    
    This way, we can also use LONG_GROUP implicitly, so we don't need
    to spell that out for many commands.
    
    Apart from mvm.h, fw/img.{c,h} changes and some copyright and
    indentation updates, this was done with spatch:
    
        @@
        identifier cmd;
        expression fw, G, C, def;
        @@
         struct iwl_host_cmd cmd = {
          .id = WIDE_ID(G, C),
        ...
         };
        ...
        -iwl_fw_lookup_cmd_ver(fw, G, C, def)
        +iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
    
        @@
        identifier cmd;
        expression fw, C, def;
        @@
         struct iwl_host_cmd cmd = {
          .id = C,
        ...
         };
        ...
        -iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
        +iwl_fw_lookup_cmd_ver(fw, cmd.id, def)
    
        @@
        identifier func;
        expression fw, G, C, mvm, flags, cmd, size, def;
        type rettype;
        @@
        rettype func(...)
        {
        +u32 cmd_id = WIDE_ID(G, C);
        ...
        -iwl_fw_lookup_cmd_ver(fw, G, C, def)
        +iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
        ...
        -iwl_mvm_send_cmd_pdu(mvm, WIDE_ID(G, C), flags, cmd, size)
        +iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
        ...
        }
    
        @@
        identifier func;
        expression fw, G, C, mvm, flags, cmd, size, def;
        type rettype;
        @@
        rettype func(...)
        {
        +u32 cmd_id = C;
        ...
        -iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
        +iwl_fw_lookup_cmd_ver(fw, cmd_id, def)
        ...
        -iwl_mvm_send_cmd_pdu(mvm, C, flags, cmd, size)
        +iwl_mvm_send_cmd_pdu(mvm, cmd_id, flags, cmd, size)
        ...
        }
    
        @@
        expression fw, C, def;
        @@
        -iwl_fw_lookup_cmd_ver(fw, \(IWL_ALWAYS_LONG_GROUP\|LONG_GROUP\), C, def)
        +iwl_fw_lookup_cmd_ver(fw, C, def)
    
        @@
        expression fw, C, G, def;
        @@
        -iwl_fw_lookup_cmd_ver(fw, G, C, def)
        +iwl_fw_lookup_cmd_ver(fw, WIDE_ID(G, C), def)
    
    Signed-off-by: Johannes Berg <johannes.berg@intel.com>
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
    Link: https://lore.kernel.org/r/iwlwifi.20220128153014.c4ac213cef5c.I6fd9a4fcbcf16ef3a3ae20a2b08ee54ebe06f96f@changeid
    Signed-off-by: Luca Coelho <luciano.coelho@intel.com>

Signed-off-by: Íñigo Huguet <ihuguet@redhat.com>
2022-05-31 14:50:46 +02:00
Thara Gopinath 93effd83b6 iwlwifi: mvm: tt: Replace thermal_notify_framework
thermal_notify_framework just updates for a single trip point where as
thermal_zone_device_update does other bookkeeping like updating the
temperature of the thermal zone and setting the next trip point etc.
Replace thermal_notify_framework with thermal_zone_device_update as the
later is more thorough.

Acked-by: Kalle Valo <kvalo@codeaurora.org>
Signed-off-by: Thara Gopinath <thara.gopinath@linaro.org>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20210122023406.3500424-2-thara.gopinath@linaro.org
2021-04-22 13:11:35 +02:00
Golan Ben Ami c61734a69c iwlwifi: mvm: reduce the print severity of failing getting NIC temp
Currently, for all devices and families, failing getting the temp
from the fw is indicated in the log as ERR.
This is too severe for two reasons:
1. The driver has a fall back - and schedules the next temp
read immediately after failing to read temp from the fw.
2. The temp read implementation in the fw is different between
HWs, and on older devices the flow is a-sync and may timeout.

Reducing the print severity from ERR to WARN will allow to
track the issue if it will appear many times, but not frighten users
if it appears once.

Signed-off-by: Golan Ben Ami <golan.ben.ami@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210210172142.dfd423b2b2ef.Icd576dc3e2e7174d3ed9c1c32f48ea0013699e72@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-02-11 01:57:37 +02:00
Johannes Berg d8367b124c iwlwifi: mvm: make iwl_mvm_tt_temp_changed() static
This is only needed within tt.c, make it static.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210205110447.20a74526d395.Id24304ec1ae4b3096dbb8112bd146b364920e89e@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-02-05 11:56:45 +02:00
Johannes Berg afc857bc2a iwlwifi: mvm: add notification size checks
We shouldn't trust the firmware with the sizes (or contents)
of notifications, accessing too much data could cause page
faults if the data doesn't fit into the allocated space. This
applies more on older NICs where multiple notifications can
be in a single RX buffer.

Add a general framework for checking a minimum size of any
notification in the RX handlers and use it for most. Some RX
handlers were already checking and I've moved the checks,
some more complex checks I left and made them _NO_SIZE for
the RX handlers.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210117130510.3e155d5e5f90.I2121fa4ac7cd7eb98970d84b793796646afa3eed@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2021-02-05 11:52:24 +02:00
Johannes Berg 8e99ea8d09 iwlwifi: use SPDX tags
Use SPDX tags instead of the long copyright notices.  Also cleanup
some duplicate copyright notices and combine the years where possible.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20201210000603.481bcb512a6f.I8146abe5a637079e7336209f23cb26af98b12b31@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-12-10 00:15:31 +02:00
Nathan Errera f9084775de iwlwifi: mvm: prepare roc_done_wk to work sync
As part of changes made to properly support auxiliary activities in CDB
NICs, an aux sta will be added when using hot spot 2.0 and will need
to be removed when roc flow is done.
In order to do so, prepare the roc_done_wk to work synchronously as the
rm_aux_sta is a SYNC command.

Since now all of th iwl_mvm_flush_sta function are using it sync,
removed the flag argument from the function.

Signed-off-by: Nathan Errera <nathan.errera@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/iwlwifi.20201008180656.71b441c8b682.Ia1d216cb680308b91d6da9f73e23ae9f4baac79f@changeid
2020-10-08 20:09:35 +03:00
Nathan Errera be9ae34ead iwlwifi: mvm: get number of stations from TLV
FW is changing the max number of supported stations. To adapt to the
change we get the max number from the TLV and act according to the new
number.

Signed-off-by: Nathan Errera <nathan.errera@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
Link: https://lore.kernel.org/r/iwlwifi.20201008180656.863ab470babc.I393223392f36436663c4e66add03fefe77b74e60@changeid
2020-10-08 20:09:25 +03:00
Gil Adam 762c523f95 iwlwifi: thermal: support new temperature measurement API
New API for temperature measurement (DTS_MEASUREMENT_TRIGGER)
involves getting an immediate response from FW, and not waiting
for a notification like in previous APIs. Support new API while
keeping backwards compatibility.

Signed-off-by: Gil Adam <gil.adam@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20200930161256.b4893554d8e7.Ia4d7f389d4ac3256fcfe3ce6144e924dd6dbf6eb@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2020-10-01 22:01:00 +03:00
Andrzej Pietrasiewicz bbcf90c064 thermal: Explicitly enable non-changing thermal zone devices
Some thermal zone devices never change their state, so they should be
always enabled.

Signed-off-by: Andrzej Pietrasiewicz <andrzej.p@collabora.com>
Reviewed-by: Bartlomiej Zolnierkiewicz <b.zolnierkie@samsung.com>
Signed-off-by: Daniel Lezcano <daniel.lezcano@linaro.org>
Link: https://lore.kernel.org/r/20200629122925.21729-9-andrzej.p@collabora.com
2020-06-29 20:26:37 +02:00
Golan Ben Ami 6bd5fa332a iwlwifi: mvm: update the DTS measurement type
Till now, the driver asked the fw for a DTS measurement in automatic
mode. This triggered a flow in which the fw actively measured the
temperature.  This is not needed anymore, as the fw performs
measurements by itself, without the driver triggering them, and the
current cadence in which the fw performs such measurements is
sufficient.

In addition, in some time-sensitive scenarios, in which the driver asks
the fw for an active measurement twice in a short time (<100ms), the fw
asserts with code 0x20100801.

Change the DTS measurement to _WITHOUT_MEASURE instead, so the fw will
respond with the last measurement it has performed.

Signed-off-by: Golan Ben Ami <golan.ben.ami@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-02-03 20:09:10 +02:00
Andrei Otcheretianski baa6cf8450 iwlwifi: mvm: Fix thermal zone registration
Use a unique name when registering a thermal zone. Otherwise, with
multiple NICS, we hit the following warning during the unregistration.

WARNING: CPU: 2 PID: 3525 at fs/sysfs/group.c:255
 RIP: 0010:sysfs_remove_group+0x80/0x90
 Call Trace:
  dpm_sysfs_remove+0x57/0x60
  device_del+0x5a/0x350
  ? sscanf+0x4e/0x70
  device_unregister+0x1a/0x60
  hwmon_device_unregister+0x4a/0xa0
  thermal_remove_hwmon_sysfs+0x175/0x1d0
  thermal_zone_device_unregister+0x188/0x1e0
  iwl_mvm_thermal_exit+0xe7/0x100 [iwlmvm]
  iwl_op_mode_mvm_stop+0x27/0x180 [iwlmvm]
  _iwl_op_mode_stop.isra.3+0x2b/0x50 [iwlwifi]
  iwl_opmode_deregister+0x90/0xa0 [iwlwifi]
  __exit_compat+0x10/0x2c7 [iwlmvm]
  __x64_sys_delete_module+0x13f/0x270
  do_syscall_64+0x5a/0x110
  entry_SYSCALL_64_after_hwframe+0x44/0xa9

Signed-off-by: Andrei Otcheretianski <andrei.otcheretianski@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2020-02-03 20:09:08 +02:00
Mordechay Goodstein 220089c720 iwlwifi: mvm: start CTDP budget from 2400mA
The current budget of 2000mA is preventing us from reaching maximum
throughput.  According to our system engineers, we can increase the
maximum budget to 2400mA to solve this problem.

Signed-off-by: Mordechay Goodstein <mordechay.goodstein@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-11-15 09:34:29 +02:00
Johannes Berg 2d88b2cf2f iwlwifi: mvm: fix build w/o CONFIG_THERMAL
Without CONFIG_THERMAL, the driver fails to link as it calls
iwl_mvm_send_temp_report_ths_cmd() unconditionally. Fix this
by making that function available, but do almost nothing but
send the empty firmware command to enable CT-kill reporting.

While at it, also fix that function itself to not error out
when the thermal zone hasn't been initialized, but instead
just send the empty firmware command in this case as well.

Fixes: 242d9c8b9a ("iwlwifi: mvm: use FW thermal monitoring regardless of CONFIG_THERMAL")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2019-09-19 21:58:12 +03:00
Emmanuel Grumbach 58d3bef416 iwlwifi: remove all the d0i3 references
As part of the d0i3 removal.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2019-09-06 15:31:13 +03:00
Luca Coelho 754f890a3a iwlwifi: remove all occurrences of the FSF address paragraph
The Free Software Foundation address is superfluous and causes
checkpatch to issue a warning when present.  Remove all paragraphs
with FSF's address to prevent that.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2018-08-31 11:38:33 +03:00
Luca Coelho 1442a9a9f2 iwlwifi: mvm: return -ENODATA when reading the temperature with the FW down
It seems that libsensors treats -EIO as a special non-recoverable
failure when it tries to read the temperature while the firmware is
not running.  To solve that, change the error code to a milder
-ENODATA.

This fixes https://bugzilla.kernel.org/show_bug.cgi?id=196941

Fixes: c221daf219 ("iwlwifi: mvm: add registration to thermal zone")
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2017-10-06 13:59:44 +03:00
Luca Coelho d460f1fb83 iwlwifi: mvm: set status before calling iwl_mvm_send_cmd_status()
We always must set the status to what we consider success before
calling iwl_mvm_send_cmd_status() (also iwl_mvm_send_cmd_pdu_status()
which calls it).  Fix a few places where initialization is missing.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2017-09-08 11:50:30 +03:00
Chaya Rachel Ivgi 61d8c62646 iwlwifi: mvm: add debugfs to force CT-kill
CT-kill is a thermal-based "RF-kill", which disables the NIC
completely if the temperature gets too high, in order to avoid damage.

Add a debugfs entry to simulate high temperatures, in order to test
CT-kill flows in the driver without having to physically heat the
device up.

Signed-off-by: Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2017-08-09 09:30:15 +03:00
Bhumika Goyal b1a1efc576 iwlwifi: mvm: add const to thermal_cooling_device_ops structure
Declare thermal_cooling_device_ops structure as const as it is only passed
as an argument to the function thermal_cooling_device_register and this
argument is of type const. So, declare the structure as const.

Signed-off-by: Bhumika Goyal <bhumirks@gmail.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2017-08-09 09:15:32 +03:00
Johannes Berg 702e975d6a iwlwifi: track current firmware image in common code
Track the current firmware image in the common code instead
of in the opmode so that later patches can access it there
in a common way.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2017-08-01 12:41:43 +03:00
Kalle Valo 833689044e First batch of iwlwifi driver patches 4.13
* Loads of FW API documentation improvements (for tools and htmldoc);
 * Continued work for the new A000 family;
 * Bumped the maximum supported FW API to 31;
 * Improve the differentiation between 8000, 9000 and A000 families;
 * A lot of fixes and cleanups here and there;
 -----BEGIN PGP SIGNATURE-----
 
 iQIzBAABCAAdFiEEF3LNfgb2BPWm68smoUecoho8xfoFAlk3AR8ACgkQoUecoho8
 xfr21w//YzwKCVCR568wtQ0kZwLaPUos/FCeEgrFCpcAEe//wZZFZphH/z4mOLmX
 xXRYmqYaQuztfqUKO/7Onw2djuXQNJJtHp+AdCCnzyMLKz6F6YbBG+M3755nM2Wl
 XDVNbmRsmlGKvc2RCSoTSXSdNiT9TND9nYyzPFl/4x+fSD9olsjPvIVk1sNn2o69
 znrcPJZJWVeYB/1uqLTqOQ0Xdm9r4tEYnnI+VsRMlwsOBQp6kgPMHEjoZdrV3RGI
 qzgu0WNnAqqy1W2QOAi6iiU1jLm5VJ9CKyTT/m/4u9GypfUOm0mBKWuykB5klswH
 6lJWz/P4dK7WZg7udCySeQrXbwiIlH0HF8uUoabDJHJd7LUXvEAljsYzG9B/cU0g
 s4/2fA13eGDKf5vJULHQKLD4OJf82S7YhMiMM855pj/xVa1FZpupVACJ1cWik4n+
 MlK8scXllrrjuFG1C7VDq7Jj3uY1ZxIN+TtuUl5vzgJ4n7buqqOcetDN07XqIwGZ
 HLoA5uhdyr12mUDbtiicq9q/wu3bFD1CMDllINoBcmh7Psr1Vng0hhWsLJigvTUI
 5+fKOYMNznjrBmcVvI/ZgRVW1Zo7+XCEOQpu25zOmoP/5vIpc2yA7kDvUgDfyzhw
 3+KL+rw6IX3kfOWIuJTMq6iMtFIdRTc0K5zndC972maXUAE3wWY=
 =oYeO
 -----END PGP SIGNATURE-----

Merge tag 'iwlwifi-next-for-kalle-2017-06-06' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next

First batch of iwlwifi driver patches 4.13

* Loads of FW API documentation improvements (for tools and htmldoc);
* Continued work for the new A000 family;
* Bumped the maximum supported FW API to 31;
* Improve the differentiation between 8000, 9000 and A000 families;
* A lot of fixes and cleanups here and there;

kvalo: There were conflicts iwl_mvm_stop_device() and
iwl_mvm_tcool_set_cur_state(). The former was easy but latter needed more
thought. Apparently the mutex was taken too late, so I fixed so that the mutex
is taken first and then check for iwl_mvm_firmware_running().
2017-06-12 19:29:39 +03:00
Johannes Berg aab6930d30 iwlwifi: mvm: add and use iwl_mvm_device_running()
This will help refactor this later.

Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2017-06-05 23:34:26 +03:00
Liad Kaufman de8ba41b5e iwlwifi: mvm: support init flow debugging
In case an assert happens on init flow, the current
driver powers down the NIC, except if iwlmvm modparam
init_dbg=1, and only on very specific flows.

Extend this capability to cover most failure cases
by keeping track of what init configurations have been
completed. This way, we can allow NOT powering down
the NIC, while making sure that when the driver is
removed we don't try to free resources that haven't
been allocated. (This can result in a kernel panic.)

Signed-off-by: Liad Kaufman <liad.kaufman@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2017-06-05 23:29:32 +03:00
Johannes Berg d995440575 iwlwifi: tt: move ucode_loaded check under mutex
The ucode_loaded check should be under the mutex, since it can
otherwise change state after we looked at it and before we got
the mutex. Fix that.

Fixes: 5c89e7bc55 ("iwlwifi: mvm: add registration to cooling device")
Signed-off-by: Johannes Berg <johannes.berg@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2017-06-05 21:47:07 +03:00
Sara Sharon 0ae988125d iwlwifi: mvm: prepare for station count change
In a000 devices we will support up to 32 stations.
The max station define is used also for invalid station marking
which makes finding usages of actual maximum station pretty hard
to sort through - change it to be a different define in order
to make future changes easier.
Use also ARRAY_SIZE intead of define when possible.
Do not move yet to 32 stations until firmware do it though.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2017-04-19 22:20:51 +03:00
Jens Axboe 92549cdc28 iwlwifi: fix kernel crash when unregistering thermal zone
A recent firmware change seems to have enabled thermal zones on the
iwlwifi driver. Unfortunately, my device fails when registering the
thermal zone. This doesn't stop the driver from attempting to unregister
the thermal zone at unload time, triggering a NULL pointer deference in
strlen() off the thermal_zone_device_unregister() path.

Don't unregister if name is NULL, for that case we failed registering.
Do the same for the cooling zone.

Signed-off-by: Jens Axboe <axboe@fb.com>
Signed-off-by: Kalle Valo <kvalo@codeaurora.org>
2017-01-21 14:58:37 +02:00
Luca Coelho 4b87e5af63 iwlwifi: remove support for fw older than -17 and -22
FW versions older than -17 for 3160 and 7260 and older than -22 for
newer NICs are not supported anymore.  Don't load these versions
and remove code that handles them.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2016-09-26 23:15:14 +03:00
Sara Sharon 13303c0fb1 iwlwifi: mvm: use helpers to get iwl_mvm_sta
Getting the mvm station out of station id requires dereferencing
the station id to get ieee80211_sta, then checking for pointer
validity and only then extract mvm station out.
Given that there are helpers to do it - use them instead of
duplicating the code whenever we need only mvm station.

Signed-off-by: Sara Sharon <sara.sharon@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
2016-05-10 22:34:04 +03:00
Luca Coelho 489c546dce iwlwifi: mvm: allow setting the thermal state in D0i3
We were not allowing the thermal state to be set when we were in D0i3
mode.  It was not very clearly specified how it should work, but now a
decision was made to allow the state to be set in D0i3 (which will
cause a brief wake up).  Remove the check in the set_cur_state
operation.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
2016-03-30 16:24:51 +03:00
Chaya Rachel Ivgi 0df1391fee iwlwifi: mvm: remove uneeded D0I3 checking
The driver can read the current state during D0I3,
therefore there is no reason not to do it.

Signed-off-by: Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
2016-03-30 16:21:29 +03:00
Chaya Rachel Ivgi ec77a33ee5 iwlwifi: mvm: handle async temperature notification with unlocked mutex
Use RX_HANDLER_ASYNC_UNLOCKED instead of unlock and re-lock
the mutex independently.

Signed-off-by: Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
2016-03-30 16:21:20 +03:00
Chaya Rachel Ivgi b358993b3f iwlwifi: mvm: return the cooling state index instead of the budget
iwl_mvm_tcool_get_cur_state is the function that returns the
cooling state index to the sysfs handler. This function returns
mvm->cooling_dev.cur_state but that variable was set to the
budget and not the cooling state index. Fix that.
Add a missing blank line while at it.

Signed-off-by: Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
2016-03-09 21:05:13 +02:00
Chaya Rachel Ivgi 00f481bd89 iwlwifi: mvm: add ctdp operations to debugfs
Add debugfs entries to get the ctdp budget average
and to stop ctdp.

Signed-off-by: Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
2016-03-09 20:59:11 +02:00
Emmanuel Grumbach 91f66a3c67 iwlwifi: mvm: avoid panics with thermal device usage
Thermal zone device registration can fail, and in this case
we don't want to remove WiFi functionality. This is why the
thermal zone registration function is void, and the flows
continue even if the thermal zone device registration failed.
Same applies for the cooling device.

This means that we at least need to remember that the thermal
zone device didn't register properly and take the minimal
precautions to avoid panic'ing when we access it.

This was missing.

Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
2016-03-06 22:01:32 +02:00
Chaya Rachel Ivgi 5c89e7bc55 iwlwifi: mvm: add registration to cooling device
Register cooling device in order to have the Thermal
Manager handle the device's power budget according to the sent
notifications.
The interface adds a new thermal cooling device to
/sys/class/thermal/ folder.

Signed-off-by: Chaya Rachel Ivgi <chaya.rachel.ivgi@intel.com>
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Signed-off-by: Emmanuel Grumbach <emmanuel.grumbach@intel.com>
2016-02-27 21:59:50 +02:00