summaryrefslogtreecommitdiff
path: root/drivers/net/wireless
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/wireless')
-rw-r--r--drivers/net/wireless/realtek/rtw89/fw.c30
-rw-r--r--drivers/net/wireless/realtek/rtw89/fw.h15
2 files changed, 36 insertions, 9 deletions
diff --git a/drivers/net/wireless/realtek/rtw89/fw.c b/drivers/net/wireless/realtek/rtw89/fw.c
index 7e682709232d..f5daea0d4f93 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.c
+++ b/drivers/net/wireless/realtek/rtw89/fw.c
@@ -277,25 +277,37 @@ void rtw89_early_fw_feature_recognize(struct device *device,
const struct rtw89_chip_info *chip,
u32 *early_feat_map)
{
- union {
- struct rtw89_mfw_hdr mfw_hdr;
- u8 fw_hdr[RTW89_FW_HDR_SIZE];
- } buf = {};
+ union rtw89_compat_fw_hdr buf = {};
const struct firmware *firmware;
+ bool full_req = false;
u32 ver_code;
int ret;
int i;
- ret = request_partial_firmware_into_buf(&firmware, chip->fw_name,
- device, &buf, sizeof(buf), 0);
+ /* If SECURITY_LOADPIN_ENFORCE is enabled, reading partial files will
+ * be denied (-EPERM). Then, we don't get right firmware things as
+ * expected. So, in this case, we have to request full firmware here.
+ */
+ if (IS_ENABLED(CONFIG_SECURITY_LOADPIN_ENFORCE))
+ full_req = true;
+
+ if (full_req)
+ ret = request_firmware(&firmware, chip->fw_name, device);
+ else
+ ret = request_partial_firmware_into_buf(&firmware, chip->fw_name,
+ device, &buf, sizeof(buf),
+ 0);
+
if (ret) {
dev_err(device, "failed to early request firmware: %d\n", ret);
return;
}
- ver_code = buf.mfw_hdr.sig != RTW89_MFW_SIG ?
- RTW89_FW_HDR_VER_CODE(&buf.fw_hdr) :
- RTW89_MFW_HDR_VER_CODE(&buf.mfw_hdr);
+ if (full_req)
+ ver_code = rtw89_compat_fw_hdr_ver_code(firmware->data);
+ else
+ ver_code = rtw89_compat_fw_hdr_ver_code(&buf);
+
if (!ver_code)
goto out;
diff --git a/drivers/net/wireless/realtek/rtw89/fw.h b/drivers/net/wireless/realtek/rtw89/fw.h
index 46d57414f24e..5c4c7de1b4f5 100644
--- a/drivers/net/wireless/realtek/rtw89/fw.h
+++ b/drivers/net/wireless/realtek/rtw89/fw.h
@@ -3291,6 +3291,21 @@ struct fwcmd_hdr {
__le32 hdr1;
};
+union rtw89_compat_fw_hdr {
+ struct rtw89_mfw_hdr mfw_hdr;
+ u8 fw_hdr[RTW89_FW_HDR_SIZE];
+};
+
+static inline u32 rtw89_compat_fw_hdr_ver_code(const void *fw_buf)
+{
+ const union rtw89_compat_fw_hdr *compat = (typeof(compat))fw_buf;
+
+ if (compat->mfw_hdr.sig == RTW89_MFW_SIG)
+ return RTW89_MFW_HDR_VER_CODE(&compat->mfw_hdr);
+ else
+ return RTW89_FW_HDR_VER_CODE(&compat->fw_hdr);
+}
+
#define RTW89_H2C_RF_PAGE_SIZE 500
#define RTW89_H2C_RF_PAGE_NUM 3
struct rtw89_fw_h2c_rf_reg_info {