iwlwifi: acpi: support reading and storing WGDS revision 2
authorLuca Coelho <luciano.coelho@intel.com>
Thu, 5 Aug 2021 11:21:58 +0000 (14:21 +0300)
committerLuca Coelho <luciano.coelho@intel.com>
Thu, 26 Aug 2021 20:36:10 +0000 (23:36 +0300)
Revisions 0 and 1 are identical, so we were already supporting that.
But revision 2 has a different size, so we have to try to read them
separately.

Add support for this new revision.

Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
Link: https://lore.kernel.org/r/iwlwifi.20210805141826.78e441b16f9c.I2d79492f05624ddd02c533c673811a36eaf8a396@changeid
Signed-off-by: Luca Coelho <luciano.coelho@intel.com>
drivers/net/wireless/intel/iwlwifi/fw/acpi.c
drivers/net/wireless/intel/iwlwifi/fw/acpi.h

index 1802a45..de1e927 100644 (file)
@@ -703,27 +703,49 @@ int iwl_sar_get_wgds_table(struct iwl_fw_runtime *fwrt)
        union acpi_object *wifi_pkg, *data;
        int i, j, k, ret, tbl_rev;
        int idx = 1; /* start from one to skip the domain */
+       u8 num_bands;
 
        data = iwl_acpi_get_object(fwrt->dev, ACPI_WGDS_METHOD);
        if (IS_ERR(data))
                return PTR_ERR(data);
 
+       /* start by trying to read revision 2 */
        wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
-                                        ACPI_WGDS_WIFI_DATA_SIZE, &tbl_rev);
+                                        ACPI_WGDS_WIFI_DATA_SIZE_REV2,
+                                        &tbl_rev);
+       if (!IS_ERR(wifi_pkg)) {
+               if (tbl_rev != 2) {
+                       ret = PTR_ERR(wifi_pkg);
+                       goto out_free;
+               }
 
-       if (IS_ERR(wifi_pkg)) {
-               ret = PTR_ERR(wifi_pkg);
-               goto out_free;
+               num_bands = ACPI_GEO_NUM_BANDS_REV2;
+
+               goto read_table;
        }
 
-       if (tbl_rev > 1) {
-               ret = -EINVAL;
-               goto out_free;
+       /* then try revision 0 (which is the same as 1) */
+       wifi_pkg = iwl_acpi_get_wifi_pkg(fwrt->dev, data,
+                                        ACPI_WGDS_WIFI_DATA_SIZE_REV0,
+                                        &tbl_rev);
+       if (!IS_ERR(wifi_pkg)) {
+               if (tbl_rev != 0 && tbl_rev != 1) {
+                       ret = PTR_ERR(wifi_pkg);
+                       goto out_free;
+               }
+
+               num_bands = ACPI_GEO_NUM_BANDS_REV0;
+
+               goto read_table;
        }
 
+       ret = PTR_ERR(wifi_pkg);
+       goto out_free;
+
+read_table:
        fwrt->geo_rev = tbl_rev;
        for (i = 0; i < ACPI_NUM_GEO_PROFILES; i++) {
-               for (j = 0; j < ACPI_GEO_NUM_BANDS_REV0; j++) {
+               for (j = 0; j < num_bands; j++) {
                        union acpi_object *entry;
 
                        entry = &wifi_pkg->package.elements[idx++];
index a424186..16ed099 100644 (file)
 #define ACPI_SAR_NUM_SUB_BANDS_REV1    11
 #define ACPI_SAR_NUM_SUB_BANDS_REV2    11
 
-#define ACPI_GEO_NUM_CHAINS            2
-#define ACPI_GEO_NUM_BANDS_REV0                2
-#define ACPI_GEO_NUM_BANDS_REV1                2
-#define ACPI_GEO_NUM_BANDS_REV2                3
-
 #define ACPI_WRDS_WIFI_DATA_SIZE_REV0  (ACPI_SAR_NUM_CHAINS_REV0 * \
                                         ACPI_SAR_NUM_SUB_BANDS_REV0 + 2)
 #define ACPI_WRDS_WIFI_DATA_SIZE_REV1  (ACPI_SAR_NUM_CHAINS_REV1 * \
 #define ACPI_EWRD_WIFI_DATA_SIZE_REV2  ((ACPI_SAR_PROFILE_NUM - 1) * \
                                         ACPI_SAR_NUM_CHAINS_REV2 * \
                                         ACPI_SAR_NUM_SUB_BANDS_REV2 + 3)
-#define ACPI_WGDS_WIFI_DATA_SIZE       19
+
+/* revision 0 and 1 are identical, except for the semantics in the FW */
+#define ACPI_GEO_NUM_BANDS_REV0                2
+#define ACPI_GEO_NUM_BANDS_REV2                3
+#define ACPI_GEO_NUM_CHAINS            2
+
+#define ACPI_WGDS_WIFI_DATA_SIZE_REV0  (ACPI_NUM_GEO_PROFILES *   \
+                                        ACPI_GEO_NUM_BANDS_REV0 * \
+                                        ACPI_GEO_PER_CHAIN_SIZE + 1)
+#define ACPI_WGDS_WIFI_DATA_SIZE_REV2  (ACPI_NUM_GEO_PROFILES *   \
+                                        ACPI_GEO_NUM_BANDS_REV2 * \
+                                        ACPI_GEO_PER_CHAIN_SIZE + 1)
+
 #define ACPI_WRDD_WIFI_DATA_SIZE       2
 #define ACPI_SPLC_WIFI_DATA_SIZE       2
 #define ACPI_ECKV_WIFI_DATA_SIZE       2