linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry
@ 2018-06-11 21:09 Brian Norris
  2018-06-11 21:09 ` [PATCH 2/4] ath10k: snoc: stop including pci.h Brian Norris
                   ` (4 more replies)
  0 siblings, 5 replies; 6+ messages in thread
From: Brian Norris @ 2018-06-11 21:09 UTC (permalink / raw)
  To: Kalle Valo
  Cc: ath10k, linux-wireless, Govind Singh, linux-kernel, Brian Norris

We're 'ath10k_snoc', not 'ath10k_pci'. This probably means we're
accessing junk data in ath10k_snoc_rx_replenish_retry(), unless
'ath10k_snoc' and 'ath10k_pci' happen to have very similar struct
layouts.

Noticed by inspection.

Fixes: d915105231ca ("ath10k: add hif rx methods for wcn3990")
Signed-off-by: Brian Norris <briannorris@chromium.org>
---
It's possible this would be a for-4.18 target, since the buggy patch is
in the -rc1 merge. But this driver is not fully operational yet. Also,
I'm sending some companion refactorings to help avoid this bug. They
probably aren't 4.18 material.

Let me know if I should do anything differently.

 drivers/net/wireless/ath/ath10k/snoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c
index ee74e0060504..c7cfc9c9b3d7 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -449,7 +449,7 @@ static void ath10k_snoc_htt_rx_cb(struct ath10k_ce_pipe *ce_state)
 
 static void ath10k_snoc_rx_replenish_retry(struct timer_list *t)
 {
-	struct ath10k_pci *ar_snoc = from_timer(ar_snoc, t, rx_post_retry);
+	struct ath10k_snoc *ar_snoc = from_timer(ar_snoc, t, rx_post_retry);
 	struct ath10k *ar = ar_snoc->ar;
 
 	ath10k_snoc_rx_post(ar);
-- 
2.18.0.rc1.242.g61856ae69a-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 2/4] ath10k: snoc: stop including pci.h
  2018-06-11 21:09 [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry Brian Norris
@ 2018-06-11 21:09 ` Brian Norris
  2018-06-11 21:09 ` [PATCH 3/4] ath10k: snoc: drop unused WCN3990_CE_ATTR_FLAGS Brian Norris
                   ` (3 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2018-06-11 21:09 UTC (permalink / raw)
  To: Kalle Valo
  Cc: ath10k, linux-wireless, Govind Singh, linux-kernel, Brian Norris

It's easier to violate abstractions and introduce bugs when snoc.h is
including pci.h. Let's not do that.

I'm not extremely familiar with this driver yet, but several of the
shared PCI/SNOC bits seem to be related to the Copy Engine, so move them
to ce.h.

Signed-off-by: Brian Norris <briannorris@chromium.org>
---
 drivers/net/wireless/ath/ath10k/ce.h   | 42 ++++++++++++++++++++++++++
 drivers/net/wireless/ath/ath10k/pci.h  | 42 --------------------------
 drivers/net/wireless/ath/ath10k/snoc.h |  1 -
 3 files changed, 42 insertions(+), 43 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/ce.h b/drivers/net/wireless/ath/ath10k/ce.h
index dbeffaef6024..b8fb5382dede 100644
--- a/drivers/net/wireless/ath/ath10k/ce.h
+++ b/drivers/net/wireless/ath/ath10k/ce.h
@@ -383,4 +383,46 @@ static inline u32 ath10k_ce_interrupt_summary(struct ath10k *ar)
 		return CE_INTERRUPT_SUMMARY;
 }
 
+/* Host software's Copy Engine configuration. */
+#define CE_ATTR_FLAGS 0
+
+/*
+ * Configuration information for a Copy Engine pipe.
+ * Passed from Host to Target during startup (one per CE).
+ *
+ * NOTE: Structure is shared between Host software and Target firmware!
+ */
+struct ce_pipe_config {
+	__le32 pipenum;
+	__le32 pipedir;
+	__le32 nentries;
+	__le32 nbytes_max;
+	__le32 flags;
+	__le32 reserved;
+};
+
+/*
+ * Directions for interconnect pipe configuration.
+ * These definitions may be used during configuration and are shared
+ * between Host and Target.
+ *
+ * Pipe Directions are relative to the Host, so PIPEDIR_IN means
+ * "coming IN over air through Target to Host" as with a WiFi Rx operation.
+ * Conversely, PIPEDIR_OUT means "going OUT from Host through Target over air"
+ * as with a WiFi Tx operation. This is somewhat awkward for the "middle-man"
+ * Target since things that are "PIPEDIR_OUT" are coming IN to the Target
+ * over the interconnect.
+ */
+#define PIPEDIR_NONE    0
+#define PIPEDIR_IN      1  /* Target-->Host, WiFi Rx direction */
+#define PIPEDIR_OUT     2  /* Host->Target, WiFi Tx direction */
+#define PIPEDIR_INOUT   3  /* bidirectional */
+
+/* Establish a mapping between a service/direction and a pipe. */
+struct service_to_pipe {
+	__le32 service_id;
+	__le32 pipedir;
+	__le32 pipenum;
+};
+
 #endif /* _CE_H_ */
diff --git a/drivers/net/wireless/ath/ath10k/pci.h b/drivers/net/wireless/ath/ath10k/pci.h
index e52fd83156b6..0ed436657108 100644
--- a/drivers/net/wireless/ath/ath10k/pci.h
+++ b/drivers/net/wireless/ath/ath10k/pci.h
@@ -86,48 +86,6 @@ struct pcie_state {
 /* PCIE_CONFIG_FLAG definitions */
 #define PCIE_CONFIG_FLAG_ENABLE_L1  0x0000001
 
-/* Host software's Copy Engine configuration. */
-#define CE_ATTR_FLAGS 0
-
-/*
- * Configuration information for a Copy Engine pipe.
- * Passed from Host to Target during startup (one per CE).
- *
- * NOTE: Structure is shared between Host software and Target firmware!
- */
-struct ce_pipe_config {
-	__le32 pipenum;
-	__le32 pipedir;
-	__le32 nentries;
-	__le32 nbytes_max;
-	__le32 flags;
-	__le32 reserved;
-};
-
-/*
- * Directions for interconnect pipe configuration.
- * These definitions may be used during configuration and are shared
- * between Host and Target.
- *
- * Pipe Directions are relative to the Host, so PIPEDIR_IN means
- * "coming IN over air through Target to Host" as with a WiFi Rx operation.
- * Conversely, PIPEDIR_OUT means "going OUT from Host through Target over air"
- * as with a WiFi Tx operation. This is somewhat awkward for the "middle-man"
- * Target since things that are "PIPEDIR_OUT" are coming IN to the Target
- * over the interconnect.
- */
-#define PIPEDIR_NONE    0
-#define PIPEDIR_IN      1  /* Target-->Host, WiFi Rx direction */
-#define PIPEDIR_OUT     2  /* Host->Target, WiFi Tx direction */
-#define PIPEDIR_INOUT   3  /* bidirectional */
-
-/* Establish a mapping between a service/direction and a pipe. */
-struct service_to_pipe {
-	__le32 service_id;
-	__le32 pipedir;
-	__le32 pipenum;
-};
-
 /* Per-pipe state. */
 struct ath10k_pci_pipe {
 	/* Handle of underlying Copy Engine */
diff --git a/drivers/net/wireless/ath/ath10k/snoc.h b/drivers/net/wireless/ath/ath10k/snoc.h
index 05dc98f46ccd..f9e530189d48 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.h
+++ b/drivers/net/wireless/ath/ath10k/snoc.h
@@ -19,7 +19,6 @@
 
 #include "hw.h"
 #include "ce.h"
-#include "pci.h"
 
 struct ath10k_snoc_drv_priv {
 	enum ath10k_hw_rev hw_rev;
-- 
2.18.0.rc1.242.g61856ae69a-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 3/4] ath10k: snoc: drop unused WCN3990_CE_ATTR_FLAGS
  2018-06-11 21:09 [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry Brian Norris
  2018-06-11 21:09 ` [PATCH 2/4] ath10k: snoc: stop including pci.h Brian Norris
@ 2018-06-11 21:09 ` Brian Norris
  2018-06-11 21:09 ` [PATCH 4/4] ath10k: snoc: sort include files Brian Norris
                   ` (2 subsequent siblings)
  4 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2018-06-11 21:09 UTC (permalink / raw)
  To: Kalle Valo
  Cc: ath10k, linux-wireless, Govind Singh, linux-kernel, Brian Norris

We started using a common CE_ATTR_FLAGS definition, so drop this one.

Signed-off-by: Brian Norris <briannorris@chromium.org>
---
 drivers/net/wireless/ath/ath10k/snoc.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c
index c7cfc9c9b3d7..61967c2966e6 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -26,7 +26,7 @@
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
 #include <linux/clk.h>
-#define  WCN3990_CE_ATTR_FLAGS 0
+
 #define ATH10K_SNOC_RX_POST_RETRY_MS 50
 #define CE_POLL_PIPE 4
 
-- 
2.18.0.rc1.242.g61856ae69a-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* [PATCH 4/4] ath10k: snoc: sort include files
  2018-06-11 21:09 [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry Brian Norris
  2018-06-11 21:09 ` [PATCH 2/4] ath10k: snoc: stop including pci.h Brian Norris
  2018-06-11 21:09 ` [PATCH 3/4] ath10k: snoc: drop unused WCN3990_CE_ATTR_FLAGS Brian Norris
@ 2018-06-11 21:09 ` Brian Norris
  2018-06-12 11:22 ` [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry Kalle Valo
  2018-06-14 15:16 ` [1/4] " Kalle Valo
  4 siblings, 0 replies; 6+ messages in thread
From: Brian Norris @ 2018-06-11 21:09 UTC (permalink / raw)
  To: Kalle Valo
  Cc: ath10k, linux-wireless, Govind Singh, linux-kernel, Brian Norris

Sort these alphabetically, with local includes in a separate section.

Signed-off-by: Brian Norris <briannorris@chromium.org>
---
 drivers/net/wireless/ath/ath10k/snoc.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/drivers/net/wireless/ath/ath10k/snoc.c b/drivers/net/wireless/ath/ath10k/snoc.c
index 61967c2966e6..c88677e0a21c 100644
--- a/drivers/net/wireless/ath/ath10k/snoc.c
+++ b/drivers/net/wireless/ath/ath10k/snoc.c
@@ -14,18 +14,19 @@
  * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
  */
 
-#include <linux/module.h>
+#include <linux/clk.h>
 #include <linux/kernel.h>
-#include "debug.h"
-#include "hif.h"
-#include "htc.h"
-#include "ce.h"
-#include "snoc.h"
+#include <linux/module.h>
 #include <linux/of.h>
 #include <linux/of_device.h>
 #include <linux/platform_device.h>
 #include <linux/regulator/consumer.h>
-#include <linux/clk.h>
+
+#include "ce.h"
+#include "debug.h"
+#include "hif.h"
+#include "htc.h"
+#include "snoc.h"
 
 #define ATH10K_SNOC_RX_POST_RETRY_MS 50
 #define CE_POLL_PIPE 4
-- 
2.18.0.rc1.242.g61856ae69a-goog


^ permalink raw reply related	[flat|nested] 6+ messages in thread

* Re: [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry
  2018-06-11 21:09 [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry Brian Norris
                   ` (2 preceding siblings ...)
  2018-06-11 21:09 ` [PATCH 4/4] ath10k: snoc: sort include files Brian Norris
@ 2018-06-12 11:22 ` Kalle Valo
  2018-06-14 15:16 ` [1/4] " Kalle Valo
  4 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2018-06-12 11:22 UTC (permalink / raw)
  To: Brian Norris; +Cc: Govind Singh, linux-wireless, linux-kernel, ath10k

Brian Norris <briannorris@chromium.org> writes:

> We're 'ath10k_snoc', not 'ath10k_pci'. This probably means we're
> accessing junk data in ath10k_snoc_rx_replenish_retry(), unless
> 'ath10k_snoc' and 'ath10k_pci' happen to have very similar struct
> layouts.
>
> Noticed by inspection.
>
> Fixes: d915105231ca ("ath10k: add hif rx methods for wcn3990")
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> ---
> It's possible this would be a for-4.18 target, since the buggy patch is
> in the -rc1 merge. But this driver is not fully operational yet. Also,
> I'm sending some companion refactorings to help avoid this bug. They
> probably aren't 4.18 material.

Yeah, in theory this should go to 4.18 but, like you said, snoc support
does not even work on 4.18 so there would be no benefit. Actually just
more work while we add final pieces of wcn3990 support to ath10k. So
I'll queue these to 4.19.

> Let me know if I should do anything differently.

This is very good as is, thanks.

-- 
Kalle Valo

^ permalink raw reply	[flat|nested] 6+ messages in thread

* Re: [1/4] ath10k: snoc: use correct bus-specific pointer in RX retry
  2018-06-11 21:09 [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry Brian Norris
                   ` (3 preceding siblings ...)
  2018-06-12 11:22 ` [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry Kalle Valo
@ 2018-06-14 15:16 ` Kalle Valo
  4 siblings, 0 replies; 6+ messages in thread
From: Kalle Valo @ 2018-06-14 15:16 UTC (permalink / raw)
  To: Brian Norris
  Cc: Kalle Valo, ath10k, linux-wireless, Govind Singh, linux-kernel,
	Brian Norris

Brian Norris <briannorris@chromium.org> wrote:

> We're 'ath10k_snoc', not 'ath10k_pci'. This probably means we're
> accessing junk data in ath10k_snoc_rx_replenish_retry(), unless
> 'ath10k_snoc' and 'ath10k_pci' happen to have very similar struct
> layouts.
> 
> Noticed by inspection.
> 
> Fixes: d915105231ca ("ath10k: add hif rx methods for wcn3990")
> Signed-off-by: Brian Norris <briannorris@chromium.org>
> Signed-off-by: Kalle Valo <kvalo@codeaurora.org>

4 patches applied to ath-next branch of ath.git, thanks.

426a0f0b5a2f ath10k: snoc: use correct bus-specific pointer in RX retry
8ac5fe8e3d11 ath10k: snoc: stop including pci.h
13e6cc0bd4ef ath10k: snoc: drop unused WCN3990_CE_ATTR_FLAGS
c9f3e7fa8bcb ath10k: snoc: sort include files

-- 
https://patchwork.kernel.org/patch/10458863/

https://wireless.wiki.kernel.org/en/developers/documentation/submittingpatches


^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2018-06-14 15:16 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-06-11 21:09 [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry Brian Norris
2018-06-11 21:09 ` [PATCH 2/4] ath10k: snoc: stop including pci.h Brian Norris
2018-06-11 21:09 ` [PATCH 3/4] ath10k: snoc: drop unused WCN3990_CE_ATTR_FLAGS Brian Norris
2018-06-11 21:09 ` [PATCH 4/4] ath10k: snoc: sort include files Brian Norris
2018-06-12 11:22 ` [PATCH 1/4] ath10k: snoc: use correct bus-specific pointer in RX retry Kalle Valo
2018-06-14 15:16 ` [1/4] " Kalle Valo

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).