From patchwork Fri Oct 7 00:54:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Shimrra Shai X-Patchwork-Id: 13000834 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7DA08C433F5 for ; Fri, 7 Oct 2022 00:55:49 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-Id:Date:Subject:To :From:Reply-To:Cc:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=pw2j4JapHBWnIlD19AwL7QVMPZDSduJSgpq3aiitSH0=; b=ISNBuAuTagJKua hw7rajzQnXdRvZl4emHfsM5OopZ84ZFJX/tE8P5Jtbt+AIrWevS2DsnAuiU0L9mQpH/ul0Rl50vag 1iMdeXQEJbHEGrKvTcLEGIkeoX9wcTX0g86RowmhJ9ZztY03QVAhqke0hzgGS4s7RjEuw9fHbqZc3 Gy8Z7Myqk+vJIxGcCXzhpbicK94fLNhI/zIPiDn5Xvu4HVJX8BJdyqdEfTXSlmyXVBpU42JOjhBu5 hsNoiGNZgbBQc7tyieMVIIXy1EOpk+Z732JrTYpWP99u+DnmCL0owUfXlx6kMPAxgTd3PPXoS+ZWn LK21KonufGMlMeGUbFfA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogbdW-006KSl-Mh; Fri, 07 Oct 2022 00:54:46 +0000 Received: from mail-pl1-x631.google.com ([2607:f8b0:4864:20::631]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ogbdT-006KOD-Ad for linux-arm-kernel@lists.infradead.org; Fri, 07 Oct 2022 00:54:45 +0000 Received: by mail-pl1-x631.google.com with SMTP id h10so3213846plb.2 for ; Thu, 06 Oct 2022 17:54:37 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:from:to:cc:subject:date:message-id:reply-to; bh=Eo14SeAzaqsbL8Vpt2dDM/RiB6XJVjgyaA83T0Lz4/M=; b=jJjn+tG0vwlXIBPa0XvUWXS0W+yfb0h7L5VMKnSMspSiNNvc/8k54XCbpk6SSuxZEZ SFU/UHYZfbMfRkhHPnY6r971ud18YqSswUc1FwdPR8PHu0THP4iPfzhm8QAGJycQYP4d V37q/KH6jbp6Z256IIbBPf+3vRx1+p02qwfiolG9UPMGJDc6d8wKMKLpKkP1vrDtF76L mTEl/YC0hGJuD0hSYzx52kya9ejDcBhXkI/8r3ZrizA9dlpJbImBXDdGCvoUlHcJGiUJ PEuDC8QOCe7YZmoT/ipjqWJxo1hDQcXzzFlYMhG8luqk9cgWE6ved5RDvGlTjwLpTAU/ 4qKA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:mime-version:message-id:date:subject:to :from:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Eo14SeAzaqsbL8Vpt2dDM/RiB6XJVjgyaA83T0Lz4/M=; b=n7XyYr3WwsLk4v2Udmj7j9wmb3fHvS1ZTIgvOpKVVTet+NFq0oYR2u0T38m8XdWPcT VULOhBAcwVhzbyZHB5CvnoWKBcTbJpl58XJaf4eSO9FcbgW4kYrWp+cq3OztEPPAf8NC waf/x83usWNuuyEK+U9UD95/Q7WxMLVtexi52IDk4jazuLuJb9RhymWMrNQl1FlxHEtm 7WroKWCE3wb0GtPWEoxXjvkNOYQIwuok3x75Dzw38Y+U9ViMRK/v3ege+RTh2UchQ9oZ Dg9ryVBTS9mUW26ypYEIOJaA7lEpGKkWIaeeXPN3aTPRkTdmaecqHyQdtkD01usVK/MD v/JA== X-Gm-Message-State: ACrzQf3fPic4ery3LTzDdq0kN/xWuXut7qyT92hiqYJ53XmMjab2K4Pi 1x++zAjasjdfpvv3yO7MdN2Yz997IFcQjg== X-Google-Smtp-Source: AMsMyM4PK2A7CA8ZScjpkQ5aML9EpEusWEA/ej8bWJDivwUSfYXAnSHVT/yQOHED+zk1GSoWzukGZQ== X-Received: by 2002:a17:902:ef85:b0:17f:5f55:9425 with SMTP id iz5-20020a170902ef8500b0017f5f559425mr2535904plb.135.1665104076157; Thu, 06 Oct 2022 17:54:36 -0700 (PDT) Received: from localhost.localdomain ([50.52.121.173]) by smtp.gmail.com with ESMTPSA id f7-20020a170902684700b001769e6d4fafsm246023pln.57.2022.10.06.17.54.35 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 06 Oct 2022 17:54:35 -0700 (PDT) From: Shimmy Shai To: linux-arm-kernel@lists.infradead.org, shimmyshai00@gmail.com Subject: [PATCH] ("Draft") irqchip: add code needed to boot successfully on Firefly ITX-3588J Date: Thu, 6 Oct 2022 17:54:21 -0700 Message-Id: <20221007005421.2118579-1-shimmyshai00@gmail.com> X-Mailer: git-send-email 2.25.1 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221006_175443_411675_706CD81F X-CRM114-Status: GOOD ( 26.82 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org --- Hi again. Posting this again because the last time, the mail client I was attempting to use screwed up the message badly - couldn't see what it was going to do and never used it before. Now I've discovered git has an email feature, which is apparently the preferred method for sending patches ... sorry about that. This patch attempts to solve an issue I posted asking for advice about earlier here: http://lists.infradead.org/pipermail/linux-arm-kernel/2022-October/779336.html where that the kernel is unable to boot properly on the Firefly ITX-3588J board with a Rockchip RK3588 ARM system-on-chip (SoC) due to "ITS queue timeout" errors. I managed to get from the code provided by the board vendor for their patched 5.10.66 kernel the relevant changes that were applied in order to make it work. Of important note here is that their code has a configuration conditional "CONFIG_NO_GKI" which is not part of the standard kernel - it appears instead to be related to Android use, but is always set to "=y" in the Linux kernel build. Presumably, since it is described as "disabling Android GKI support" these should be made unconditional for this mainline kernel patch, but I am not sure of that, so want to run it by you first and thus why I am marking this as a "draft" still as I'm not sure whether that check should be simply dropped or not (I'd drop it, but you might have other thoughts). Thanks, Shimrra SHAI. drivers/irqchip/irq-gic-v3-its.c | 67 ++++++++++++++++++++++++++++++-- 1 file changed, 63 insertions(+), 4 deletions(-) diff --git a/drivers/irqchip/irq-gic-v3-its.c b/drivers/irqchip/irq-gic-v3-its.c index beead1a0191c..1caefcd3cfc5 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,9 @@ 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 +2309,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 +2321,11 @@ 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 +2372,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 +2964,9 @@ 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 +3122,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 +3152,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 +3321,12 @@ 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 +3415,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 +3431,11 @@ 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 +5059,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 +5113,11 @@ 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 +5148,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)) { /*