mei: bus: add client dma interface
Subsystems (3)
PATCH RESEND 1/3 mei: bus: add client dma interface
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface. The client dma has to be mapped before the device is enabled, therefore we need to create device linking already during mapping and we need to unmap after the client is disable hence we need to postpone the unlink and flush till unmapping or when destroying the device.
---
This is a another version of the patch:
https://lore.kernel.org/lkml/[email protected]/
Greg asked to route this patch through the wireless drivers tree:
https://lore.kernel.org/lkml/[email protected]/
So here it is.
---
drivers/misc/mei/bus.c | 67 ++++++++++++++++++++++++++++++++++++-- drivers/misc/mei/client.c | 3 ++ drivers/misc/mei/hw.h | 5 +++ include/linux/mei_cl_bus.h | 3 ++ 4 files changed, 75 insertions(+), 3 deletions(-)
drivers/misc/mei/bus.c +64 -3
@@ -643,6 +643,64 @@ static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev)kfree (cl_vtag); } +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 buffer_id,size_t size) +{ +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev || !buffer_id || !size) +return ERR_PTR (-EINVAL ); + +if (!IS_ALIGNED (size,MEI_FW_PAGE_SIZE )) { +dev_err (&cldev->dev,"Map size should be aligned to %lu\n" , +MEI_FW_PAGE_SIZE ); +return ERR_PTR (-EINVAL ); + } + + cl = cldev->cl; + bus = cldev->bus; + +mutex_lock (&bus->device_lock); +if (cl->state ==MEI_FILE_UNINITIALIZED ) { + ret =mei_cl_link (cl); +if (ret) + goto out; +/* update pointers */ + cl->cldev = cldev; + } + + ret =mei_cl_dma_alloc_and_map (cl,NULL , buffer_id, size); +out: +mutex_unlock (&bus->device_lock); +if (ret) +return ERR_PTR (ret); +return cl->dma.vaddr; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_map); + +int mei_cldev_dma_unmap (struct mei_cl_device *cldev) +{ +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev) +return -EINVAL ; + + cl = cldev->cl; + bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_unmap (cl,NULL ); + +mei_cl_flush_queues (cl,NULL ); +mei_cl_unlink (cl); +mutex_unlock (&bus->device_lock); +return ret; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_unmap); +/** * mei_cldev_enable - enable me client device * create connection with me client
@@ -753,9 +811,11 @@ int mei_cldev_disable(struct mei_cl_device *cldev)dev_err (bus->dev,"Could not disconnect from the ME client\n" ); out: -/* Flush queues and remove any pending read */ -mei_cl_flush_queues (cl,NULL ); -mei_cl_unlink (cl); +/* Flush queues and remove any pending read unless we have mapped DMA */ +if (!cl->dma_mapped) { +mei_cl_flush_queues (cl,NULL ); +mei_cl_unlink (cl); + }mutex_unlock (&bus->device_lock);return err;
@@ -1054,6 +1114,7 @@ static void mei_cl_bus_dev_release(struct device *dev)if (!cldev)return ; +mei_cl_flush_queues (cldev->cl,NULL );mei_me_cl_put (cldev->me_cl);mei_dev_bus_put (cldev->bus);mei_cl_unlink (cldev->cl);
drivers/misc/mei/client.c +3 -0
@@ -700,6 +700,9 @@ int mei_cl_unlink(struct mei_cl *cl)cl_dbg (dev, cl,"unlink client" ); +if (cl->state ==MEI_FILE_UNINITIALIZED ) +return 0 ; +if (dev->open_handle_count >0 ) dev->open_handle_count--;
drivers/misc/mei/hw.h +5 -0
@@ -22,6 +22,11 @@#define MEI_D0I3_TIMEOUT 5/* D0i3 set/unset max response time */ #define MEI_HBM_TIMEOUT 1/* 1 second */ +/* +* FW page size for DMA allocations +*/ +#define MEI_FW_PAGE_SIZE 4096UL +/* * MEI Version */
include/linux/mei_cl_bus.h +3 -0
@@ -116,4 +116,7 @@ int mei_cldev_enable(struct mei_cl_device *cldev);int mei_cldev_disable (struct mei_cl_device *cldev);bool mei_cldev_enabled (struct mei_cl_device *cldev); +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 buffer_id,size_t size); +int mei_cldev_dma_unmap (struct mei_cl_device *cldev); +#endif /* _LINUX_MEI_CL_BUS_H */
Signature · 1 line
2.25.1
PATCH RESEND 2/3 iwlwifi: mei: add the driver to allow cooperation with CSME
iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.
--- drivers/net/wireless/intel/iwlwifi/Kconfig | 13 + drivers/net/wireless/intel/iwlwifi/Makefile | 2 + .../net/wireless/intel/iwlwifi/mei/Makefile | 8 + .../net/wireless/intel/iwlwifi/mei/internal.h | 20 + .../net/wireless/intel/iwlwifi/mei/iwl-mei.h | 440 ++++ drivers/net/wireless/intel/iwlwifi/mei/main.c | 2026 +++++++++++++++++ drivers/net/wireless/intel/iwlwifi/mei/net.c | 409 ++++ drivers/net/wireless/intel/iwlwifi/mei/sap.h | 736 ++++++ .../wireless/intel/iwlwifi/mei/trace-data.h | 69 + .../net/wireless/intel/iwlwifi/mei/trace.c | 15 + .../net/wireless/intel/iwlwifi/mei/trace.h | 62 + 11 files changed, 3800 insertions(+) create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/Makefile create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/internal.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/main.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/net.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/sap.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace-data.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.h
drivers/net/wireless/intel/iwlwifi/Kconfig +13 -0
@@ -92,6 +92,19 @@ config IWLWIFI_BCAST_FILTERING If unsure, don't enable this option, as some programs might expect incoming broadcasts for their normal operations. +config IWLMEI + tristate "Enable V-PRO for WLAN" + depends on INTEL_MEI + depends on IWLMVM + help + Enable V-PRO. This allows to communicate with the CSME firmware. + This is supported starting from Tiger Lake platforms and has been + tested on 9260 devices only. Enabling this option on a platform that + has a different device and has Wireless enabled on AMT can prevent + WiFi from working correctly. + + If unsure, say N. + menu "Debugging Options" config IWLWIFI_DEBUG
drivers/net/wireless/intel/iwlwifi/Makefile +2 -0
@@ -30,4 +30,6 @@ ccflags-y += -I$(src) obj-$(CONFIG_IWLDVM) += dvm/ obj-$(CONFIG_IWLMVM) += mvm/ +obj-$(CONFIG_IWLMEI) += mei/ + CFLAGS_iwl-devtrace.o := -I$(src)
drivers/net/wireless/intel/iwlwifi/mei/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_IWLMEI) += iwlmei.o +iwlmei-y += main.o +iwlmei-y += net.o +iwlmei-$(CONFIG_IWLWIFI_DEVICE_TRACING) += trace.o +CFLAGS_trace.o := -I$(src) + +ccflags-y += -I$(src)/../
drivers/net/wireless/intel/iwlwifi/mei/internal.h new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause +/* +* Copyright (C) 2021 Intel Corporation +*/ + +#ifndef __IWLMEI_INTERNAL_H_ +#define __IWLMEI_INTERNAL_H_ + +#include <uapi/linux/if_ether.h> +#include <linux/netdevice.h> + +#include "sap.h" + +rx_handler_result_t iwl_mei_rx_filter (struct sk_buff *skb, +const struct iwl_sap_oob_filters *filters, +bool *pass_to_csme); + +void iwl_mei_add_data_to_ring (struct sk_buff *skb,bool cb_tx); + +#endif /* __IWLMEI_INTERNAL_H_ */
drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h new file +440 -0
440 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2026 -0
2,026 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/net.c new file +409 -0
409 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/sap.h new file +736 -0
72 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/trace-data.h new file +69 -0
69 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/trace.c new file +15 -0
Lines of this file are not shown. View the raw message.
drivers/net/wireless/intel/iwlwifi/mei/trace.h new file +62 -0
62 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
Greg KH
maintainerRe: [PATCH RESEND 2/3] iwlwifi: mei: add the driver to allow cooperation with CSME
Quoted 38 lines · Emmanuel Grumbach
iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.Co-Developed-by Ayala Beker <[email protected]>Signed-off-by Emmanuel Grumbach <[email protected]>Signed-off-by Luca Coelho <[email protected]>--- drivers/net/wireless/intel/iwlwifi/Kconfig | 13 + drivers/net/wireless/intel/iwlwifi/Makefile | 2 + .../net/wireless/intel/iwlwifi/mei/Makefile | 8 + .../net/wireless/intel/iwlwifi/mei/internal.h | 20 + .../net/wireless/intel/iwlwifi/mei/iwl-mei.h | 440 ++++ drivers/net/wireless/intel/iwlwifi/mei/main.c | 2026 +++++++++++++++++ drivers/net/wireless/intel/iwlwifi/mei/net.c | 409 ++++ drivers/net/wireless/intel/iwlwifi/mei/sap.h | 736 ++++++ .../wireless/intel/iwlwifi/mei/trace-data.h | 69 + .../net/wireless/intel/iwlwifi/mei/trace.c | 15 + .../net/wireless/intel/iwlwifi/mei/trace.h | 62 + 11 files changed, 3800 insertions(+) create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/Makefile create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/internal.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/main.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/net.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/sap.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace-data.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.hdrivers/net/wireless/intel/iwlwifi/Kconfig +0
-0@@ -92,6 +92,19 @@ config IWLWIFI_BCAST_FILTERING If unsure, don't enable this option, as some programs might expect incoming broadcasts for their normal operations.
drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 104
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +10
-0+config IWLMEI + tristate "Enable V-PRO for WLAN" + depends on INTEL_MEI + depends on IWLMVM + help + Enable V-PRO. This allows to communicate with the CSME firmware. + This is supported starting from Tiger Lake platforms and has been + tested on 9260 devices only. Enabling this option on a platform that + has a different device and has Wireless enabled on AMT can prevent + WiFi from working correctly.
What does any of that mean? I can't understand it at all, and here I thought I understand new hardware terms :(
drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 106
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +2
-0+ + If unsure, say N.
module name?
drivers/net/wireless/intel/iwlwifi/Makefile ccflags-y += -I$(src) · line 33
Quoted 13 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +1
-0+ menu "Debugging Options" config IWLWIFI_DEBUGdrivers/net/wireless/intel/iwlwifi/Makefile +1
-0@@ -30,4 +30,6 @@ ccflags-y += -I$(src) obj-$(CONFIG_IWLDVM) += dvm/ obj-$(CONFIG_IWLMVM) += mvm/ +obj-$(CONFIG_IWLMEI) += mei/
Cuddle up against the line above?
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0@@ -0,0 +1,2026 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause
I didn't think that Intel was doing dual-license for .c files in the kernel, especially for ones that call GPL-only kernel symbols :(
The "loonacy" of doing this for .h files kind of makes sense if you really squint, but even then, it's crazy. But for .c files like this, that's not good.
You all have the right to license the code under whatever you want, so why keep a BSD license on it when it goes into the kernel tree?
In the past, I have been told by various Intel lawyers/legal-types that they were not going to do this anymore. I know things change, but are you sure that this is ok with the current corporate position of Linux kernel code that calls other parts of the core kernel like this?
Same for all new files in this patchset.
Quoted 21 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +21
-0+/* +* Copyright (C) 2021 Intel Corporation +*/ + +#include <linux/etherdevice.h> +#include <linux/netdevice.h> +#include <linux/rtnetlink.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/mei_cl_bus.h> +#include <linux/rcupdate.h> +#include <linux/debugfs.h> +#include <linux/skbuff.h> +#include <linux/wait.h> +#include <linux/slab.h> +#include <linux/mm.h> + +#include "internal.h" +#include "iwl-mei.h" +#include "trace.h" +#include "trace-data.h"
drivers/net/wireless/intel/iwlwifi/mei/main.c line 32
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+#include "sap.h" + +MODULE_DESCRIPTION ("The Intel(R) wireless / CSME firmware interface" ); +MODULE_LICENSE ("GPL" ); + +#define CHECK_FOR_NEWLINE (f) BUILD_BUG_ON(f[sizeof(f) - 2] != '\n') + +#define IWL_MEI_DEBUG(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \
Huh?
drivers/net/wireless/intel/iwlwifi/mei/main.c line 33
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ dev_dbg(&(c)->dev, f, ## a); \
Just use dev_dbg(), don't be special for a single driver, it hurts when trying to read different drivers.
drivers/net/wireless/intel/iwlwifi/mei/main.c line 46
Quoted 13 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +13
-0+ } while (0) + +#define IWL_MEI_INFO(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \ + dev_info(&(c)->dev, f, ## a); \ + } while (0) + +#define IWL_MEI_ERR(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \ + dev_err(&(c)->dev, f, ## a); \ + } while (0)
Same for all of the above, just use dev_info() and dev_err() please.
Quoted 9 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +9
-0+ +#define MEI_WLAN_UUID UUID_LE(0x13280904, 0x7792, 0x4fcb, \ + 0xa1, 0xaa, 0x5e, 0x70, 0xcb, 0xb1, 0xe8, 0x65) + +/* +* Since iwlwifi calls iwlmei without any context, hold a pointer to the +* mei_cl_device structure here. +* Define a mutex that will synchronize all the flows between iwlwifi and +* iwlmei.
drivers/net/wireless/intel/iwlwifi/mei/main.c line 65
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+*/ +static struct mei_cl_device *iwl_mei_global_cldev; +static DEFINE_MUTEX (iwl_mei_mutex); +static unsigned long iwl_mei_status; +#if IS_ENABLED (CONFIG_DEBUG_FS ) +static bool defer_start_message; + +module_param_named (defer_start_message, defer_start_message, bool,0644 ); +MODULE_PARM_DESC (defer_start_message, +"Defer the start message Tx to CSME (default false)" );
Why do you need this? Who is going to set it to anything else, and why would they? This isn't the 1990's anymore, please do not add new module parameters.
drivers/net/wireless/intel/iwlwifi/mei/main.c line 76
Quoted 11 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +11
-0+#endif + +enum iwl_mei_status_bits { +IWL_MEI_STATUS_SAP_CONNECTED , +}; + +bool iwl_mei_is_connected (void ) +{ +return test_bit (IWL_MEI_STATUS_SAP_CONNECTED , &iwl_mei_status); +} +EXPORT_SYMBOL (iwl_mei_is_connected);
EXPORT_SYMBOL_GPL()? I have to ask... :)
Quoted 13 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +13
-0+struct iwl_mei { +wait_queue_head_t get_nvm_wq; +struct work_struct send_csa_msg_wk; +wait_queue_head_t get_ownership_wq; +struct iwl_mei_shared_mem_ptrs shared_mem; +struct mei_cl_device *cldev; +struct iwl_mei_nvm *nvm; +struct iwl_mei_filters __rcu *filters; +bool got_ownership; +bool amt_enabled; +bool csa_throttled; +bool csme_taking_ownership; +struct delayed_work csa_throttle_end_wk;
drivers/net/wireless/intel/iwlwifi/mei/main.c line 205
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+spinlock_t data_q_lock; + +atomic_t sap_seq_no; +atomic_t seq_no; + +#if IS_ENABLED (CONFIG_DEBUG_FS ) +struct dentry *dbgfs_dir; +wait_queue_head_t debugfs_wq; +bool ping_pending; +#endif
Why #ifdef? Does the size really matter?
drivers/net/wireless/intel/iwlwifi/mei/main.c line 323
Quoted 13 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +13
-0+static ssize_t iwl_mei_write_cyclic_buf (struct mei_cl_device *cldev, +struct iwl_sap_q_ctrl_blk *notif_q, +u8 *q_head, +const struct iwl_sap_hdr *hdr) +{ +u32 rd =le32_to_cpu (READ_ONCE (notif_q->rd_ptr)); +u32 wr =le32_to_cpu (READ_ONCE (notif_q->wr_ptr)); +u32 q_sz =le32_to_cpu (notif_q->size); +size_t room_in_buf; +size_t tx_sz =sizeof (*hdr) +le16_to_cpu (hdr->len); + +if (WARN_ON (rd > q_sz || wr > q_sz)) +return -EINVAL ;
If any of the WARN_ON() things in this driver can ever trigger, just handle them normally and do NOT call WARN_ON() as you just rebooted the box for a simple thing that you could have recovered from.
Some of these WARN_ON() in the code feel very lazy as you control the caller so you "know" that this will never happen. So don't leave them in, it's debugging code that you can now remove.
drivers/net/wireless/intel/iwlwifi/mei/main.c line 329
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+ + room_in_buf = wr >= rd ? q_sz - wr + rd : rd - wr; + +/* we don't have enough room for the data to write */ +if (WARN_ON (room_in_buf < tx_sz)) +return -ENOSPC ;
Can userspace trigger this? If so, again, you just crashed the machine when panic_on_warn is enabled.
Just do a real check and handle the issue.
Quoted 15 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +15
-0+static void +iwl_mei_handle_rx_start_ok (struct mei_cl_device *cldev, +const struct iwl_sap_me_msg_start_ok *rsp, +ssize_t len) +{ +struct iwl_mei *mei =mei_cldev_get_drvdata (cldev); + +if (len !=sizeof (*rsp)) { +IWL_MEI_ERR (cldev, +"got invalid SAP_ME_MSG_START_OK from CSME firmware\n" ); +IWL_MEI_ERR (cldev, +"size is incorrect: %ld instead of %lu\n" , + len,sizeof (*rsp)); +return ; + }
drivers/net/wireless/intel/iwlwifi/mei/main.c line 614
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +if (rsp->supported_version !=SAP_VERSION ) { +IWL_MEI_ERR (cldev, +"didn't get the expected version: got %d\n" , + rsp->supported_version); +return ; + } + +IWL_MEI_INFO (cldev, +"Got a valid SAP_ME_MSG_START_OK from CSME firmware\n" );
When drivers work properly, they are quiet. This is very noisy, please remove debugging code like this.
drivers/net/wireless/intel/iwlwifi/mei/main.c line 621
Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7
-0+ +mutex_lock (&iwl_mei_mutex); +set_bit (IWL_MEI_STATUS_SAP_CONNECTED , &iwl_mei_status); +/* wifi driver has registered already */ +if (iwl_mei_cache.ops) { +WARN_ON (iwl_mei_send_sap_msg (mei->cldev, +SAP_MSG_NOTIF_WIFIDR_UP ));
Why????
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +4
-0+ iwl_mei_cache.ops->sap_connected (iwl_mei_cache.priv); + } + +mutex_unlock (&iwl_mei_mutex);
drivers/net/wireless/intel/iwlwifi/mei/main.c line 635
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+} + +static void iwl_mei_handle_csme_filters (struct mei_cl_device *cldev, +const struct iwl_sap_csme_filters *filters) +{ +struct iwl_mei *mei =mei_cldev_get_drvdata (iwl_mei_global_cldev); +struct iwl_mei_filters *new_filters; +struct iwl_mei_filters *old_filters; + +IWL_MEI_DEBUG (cldev,"Got CSME filters\n" );
ftrace is your friend, remove these pointless "the code got here!" lines. You have loads of them...
drivers/net/wireless/intel/iwlwifi/mei/main.c line 851
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+static void iwl_mei_handle_rx_host_own_req (struct mei_cl_device *cldev, +const struct iwl_sap_msg_dw *dw) +{ +struct iwl_mei *mei =mei_cldev_get_drvdata (cldev); + +IWL_MEI_DEBUG (cldev,"Got ownership req response: %d\n" , dw->val);
Code got here! :(
drivers/net/wireless/intel/iwlwifi/mei/main.c line 854
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+ +if (!dw->val) { +IWL_MEI_INFO (cldev,"Ownership req denied\n" );
why?????
drivers/net/wireless/intel/iwlwifi/mei/main.c line 174
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+return ;
No error returned?
Quoted 12 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +12
-0+ } + + mei->got_ownership = true; +wake_up_all (&mei->get_ownership_wq); + +iwl_mei_send_sap_msg (cldev, +SAP_MSG_NOTIF_HOST_OWNERSHIP_CONFIRMED ); + +/* We can now start the connection, unblock rfkill */ +if (iwl_mei_cache.ops) + iwl_mei_cache.ops->rfkill (iwl_mei_cache.priv, false); +}
drivers/net/wireless/intel/iwlwifi/mei/main.c line 877
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +static void iwl_mei_handle_pong (struct mei_cl_device *cldev, +const void *payload) +{ +#if IS_ENABLED (CONFIG_DEBUG_FS ) +struct iwl_mei *mei =mei_cldev_get_drvdata (cldev); + + mei->ping_pending = false; +wake_up_interruptible_all (&mei->debugfs_wq); +#endif
Why is this dependant on debugfs?
drivers/net/wireless/intel/iwlwifi/mei/main.c line 879
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+ +IWL_MEI_DEBUG (cldev,"Got PONG\n" );
again, ftrace.
drivers/net/wireless/intel/iwlwifi/mei/main.c line 975
Quoted 12 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +12
-0+static void iwl_mei_handle_sap_data (struct mei_cl_device *cldev, +const u8 *q_head,u32 q_sz, +u32 rd,u32 wr,ssize_t valid_rx_sz, +struct sk_buff_head *tx_skbs) +{ +struct iwl_sap_hdr hdr; +struct net_device *netdev = +rcu_dereference_protected (iwl_mei_cache.netdev, +lockdep_is_held (&iwl_mei_mutex)); + +if (!netdev) { +IWL_MEI_INFO (cldev,"No netdevice, dropping the Tx packet\n" );
quiet!!!
Or at the least, make this an error so that a user can handle it properly. They can do something about this, right? If not, why did you just tell them this happened?
drivers/net/wireless/intel/iwlwifi/mei/main.c line 211
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+return ;
No error value?
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+ } + +while (valid_rx_sz >=sizeof (hdr)) { +struct ethhdr *ethhdr; +unsigned char *data; +struct sk_buff *skb;
drivers/net/wireless/intel/iwlwifi/mei/main.c line 992
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+u16 len; + +iwl_mei_read_from_q (q_head, q_sz, &rd, wr, &hdr,sizeof (hdr)); + valid_rx_sz -=sizeof (hdr); + len =le16_to_cpu (hdr.len); + +if (valid_rx_sz < len) { +IWL_MEI_ERR (cldev, +"Data queue is corrupted: valid data len %ld, len %d\n" , + valid_rx_sz, len);
What can be done if this happens?
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +4
-0+break ; + } + +if (len <sizeof (*ethhdr)) {
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1006
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+IWL_MEI_ERR (cldev, +"Data len is smaller than an ethernet header? len = %d\n" , + len); + } + + valid_rx_sz -= len; + +if (le16_to_cpu (hdr.type) !=SAP_MSG_DATA_PACKET ) { +IWL_MEI_INFO (cldev,"Unsupported message: type %d, len %d\n" , +le16_to_cpu (hdr.type), len);
So userspace can spam the kernel log?
Please revisit _ALL_ of your messages you are printing out here, it feels way way way too noisy, like you got the code up and working with the debug lines in it and forgot to remove it.
How did this get missed in the internal Intel reviews that of course was required to happen before sending it to others outside of the firewall to review?
Quoted 55 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +55
-0+continue ; + } + +/* We need enough room for the WiFi header + SNAP + IV */ + skb =netdev_alloc_skb (netdev, len +26 +8 +8 ); + +skb_reserve (skb,26 +8 +8 ); + ethhdr =skb_push (skb,sizeof (*ethhdr)); + +iwl_mei_read_from_q (q_head, q_sz, &rd, wr, + ethhdr,sizeof (*ethhdr)); + len -=sizeof (*ethhdr); + +skb_reset_mac_header (skb); +skb_reset_network_header (skb); + skb->protocol = ethhdr->h_proto; + +/* we don't really want to get anything besides 802.3 packets */ +WARN_ON_ONCE (!eth_proto_is_802_3 (ethhdr->h_proto)); + + data =skb_put (skb, len); +iwl_mei_read_from_q (q_head, q_sz, &rd, wr, data, len); + +/* +* Enqueue the skb here so that it can be sent later when we +* do not hold the mutex. TX'ing a packet with a mutex held is +* possible, but it wouldn't be nice to forbid the TX path to +* call any of iwlmei's functions, since every API from iwlmei +* needs the mutex. +*/ +__skb_queue_tail (tx_skbs, skb); + } +} + +static void iwl_mei_handle_sap_rx_cmd (struct mei_cl_device *cldev, +const u8 *q_head,u32 q_sz, +u32 rd,u32 wr,ssize_t valid_rx_sz) +{ +struct page *p =alloc_page (GFP_KERNEL ); +struct iwl_sap_hdr *hdr; + +if (!p) +return ; + + hdr =page_address (p); + +while (valid_rx_sz >=sizeof (*hdr)) { +u16 len; + +iwl_mei_read_from_q (q_head, q_sz, &rd, wr, hdr,sizeof (*hdr)); + valid_rx_sz -=sizeof (*hdr); + len =le16_to_cpu (hdr->len); + +if (valid_rx_sz < len) +break ;
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1071
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +iwl_mei_read_from_q (q_head, q_sz, &rd, wr, hdr +1 , len); + +trace_iwlmei_sap_cmd (hdr, false); +iwl_mei_handle_sap_msg (cldev, hdr); + valid_rx_sz -= len; + } + +/* valid_rx_sz must be 0 now... */ +WARN_ON_ONCE (valid_rx_sz);
reboot!
{sigh}
<snip>
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1789
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+static void iwl_mei_dbgfs_register (struct iwl_mei *mei) +{ + mei->dbgfs_dir =debugfs_create_dir (KBUILD_MODNAME ,NULL );
At the root of debugfs, bold move :)
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1792
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+ +if (!mei->dbgfs_dir) +return ;
Why check this? Just feed the result back into other debugfs_create() calls, no need to care.
And why save the directory name at all, can't you just look it up when you want to remove it anyway?
Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7
-0+ +init_waitqueue_head (&mei->debugfs_wq); + +debugfs_create_ulong ("status" ,S_IRUSR , + mei->dbgfs_dir, &iwl_mei_status); +debugfs_create_file ("ping" ,S_IRUSR , mei->dbgfs_dir, + mei, &iwl_mei_dbgfs_ping_ops);
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1809
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+debugfs_create_file ("send_start_message" ,S_IWUSR , mei->dbgfs_dir, + mei, &iwl_mei_dbgfs_send_start_message_ops); +debugfs_create_file ("req_ownserhip" ,S_IWUSR , mei->dbgfs_dir, + mei, &iwl_mei_dbgfs_req_ownership_ops); +} + +static void iwl_mei_dbgfs_unregister (struct iwl_mei *mei) +{ +debugfs_remove_recursive (mei->dbgfs_dir); + mei->dbgfs_dir =NULL ;
Why set this to NULL?
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1815
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+} + +#else + +static void iwl_mei_dbgfs_register (struct iwl_mei *mei) {} +static void iwl_mei_dbgfs_unregister (struct iwl_mei *mei) {}
This type of thing goes in a .h file, you know better.
Quoted 34 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +34
-0+ +#endif /* CONFIG_DEBUG_FS */ + +/** +* iwl_mei_probe - the probe function called by the mei bus enumeration +* +* This allocates the data needed by iwlmei and sets a pointer to this data +* into the mei_cl_device's drvdata. +* It starts the SAP protocol by sending the SAP_ME_MSG_START without +* waiting for the answer. The answer will be caught later by the Rx callback. +*/ +static int iwl_mei_probe (struct mei_cl_device *cldev, +const struct mei_cl_device_id *id) +{ +struct iwl_mei *mei; +int ret; + + mei =devm_kzalloc (&cldev->dev,sizeof (*mei),GFP_KERNEL ); +if (!mei) +return -ENOMEM ; + +init_waitqueue_head (&mei->get_nvm_wq); +INIT_WORK (&mei->send_csa_msg_wk, iwl_mei_send_csa_msg_wk); +INIT_DELAYED_WORK (&mei->csa_throttle_end_wk, + iwl_mei_csa_throttle_end_wk); +init_waitqueue_head (&mei->get_ownership_wq); +spin_lock_init (&mei->data_q_lock); + +mei_cldev_set_drvdata (cldev, mei); + mei->cldev = cldev; + + ret =iwl_mei_alloc_shared_mem (cldev); +if (ret) + goto free;
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1859
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +iwl_mei_init_shared_mem (mei); + + ret =iwl_mei_enable (cldev); +if (ret) + goto free_shared_mem; + +iwl_mei_dbgfs_register (mei); + +#if IS_ENABLED (CONFIG_DEBUG_FS )
#if should not be in .c files, again, you all know better...
I'm giving up here, sorry, I can't do it anymore...
greg k-h
RE: [PATCH RESEND 2/3] iwlwifi: mei: add the driver to allow cooperation with CSME
Quoted 135 lines · Emmanuel Grumbach
Quoted 39 lines
iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.Co-Developed-by Ayala Beker <[email protected]>Signed-off-by Emmanuel Grumbach <[email protected]>Signed-off-by Luca Coelho <[email protected]>--- drivers/net/wireless/intel/iwlwifi/Kconfig | 13 + drivers/net/wireless/intel/iwlwifi/Makefile | 2 + .../net/wireless/intel/iwlwifi/mei/Makefile | 8 + .../net/wireless/intel/iwlwifi/mei/internal.h | 20 + .../net/wireless/intel/iwlwifi/mei/iwl-mei.h | 440 ++++ drivers/net/wireless/intel/iwlwifi/mei/main.c | 2026 +++++++++++++++++ drivers/net/wireless/intel/iwlwifi/mei/net.c | 409 ++++ drivers/net/wireless/intel/iwlwifi/mei/sap.h | 736 ++++++ .../wireless/intel/iwlwifi/mei/trace-data.h | 69 + .../net/wireless/intel/iwlwifi/mei/trace.c | 15 + .../net/wireless/intel/iwlwifi/mei/trace.h | 62 + 11 files changed, 3800 insertions(+) create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/Makefile create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/internal.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/main.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/net.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/sap.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace-data.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.hdrivers/net/wireless/intel/iwlwifi/Kconfig +0
-0@@ -92,6 +92,19 @@ config IWLWIFI_BCAST_FILTERING If unsure, don't enable this option, as some programs might expect incoming broadcasts for their normal operations.drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 103
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +9
-0+config IWLMEI + tristate "Enable V-PRO for WLAN" + depends on INTEL_MEI + depends on IWLMVM + help + Enable V-PRO. This allows to communicate with the CSME firmware. + This is supported starting from Tiger Lake platforms and has been + tested on 9260 devices only. Enabling this option on a platform that + has a different device and has Wireless enabled on AMT canprevent
drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 104
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/Kconfig +1
-0+ WiFi from working correctly.What does any of that mean? I can't understand it at all, and here I thought I understand new hardware terms :(
drivers/net/wireless/intel/iwlwifi/Kconfig config IWLWIFI_BCAST_FILTERING · line 106
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +2
-0+ + If unsure, say N.module name?
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/Kconfig +1
-0+ menu "Debugging Options" config IWLWIFI_DEBUGdrivers/net/wireless/intel/iwlwifi/Makefile +0
-0drivers/net/wireless/intel/iwlwifi/Makefile ccflags-y += -I$(src) · line 33
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/Makefile +1
-0@@ -30,4 +30,6 @@ ccflags-y += -I$(src) obj-$(CONFIG_IWLDVM) += dvm/ obj-$(CONFIG_IWLMVM) += mvm/ +obj-$(CONFIG_IWLMEI) += mei/Cuddle up against the line above?
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0@@ -0,0 +1,2026 @@ +// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause I didn't think that Intel was doing dual-license for .c files in the kernel, especially for ones that call GPL-only kernel symbols :(
The "loonacy" of doing this for .h files kind of makes sense if you really squint, but even then, it's crazy. But for .c files like this, that's not good.
You all have the right to license the code under whatever you want, so why keep a BSD license on it when it goes into the kernel tree?
In the past, I have been told by various Intel lawyers/legal-types that they were not going to do this anymore. I know things change, but are you sure that this is ok with the current corporate position of Linux kernel code that calls other parts of the core kernel like this?
Same for all new files in this patchset.
Quoted 20 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +20
-0+/* +* Copyright (C) 2021 Intel Corporation */ + +#include <linux/etherdevice.h> +#include <linux/netdevice.h> +#include <linux/rtnetlink.h> +#include <linux/module.h> +#include <linux/moduleparam.h> +#include <linux/mei_cl_bus.h> +#include <linux/rcupdate.h> +#include <linux/debugfs.h> +#include <linux/skbuff.h> +#include <linux/wait.h> +#include <linux/slab.h> +#include <linux/mm.h> + +#include "internal.h" +#include "iwl-mei.h" +#include "trace.h" +#include "trace-data.h" drivers/net/wireless/intel/iwlwifi/mei/main.c line 32
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+#include "sap.h" + +MODULE_DESCRIPTION ("The Intel(R) wireless / CSME firmware +interface"); MODULE_LICENSE("GPL"); + +#define CHECK_FOR_NEWLINE (f) BUILD_BUG_ON(f[sizeof(f) - 2] != '\n') + +#define IWL_MEI_DEBUG(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \Huh?
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 33
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ dev_dbg(&(c)->dev, f, ## a); \Just use
dev_dbg(), don't be special for a single driver, it hurts when trying to read different drivers.
I took this from iwlwifi. I can change if needed, not a big deal.
Quoted 17 lines
Quoted 5 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+ }while (0 ) + +#define IWL_MEI_INFO(c, f, a...) \drivers/net/wireless/intel/iwlwifi/mei/main.c line 46
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+do { \ +CHECK_FOR_NEWLINE (f); \ + dev_info(&(c)->dev, f, ## a); \ + } while (0) + +#define IWL_MEI_ERR(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \ + dev_err(&(c)->dev, f, ## a); \ + } while (0)Same for all of the above, just use
dev_info()anddev_err()please.
Sure
Quoted 19 lines
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7
-0+ +#define MEI_WLAN_UUID UUID_LE(0x13280904, 0x7792, 0x4fcb, \ + 0xa1, 0xaa, 0x5e, 0x70, 0xcb, 0xb1, 0xe8, 0x65) + +/* +* Since iwlwifi calls iwlmei without any context, hold a pointer to +the drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+* mei_cl_device structure here. +* Define a mutex that will synchronize all the flows between iwlwifi +and +* iwlmei. +*/ +static struct mei_cl_device *iwl_mei_global_cldev;static +DEFINE_MUTEX(iwl_mei_mutex); static unsigned long iwl_mei_status; #if +IS_ENABLED(CONFIG_DEBUG_FS) static bool defer_start_message; + +module_param_named(defer_start_message, defer_start_message,bool,
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 64
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+0644); MODULE_PARM_DESC(defer_start_message, +"Defer the start message Tx to CSME (default false)" );Why do you need this? Who is going to set it to anything else, and why would they? This isn't the 1990's anymore, please do not add new module parameters.
For testing. I need this to be able to force a certain order of initialization which is possible (and hence must be tested) but not likely to happen. Another point is tracing. This allows me to load the module but prevent any real operation. Then, start tracing. This way, I can see the whole flow in tracing, even the very beginning.
Quoted 34 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 11 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +9
-0+#endif + +enum iwl_mei_status_bits { +IWL_MEI_STATUS_SAP_CONNECTED , +}; + +bool iwl_mei_is_connected (void ) +{ + return test_bit(IWL_MEI_STATUS_SAP_CONNECTED,
&iwl_mei_status); }drivers/net/wireless/intel/iwlwifi/mei/main.c line 76
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+EXPORT_SYMBOL (iwl_mei_is_connected);
EXPORT_SYMBOL_GPL()? I have to ask... :)Quoted 17 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +17
-0+struct iwl_mei { +wait_queue_head_t get_nvm_wq; +struct work_struct send_csa_msg_wk; +wait_queue_head_t get_ownership_wq; +struct iwl_mei_shared_mem_ptrs shared_mem; +struct mei_cl_device *cldev; +struct iwl_mei_nvm *nvm; +struct iwl_mei_filters __rcu *filters; +bool got_ownership; +bool amt_enabled; +bool csa_throttled; +bool csme_taking_ownership; +struct delayed_work csa_throttle_end_wk; +spinlock_t data_q_lock; + +atomic_t sap_seq_no; +atomic_t seq_no;
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 205
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+ +#if IS_ENABLED (CONFIG_DEBUG_FS ) +struct dentry *dbgfs_dir; +wait_queue_head_t debugfs_wq; +bool ping_pending; +#endif Why #ifdef? Does the size really matter?
Size. I can drop those.
Quoted 10 lines
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +9
-0+static ssize_t iwl_mei_write_cyclic_buf (struct mei_cl_device *cldev, +struct iwl_sap_q_ctrl_blk *notif_q, +u8 *q_head, +const struct iwl_sap_hdr *hdr) +{ +u32 rd =le32_to_cpu (READ_ONCE (notif_q->rd_ptr)); +u32 wr =le32_to_cpu (READ_ONCE (notif_q->wr_ptr)); +u32 q_sz =le32_to_cpu (notif_q->size); +size_t room_in_buf;
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 323
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +4
-0+size_t tx_sz =sizeof (*hdr) +le16_to_cpu (hdr->len); + +if (WARN_ON (rd > q_sz || wr > q_sz)) +return -EINVAL ;If any of the
WARN_ON()things in this driver can ever trigger, just handle them normally and do NOT callWARN_ON()as you just rebooted the box for a simple thing that you could have recovered from.
My understanding is that WARN_ON does not reboot the box which is why it was invented when we already had BUG_ON. This can't be triggered by the user space, but can be triggered by the CSME firmware that runs on the chipset.
Quoted 4 lines
Some of these
WARN_ON()in the code feel very lazy as you control the caller so you "know" that this will never happen. So don't leave them in, it's debugging code that you can now remove.
I can transform them in error prints, but again, my understanding is / was that WARN_ON is ok to use and won't reboot the box since it differs from BUG_ON.
Quoted 11 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 329
Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+ + room_in_buf = wr >= rd ? q_sz - wr + rd : rd - wr; + +/* we don't have enough room for the data to write */ +if (WARN_ON (room_in_buf < tx_sz)) +return -ENOSPC ;Can userspace trigger this? If so, again, you just crashed the machine when
panic_on_warnis enabled.
Quoted 1 line
Just do a real check and handle the issue.
I'll change to a simple print.
Quoted 29 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 11 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+static void +iwl_mei_handle_rx_start_ok (struct mei_cl_device *cldev, +const struct iwl_sap_me_msg_start_ok *rsp, +ssize_t len) +{ +struct iwl_mei *mei =mei_cldev_get_drvdata (cldev); + +if (len !=sizeof (*rsp)) { + IWL_MEI_ERR(cldev, + "got invalid SAP_ME_MSG_START_OK from CSMEfirmware\n");
Quoted 5 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +5
-0+IWL_MEI_ERR (cldev, +"size is incorrect: %ld instead of %lu\n" , + len,sizeof (*rsp)); +return ; + }drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +if (rsp->supported_version !=SAP_VERSION ) { +IWL_MEI_ERR (cldev, +"didn't get the expected version: got %d\n" , + rsp->supported_version); +return ; + } + + IWL_MEI_INFO(cldev, + "Got a valid SAP_ME_MSG_START_OK from CSMEfirmware\n");
Quoted 2 lines
When drivers work properly, they are quiet. This is very noisy, please remove debugging code like this.
I'll move to dbg level.
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 621
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7
-0+ +mutex_lock (&iwl_mei_mutex); +set_bit (IWL_MEI_STATUS_SAP_CONNECTED , &iwl_mei_status); +/* wifi driver has registered already */ +if (iwl_mei_cache.ops) { +WARN_ON (iwl_mei_send_sap_msg (mei->cldev, +SAP_MSG_NOTIF_WIFIDR_UP ));Why????
Same explanation as above.
Quoted 12 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 9 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +8
-0+ iwl_mei_cache.ops->sap_connected (iwl_mei_cache.priv); + } + +mutex_unlock (&iwl_mei_mutex); +} + +static void iwl_mei_handle_csme_filters (struct mei_cl_device *cldev, + const struct iwl_sap_csme_filters*filters) {
drivers/net/wireless/intel/iwlwifi/mei/main.c line 157
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ struct iwl_mei *mei =
mei_cldev_get_drvdata(iwl_mei_global_cldev);
Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 635
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +4
-0+struct iwl_mei_filters *new_filters; +struct iwl_mei_filters *old_filters; + +IWL_MEI_DEBUG (cldev,"Got CSME filters\n" );ftrace is your friend, remove these pointless "the code got here!" lines. You have loads of them...
This is debug. Won't appear unless you want it.
I have extensive tracing support.
Quoted 11 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 162
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+static void iwl_mei_handle_rx_host_own_req(struct mei_cl_device*cldev,
drivers/net/wireless/intel/iwlwifi/mei/main.c line 163
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ const struct iwl_sap_msg_dw *dw){
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+struct iwl_mei *mei =mei_cldev_get_drvdata (cldev); + + IWL_MEI_DEBUG(cldev, "Got ownership req response: %d\n", dw-val);
Code got here! :(
Same, this is protected by a dynamic debug knob.
I can see tons of those in mei bus driver .
$ git grep _dbg\( -- drivers/misc/mei | wc -l 228
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 854
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+ +if (!dw->val) { +IWL_MEI_INFO (cldev,"Ownership req denied\n" );why?????
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+return ;No error returned?
This is not an error. This means that the CSME firmware is not allowing the host to use the WLAN device.
Quoted 9 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 863
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7
-0+ } + + mei->got_ownership = true; +wake_up_all (&mei->get_ownership_wq); + + iwl_mei_send_sap_msg(cldev, +
SAP_MSG_NOTIF_HOST_OWNERSHIP_CONFIRMED);
Quoted 16 lines
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +4
-0+ +/* We can now start the connection, unblock rfkill */ +if (iwl_mei_cache.ops) + iwl_mei_cache.ops->rfkill (iwl_mei_cache.priv, false); }drivers/net/wireless/intel/iwlwifi/mei/main.c line 877
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +static void iwl_mei_handle_pong (struct mei_cl_device *cldev, +const void *payload) +{ +#if IS_ENABLED (CONFIG_DEBUG_FS ) +struct iwl_mei *mei =mei_cldev_get_drvdata (cldev); + + mei->ping_pending = false; +wake_up_interruptible_all (&mei->debugfs_wq); +#endif Why is this dependant on debugfs?
Because only debugfs can trigger the flow that would be waiting for the pong. I can remove this debugfs know if you like.
Quoted 15 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 879
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+ +IWL_MEI_DEBUG (cldev,"Got PONG\n" );again, ftrace.
drivers/net/wireless/intel/iwlwifi/mei/main.c line 973
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +8
-0+static void iwl_mei_handle_sap_data (struct mei_cl_device *cldev, +const u8 *q_head,u32 q_sz, +u32 rd,u32 wr,ssize_t valid_rx_sz, +struct sk_buff_head *tx_skbs) { +struct iwl_sap_hdr hdr; +struct net_device *netdev = + rcu_dereference_protected(iwl_mei_cache.netdev, +
lockdep_is_held(&iwl_mei_mutex));
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+ +if (!netdev) { + IWL_MEI_INFO(cldev, "No netdevice, dropping the Txpacket\n");
quiet!!!
This is actually not a usual path. A race is happening here...
Quoted 4 lines
Or at the least, make this an error so that a user can handle it properly. They can do something about this, right? If not, why did you just tell them this happened?
There isn't much I can do here. The CSME firmware is sending a packet to iwlmei to send on the WLAN link, but the link isn't valid anymore.
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+return ;No error value?
Nobody will read this error value. This is a handler for a notification from the CSME firmware.
Quoted 18 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +9
-0+ } + +while (valid_rx_sz >=sizeof (hdr)) { +struct ethhdr *ethhdr; +unsigned char *data; +struct sk_buff *skb; +u16 len; + + iwl_mei_read_from_q(q_head, q_sz, &rd, wr, &hdr,sizeof(hdr));
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+ valid_rx_sz -=sizeof (hdr); + len =le16_to_cpu (hdr.len); + +if (valid_rx_sz < len) { + IWL_MEI_ERR(cldev, + "Data queue is corrupted: valid data len%ld, len %d\n",
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 992
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ valid_rx_sz, len);What can be done if this happens?
I guess I can restart the whole handshake with the CSME firmware. I haven't implemented this flow (yet).
Quoted 16 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+break ; + } + +if (len <sizeof (*ethhdr)) { + IWL_MEI_ERR(cldev, + "Data len is smaller than an ethernetheader? len = %d\n",
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +7
-0+ len); + } + + valid_rx_sz -= len; + +if (le16_to_cpu (hdr.type) !=SAP_MSG_DATA_PACKET ) { + IWL_MEI_INFO(cldev, "Unsupported message: type%d, len %d\n",
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1006
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ le16_to_cpu(hdr.type), len);So userspace can spam the kernel log?
This is not userspace, this is the CSME firmware.
Quoted 4 lines
Please revisit _ALL_ of your messages you are printing out here, it feels way way way too noisy, like you got the code up and working with the debug lines in it and forgot to remove it.
[ 12.665966] iwlmei 0000:00:16.0-13280904-7792-4fcb-a1aa-5e70cbb1e865: Got a valid SAP_ME_MSG_START_OK from CSME firmware
That's the only line I am printing by default. I can remove it. I can't do better than 0 printing.
Quoted 74 lines
How did this get missed in the internal Intel reviews that of course was required to happen before sending it to others outside of the firewall to review?
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +8
-0+continue ; + } + +/* We need enough room for the WiFi header + SNAP + IV */ + skb =netdev_alloc_skb (netdev, len +26 +8 +8 ); + +skb_reserve (skb,26 +8 +8 ); + ethhdr =skb_push (skb,sizeof (*ethhdr));drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +iwl_mei_read_from_q (q_head, q_sz, &rd, wr, + ethhdr,sizeof (*ethhdr)); + len -=sizeof (*ethhdr); + +skb_reset_mac_header (skb); +skb_reset_network_header (skb); + skb->protocol = ethhdr->h_proto; + +/* we don't really want to get anything besides 802.3 packets */
Quoted 21 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +21
-0+WARN_ON_ONCE (!eth_proto_is_802_3 (ethhdr->h_proto)); + + data =skb_put (skb, len); +iwl_mei_read_from_q (q_head, q_sz, &rd, wr, data, len); + +/* +* Enqueue the skb here so that it can be sent later when we +* do not hold the mutex. TX'ing a packet with a mutex held is +* possible, but it wouldn't be nice to forbid the TX path to +* call any of iwlmei's functions, since every API from iwlmei +* needs the mutex. +*/ +__skb_queue_tail (tx_skbs, skb); + } +} + +static void iwl_mei_handle_sap_rx_cmd (struct mei_cl_device *cldev, +const u8 *q_head,u32 q_sz, +u32 rd,u32 wr,ssize_t valid_rx_sz) { +struct page *p =alloc_page (GFP_KERNEL ); +struct iwl_sap_hdr *hdr;drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +if (!p) +return ; + + hdr =page_address (p); + +while (valid_rx_sz >=sizeof (*hdr)) { +u16 len; + + iwl_mei_read_from_q(q_head, q_sz, &rd, wr, hdr,
sizeof(*hdr));Quoted 5 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +5
-0+ valid_rx_sz -=sizeof (*hdr); + len =le16_to_cpu (hdr->len); + +if (valid_rx_sz < len) +break ;drivers/net/wireless/intel/iwlwifi/mei/main.c line 1071
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +iwl_mei_read_from_q (q_head, q_sz, &rd, wr, hdr +1 , len); + +trace_iwlmei_sap_cmd (hdr, false); +iwl_mei_handle_sap_msg (cldev, hdr); + valid_rx_sz -= len; + } + +/* valid_rx_sz must be 0 now... */ +WARN_ON_ONCE (valid_rx_sz);reboot!
Quoted 8 lines
{sigh}
<snip>
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+static void iwl_mei_dbgfs_register (struct iwl_mei *mei) { + mei->dbgfs_dir =debugfs_create_dir (KBUILD_MODNAME ,NULL );At the root of debugfs, bold move :)
There is no other place since the mei bus doesn't provide another dir to hook on.
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1792
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+ +if (!mei->dbgfs_dir) +return ;Why check this? Just feed the result back into other
debugfs_create()calls, no need to care.And why save the directory name at all, can't you just look it up when you want to remove it anyway?
Possible.
Quoted 12 lines
Quoted 12 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +8
-0+ +init_waitqueue_head (&mei->debugfs_wq); + +debugfs_create_ulong ("status" ,S_IRUSR , + mei->dbgfs_dir, &iwl_mei_status); +debugfs_create_file ("ping" ,S_IRUSR , mei->dbgfs_dir, + mei, &iwl_mei_dbgfs_ping_ops); + debugfs_create_file("send_start_message", S_IWUSR, mei-
dbgfs_dir,drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+ mei, &iwl_mei_dbgfs_send_start_message_ops); + debugfs_create_file("req_ownserhip", S_IWUSR, mei->dbgfs_dir,
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1809
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+ mei, &iwl_mei_dbgfs_req_ownership_ops); +} + +static void iwl_mei_dbgfs_unregister (struct iwl_mei *mei) { +debugfs_remove_recursive (mei->dbgfs_dir); + mei->dbgfs_dir =NULL ;Why set this to NULL?
I can remove.
Quoted 9 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 7 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+} + +#else + +static void iwl_mei_dbgfs_register (struct iwl_mei *mei) {}static +void iwl_mei_dbgfs_unregister (struct iwl_mei *mei) {}This type of thing goes in a .h file, you know better.
A header file only for less a handful of functions?
Quoted 55 lines
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+ +#endif /* CONFIG_DEBUG_FS */ drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +/** +* iwl_mei_probe - the probe function called by the mei bus +enumeration +* +* This allocates the data needed by iwlmei and sets a pointer to +this data +* into the mei_cl_device's drvdata. +* It starts the SAP protocol by sending the SAP_ME_MSG_START without +* waiting for the answer. The answer will be caught later by the Rx callback.
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 12 lines
+ */
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +11
-0+static int iwl_mei_probe (struct mei_cl_device *cldev, +const struct mei_cl_device_id *id) { +struct iwl_mei *mei; +int ret; + + mei =devm_kzalloc (&cldev->dev,sizeof (*mei),GFP_KERNEL ); +if (!mei) +return -ENOMEM ; + +init_waitqueue_head (&mei->get_nvm_wq); + INIT_WORK(&mei->send_csa_msg_wk,
iwl_mei_send_csa_msg_wk);Quoted 11 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +11
-0+INIT_DELAYED_WORK (&mei->csa_throttle_end_wk, + iwl_mei_csa_throttle_end_wk); +init_waitqueue_head (&mei->get_ownership_wq); +spin_lock_init (&mei->data_q_lock); + +mei_cldev_set_drvdata (cldev, mei); + mei->cldev = cldev; + + ret =iwl_mei_alloc_shared_mem (cldev); +if (ret) + goto free;drivers/net/wireless/intel/iwlwifi/mei/main.c line 1859
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +10
-0+ +iwl_mei_init_shared_mem (mei); + + ret =iwl_mei_enable (cldev); +if (ret) + goto free_shared_mem; + +iwl_mei_dbgfs_register (mei); + +#if IS_ENABLED (CONFIG_DEBUG_FS )#if should not be in .c files, again, you all know better...
I'm giving up here, sorry, I can't do it anymore...
greg k-h
Greg KH
maintainerRe: [PATCH RESEND 2/3] iwlwifi: mei: add the driver to allow cooperation with CSME
Quoted 6 lines · Emmanuel
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 32
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+#define IWL_MEI_DEBUG(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \Huh?
Quoted 6 lines
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 33
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ dev_dbg(&(c)->dev, f, ## a); \Just use
dev_dbg(), don't be special for a single driver, it hurts when trying to read different drivers.I took this from iwlwifi. I can change if needed, not a big deal.
Please do.
Quoted 11 lines
Quoted 8 lines
Quoted 1 line
+module_param_named(defer_start_message,
defer_start_message,bool,
drivers/net/wireless/intel/iwlwifi/mei/main.c line 65
Quoted 2 lines
+0644); MODULE_PARM_DESC(defer_start_message,
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ "Defer the start message Tx to CSME (default false)");Why do you need this? Who is going to set it to anything else, and why would they? This isn't the 1990's anymore, please do not add new module parameters.
For testing. I need this to be able to force a certain order of initialization which is possible (and hence must be tested) but not likely to happen. Another point is tracing. This allows me to load the module but prevent any real operation. Then, start tracing. This way, I can see the whole flow in tracing, even the very beginning.
Then call this something obvious, "kernel_hacker_debuging_testing_only_use_if_you_know_what_you_are_doing".
Or better yet, just put it in debugfs to turn it on/off and no module parameter is needed at all.
Quoted 8 lines
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 323
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+if (WARN_ON (rd > q_sz || wr > q_sz)) +return -EINVAL ;If any of the
WARN_ON()things in this driver can ever trigger, just handle them normally and do NOT callWARN_ON()as you just rebooted the box for a simple thing that you could have recovered from.My understanding is that
WARN_ONdoes not reboot the box which is why it was invented when we already hadBUG_ON. This can't be triggered by the user space, but can be triggered by the CSME firmware that runs on the chipset.
when panic_on_warn is enabled, the box will reboot.
If firmware can cause this, then properly handle the issue and continue on, don't reboot machines.
Quoted 5 lines
Quoted 3 lines
Some of these
WARN_ON()in the code feel very lazy as you control the caller so you "know" that this will never happen. So don't leave them in, it's debugging code that you can now remove.I can transform them in error prints, but again, my understanding is / was that
WARN_ONis ok to use and won't reboot the box since it differs fromBUG_ON.
Again, panic_on_warn.
Quoted 8 lines
Quoted 5 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 635
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+ +IWL_MEI_DEBUG (cldev,"Got CSME filters\n" );ftrace is your friend, remove these pointless "the code got here!" lines. You have loads of them...
This is debug. Won't appear unless you want it.
I have extensive tracing support.
Again, use ftrace for tracing, don't use debug print messages.
Quoted 11 lines
Quoted 10 lines
Quoted 1 line
+static void iwl_mei_handle_rx_host_own_req(struct
mei_cl_device*cldev,
Review
Quoted 1 line
(quoted diff) +1
-0+ const struct iwl_sap_msg_dw *dw){
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+struct iwl_mei *mei =mei_cldev_get_drvdata (cldev); + + IWL_MEI_DEBUG(cldev, "Got ownership req response: %d\n", dw-val);
Code got here! :(
Quoted 4 lines
Same, this is protected by a dynamic debug knob.
I can see tons of those in mei bus driver .$ git grep _dbg\( -- drivers/misc/mei | wc -l 228
mei should be fixed as well.
Quoted 11 lines
Quoted 9 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 854
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+ +if (!dw->val) { +IWL_MEI_INFO (cldev,"Ownership req denied\n" );why?????
Review
Quoted 1 line
(quoted diff) +1
-0+ return;No error returned?
This is not an error. This means that the CSME firmware is not allowing the host to use the WLAN device.
Ok, and what can a user do about this?
Quoted 7 lines
Quoted 5 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (!netdev) { + IWL_MEI_INFO(cldev, "No netdevice, dropping the Txpacket\n");
quiet!!!
This is actually not a usual path. A race is happening here...
"race" implies "error" which is not "dev_info()" material.
Quoted 6 lines
Quoted 3 lines
Or at the least, make this an error so that a user can handle it properly. They can do something about this, right? If not, why did you just tell them this happened?
There isn't much I can do here. The CSME firmware is sending a packet to iwlmei to send on the WLAN link, but the link isn't valid anymore.
Then report an error.
Quoted 8 lines
Quoted 6 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (le16_to_cpu(hdr.type) != SAP_MSG_DATA_PACKET) { + IWL_MEI_INFO(cldev, "Unsupported message: type%d, len %d\n",
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1006
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ le16_to_cpu(hdr.type), len);So userspace can spam the kernel log?
This is not userspace, this is the CSME firmware.
Then make it an error, not an informational message. Someone needs to see it to fix the firmware, right?
Quoted 7 lines
Quoted 3 lines
Please revisit _ALL_ of your messages you are printing out here, it feels way way way too noisy, like you got the code up and working with the debug lines in it and forgot to remove it.
[ 12.665966] iwlmei 0000:00:16.0-13280904-7792-4fcb-a1aa-5e70cbb1e865: Got a valid SAP_ME_MSG_START_OK from CSME firmwareThat's the only line I am printing by default. I can remove it. I can't do better than 0 printing.
0 printing would be good.
Quoted 10 lines
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+} + +#else + +static void iwl_mei_dbgfs_register (struct iwl_mei *mei) {}static +void iwl_mei_dbgfs_unregister (struct iwl_mei *mei) {}This type of thing goes in a .h file, you know better.
A header file only for less a handful of functions?
You already have .h files for this code, why not put it in there?
thanks,
greg k-h
RE: [PATCH RESEND 2/3] iwlwifi: mei: add the driver to allow cooperation with CSME
Quoted 32 lines · Emmanuel
Quoted 6 lines
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 32
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+#define IWL_MEI_DEBUG(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \Huh?
Quoted 6 lines
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 33
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ dev_dbg(&(c)->dev, f, ## a); \Just use
dev_dbg(), don't be special for a single driver, it hurts when trying to read different drivers.I took this from iwlwifi. I can change if needed, not a big deal.
Please do.
Quoted 10 lines
Quoted 8 lines
Quoted 1 line
+module_param_named(defer_start_message,
defer_start_message,bool,
drivers/net/wireless/intel/iwlwifi/mei/main.c line 65
Quoted 2 lines
+0644); MODULE_PARM_DESC(defer_start_message,
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ "Defer the start message Tx to CSME (default false)");Why do you need this? Who is going to set it to anything else, and why would they? This isn't the 1990's anymore, please do not add new module parameters.
For testing. I need this to be able to force a certain order of initialization
which is possible (and hence must be tested) but not likely to happen.
Quoted 1 line
Another point is tracing. This allows me to load the module but prevent any
real operation. Then, start tracing. This way, I can see the whole flow in tracing, even the very beginning.
Quoted 7 lines
Then call this something obvious, "
kernel_hacker_debuging_testing_only_use_if_you_know_what_you_are_doing".Or better yet, just put it in debugfs to turn it on/off and no module parameter is needed at all.
Debugfs is not a replacement for module parameters. Debugfs can be used only after the driver already ran quite a bit of its initialization code path. Here I want to be able to catch the very first messages with tracing.
Quoted 8 lines
Quoted 8 lines
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 323
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+if (WARN_ON (rd > q_sz || wr > q_sz)) +return -EINVAL ;If any of the
WARN_ON()things in this driver can ever trigger, just handle them normally and do NOT callWARN_ON()as you just rebooted the box for a simple thing that you could have recovered from.My understanding is that
WARN_ONdoes not reboot the box which is why
Quoted 8 lines
it was invented when we already had
BUG_ON. This can't be triggered by the user space, but can be triggered by the CSME firmware that runs on the chipset.when
panic_on_warnis enabled, the box will reboot.If firmware can cause this, then properly handle the issue and continue on, don't reboot machines.
I'll print an error then. I still didn't understand what's the difference between BUG_ON and WARN_ON in your eyes.
Quoted 46 lines
Quoted 6 lines
Quoted 4 lines
Some of these
WARN_ON()in the code feel very lazy as you control the caller so you "know" that this will never happen. So don't leave them in, it's debugging code that you can now remove.I can transform them in error prints, but again, my understanding is / was
that
WARN_ONis ok to use and won't reboot the box since it differs fromBUG_ON.Again,
panic_on_warn.Quoted 8 lines
Quoted 5 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 635
Quoted 2 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +2
-0+ +IWL_MEI_DEBUG (cldev,"Got CSME filters\n" );ftrace is your friend, remove these pointless "the code got here!" lines. You have loads of them...
This is debug. Won't appear unless you want it.
I have extensive tracing support.Again, use ftrace for tracing, don't use debug print messages.
Quoted 11 lines
Quoted 10 lines
Quoted 1 line
+static void iwl_mei_handle_rx_host_own_req(struct
mei_cl_device*cldev,
Review
Quoted 1 line
(quoted diff) +1
-0+ const struct iwl_sap_msg_dw *dw){
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+struct iwl_mei *mei =mei_cldev_get_drvdata (cldev); + + IWL_MEI_DEBUG(cldev, "Got ownership req response: %d\n", dw-val);
Code got here! :(
Quoted 4 lines
Same, this is protected by a dynamic debug knob.
I can see tons of those in mei bus driver .$ git grep _dbg\( -- drivers/misc/mei | wc -l 228mei should be fixed as well.
Quoted 6 lines
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 854
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+ +if (!dw->val) { +IWL_MEI_INFO (cldev,"Ownership req denied\n" );why?????
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
Review
Quoted 1 line
(quoted diff) +1
-0+ return;No error returned?
This is not an error. This means that the CSME firmware is not allowing the
host to use the WLAN device.
Ok, and what can a user do about this?
Not much, but a kernel developer would like to know that it happened.
Quoted 23 lines
Quoted 8 lines
Quoted 6 lines
Review
Quoted 3 lines
(quoted diff) +2
-0+ if (!netdev) { + IWL_MEI_INFO(cldev, "No netdevice, dropping the Txpacket\n");
quiet!!!
This is actually not a usual path. A race is happening here...
"race" implies "error" which is not "
dev_info()" material.Quoted 6 lines
Quoted 3 lines
Or at the least, make this an error so that a user can handle it properly. They can do something about this, right? If not, why did you just tell them this happened?
There isn't much I can do here. The CSME firmware is sending a packet to iwlmei to send on the WLAN link, but the link isn't valid anymore.
Then report an error.
Quoted 3 lines
Quoted 3 lines
Review
Quoted 2 lines
(quoted diff) +2
-0+ if (le16_to_cpu(hdr.type) != SAP_MSG_DATA_PACKET) { + IWL_MEI_INFO(cldev, "Unsupported message: type%d, len %d\n",
Quoted 8 lines
Quoted 5 lines
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 1006
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ le16_to_cpu(hdr.type), len);So userspace can spam the kernel log?
This is not userspace, this is the CSME firmware.
Then make it an error, not an informational message. Someone needs to see it to fix the firmware, right?
Ok.
Quoted 29 lines
Quoted 6 lines
Quoted 4 lines
Please revisit _ALL_ of your messages you are printing out here, it feels way way way too noisy, like you got the code up and working with the debug lines in it and forgot to remove it.
[ 12.665966] iwlmei 0000:00:16.0-13280904-7792-4fcb-a1aa-5e70cbb1e865:Got a valid
SAP_ME_MSG_START_OKfrom CSME firmwareQuoted 2 lines
That's the only line I am printing by default. I can remove it. I can't do better
than 0 printing.
0 printing would be good.
Quoted 10 lines
Quoted 8 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +6
-0+} + +#else + +static void iwl_mei_dbgfs_register (struct iwl_mei *mei) {}static +void iwl_mei_dbgfs_unregister (struct iwl_mei *mei) {}This type of thing goes in a .h file, you know better.
A header file only for less a handful of functions?
You already have .h files for this code, why not put it in there?
thanks,
greg k-h
Greg KH
maintainerRe: [PATCH RESEND 2/3] iwlwifi: mei: add the driver to allow cooperation with CSME
Quoted 36 lines · Emmanuel
Quoted 36 lines · Emmanuel
Quoted 6 lines
Quoted 6 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 32
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+#define IWL_MEI_DEBUG(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \Huh?
Quoted 6 lines
Quoted 4 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 33
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ dev_dbg(&(c)->dev, f, ## a); \Just use
dev_dbg(), don't be special for a single driver, it hurts when trying to read different drivers.I took this from iwlwifi. I can change if needed, not a big deal.
Please do.
Quoted 10 lines
Quoted 8 lines
Quoted 1 line
+module_param_named(defer_start_message,
defer_start_message,bool,
drivers/net/wireless/intel/iwlwifi/mei/main.c line 65
Quoted 2 lines
+0644); MODULE_PARM_DESC(defer_start_message,
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ "Defer the start message Tx to CSME (default false)");Why do you need this? Who is going to set it to anything else, and why would they? This isn't the 1990's anymore, please do not add new module parameters.
For testing. I need this to be able to force a certain order of initialization
which is possible (and hence must be tested) but not likely to happen.
Quoted 1 line
Another point is tracing. This allows me to load the module but prevent any
real operation. Then, start tracing. This way, I can see the whole flow in tracing, even the very beginning.
Then call this something obvious, "
kernel_hacker_debuging_testing_only_use_if_you_know_what_you_are_doing".
Quoted 8 lines
Quoted 3 lines
Or better yet, just put it in debugfs to turn it on/off and no module parameter is needed at all.
Debugfs is not a replacement for module parameters. Debugfs can be used only after the driver already ran quite a bit of its initialization code path. Here I want to be able to catch the very first messages with tracing.
Then use the proper trace functionality of the kernel, which is not module parameters :(
Quoted 1 line
I'll print an error then. I still didn't understand what's the difference between
BUG_ONandWARN_ONin your eyes.
Neither should be used in new code unless the kernel is so messed up that the only way out is to reboot the machine, as both of them cause that to happen.
thanks,
greg k-h
RE: [PATCH RESEND 2/3] iwlwifi: mei: add the driver to allow cooperation with CSME
Quoted 46 lines · Emmanuel
Quoted 13 lines
Quoted 13 lines · Emmanuel
Quoted 11 lines
Quoted 10 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c line 32
Quoted 3 lines
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +3
-0+#define IWL_MEI_DEBUG(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \Huh?
drivers/net/wireless/intel/iwlwifi/mei/main.c line 33
Quoted 1 line
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1
-0+ dev_dbg(&(c)->dev, f, ## a); \Just use
dev_dbg(), don't be special for a single driver, it hurts when trying to read different drivers.Quoted 5 lines
Quoted 5 lines
Quoted 1 line
I took this from iwlwifi. I can change if needed, not a big deal.
Please do.
Quoted 1 line
Quoted 1 line
Quoted 1 line
+module_param_named(defer_start_message,
defer_start_message,Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
bool,
Review
Quoted 2 lines
+0644); MODULE_PARM_DESC(defer_start_message,
(quoted diff) +1
-0+ "Defer the start message Tx to CSME (defaultfalse)");
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Why do you need this? Who is going to set it to anything else, and why would they? This isn't the 1990's anymore, please do not add new module parameters.
For testing. I need this to be able to force a certain order of initialization
Quoted 8 lines
Quoted 8 lines
which is possible (and hence must be tested) but not likely to happen.
Quoted 2 lines
Another point is tracing. This allows me to load the module but prevent any
real operation. Then, start tracing. This way, I can see the whole flow in tracing, even the very beginning.
Then call this something obvious,
"
kernel_hacker_debuging_testing_only_use_if_you_know_what_you_are_Quoted 6 lines
Quoted 5 lines
doing".
Or better yet, just put it in debugfs to turn it on/off and no module parameter is needed at all.
Quoted 7 lines
Quoted 4 lines
Debugfs is not a replacement for module parameters. Debugfs can be used only after the driver already ran quite a bit of its initialization code path. Here I want to be able to catch the very first messages with tracing.
Then use the proper trace functionality of the kernel, which is not module parameters :(
I am sorry if I drive you nuts but I don't know any "proper trace functionality" in the kernel that the user could enable / disable and that would be available immediately at init. The user needs to "activate" the trace points using trace-cmd or whatever other tool. By the time the user does so, the driver has already run the code path I wish to debug. I can use debug prints, but you didn't seem happy about it. So I am happy to use tracing, but then we need to make sure it cover all the cases. The way I make it cover all the cases is with this module parameter. If you know a better way, I'll be happy to use it.
Greg KH
maintainerRe: [PATCH RESEND 2/3] iwlwifi: mei: add the driver to allow cooperation with CSME
Quoted 51 lines · Emmanuel
Quoted 51 lines · Emmanuel
Quoted 13 lines
Quoted 13 lines · Emmanuel
Quoted 11 lines
Quoted 10 lines
Review
Quoted 3 lines
(quoted diff) +3
-0+#define IWL_MEI_DEBUG(c, f, a...) \ + do { \ + CHECK_FOR_NEWLINE(f); \Huh?
Review
Quoted 1 line
(quoted diff) +1
-0+ dev_dbg(&(c)->dev, f, ## a); \Just use
dev_dbg(), don't be special for a single driver, it hurts when trying to read different drivers.Quoted 5 lines
Quoted 5 lines
Quoted 1 line
I took this from iwlwifi. I can change if needed, not a big deal.
Please do.
Quoted 1 line
Quoted 1 line
Quoted 1 line
+module_param_named(defer_start_message,
defer_start_message,Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
Quoted 3 lines
bool,
Review
Quoted 2 lines
+0644); MODULE_PARM_DESC(defer_start_message,
(quoted diff) +1
-0+ "Defer the start message Tx to CSME (defaultfalse)");
Quoted 7 lines
Quoted 7 lines
Quoted 7 lines
Quoted 4 lines
Why do you need this? Who is going to set it to anything else, and why would they? This isn't the 1990's anymore, please do not add new module parameters.
For testing. I need this to be able to force a certain order of initialization
Quoted 8 lines
Quoted 8 lines
which is possible (and hence must be tested) but not likely to happen.
Quoted 2 lines
Another point is tracing. This allows me to load the module but prevent any
real operation. Then, start tracing. This way, I can see the whole flow in tracing, even the very beginning.
Then call this something obvious,
"
kernel_hacker_debuging_testing_only_use_if_you_know_what_you_are_Quoted 10 lines
Quoted 5 lines
doing".
Or better yet, just put it in debugfs to turn it on/off and no module parameter is needed at all.
Debugfs is not a replacement for module parameters. Debugfs can be used only after the driver already ran quite a bit of its initialization code path. Here I want to be able to catch the very first messages with tracing.
Quoted 6 lines
Quoted 2 lines
Then use the proper trace functionality of the kernel, which is not module parameters :(
I am sorry if I drive you nuts but I don't know any "proper trace functionality" in the kernel that the user could enable / disable and that would be available immediately at init.
The in-kernel trace facilities do not work for boot code? Documentation/tracing/boottime-trace.rst seems to disagree :)
Quoted 8 lines
The user needs to
"activate" the trace points using trace-cmd or whatever other tool. By the time the user does so, the driver has already run the code path I wish to debug. I can use debug prints, but you didn't seem happy about it. So I am happy to use tracing, but then we need to make sure it cover all the cases. The way I make it cover all the cases is with this module parameter. If you know a better way, I'll be happy to use it.
See the above document, there's nothing "special" about a single kernel driver that should warrant a one-off user/kernel api like this.
thanks,
greg k-h
PATCH RESEND 3/3 iwlwifi: integrate with iwlmei
In reply to Emmanuel GrumbachThis allows to cooperate with iwlmei.
--- .../wireless/intel/iwlwifi/iwl-nvm-parse.c | 61 ++++++ .../wireless/intel/iwlwifi/iwl-nvm-parse.h | 11 +- .../net/wireless/intel/iwlwifi/iwl-trans.h | 2 + drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 3 +- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 42 +++- drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 70 ++++++ drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 205 +++++++++++++++++- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 7 +- drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 25 +++ .../net/wireless/intel/iwlwifi/pcie/trans.c | 16 +- 10 files changed, 423 insertions(+), 19 deletions(-)
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +61 -0
@@ -22,6 +22,7 @@#include "fw/api/commands.h" #include "fw/api/cmdhdr.h" #include "fw/img.h" +#include "mei/iwl-mei.h" /* NVM offsets (in words) definitions */ enum nvm_offsets {
@@ -1060,6 +1061,66 @@ iwl_nvm_no_wide_in_5ghz(struct iwl_trans *trans, const struct iwl_cfg *cfg,return false; } +struct iwl_nvm_data * +iwl_parse_mei_nvm_data (struct iwl_trans *trans,const struct iwl_cfg *cfg, +const struct iwl_mei_nvm *mei_nvm, +const struct iwl_fw *fw) +{ +struct iwl_nvm_data *data; +u32 sbands_flags =0 ; +u8 rx_chains = fw->valid_rx_ant; +u8 tx_chains = fw->valid_rx_ant; + +if (cfg->uhb_supported) + data =kzalloc (struct_size (data, channels, +IWL_NVM_NUM_CHANNELS_UHB ), +GFP_KERNEL ); +else + data =kzalloc (struct_size (data, channels, +IWL_NVM_NUM_CHANNELS_EXT ), +GFP_KERNEL ); +if (!data) +return NULL ; + +BUILD_BUG_ON (ARRAY_SIZE (mei_nvm->channels) != +IWL_NVM_NUM_CHANNELS_UHB ); + data->nvm_version = mei_nvm->nvm_version; + +iwl_set_radio_cfg (cfg, data, mei_nvm->radio_cfg); +if (data->valid_tx_ant) + tx_chains &= data->valid_tx_ant; +if (data->valid_rx_ant) + rx_chains &= data->valid_rx_ant; + + data->sku_cap_mimo_disabled = false; + data->sku_cap_band_24ghz_enable = true; + data->sku_cap_band_52ghz_enable = true; + data->sku_cap_11n_enable = + !(iwlwifi_mod_params.disable_11n &IWL_DISABLE_HT_ALL ); + data->sku_cap_11ac_enable = true; + data->sku_cap_11ax_enable = + mei_nvm->caps &MEI_NVM_CAPS_11AX_SUPPORT ; + + data->lar_enabled = mei_nvm->caps &MEI_NVM_CAPS_LARI_SUPPORT ; + + data->n_hw_addrs = mei_nvm->n_hw_addrs; +/* If no valid mac address was found - bail out */ +if (iwl_set_hw_address (trans, cfg, data,NULL ,NULL )) { +kfree (data); +return NULL ; + } + +if (data->lar_enabled && +fw_has_capa (&fw->ucode_capa,IWL_UCODE_TLV_CAPA_LAR_SUPPORT )) + sbands_flags |=IWL_NVM_SBANDS_FLAGS_LAR ; + +iwl_init_sbands (trans, data, mei_nvm->channels, tx_chains, rx_chains, + sbands_flags, true); + +return data; +} +IWL_EXPORT_SYMBOL (iwl_parse_mei_nvm_data); +struct iwl_nvm_data * iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, const struct iwl_fw *fw,
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h +10 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* -* Copyright (C) 2005-2015, 2018-2020 Intel Corporation +* Copyright (C) 2005-2015, 2018-2021 Intel Corporation * Copyright (C) 2016-2017 Intel Deutschland GmbH */ #ifndef __iwl_nvm_parse_h__
@@ -8,6 +8,7 @@#include <net/cfg80211.h> #include "iwl-eeprom-parse.h" +#include "mei/iwl-mei.h" /** * enum iwl_nvm_sbands_flags - modification flags for the channel profiles
@@ -81,4 +82,12 @@ void iwl_nvm_fixups(u32 hw_id, unsigned int section, u8 *data,struct iwl_nvm_data *iwl_get_nvm (struct iwl_trans *trans,const struct iwl_fw *fw); +/** +* iwl_parse_mei_nvm_data - parse the mei_nvm_data and get an iwl_nvm_data +*/ +struct iwl_nvm_data * +iwl_parse_mei_nvm_data (struct iwl_trans *trans,const struct iwl_cfg *cfg, +const struct iwl_mei_nvm *mei_nvm, +const struct iwl_fw *fw); +#endif /* __iwl_nvm_parse_h__ */
drivers/net/wireless/intel/iwlwifi/iwl-trans.h +2 -0
@@ -902,6 +902,7 @@ struct iwl_trans_txqs {/** * struct iwl_trans - transport common data * +* @csme_own - true if we couldn't get ownership on the device * @ops - pointer to iwl_trans_ops * @op_mode - pointer to the op_mode * @trans_cfg: the trans-specific configuration part
@@ -936,6 +937,7 @@ struct iwl_trans_txqs {* @iwl_trans_txqs: transport tx queues data. */ struct iwl_trans { +bool csme_own;const struct iwl_trans_ops *ops;struct iwl_op_mode *op_mode;const struct iwl_cfg_trans_params *trans_cfg;
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +2 -1
@@ -796,6 +796,8 @@ int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b)if (ret)return ret; +iwl_mei_set_power_limit (per_chain); +IWL_DEBUG_RADIO (mvm,"Sending REDUCE_TX_POWER_CMD per chain\n" );return iwl_mvm_send_cmd_pdu (mvm,REDUCE_TX_POWER_CMD ,0 , len, &cmd); }
@@ -1392,7 +1394,6 @@ static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm)if (iwl_mvm_has_unified_ucode (mvm))return iwl_run_unified_mvm_ucode (mvm); -WARN_ON (!mvm->nvm_data); ret =iwl_run_init_mvm_ucode (mvm);if (ret) {
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +40 -2
84 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +70 -0
104 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mvm/ops.c +193 -12
305 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +6 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* -* Copyright (C) 2012-2014, 2018-2020 Intel Corporation +* Copyright (C) 2012-2014, 2018-2021 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2016-2017 Intel Deutschland GmbH */
@@ -1117,6 +1117,11 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,/* From now on, we cannot access info->control */ iwl_mvm_skb_prepare_status (skb, dev_cmd); +if (ieee80211_is_data (fc)) +iwl_mvm_mei_tx_copy_to_csme (mvm, skb, + info->control.hw_key ? + info->control.hw_key->iv_len :0 ); +if (iwl_trans_tx (mvm->trans, skb, dev_cmd, txq_id)) goto drop_unlock_sta;
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +25 -0
@@ -1073,6 +1073,27 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) trans_pcie =IWL_TRANS_GET_PCIE_TRANS (iwl_trans); +/* +* Let's try to grab NIC access early here. Sometimes, NICs may +* fail to initialize, and if that happens it's better if we see +* issues early on (and can reprobe, per the logic inside), than +* first trying to load the firmware etc. and potentially only +* detecting any problems when the first interface is brought up. +*/ + ret =iwl_pcie_prepare_card_hw (iwl_trans); +if (!ret) { + ret =iwl_finish_nic_init (iwl_trans, trans); +if (ret) + goto out_free_trans; +if (iwl_trans_grab_nic_access (iwl_trans)) { +/* all good */ +iwl_trans_release_nic_access (iwl_trans); + }else { + ret = -EIO ; + goto out_free_trans; + } + } + iwl_trans->hw_rf_id =iwl_read32 (iwl_trans,CSR_HW_RF_ID );for (i =0 ; i <ARRAY_SIZE (iwl_dev_info_table); i++) {
@@ -1198,6 +1219,10 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) }pci_set_drvdata (pdev, iwl_trans); + +/* try to get ownership so that we'll know if we don't own it */ +iwl_pcie_prepare_card_hw (iwl_trans); + iwl_trans->drv =iwl_drv_start (iwl_trans);if (IS_ERR (iwl_trans->drv)) {
drivers/net/wireless/intel/iwlwifi/pcie/trans.c +14 -2
@@ -24,6 +24,7 @@#include "fw/error-dump.h" #include "fw/dbg.h" #include "fw/api/tx.h" +#include "mei/iwl-mei.h" #include "internal.h" #include "iwl-fh.h" #include "iwl-context-info-gen3.h"
@@ -576,8 +577,10 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) ret =iwl_pcie_set_hw_ready (trans);/* If the card is ready, exit 0 */ -if (ret >=0 ) +if (ret >=0 ) { + trans->csme_own = false;return 0 ; + }iwl_set_bit (trans,CSR_DBG_LINK_PWR_MGMT_REG ,CSR_RESET_LINK_PWR_MGMT_DISABLED );
@@ -590,8 +593,17 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) do { ret = iwl_pcie_set_hw_ready(trans); - if (ret >= 0) + if (ret >= 0) { + trans->csme_own = false; return 0; + } + + if (iwl_mei_is_connected()) { + IWL_WARN(trans, + "Couldn't prepare the card but SAP is connected\n"); + trans->csme_own = true; + return -EBUSY; + } usleep_range(200, 1000); t += 200;
Signature · 1 line
2.25.1
Greg KH
maintainerRe: [PATCH RESEND 3/3] iwlwifi: integrate with iwlmei
Quoted 1 line · Emmanuel Grumbach
This allows to cooperate with iwlmei.
This changelog text says nothing that helps anyone reading this patch :(
kernel test robot
build botRe: [PATCH RESEND 3/3] iwlwifi: integrate with iwlmei
In reply to Emmanuel GrumbachThank you for the patch! Yet something to improve:
Hi Emmanuel,
Thank you for the patch! Yet something to improve:
[auto build test ERROR on wireless-drivers-next/master]
[also build test ERROR on wireless-drivers/master char-misc/char-misc-testing v5.12-rc7 next-20210412] [If your patch is applied to the wrong git tree, kindly drop us a note.
And when submitting patch, we suggest to use '--base' as documented in
https://git-scm.com/docs/git-format-patch]
url: https://github.com/0day-ci/linux/commits/Emmanuel-Grumbach/mei-bus-add-client-dma-interface/20210412-204450 base: https://git.kernel.org/pub/scm/linux/kernel/git/kvalo/wireless-drivers-next.git master config: arc-allyesconfig (attached as .config) compiler: arceb-elf-gcc (GCC) 9.3.0
reproduce (this is a W=1 build):
wget https://raw.githubusercontent.com/intel/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross chmod +x ~/bin/make.cross
# https://github.com/0day-ci/linux/commit/282793cf36fcc2c1b65dd2ca6ba4abc0cff126ac
git remote add linux-review https://github.com/0day-ci/linux
git fetch --no-tags linux-review Emmanuel-Grumbach/mei-bus-add-client-dma-interface/20210412-204450 git checkout 282793cf36fcc2c1b65dd2ca6ba4abc0cff126ac
# save the attached .config to linux build tree
COMPILER_INSTALL_PATH=$HOME/0day COMPILER=gcc-9.3.0 make.cross ARCH=arc
If you fix the issue, kindly add following tag as appropriate
All errors (new ones prefixed by >>):
drivers/net/wireless/intel/iwlwifi/mvm/ops.c: In function 'iwl_mvm_start_post_nvm':
>> drivers/net/wireless/intel/iwlwifi/mvm/ops.c:715:2: error: implicit declaration of function 'wiphy_rfkill_set_hw_state_reason'; did you mean 'wiphy_rfkill_set_hw_state'? [-Werror=implicit-function-declaration]
715 | wiphy_rfkill_set_hw_state_reason(mvm->hw->wiphy,
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
| wiphy_rfkill_set_hw_state
>> drivers/net/wireless/intel/iwlwifi/mvm/ops.c:717:7: error: 'RFKILL_HARD_BLOCK_NOT_OWNER' undeclared (first use in this function)
717 | RFKILL_HARD_BLOCK_NOT_OWNER);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~
drivers/net/wireless/intel/iwlwifi/mvm/ops.c:717:7: note: each undeclared identifier is reported only once for each function it appears in
drivers/net/wireless/intel/iwlwifi/mvm/ops.c: In function 'iwl_mvm_mei_rfkill':
drivers/net/wireless/intel/iwlwifi/mvm/ops.c:754:7: error: 'RFKILL_HARD_BLOCK_NOT_OWNER' undeclared (first use in this function)
754 | RFKILL_HARD_BLOCK_NOT_OWNER);
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~cc1: some warnings being treated as errors
vim +715 drivers/net/wireless/intel/iwlwifi/mvm/ops.c
699
700 static int iwl_mvm_start_post_nvm(struct iwl_mvm *mvm)
701 {
702 struct iwl_mvm_csme_conn_info *csme_conn_info __maybe_unused;
703 int ret;
704
705 iwl_mvm_toggle_tx_ant(mvm, &mvm->mgmt_last_antenna_idx);
706
707 ret = iwl_mvm_mac_setup_register(mvm);
708 if (ret)
709 return ret;
710
711 mvm->hw_registered = true;
712
713 iwl_mvm_dbgfs_register(mvm);
714
> 715 wiphy_rfkill_set_hw_state_reason(mvm->hw->wiphy, 716 mvm->mei_rfkill_blocked, > 717 RFKILL_HARD_BLOCK_NOT_OWNER);
718 return 0;
719 }
720
---
0-DAY CI Kernel Test Service, Intel Corporation
https://lists.01.org/hyperkitty/list/kbuild-all(a)lists.01.org
Greg KH
maintainerQuoted 14 lines · Emmanuel Grumbach
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface. The client dma has to be mapped before the device is enabled, therefore we need to create device linking already during mapping and we need to unmap after the client is disable hence we need to postpone the unlink and flush till unmapping or when destroying the device.
Signed-off-by Alexander Usyskin <[email protected]>Co-developed-by Tomas Winkler <[email protected]>Signed-off-by Tomas Winkler <[email protected]>Signed-off-by Emmanuel Grumbach <[email protected]>Signed-off-by Luca Coelho <[email protected]>
Quoted 7 lines
---
This is a another version of the patch:
https://lore.kernel.org/lkml/[email protected]/Greg asked to route this patch through the wireless drivers tree:
https://lore.kernel.org/lkml/[email protected]/
So here it is.
Patch 2 still needs loads of work, so NAK on this getting merged through any tree at the moment.
thanks,
greg k-h
PATCH v2 1/3 mei: bus: add client dma interface
In reply to Emmanuel GrumbachFrom: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface. The client dma has to be mapped before the device is enabled, therefore we need to create device linking already during mapping and we need to unmap after the client is disable hence we need to postpone the unlink and flush till unmapping or when destroying the device.
---
This is a another version of the patch:
https://lore.kernel.org/lkml/[email protected]/
Greg asked to route this patch through the wireless drivers tree:
https://lore.kernel.org/lkml/[email protected]/
So here it is.
---
--- drivers/misc/mei/bus.c | 67 ++++++++++++++++++++++++++++++++++++-- drivers/misc/mei/client.c | 3 ++ drivers/misc/mei/hw.h | 5 +++ include/linux/mei_cl_bus.h | 3 ++ 4 files changed, 75 insertions(+), 3 deletions(-)
drivers/misc/mei/bus.c +64 -3
@@ -643,6 +643,64 @@ static void mei_cl_bus_vtag_free(struct mei_cl_device *cldev)kfree (cl_vtag); } +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 buffer_id,size_t size) +{ +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev || !buffer_id || !size) +return ERR_PTR (-EINVAL ); + +if (!IS_ALIGNED (size,MEI_FW_PAGE_SIZE )) { +dev_err (&cldev->dev,"Map size should be aligned to %lu\n" , +MEI_FW_PAGE_SIZE ); +return ERR_PTR (-EINVAL ); + } + + cl = cldev->cl; + bus = cldev->bus; + +mutex_lock (&bus->device_lock); +if (cl->state ==MEI_FILE_UNINITIALIZED ) { + ret =mei_cl_link (cl); +if (ret) + goto out; +/* update pointers */ + cl->cldev = cldev; + } + + ret =mei_cl_dma_alloc_and_map (cl,NULL , buffer_id, size); +out: +mutex_unlock (&bus->device_lock); +if (ret) +return ERR_PTR (ret); +return cl->dma.vaddr; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_map); + +int mei_cldev_dma_unmap (struct mei_cl_device *cldev) +{ +struct mei_device *bus; +struct mei_cl *cl; +int ret; + +if (!cldev) +return -EINVAL ; + + cl = cldev->cl; + bus = cldev->bus; + +mutex_lock (&bus->device_lock); + ret =mei_cl_dma_unmap (cl,NULL ); + +mei_cl_flush_queues (cl,NULL ); +mei_cl_unlink (cl); +mutex_unlock (&bus->device_lock); +return ret; +} +EXPORT_SYMBOL_GPL (mei_cldev_dma_unmap); +/** * mei_cldev_enable - enable me client device * create connection with me client
@@ -753,9 +811,11 @@ int mei_cldev_disable(struct mei_cl_device *cldev)dev_err (bus->dev,"Could not disconnect from the ME client\n" ); out: -/* Flush queues and remove any pending read */ -mei_cl_flush_queues (cl,NULL ); -mei_cl_unlink (cl); +/* Flush queues and remove any pending read unless we have mapped DMA */ +if (!cl->dma_mapped) { +mei_cl_flush_queues (cl,NULL ); +mei_cl_unlink (cl); + }mutex_unlock (&bus->device_lock);return err;
@@ -1054,6 +1114,7 @@ static void mei_cl_bus_dev_release(struct device *dev)if (!cldev)return ; +mei_cl_flush_queues (cldev->cl,NULL );mei_me_cl_put (cldev->me_cl);mei_dev_bus_put (cldev->bus);mei_cl_unlink (cldev->cl);
drivers/misc/mei/client.c +3 -0
@@ -700,6 +700,9 @@ int mei_cl_unlink(struct mei_cl *cl)cl_dbg (dev, cl,"unlink client" ); +if (cl->state ==MEI_FILE_UNINITIALIZED ) +return 0 ; +if (dev->open_handle_count >0 ) dev->open_handle_count--;
drivers/misc/mei/hw.h +5 -0
@@ -22,6 +22,11 @@#define MEI_D0I3_TIMEOUT 5/* D0i3 set/unset max response time */ #define MEI_HBM_TIMEOUT 1/* 1 second */ +/* +* FW page size for DMA allocations +*/ +#define MEI_FW_PAGE_SIZE 4096UL +/* * MEI Version */
include/linux/mei_cl_bus.h +3 -0
@@ -116,4 +116,7 @@ int mei_cldev_enable(struct mei_cl_device *cldev);int mei_cldev_disable (struct mei_cl_device *cldev);bool mei_cldev_enabled (struct mei_cl_device *cldev); +void *mei_cldev_dma_map (struct mei_cl_device *cldev,u8 buffer_id,size_t size); +int mei_cldev_dma_unmap (struct mei_cl_device *cldev); +#endif /* _LINUX_MEI_CL_BUS_H */
Signature · 1 line
2.25.1
PATCH v2 2/3 iwlwifi: mei: add the driver to allow cooperation with CSME
iwlmei is a driver that handles the communication with the Wireless driver of the CSME firmware.
More details in the documentation included in this patch.
---
v2:
* relicense to GPL only
* rewrite the Kconfig description
* Remove all WARN_ONs and replace them by dev_err
* drop the IWL_MEI_* macros
* drop the module parameter
* drop ifdef DEBUGFS clauses
* drop most debug prints
* drop iwl_mei_handle_nic_owner since it only included a debug print
* drop the ping debugfs hook
--- drivers/net/wireless/intel/iwlwifi/Kconfig | 16 + drivers/net/wireless/intel/iwlwifi/Makefile | 1 + .../net/wireless/intel/iwlwifi/mei/Makefile | 8 + .../net/wireless/intel/iwlwifi/mei/internal.h | 20 + .../net/wireless/intel/iwlwifi/mei/iwl-mei.h | 440 ++++ drivers/net/wireless/intel/iwlwifi/mei/main.c | 1960 +++++++++++++++++ drivers/net/wireless/intel/iwlwifi/mei/net.c | 409 ++++ drivers/net/wireless/intel/iwlwifi/mei/sap.h | 736 +++++++ .../wireless/intel/iwlwifi/mei/trace-data.h | 69 + .../net/wireless/intel/iwlwifi/mei/trace.c | 15 + .../net/wireless/intel/iwlwifi/mei/trace.h | 62 + 11 files changed, 3736 insertions(+) create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/Makefile create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/internal.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/main.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/net.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/sap.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace-data.h create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.c create mode 100644 drivers/net/wireless/intel/iwlwifi/mei/trace.h
drivers/net/wireless/intel/iwlwifi/Kconfig +16 -0
@@ -92,6 +92,22 @@ config IWLWIFI_BCAST_FILTERING If unsure, don't enable this option, as some programs might expect incoming broadcasts for their normal operations. +config IWLMEI + tristate "Intel Management Engine communication over WLAN" + depends on INTEL_MEI + depends on IWLMVM + help + Enables the iwlmei kernel module. This allows to communicate with + the Intel Management Engine over Wifi. This is supported starting + from Tiger Lake platforms and has been tested on 9260 devices only. + Enabling this option on a platform that has a different device and + has Wireless enabled on AMT can prevent WiFi from working correctly. + + For more information see + <https://software.intel.com/en-us/manageability/> + + If unsure, say N. + menu "Debugging Options" config IWLWIFI_DEBUG
drivers/net/wireless/intel/iwlwifi/Makefile +1 -0
@@ -29,5 +29,6 @@ ccflags-y += -I$(src) obj-$(CONFIG_IWLDVM) += dvm/ obj-$(CONFIG_IWLMVM) += mvm/ +obj-$(CONFIG_IWLMEI) += mei/ CFLAGS_iwl-devtrace.o := -I$(src)
drivers/net/wireless/intel/iwlwifi/mei/Makefile new file +8 -0
@@ -0,0 +1,8 @@ +# SPDX-License-Identifier: GPL-2.0 +obj-$(CONFIG_IWLMEI) += iwlmei.o +iwlmei-y += main.o +iwlmei-y += net.o +iwlmei-$(CONFIG_IWLWIFI_DEVICE_TRACING) += trace.o +CFLAGS_trace.o := -I$(src) + +ccflags-y += -I$(src)/../
drivers/net/wireless/intel/iwlwifi/mei/internal.h new file +20 -0
@@ -0,0 +1,20 @@ +// SPDX-License-Identifier: GPL-2.0 +/* +* Copyright (C) 2021 Intel Corporation +*/ + +#ifndef __IWLMEI_INTERNAL_H_ +#define __IWLMEI_INTERNAL_H_ + +#include <uapi/linux/if_ether.h> +#include <linux/netdevice.h> + +#include "sap.h" + +rx_handler_result_t iwl_mei_rx_filter (struct sk_buff *skb, +const struct iwl_sap_oob_filters *filters, +bool *pass_to_csme); + +void iwl_mei_add_data_to_ring (struct sk_buff *skb,bool cb_tx); + +#endif /* __IWLMEI_INTERNAL_H_ */
drivers/net/wireless/intel/iwlwifi/mei/iwl-mei.h new file +440 -0
440 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/main.c new file +1960 -0
1,960 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/net.c new file +409 -0
409 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/sap.h new file +736 -0
135 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/trace-data.h new file +69 -0
69 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mei/trace.c new file +15 -0
Lines of this file are not shown. View the raw message.
drivers/net/wireless/intel/iwlwifi/mei/trace.h new file +62 -0
62 lines not on this page · raw message
The rest of this diff is not shown. View the raw message.
Signature · 1 line
2.25.1
Part of the diff is not shown here. View the raw message.
Greg KH
maintainerRe: [PATCH v2 2/3] iwlwifi: mei: add the driver to allow cooperation with CSME
Quoted 1 line · Emmanuel Grumbach
+#define
ROUND_UP_TO(x, y)(((x) + (y) - 1) / (y) * (y))
What's wrong with roundup() that the kernel provides?
Please don't reinvent things we already have :(
thanks,
greg k-h
PATCH v2 3/3 iwlwifi: integrate with iwlmei
In reply to Emmanuel Grumbachiwlmei needs to know about the follwing events:
* Association
* De-association
* Country Code change
* SW Rfkill change
* SAR table changes
iwlmei can take the device away from us, so report the new rfkill type when this happens.
Advertise the required data from the CSME firmware to the
usersapce: mostly, the AP that the CSME firmware is currently associated to in case there is an active link protection session.
--- .../wireless/intel/iwlwifi/iwl-nvm-parse.c | 61 ++++++ .../wireless/intel/iwlwifi/iwl-nvm-parse.h | 11 +- .../net/wireless/intel/iwlwifi/iwl-trans.h | 2 + drivers/net/wireless/intel/iwlwifi/mvm/fw.c | 3 +- .../net/wireless/intel/iwlwifi/mvm/mac80211.c | 42 +++- drivers/net/wireless/intel/iwlwifi/mvm/mvm.h | 70 ++++++ drivers/net/wireless/intel/iwlwifi/mvm/ops.c | 205 +++++++++++++++++- drivers/net/wireless/intel/iwlwifi/mvm/tx.c | 7 +- drivers/net/wireless/intel/iwlwifi/pcie/drv.c | 25 +++ .../net/wireless/intel/iwlwifi/pcie/trans.c | 16 +- 10 files changed, 423 insertions(+), 19 deletions(-)
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.c +61 -0
@@ -22,6 +22,7 @@#include "fw/api/commands.h" #include "fw/api/cmdhdr.h" #include "fw/img.h" +#include "mei/iwl-mei.h" /* NVM offsets (in words) definitions */ enum nvm_offsets {
@@ -1060,6 +1061,66 @@ iwl_nvm_no_wide_in_5ghz(struct iwl_trans *trans, const struct iwl_cfg *cfg,return false; } +struct iwl_nvm_data * +iwl_parse_mei_nvm_data (struct iwl_trans *trans,const struct iwl_cfg *cfg, +const struct iwl_mei_nvm *mei_nvm, +const struct iwl_fw *fw) +{ +struct iwl_nvm_data *data; +u32 sbands_flags =0 ; +u8 rx_chains = fw->valid_rx_ant; +u8 tx_chains = fw->valid_rx_ant; + +if (cfg->uhb_supported) + data =kzalloc (struct_size (data, channels, +IWL_NVM_NUM_CHANNELS_UHB ), +GFP_KERNEL ); +else + data =kzalloc (struct_size (data, channels, +IWL_NVM_NUM_CHANNELS_EXT ), +GFP_KERNEL ); +if (!data) +return NULL ; + +BUILD_BUG_ON (ARRAY_SIZE (mei_nvm->channels) != +IWL_NVM_NUM_CHANNELS_UHB ); + data->nvm_version = mei_nvm->nvm_version; + +iwl_set_radio_cfg (cfg, data, mei_nvm->radio_cfg); +if (data->valid_tx_ant) + tx_chains &= data->valid_tx_ant; +if (data->valid_rx_ant) + rx_chains &= data->valid_rx_ant; + + data->sku_cap_mimo_disabled = false; + data->sku_cap_band_24ghz_enable = true; + data->sku_cap_band_52ghz_enable = true; + data->sku_cap_11n_enable = + !(iwlwifi_mod_params.disable_11n &IWL_DISABLE_HT_ALL ); + data->sku_cap_11ac_enable = true; + data->sku_cap_11ax_enable = + mei_nvm->caps &MEI_NVM_CAPS_11AX_SUPPORT ; + + data->lar_enabled = mei_nvm->caps &MEI_NVM_CAPS_LARI_SUPPORT ; + + data->n_hw_addrs = mei_nvm->n_hw_addrs; +/* If no valid mac address was found - bail out */ +if (iwl_set_hw_address (trans, cfg, data,NULL ,NULL )) { +kfree (data); +return NULL ; + } + +if (data->lar_enabled && +fw_has_capa (&fw->ucode_capa,IWL_UCODE_TLV_CAPA_LAR_SUPPORT )) + sbands_flags |=IWL_NVM_SBANDS_FLAGS_LAR ; + +iwl_init_sbands (trans, data, mei_nvm->channels, tx_chains, rx_chains, + sbands_flags, true); + +return data; +} +IWL_EXPORT_SYMBOL (iwl_parse_mei_nvm_data); +struct iwl_nvm_data * iwl_parse_nvm_data(struct iwl_trans *trans, const struct iwl_cfg *cfg, const struct iwl_fw *fw,
drivers/net/wireless/intel/iwlwifi/iwl-nvm-parse.h +10 -1
@@ -1,6 +1,6 @@/* SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause */ /* -* Copyright (C) 2005-2015, 2018-2020 Intel Corporation +* Copyright (C) 2005-2015, 2018-2021 Intel Corporation * Copyright (C) 2016-2017 Intel Deutschland GmbH */ #ifndef __iwl_nvm_parse_h__
@@ -8,6 +8,7 @@#include <net/cfg80211.h> #include "iwl-eeprom-parse.h" +#include "mei/iwl-mei.h" /** * enum iwl_nvm_sbands_flags - modification flags for the channel profiles
@@ -81,4 +82,12 @@ void iwl_nvm_fixups(u32 hw_id, unsigned int section, u8 *data,struct iwl_nvm_data *iwl_get_nvm (struct iwl_trans *trans,const struct iwl_fw *fw); +/** +* iwl_parse_mei_nvm_data - parse the mei_nvm_data and get an iwl_nvm_data +*/ +struct iwl_nvm_data * +iwl_parse_mei_nvm_data (struct iwl_trans *trans,const struct iwl_cfg *cfg, +const struct iwl_mei_nvm *mei_nvm, +const struct iwl_fw *fw); +#endif /* __iwl_nvm_parse_h__ */
drivers/net/wireless/intel/iwlwifi/iwl-trans.h +2 -0
@@ -902,6 +902,7 @@ struct iwl_trans_txqs {/** * struct iwl_trans - transport common data * +* @csme_own - true if we couldn't get ownership on the device * @ops - pointer to iwl_trans_ops * @op_mode - pointer to the op_mode * @trans_cfg: the trans-specific configuration part
@@ -936,6 +937,7 @@ struct iwl_trans_txqs {* @iwl_trans_txqs: transport tx queues data. */ struct iwl_trans { +bool csme_own;const struct iwl_trans_ops *ops;struct iwl_op_mode *op_mode;const struct iwl_cfg_trans_params *trans_cfg;
drivers/net/wireless/intel/iwlwifi/mvm/fw.c +2 -1
@@ -750,6 +750,8 @@ int iwl_mvm_sar_select_profile(struct iwl_mvm *mvm, int prof_a, int prof_b)if (ret)return ret; +iwl_mei_set_power_limit (per_chain); +IWL_DEBUG_RADIO (mvm,"Sending REDUCE_TX_POWER_CMD per chain\n" );return iwl_mvm_send_cmd_pdu (mvm,REDUCE_TX_POWER_CMD ,0 , len, &cmd); }
@@ -1297,7 +1299,6 @@ static int iwl_mvm_load_rt_fw(struct iwl_mvm *mvm)if (iwl_mvm_has_unified_ucode (mvm))return iwl_run_unified_mvm_ucode (mvm); -WARN_ON (!mvm->nvm_data); ret =iwl_run_init_mvm_ucode (mvm);if (ret) {
drivers/net/wireless/intel/iwlwifi/mvm/mac80211.c +40 -2
84 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mvm/mvm.h +70 -0
104 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mvm/ops.c +193 -12
305 lines not on this page · raw message
drivers/net/wireless/intel/iwlwifi/mvm/tx.c +6 -1
@@ -1,6 +1,6 @@// SPDX-License-Identifier: GPL-2.0 OR BSD-3-Clause /* -* Copyright (C) 2012-2014, 2018-2020 Intel Corporation +* Copyright (C) 2012-2014, 2018-2021 Intel Corporation * Copyright (C) 2013-2015 Intel Mobile Communications GmbH * Copyright (C) 2016-2017 Intel Deutschland GmbH */
@@ -1117,6 +1117,11 @@ static int iwl_mvm_tx_mpdu(struct iwl_mvm *mvm, struct sk_buff *skb,/* From now on, we cannot access info->control */ iwl_mvm_skb_prepare_status (skb, dev_cmd); +if (ieee80211_is_data (fc)) +iwl_mvm_mei_tx_copy_to_csme (mvm, skb, + info->control.hw_key ? + info->control.hw_key->iv_len :0 ); +if (iwl_trans_tx (mvm->trans, skb, dev_cmd, txq_id)) goto drop_unlock_sta;
drivers/net/wireless/intel/iwlwifi/pcie/drv.c +25 -0
@@ -1144,6 +1144,27 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) trans_pcie =IWL_TRANS_GET_PCIE_TRANS (iwl_trans); +/* +* Let's try to grab NIC access early here. Sometimes, NICs may +* fail to initialize, and if that happens it's better if we see +* issues early on (and can reprobe, per the logic inside), than +* first trying to load the firmware etc. and potentially only +* detecting any problems when the first interface is brought up. +*/ + ret =iwl_pcie_prepare_card_hw (iwl_trans); +if (!ret) { + ret =iwl_finish_nic_init (iwl_trans, trans); +if (ret) + goto out_free_trans; +if (iwl_trans_grab_nic_access (iwl_trans)) { +/* all good */ +iwl_trans_release_nic_access (iwl_trans); + }else { + ret = -EIO ; + goto out_free_trans; + } + } + iwl_trans->hw_rf_id =iwl_read32 (iwl_trans,CSR_HW_RF_ID );for (i =0 ; i <ARRAY_SIZE (iwl_dev_info_table); i++) {
@@ -1281,6 +1302,10 @@ static int iwl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) goto out_free_trans;pci_set_drvdata (pdev, iwl_trans); + +/* try to get ownership so that we'll know if we don't own it */ +iwl_pcie_prepare_card_hw (iwl_trans); + iwl_trans->drv =iwl_drv_start (iwl_trans);if (IS_ERR (iwl_trans->drv)) {
drivers/net/wireless/intel/iwlwifi/pcie/trans.c +14 -2
@@ -24,6 +24,7 @@#include "fw/error-dump.h" #include "fw/dbg.h" #include "fw/api/tx.h" +#include "mei/iwl-mei.h" #include "internal.h" #include "iwl-fh.h" #include "iwl-context-info-gen3.h"
@@ -576,8 +577,10 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) ret =iwl_pcie_set_hw_ready (trans);/* If the card is ready, exit 0 */ -if (ret >=0 ) +if (ret >=0 ) { + trans->csme_own = false;return 0 ; + }iwl_set_bit (trans,CSR_DBG_LINK_PWR_MGMT_REG ,CSR_RESET_LINK_PWR_MGMT_DISABLED );
@@ -590,8 +593,17 @@ int iwl_pcie_prepare_card_hw(struct iwl_trans *trans) do { ret = iwl_pcie_set_hw_ready(trans); - if (ret >= 0) + if (ret >= 0) { + trans->csme_own = false; return 0; + } + + if (iwl_mei_is_connected()) { + IWL_WARN(trans, + "Couldn't prepare the card but SAP is connected\n"); + trans->csme_own = true; + return -EBUSY; + } usleep_range(200, 1000); t += 200;
Signature · 1 line
2.25.1
Hi Greg,
Quoted 15 lines · Emmanuel Grumbach
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface. The client dma has to be mapped before the device is enabled, therefore we need to create device linking already during mapping and we need to unmap after the client is disable hence we need to postpone the unlink and flush till unmapping or when destroying the device.
Signed-off-by Alexander Usyskin <[email protected]>Co-developed-by Tomas Winkler <[email protected]>Signed-off-by Tomas Winkler <[email protected]>Signed-off-by Emmanuel Grumbach <[email protected]>Signed-off-by Luca Coelho <[email protected]>
Quoted 8 lines
---
This is a another version of the patch:
https://lore.kernel.org/lkml/[email protected]/Greg asked to route this patch through the wireless drivers tree:
https://lore.kernel.org/lkml/[email protected]/
So here it is.
---
I think I fixed all the issues you raised on the previous version of the patch. This series has been reviewed internally as well. The merge window is now closed, can we move forward with this?
Thanks.
Greg KH
maintainerQuoted 23 lines · Emmanuel Grumbach
Hi Greg,
Quoted 19 lines · Emmanuel Grumbach
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface. The client dma has to be mapped before the device is enabled, therefore we need to create device linking already during mapping and we need to unmap after the client is disable hence we need to postpone the unlink and flush till unmapping or when destroying the device.
Signed-off-by Alexander Usyskin <[email protected]>Co-developed-by Tomas Winkler <[email protected]>Signed-off-by Tomas Winkler <[email protected]>Signed-off-by Emmanuel Grumbach <[email protected]>Signed-off-by Luca Coelho <[email protected]>---
This is a another version of the patch:
https://lore.kernel.org/lkml/[email protected]/
Quoted 8 lines
Quoted 4 lines
Greg asked to route this patch through the wireless drivers tree:
https://lore.kernel.org/lkml/[email protected]/
So here it is.
---I think I fixed all the issues you raised on the previous version of the patch. This series has been reviewed internally as well. The merge window is now closed, can we move forward with this?
$ mdfrm -c ~/mail/todo/ 1823 messages in /home/gregkh/mail/todo/
Please relax, there is no rush.
greg k-h
Quoted 14 lines · Emmanuel Grumbach
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface. The client dma has to be mapped before the device is enabled, therefore we need to create device linking already during mapping and we need to unmap after the client is disable hence we need to postpone the unlink and flush till unmapping or when destroying the device.
Signed-off-by Alexander Usyskin <[email protected]>Co-developed-by Tomas Winkler <[email protected]>Signed-off-by Tomas Winkler <[email protected]>Signed-off-by Emmanuel Grumbach <[email protected]>Signed-off-by Luca Coelho <[email protected]>
Quoted 7 lines
---
This is a another version of the patch:
https://lore.kernel.org/lkml/[email protected]/Greg asked to route this patch through the wireless drivers tree:
https://lore.kernel.org/lkml/[email protected]/
So here it is.
Quoted 9 lines · Emmanuel Grumbach
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface. The client dma has to be mapped before the device is enabled, therefore we need to create device linking already during mapping and we need to unmap after the client is disable hence we need to postpone the unlink and flush till unmapping or when destroying the device.
Quoted 6 lines
Signed-off-by Alexander Usyskin <[email protected]>Co-developed-by Tomas Winkler <[email protected]>Signed-off-by Tomas Winkler <[email protected]>Signed-off-by Emmanuel Grumbach <[email protected]>Signed-off-by Luca Coelho <[email protected]>
3 patches applied to iwlwifi-next.git, thanks.
d0f2edda1651 iwlwifi: pcie: don't enable BHs with IRQs disabled fc07b83286af mei: bus: add client dma interface09df8fa50be8 iwlwifi: mei: add the driver to allow cooperation with CSME
Quoted 18 lines · Luca Coelho
Quoted 9 lines · Emmanuel Grumbach
From: Alexander Usyskin <[email protected]>
Expose the client dma mapping via mei client bus interface. The client dma has to be mapped before the device is enabled, therefore we need to create device linking already during mapping and we need to unmap after the client is disable hence we need to postpone the unlink and flush till unmapping or when destroying the device.
Quoted 6 lines
Signed-off-by Alexander Usyskin <[email protected]>Co-developed-by Tomas Winkler <[email protected]>Signed-off-by Tomas Winkler <[email protected]>Signed-off-by Emmanuel Grumbach <[email protected]>Signed-off-by Luca Coelho <[email protected]>
Quoted 3 lines
3 patches applied to iwlwifi-next.git, thanks.
d0f2edda1651iwlwifi: pcie: don't enable BHs with IRQs disabled
This came out wrong.
Quoted 2 lines
fc07b83286afmei: bus: add client dma interface09df8fa50be8iwlwifi: mei: add the driver to allow cooperation with CSME
This one was the third commit that was applied:
43d400b75bbf iwlwifi: integrate with iwlmei
--
Cheers,
Luca.