[PATCH/FIX?] Re: Testing new release 6.0.0+ on Firefly ITX-3588J fails: "ITS queue timeout"

Shimmy Shai shimmyshai00 at gmail.com
Wed Oct 5 12:08:03 PDT 2022


(Not sure this message is going to be properly threaded - my email client [Thunderbird 78.13.0] seems to be ignoring parts of the mailto link, don't know how to deal with that)

I think I have actually gotten this problem fixed. Apparently, after looking more closely at the kernel code in the drivers/irqchip/irq-gic-v3-its.c that is provided with the board vendor's (Firefly) modified 5.10.66 kernel, I managed to dig out some code pieces that look like they may have relevance to the issue and that are not in the current mainline kernel. I am putting a DRAFT patch below for the 6.0.0+ release, containing the necessary code snippets. Note that it specifically checks for RK3588 chipset. I call this a DRAFT patch because the provided code is switched with a vendor-added Android-related kernel config option, "CONFIG_NO_GKI", which is set to "yes" in the Linux-targeted kernel build (GKI appears to be an Android specific feature, so setting NO_GKI turns it *off*), and so I do not know what the implications for mainline integration of this code are that are implied by that.  Hence I don't want to claim this is a finalized patch yet until it can be worked out how to properly integrate its code given that particular bit of organizational stuff. Right now the DRAFT patch just #defines that option to 1 (on) so as to force the code to always operate. There's also some extra bits for RK3566 and RK3568; don't think they're needed for this specific problem but maybe they'll help, too.

======================

diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c

index beead1a0191c..7edcdce00b1d 100644

--- a/drivers/irqchip/irq-gic-v3-its.c

+++ b/drivers/irqchip/irq-gic-v3-its.c

@@ -39,6 +39,11 @@

  

  #include "irq-gic-common.h"

  

+/* (S. Shai): This part I'm not sure about how it should fit into

+ * the rest of the kernel scheme...

+ */

+#define CONFIG_NO_GKI   1

+

  #define ITS_FLAGS_CMDQ_NEEDS_FLUSHING        (1ULL << 0)

  #define ITS_FLAGS_WORKAROUND_CAVIUM_22375    (1ULL << 1)

  #define ITS_FLAGS_WORKAROUND_CAVIUM_23144    (1ULL << 2)

@@ -2178,6 +2183,8 @@ static struct page *its_allocate_prop_table(gfp_t gfp_flags)

  {

      struct page *prop_page;

  

+    if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))

+        gfp_flags |= GFP_DMA32;

      prop_page = alloc_pages(gfp_flags, get_order(LPI_PROPBASE_SZ));

      if (!prop_page)

          return NULL;

@@ -2301,6 +2308,7 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,

      u32 alloc_pages, psz;

      struct page *page;

      void *base;

+    gfp_t gfp_flags;

  

      psz = baser->psz;

      alloc_pages = (PAGE_ORDER_TO_SIZE(order) / psz);

@@ -2312,7 +2320,10 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,

          order = get_order(GITS_BASER_PAGES_MAX * psz);

      }

  

-    page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO, order);

+    gfp_flags = GFP_KERNEL | __GFP_ZERO;

+    if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))

+        gfp_flags |= GFP_DMA32;

+    page = alloc_pages_node(its->numa_node, gfp_flags, order);

      if (!page)

          return -ENOMEM;

  

@@ -2359,6 +2370,16 @@ static int its_setup_baser(struct its_node *its, struct its_baser *baser,

      its_write_baser(its, baser, val);

      tmp = baser->val;

  

+    if (IS_ENABLED(CONFIG_NO_GKI) &&

+        (of_machine_is_compatible("rockchip,rk3568") ||

+         of_machine_is_compatible("rockchip,rk3566") ||

+         of_machine_is_compatible("rockchip,rk3588"))) {

+        if (tmp & GITS_BASER_SHAREABILITY_MASK)

+            tmp &= ~GITS_BASER_SHAREABILITY_MASK;

+        else

+            gic_flush_dcache_to_poc(base, PAGE_ORDER_TO_SIZE(order));

+    }

+

      if ((val ^ tmp) & GITS_BASER_SHAREABILITY_MASK) {

          /*

           * Shareability didn't stick. Just use

@@ -2941,6 +2962,8 @@ static struct page *its_allocate_pending_table(gfp_t gfp_flags)

  {

      struct page *pend_page;

  

+    if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))

+        gfp_flags |= GFP_DMA32;

      pend_page = alloc_pages(gfp_flags | __GFP_ZERO,

                  get_order(LPI_PENDBASE_SZ));

      if (!pend_page)

@@ -3096,6 +3119,12 @@ static void its_cpu_init_lpis(void)

      gicr_write_propbaser(val, rbase + GICR_PROPBASER);

      tmp = gicr_read_propbaser(rbase + GICR_PROPBASER);

  

+    if (IS_ENABLED(CONFIG_NO_GKI) &&

+        (of_machine_is_compatible("rockchip,rk3568") ||

+         of_machine_is_compatible("rockchip,rk3566") ||

+         of_machine_is_compatible("rockchip,rk3588")))

+        tmp &= ~GICR_PROPBASER_SHAREABILITY_MASK;

+

      if ((tmp ^ val) & GICR_PROPBASER_SHAREABILITY_MASK) {

          if (!(tmp & GICR_PROPBASER_SHAREABILITY_MASK)) {

              /*

@@ -3120,6 +3149,12 @@ static void its_cpu_init_lpis(void)

      gicr_write_pendbaser(val, rbase + GICR_PENDBASER);

      tmp = gicr_read_pendbaser(rbase + GICR_PENDBASER);

  

+    if (IS_ENABLED(CONFIG_NO_GKI) &&

+        (of_machine_is_compatible("rockchip,rk3568") ||

+         of_machine_is_compatible("rockchip,rk3566") ||

+         of_machine_is_compatible("rockchip,rk3588")))

+        tmp &= ~GICR_PENDBASER_SHAREABILITY_MASK;

+

      if (!(tmp & GICR_PENDBASER_SHAREABILITY_MASK)) {

          /*

           * The HW reports non-shareable, we must remove the

@@ -3283,7 +3318,11 @@ static bool its_alloc_table_entry(struct its_node *its,

  

      /* Allocate memory for 2nd level table */

      if (!table[idx]) {

-        page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO,

+        gfp_t gfp_flags = GFP_KERNEL | __GFP_ZERO;

+

+        if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))

+            gfp_flags |= GFP_DMA32;

+        page = alloc_pages_node(its->numa_node, gfp_flags,

                      get_order(baser->psz));

          if (!page)

              return false;

@@ -3372,6 +3411,7 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,

      int nr_lpis;

      int nr_ites;

      int sz;

+    gfp_t gfp_flags;

  

      if (!its_alloc_device_table(its, dev_id))

          return NULL;

@@ -3387,7 +3427,10 @@ static struct its_device *its_create_device(struct its_node *its, u32 dev_id,

      nr_ites = max(2, nvecs);

      sz = nr_ites * (FIELD_GET(GITS_TYPER_ITT_ENTRY_SIZE, its->typer) + 1);

      sz = max(sz, ITS_ITT_ALIGN) + ITS_ITT_ALIGN - 1;

-    itt = kzalloc_node(sz, GFP_KERNEL, its->numa_node);

+    gfp_flags = GFP_KERNEL;

+    if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))

+        gfp_flags |= GFP_DMA32;

+    itt = kzalloc_node(sz, gfp_flags, its->numa_node);

      if (alloc_lpis) {

          lpi_map = its_lpi_alloc(nvecs, &lpi_base, &nr_lpis);

          if (lpi_map)

@@ -5011,6 +5054,7 @@ static int __init its_probe_one(struct resource *res,

      struct page *page;

      u32 ctlr;

      int err;

+    gfp_t gfp_flags;

  

      its_base = its_map_one(res, &err);

      if (!its_base)

@@ -5064,7 +5108,10 @@ static int __init its_probe_one(struct resource *res,

  

      its->numa_node = numa_node;

  

-    page = alloc_pages_node(its->numa_node, GFP_KERNEL | __GFP_ZERO,

+    gfp_flags = GFP_KERNEL | __GFP_ZERO;

+    if (of_machine_is_compatible("rockchip,rk3568") || of_machine_is_compatible("rockchip,rk3566"))

+        gfp_flags |= GFP_DMA32;

+    page = alloc_pages_node(its->numa_node, gfp_flags,

                  get_order(ITS_CMD_QUEUE_SZ));

      if (!page) {

          err = -ENOMEM;

@@ -5095,6 +5142,12 @@ static int __init its_probe_one(struct resource *res,

      gits_write_cbaser(baser, its->base + GITS_CBASER);

      tmp = gits_read_cbaser(its->base + GITS_CBASER);

  

+    if (IS_ENABLED(CONFIG_NO_GKI) &&

+        (of_machine_is_compatible("rockchip,rk3568") ||

+         of_machine_is_compatible("rockchip,rk3566") ||

+         of_machine_is_compatible("rockchip,rk3588")))

+        tmp &= ~GITS_CBASER_SHAREABILITY_MASK;

+

      if ((tmp ^ baser) & GITS_CBASER_SHAREABILITY_MASK) {

          if (!(tmp & GITS_CBASER_SHAREABILITY_MASK)) {

              /*

======================

Thanks,

Shimrra SHAI.




More information about the linux-arm-kernel mailing list