Commit 3b03fc9a authored by Kalle Valo's avatar Kalle Valo
Browse files

Merge tag 'iwlwifi-next-for-kalle-2022-03-10' of...

Merge tag 'iwlwifi-next-for-kalle-2022-03-10' of git://git.kernel.org/pub/scm/linux/kernel/git/iwlwifi/iwlwifi-next

iwlwifi patches for v5.18

* Mostly debugging infra changes;
* Some more work on the Bz family of devices;
* Bump the FW API twice;
* Some other small fixes, clean-ups and improvements.
parents ea372064 8594ab86
Loading
Loading
Loading
Loading
+17 −2
Original line number Diff line number Diff line
// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
/*
 * Copyright (C) 2015-2017 Intel Deutschland GmbH
 * Copyright (C) 2018-2021 Intel Corporation
 * Copyright (C) 2018-2022 Intel Corporation
 */
#include <linux/module.h>
#include <linux/stringify.h>
@@ -10,7 +10,7 @@
#include "fw/api/txq.h"

/* Highest firmware API version supported */
#define IWL_22000_UCODE_API_MAX	70
#define IWL_22000_UCODE_API_MAX	72

/* Lowest firmware API version supported */
#define IWL_22000_UCODE_API_MIN	39
@@ -391,6 +391,21 @@ const struct iwl_cfg_trans_params iwl_so_long_latency_trans_cfg = {
	.ltr_delay = IWL_CFG_TRANS_LTR_DELAY_2500US,
};

const struct iwl_cfg_trans_params iwl_so_long_latency_imr_trans_cfg = {
	.mq_rx_supported = true,
	.use_tfh = true,
	.rf_id = true,
	.gen2 = true,
	.device_family = IWL_DEVICE_FAMILY_AX210,
	.base_params = &iwl_ax210_base_params,
	.umac_prph_offset = 0x300000,
	.integrated = true,
	.low_latency_xtal = true,
	.xtal_latency = 12000,
	.ltr_delay = IWL_CFG_TRANS_LTR_DELAY_2500US,
	.imr_enabled = true,
};

/*
 * If the device doesn't support HE, no need to have that many buffers.
 * 22000 devices can split multiple frames into a single RB, so fewer are
+208 −3
Original line number Diff line number Diff line
@@ -4,6 +4,7 @@
 * Copyright (C) 2019-2021 Intel Corporation
 */
#include <linux/uuid.h>
#include <linux/dmi.h>
#include "iwl-drv.h"
#include "iwl-debug.h"
#include "acpi.h"
@@ -19,6 +20,30 @@ const guid_t iwl_rfi_guid = GUID_INIT(0x7266172C, 0x220B, 0x4B29,
				      0xDD, 0x26, 0xB5, 0xFD);
IWL_EXPORT_SYMBOL(iwl_rfi_guid);

static const struct dmi_system_id dmi_ppag_approved_list[] = {
	{ .ident = "HP",
	  .matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "HP"),
		},
	},
	{ .ident = "SAMSUNG",
	  .matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "SAMSUNG ELECTRONICS CO., LTD"),
		},
	},
	{ .ident = "MSFT",
	  .matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "Microsoft Corporation"),
		},
	},
	{ .ident = "ASUS",
	  .matches = {
			DMI_MATCH(DMI_SYS_VENDOR, "ASUSTek COMPUTER INC."),
		},
	},
	{}
};

static int iwl_acpi_get_handle(struct device *dev, acpi_string method,
			       acpi_handle *ret_handle)
{
@@ -537,8 +562,8 @@ IWL_EXPORT_SYMBOL(iwl_sar_select_profile);
int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt)
{
	union acpi_object *wifi_pkg, *table, *data;
	bool enabled;
	int ret, tbl_rev;
	u32 flags;
	u8 num_chains, num_sub_bands;

	data = iwl_acpi_get_object(fwrt->dev, ACPI_WRDS_METHOD);
@@ -604,7 +629,8 @@ int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt)

	IWL_DEBUG_RADIO(fwrt, "Reading WRDS tbl_rev=%d\n", tbl_rev);

	enabled = !!(wifi_pkg->package.elements[1].integer.value);
	flags = wifi_pkg->package.elements[1].integer.value;
	fwrt->reduced_power_flags = flags >> IWL_REDUCE_POWER_FLAGS_POS;

	/* position of the actual table */
	table = &wifi_pkg->package.elements[2];
@@ -612,7 +638,8 @@ int iwl_sar_get_wrds_table(struct iwl_fw_runtime *fwrt)
	/* The profile from WRDS is officially profile 1, but goes
	 * into sar_profiles[0] (because we don't have a profile 0).
	 */
	ret = iwl_sar_set_profile(table, &fwrt->sar_profiles[0], enabled,
	ret = iwl_sar_set_profile(table, &fwrt->sar_profiles[0],
				  flags & IWL_SAR_ENABLE_MSK,
				  num_chains, num_sub_bands);
out_free:
	kfree(data);
@@ -969,3 +996,181 @@ __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt)
	return config_bitmap;
}
IWL_EXPORT_SYMBOL(iwl_acpi_get_lari_config_bitmap);

int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt)
{
	union acpi_object *wifi_pkg, *data, *flags;
	int i, j, ret, tbl_rev, num_sub_bands = 0;
	int idx = 2;

	fwrt->ppag_flags = 0;

	data = iwl_acpi_get_object(fwrt->dev, ACPI_PPAG_METHOD);
	if (IS_ERR(data))
		return PTR_ERR(data);

	/* try to read ppag table rev 2 or 1 (both have the same data size) */
	wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
				ACPI_PPAG_WIFI_DATA_SIZE_V2, &tbl_rev);

	if (!IS_ERR(wifi_pkg)) {
		if (tbl_rev == 1 || tbl_rev == 2) {
			num_sub_bands = IWL_NUM_SUB_BANDS_V2;
			IWL_DEBUG_RADIO(fwrt,
					"Reading PPAG table v2 (tbl_rev=%d)\n",
					tbl_rev);
			goto read_table;
		} else {
			ret = -EINVAL;
			goto out_free;
		}
	}

	/* try to read ppag table revision 0 */
	wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
			ACPI_PPAG_WIFI_DATA_SIZE_V1, &tbl_rev);

	if (!IS_ERR(wifi_pkg)) {
		if (tbl_rev != 0) {
			ret = -EINVAL;
			goto out_free;
		}
		num_sub_bands = IWL_NUM_SUB_BANDS_V1;
		IWL_DEBUG_RADIO(fwrt, "Reading PPAG table v1 (tbl_rev=0)\n");
		goto read_table;
	}

read_table:
	fwrt->ppag_ver = tbl_rev;
	flags = &wifi_pkg->package.elements[1];

	if (flags->type != ACPI_TYPE_INTEGER) {
		ret = -EINVAL;
		goto out_free;
	}

	fwrt->ppag_flags = flags->integer.value & ACPI_PPAG_MASK;

	if (!fwrt->ppag_flags) {
		ret = 0;
		goto out_free;
	}

	/*
	 * read, verify gain values and save them into the PPAG table.
	 * first sub-band (j=0) corresponds to Low-Band (2.4GHz), and the
	 * following sub-bands to High-Band (5GHz).
	 */
	for (i = 0; i < IWL_NUM_CHAIN_LIMITS; i++) {
		for (j = 0; j < num_sub_bands; j++) {
			union acpi_object *ent;

			ent = &wifi_pkg->package.elements[idx++];
			if (ent->type != ACPI_TYPE_INTEGER) {
				ret = -EINVAL;
				goto out_free;
			}

			fwrt->ppag_chains[i].subbands[j] = ent->integer.value;

			if ((j == 0 &&
				(fwrt->ppag_chains[i].subbands[j] > ACPI_PPAG_MAX_LB ||
				 fwrt->ppag_chains[i].subbands[j] < ACPI_PPAG_MIN_LB)) ||
				(j != 0 &&
				(fwrt->ppag_chains[i].subbands[j] > ACPI_PPAG_MAX_HB ||
				fwrt->ppag_chains[i].subbands[j] < ACPI_PPAG_MIN_HB))) {
					fwrt->ppag_flags = 0;
					ret = -EINVAL;
					goto out_free;
				}
		}
	}


	ret = 0;

out_free:
	kfree(data);
	return ret;
}
IWL_EXPORT_SYMBOL(iwl_acpi_get_ppag_table);

int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt, union iwl_ppag_table_cmd *cmd,
			int *cmd_size)
{
        u8 cmd_ver;
        int i, j, num_sub_bands;
        s8 *gain;

        if (!fw_has_capa(&fwrt->fw->ucode_capa, IWL_UCODE_TLV_CAPA_SET_PPAG)) {
                IWL_DEBUG_RADIO(fwrt,
                                "PPAG capability not supported by FW, command not sent.\n");
                return -EINVAL;
        }
        if (!fwrt->ppag_flags) {
                IWL_DEBUG_RADIO(fwrt, "PPAG not enabled, command not sent.\n");
                return -EINVAL;
        }

        /* The 'flags' field is the same in v1 and in v2 so we can just
         * use v1 to access it.
         */
        cmd->v1.flags = cpu_to_le32(fwrt->ppag_flags);
        cmd_ver = iwl_fw_lookup_cmd_ver(fwrt->fw,
                                        WIDE_ID(PHY_OPS_GROUP, PER_PLATFORM_ANT_GAIN_CMD),
                                        IWL_FW_CMD_VER_UNKNOWN);
	if (cmd_ver == 1) {
                num_sub_bands = IWL_NUM_SUB_BANDS_V1;
                gain = cmd->v1.gain[0];
                *cmd_size = sizeof(cmd->v1);
                if (fwrt->ppag_ver == 1 || fwrt->ppag_ver == 2) {
                        IWL_DEBUG_RADIO(fwrt,
                                        "PPAG table rev is %d but FW supports v1, sending truncated table\n",
                                        fwrt->ppag_ver);
                        cmd->v1.flags &= cpu_to_le32(IWL_PPAG_ETSI_MASK);
		}
	} else if (cmd_ver == 2 || cmd_ver == 3) {
                num_sub_bands = IWL_NUM_SUB_BANDS_V2;
                gain = cmd->v2.gain[0];
                *cmd_size = sizeof(cmd->v2);
                if (fwrt->ppag_ver == 0) {
                        IWL_DEBUG_RADIO(fwrt,
                                        "PPAG table is v1 but FW supports v2, sending padded table\n");
                } else if (cmd_ver == 2 && fwrt->ppag_ver == 2) {
                        IWL_DEBUG_RADIO(fwrt,
                                        "PPAG table is v3 but FW supports v2, sending partial bitmap.\n");
                        cmd->v1.flags &= cpu_to_le32(IWL_PPAG_ETSI_MASK);
                }
        } else {
                IWL_DEBUG_RADIO(fwrt, "Unsupported PPAG command version\n");
                return -EINVAL;
        }

	for (i = 0; i < IWL_NUM_CHAIN_LIMITS; i++) {
                for (j = 0; j < num_sub_bands; j++) {
                        gain[i * num_sub_bands + j] =
                                fwrt->ppag_chains[i].subbands[j];
                        IWL_DEBUG_RADIO(fwrt,
                                        "PPAG table: chain[%d] band[%d]: gain = %d\n",
                                        i, j, gain[i * num_sub_bands + j]);
                }
        }

	return 0;
}
IWL_EXPORT_SYMBOL(iwl_read_ppag_table);

bool iwl_acpi_is_ppag_approved(struct iwl_fw_runtime *fwrt)
{

	if (!dmi_check_system(dmi_ppag_approved_list)) {
		IWL_DEBUG_RADIO(fwrt,
			"System vendor '%s' is not in the approved list, disabling PPAG.\n",
			dmi_get_system_info(DMI_SYS_VENDOR));
			fwrt->ppag_flags = 0;
			return false;
	}

	return true;
}
IWL_EXPORT_SYMBOL(iwl_acpi_is_ppag_approved);
+28 −0
Original line number Diff line number Diff line
@@ -91,6 +91,11 @@
#define ACPI_PPAG_MAX_LB 24
#define ACPI_PPAG_MIN_HB -16
#define ACPI_PPAG_MAX_HB 40
#define ACPI_PPAG_MASK 3
#define IWL_PPAG_ETSI_MASK BIT(0)

#define IWL_SAR_ENABLE_MSK		BIT(0)
#define IWL_REDUCE_POWER_FLAGS_POS	1

/*
 * The profile for revision 2 is a superset of revision 1, which is in
@@ -220,6 +225,13 @@ int iwl_acpi_get_tas(struct iwl_fw_runtime *fwrt,

__le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt);

int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt);

int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt, union iwl_ppag_table_cmd *cmd,
			int *cmd_size);

bool iwl_acpi_is_ppag_approved(struct iwl_fw_runtime *fwrt);

#else /* CONFIG_ACPI */

static inline void *iwl_acpi_get_object(struct device *dev, acpi_string method)
@@ -307,6 +319,22 @@ static inline __le32 iwl_acpi_get_lari_config_bitmap(struct iwl_fw_runtime *fwrt
	return 0;
}

static inline int iwl_acpi_get_ppag_table(struct iwl_fw_runtime *fwrt)
{
	return -ENOENT;
}

static inline int iwl_read_ppag_table(struct iwl_fw_runtime *fwrt,
				    union iwl_ppag_table_cmd *cmd, int *cmd_size)
{
	return -ENOENT;
}

static inline bool iwl_acpi_is_ppag_approved(struct iwl_fw_runtime *fwrt)
{
	return false;
}

#endif /* CONFIG_ACPI */

static inline union acpi_object *
+25 −2
Original line number Diff line number Diff line
/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */
/*
 * Copyright (C) 2012-2014, 2018-2021 Intel Corporation
 * Copyright (C) 2012-2014, 2018-2022 Intel Corporation
 * Copyright (C) 2013-2014 Intel Mobile Communications GmbH
 * Copyright (C) 2015-2017 Intel Deutschland GmbH
 */
@@ -340,7 +340,7 @@ struct iwl_dev_tx_power_cmd_v5 {
} __packed; /* TX_REDUCED_POWER_API_S_VER_5 */

/**
 * struct iwl_dev_tx_power_cmd_v5 - TX power reduction command version 5
 * struct iwl_dev_tx_power_cmd_v6 - TX power reduction command version 6
 * @per_chain: per chain restrictions
 * @enable_ack_reduction: enable or disable close range ack TX power
 *	reduction.
@@ -360,6 +360,28 @@ struct iwl_dev_tx_power_cmd_v6 {
	__le32 timer_period;
} __packed; /* TX_REDUCED_POWER_API_S_VER_6 */

/**
 * struct iwl_dev_tx_power_cmd_v7 - TX power reduction command version 7
 * @per_chain: per chain restrictions
 * @enable_ack_reduction: enable or disable close range ack TX power
 *	reduction.
 * @per_chain_restriction_changed: is per_chain_restriction has changed
 *	from last command. used if set_mode is
 *	IWL_TX_POWER_MODE_SET_SAR_TIMER.
 *	note: if not changed, the command is used for keep alive only.
 * @reserved: reserved (padding)
 * @timer_period: timer in milliseconds. if expires FW will change to default
 *	BIOS values. relevant if setMode is IWL_TX_POWER_MODE_SET_SAR_TIMER
 * @flags: reduce power flags.
 */
struct iwl_dev_tx_power_cmd_v7 {
	__le16 per_chain[IWL_NUM_CHAIN_TABLES_V2][IWL_NUM_CHAIN_LIMITS][IWL_NUM_SUB_BANDS_V2];
	u8 enable_ack_reduction;
	u8 per_chain_restriction_changed;
	u8 reserved[2];
	__le32 timer_period;
	__le32 flags;
} __packed; /* TX_REDUCED_POWER_API_S_VER_7 */
/**
 * struct iwl_dev_tx_power_cmd - TX power reduction command (multiversion)
 * @common: common part of the command
@@ -375,6 +397,7 @@ struct iwl_dev_tx_power_cmd {
		struct iwl_dev_tx_power_cmd_v4 v4;
		struct iwl_dev_tx_power_cmd_v5 v5;
		struct iwl_dev_tx_power_cmd_v6 v6;
		struct iwl_dev_tx_power_cmd_v7 v7;
	};
};

+32 −2
Original line number Diff line number Diff line
@@ -2430,6 +2430,9 @@ static u32 iwl_dump_ini_trigger(struct iwl_fw_runtime *fwrt,
	struct iwl_dump_ini_region_data reg_data = {
		.dump_data = dump_data,
	};
	struct iwl_dump_ini_region_data imr_reg_data = {
		.dump_data = dump_data,
	};
	int i;
	u32 size = 0;
	u64 regions_mask = le64_to_cpu(trigger->regions_mask) &
@@ -2465,10 +2468,32 @@ static u32 iwl_dump_ini_trigger(struct iwl_fw_runtime *fwrt,
				 tp_id);
			continue;
		}
		/*
		 * DRAM_IMR can be collected only for FW/HW error timepoint
		 * when fw is not alive. In addition, it must be collected
		 * lastly as it overwrites SRAM that can possibly contain
		 * debug data which also need to be collected.
		 */
		if (reg_type == IWL_FW_INI_REGION_DRAM_IMR) {
			if (tp_id == IWL_FW_INI_TIME_POINT_FW_ASSERT ||
			    tp_id == IWL_FW_INI_TIME_POINT_FW_HW_ERROR)
				imr_reg_data.reg_tlv = fwrt->trans->dbg.active_regions[i];
			else
				IWL_INFO(fwrt,
					 "WRT: trying to collect DRAM_IMR at time point: %d, skipping\n",
					 tp_id);
		/* continue to next region */
			continue;
		}


		size += iwl_dump_ini_mem(fwrt, list, &reg_data,
					 &iwl_dump_ini_region_ops[reg_type]);
	}
	/* collect DRAM_IMR region in the last */
	if (imr_reg_data.reg_tlv)
		size += iwl_dump_ini_mem(fwrt, list, &reg_data,
					 &iwl_dump_ini_region_ops[IWL_FW_INI_REGION_DRAM_IMR]);

	if (size)
		size += iwl_dump_ini_info(fwrt, trigger, list);
@@ -2880,6 +2905,11 @@ static void iwl_fw_dbg_collect_sync(struct iwl_fw_runtime *fwrt, u8 wk_idx)
	if (!test_bit(wk_idx, &fwrt->dump.active_wks))
		return;

	if (!dump_data->trig) {
		IWL_ERR(fwrt, "dump trigger data is not set\n");
		goto out;
	}

	if (!test_bit(STATUS_DEVICE_ENABLED, &fwrt->trans->status)) {
		IWL_ERR(fwrt, "Device is not enabled - cannot dump error\n");
		goto out;
@@ -2967,10 +2997,10 @@ int iwl_fw_dbg_ini_collect(struct iwl_fw_runtime *fwrt,
		 "WRT: Collecting data: ini trigger %d fired (delay=%dms).\n",
		 tp_id, (u32)(delay / USEC_PER_MSEC));

	schedule_delayed_work(&fwrt->dump.wks[idx].wk, usecs_to_jiffies(delay));

	if (sync)
		iwl_fw_dbg_collect_sync(fwrt, idx);
	else
		schedule_delayed_work(&fwrt->dump.wks[idx].wk, usecs_to_jiffies(delay));

	return 0;
}
Loading