From patchwork Wed Oct 25 18:56:37 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13436548 X-Patchwork-Delegate: mail@conchuod.ie 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 1DC1FC07545 for ; Wed, 25 Oct 2023 18:56:53 +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:Cc:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=BdHOzqz1aRHAx3/aa/n763vB03mELKw1YhV4N8++bXc=; b=LTpHZA9Rkceu5M Gdb7qxQd1Ha8ioo/c68AZsF9fCUr671//3Cm77gcbPOjLDd2nT+DJfJ4ZA3KikkKUYSWtlJDr58RH IslPSDVOn8v4WFaF2mc/3ty4fGsn5PSdUbEKbyqwj7Dd1hg/xy76lRfzjM2uDWIhJuLDs2+BlrrrT 0t4PkTuc7Aamu2x4TFpb+hltJcP19knZ7UNc5fpv2D+LiJsAXe+/VWx1qkPuocP1C4F7/V8OTrdyf Wba6MXKIB42udLHHYRP4I6P30kcMXD3Ne0t+Qk28Enj8qWahSKAHB90sIgLb1wDD/Ls7P7fMmvPMU sNj4XJPZaHX76xRMaaEw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvj3g-00CuU1-0T; Wed, 25 Oct 2023 18:56:48 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qvj3d-00CuRo-0t for linux-riscv@lists.infradead.org; Wed, 25 Oct 2023 18:56:47 +0000 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id CCEFA3FD3B for ; Wed, 25 Oct 2023 18:56:39 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1698260199; bh=dpC5A+l/P4E3TUZnqSQSiD+h/0pN6MHwAsvozKjAyuE=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=gP7AzUNPkSNq+l8ch77TOIkMBwdpiEVv7X8mx/SK7jMD4VxuGaheTiU6w3BnVuIXR mulprZVfHP9ChvmgRaz3SQOxIfUS6wT4OorlGAcOxRK69DDSkiCrLq8nCiUNezvEQY dq66RMJrJs6gPQhvS4TGbX82Ck2s5Bipg9ucvFNdUx6BXTg+pbR9GqHJq5NZPFIlCP 8MkMXxr5WkIlPBveAtnKSQQUzoO2TCXChh3UKfCsdK1Ppjekv+Nlk13LCxNRm7FHqz CODHYLrK10IT+xrZFcs34y86weIUpO3GSrl5z4vLO1M5b81xLo/F9/q5/UzmbcnBTm Lo4dhOsFtzv8w== Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-41cdce61dcbso1249991cf.3 for ; Wed, 25 Oct 2023 11:56:39 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698260198; x=1698864998; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=dpC5A+l/P4E3TUZnqSQSiD+h/0pN6MHwAsvozKjAyuE=; b=tze/yJ3h/92hHqFdnWlik+mmoxtYyogrS4nI6WKyk5P69Yn2/+TGR4Omc51BLJtokJ 6X+HItZBZVw/pXvkzWvv5o/cH574qnOg2P0bG5l5JzOnbWsvvWx+J7nU8Z3GEygcsLoZ RbNkvQN+Hx1XAt+xQMJEaHkcqcvkkxooD4K+F3ftk7hI76XWCmXGQqoSf+IJ/U/9E0Id 0mRWr5ufp+p3AqWRbtJb/m/VSKe4eUogwr8IVNhl91m2KpolsWIUK25HuXPdq0LB4dQK xsWP6jO9ODiiMvTcQBo8WfaZ+Zl9i5D+U44ZHuyDo8w41GEQNx1Z2K/A09xgUyrkzZAX ZrGA== X-Gm-Message-State: AOJu0Yzx5dG2ti17TdyOSHm8benNY6meh5Wp+ku01f0tVSqtvvo76Lvw 6UZtofT68bi1tIQ4aR8cP1jCoRDZKLsZAd7lPfXdrwFrWYSiQawAXOJf8wwNY8vmdP2+v6y45mD NsxHGEey5oOGQDSksIQf71/D6FPFwcXfWz0bFxZGJ20Vd2rJbGUurh6IFbaCe2em/mD0FpQ== X-Received: by 2002:a05:622a:1492:b0:41e:3de2:c8ff with SMTP id t18-20020a05622a149200b0041e3de2c8ffmr481496qtx.51.1698260198097; Wed, 25 Oct 2023 11:56:38 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEODfT6JXWwGmjJQBhTKiW+hVEHvY4WjoEtxUQiB6AZJTG4R8jFdnVJvecEIj+8lVHfkYW9vqesF3eZs9EmsZA= MIME-Version: 1.0 X-Received: by 2002:a05:622a:1492:b0:41e:3de2:c8ff with SMTP id t18-20020a05622a149200b0041e3de2c8ffmr481483qtx.51.1698260197850; Wed, 25 Oct 2023 11:56:37 -0700 (PDT) Received: from 348282803490 named unknown by gmailapi.google.com with HTTPREST; Wed, 25 Oct 2023 11:56:37 -0700 From: Emil Renner Berthing Date: Wed, 25 Oct 2023 11:56:37 -0700 Message-ID: Subject: [PATCH 1/4] dt-bindings: cache: sifive,ccache0: Add StarFive JH7100 compatible To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Palmer Dabbelt , Paul Walmsley , Emil Renner Berthing X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231025_115645_440675_D77D3F2D X-CRM114-Status: UNSURE ( 8.25 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This cache controller is also used on the StarFive JH7100 SoC. Unfortunately it needs a quirk to work properly, so add dedicated compatible string to be able to match it. Signed-off-by: Emil Renner Berthing Reviewed-by: Conor Dooley --- Documentation/devicetree/bindings/cache/sifive,ccache0.yaml | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/Documentation/devicetree/bindings/cache/sifive,ccache0.yaml b/Documentation/devicetree/bindings/cache/sifive,ccache0.yaml index 8a6a78e1a7ab..7e8cebe21584 100644 --- a/Documentation/devicetree/bindings/cache/sifive,ccache0.yaml +++ b/Documentation/devicetree/bindings/cache/sifive,ccache0.yaml @@ -38,7 +38,9 @@ properties: - sifive,fu740-c000-ccache - const: cache - items: - - const: starfive,jh7110-ccache + - enum: + - starfive,jh7100-ccache + - starfive,jh7110-ccache - const: sifive,ccache0 - const: cache - items: @@ -88,6 +90,7 @@ allOf: contains: enum: - sifive,fu740-c000-ccache + - starfive,jh7100-ccache - starfive,jh7110-ccache - microchip,mpfs-ccache @@ -111,6 +114,7 @@ allOf: contains: enum: - sifive,fu740-c000-ccache + - starfive,jh7100-ccache - starfive,jh7110-ccache then: From patchwork Wed Oct 25 18:56:39 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13436546 X-Patchwork-Delegate: mail@conchuod.ie 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 6FEE7C25B6F for ; Wed, 25 Oct 2023 18:56:53 +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:Cc:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=N8Q8aOMGu9kU7l2M6RvZR2zdYv8jqL0/4cs46haN+tU=; b=aeWax6DnyoH0av OWhndILwDUJ+k5XnQS3Aj/+oaRYTnxsK7QUz68BlGy50E/K6X3fbaUDc8Qj3ZMpV0/0SC7RLEK6Gv 313ZqypMymwbKjEa4Az3EdsryVDG+554BccUqHR6NLSyJwjkDQUt6kJoEo8ZfNo3ObAIMJXymLQLE QDSE3M+Bop5FTL78wYWzyfje5hP2MDlP4fOqrgBkWtH1ARA+28XQGLbP/XbeITYdoEcsrdphEcyBP 8VO6hRJK8y9ug26IUcFkLFcmAZKKNPnrW9C2iGam6hmhLhN0kWZ8KEKAqxSkflopdZAsbykN31pQP PwtbbgZK3KSvvgvjPZTg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvj3g-00CuUL-2K; Wed, 25 Oct 2023 18:56:48 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qvj3e-00CuSf-0F for linux-riscv@lists.infradead.org; Wed, 25 Oct 2023 18:56:47 +0000 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id 312CC3FD3A for ; Wed, 25 Oct 2023 18:56:44 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1698260204; bh=8ZSwQnx25XWx6H9WHSt+QTyzglk67NwsJMp2gzIlTF8=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=oRXQvxGFWV+36DVVfwcqEhGl1Xhmyd/NxGQSoAHu7trykUzSe4dR06Bu/BKP9fMRU ZDP69C01hJwKDoSbtRH0xmRQ4NpWCjEFEDMA5eFkW1nvZdPbxDphCivbGdW6WbRgld 6Qtd9qhW8Iadt88OZ0UmBq7UI1T8H8vfQOdYpV3bPjLVv3BSyeY8zYFhlHbVYDvrMY zwTqPgZ4UeYtemPIoTFo/wSG5yU/H6HLPSI7x4U/TCaY6FpZSP/rRQzihx27CoTdjt ncthGM88eIqznmrhQa0c/WLbxaN+hWm+B8mTG/jTipPMo7w4yDJP+PFlnwnIoleJ2c SkQ4r5XXLdDJQ== Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-41cb6df5c7bso1682431cf.3 for ; Wed, 25 Oct 2023 11:56:44 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698260200; x=1698865000; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=8ZSwQnx25XWx6H9WHSt+QTyzglk67NwsJMp2gzIlTF8=; b=XwEnal4A5P9x5zpVS7FcRTiQwYKAHO9y1UTD4IGApPdJh9jTpb1/SPriNl5X8tOtFI qyeosJ2T9FyPR6aKfhZXX9U+IofU+Nhi1fDOaq7cx/EgYAeTtgiRLatt4cXcwKKaJCwG eyKG9WLmuZjiu4m3GeczGHemUgiV0nhlgDE20d2/Vix8/d/HQB81Pt/eE+Zloh5ADnbY 0O9HA2XdxJlDltOiVmFFqCjZHpTkhoWvGrb7s0RzDA9CdiOxaNIXLEcon8hvkREepnPa famrnE9pXyLsnCFZhJVbmFcrGPkYaODvJZvHNB7wpj9K9Kbc8MjeB5koLtkSUUl6fTlo /bdg== X-Gm-Message-State: AOJu0YwFrd7YtvSQ5k1zDPPRlViagaw4reZuHTD+e1C9UwoilaqEZLt6 TGUjGj1Sacv8K9EBfpKVdf2QlkqssBc7MwmJHZlbX6RppEkhhnQc49fOp/T6rHN3RCGEPjbEbaH 6+lxkox4KsXnm4I0P9v0tfKw372xk+9Ow/pEawqBvzoVgGeFA6+eJSAQnxFz+FkoywGItSA== X-Received: by 2002:a05:622a:1b9f:b0:417:bd2c:2683 with SMTP id bp31-20020a05622a1b9f00b00417bd2c2683mr17944699qtb.19.1698260200208; Wed, 25 Oct 2023 11:56:40 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHJTkG3zv5DTeWRvY1y/BasKIXcM7hXfHiMkDTcbRf8mjI+q0VqgB+zstaBrwJ9z4uKKWXR3bFMed8oDTtI7W0= MIME-Version: 1.0 X-Received: by 2002:a05:622a:1b9f:b0:417:bd2c:2683 with SMTP id bp31-20020a05622a1b9f00b00417bd2c2683mr17944683qtb.19.1698260199921; Wed, 25 Oct 2023 11:56:39 -0700 (PDT) Received: from 348282803490 named unknown by gmailapi.google.com with HTTPREST; Wed, 25 Oct 2023 11:56:39 -0700 From: emil.renner.berthing@canonical.com Date: Wed, 25 Oct 2023 11:56:39 -0700 Message-ID: Subject: [PATCH 2/4] soc: sifive: ccache: Add StarFive JH7100 support To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Palmer Dabbelt , Paul Walmsley , Emil Renner Berthing X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231025_115646_244715_F0FC84B4 X-CRM114-Status: GOOD ( 13.46 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This adds support for the StarFive JH7100 SoC which also features this SiFive cache controller. Unfortunately the interrupt for uncorrected data is broken on the JH7100 and fires continuously, so add a quirk to not register a handler for it. Signed-off-by: Emil Renner Berthing --- drivers/soc/sifive/sifive_ccache.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/drivers/soc/sifive/sifive_ccache.c b/drivers/soc/sifive/sifive_ccache.c index 3684f5b40a80..676468c35859 100644 --- a/drivers/soc/sifive/sifive_ccache.c +++ b/drivers/soc/sifive/sifive_ccache.c @@ -106,6 +106,7 @@ static void ccache_config_read(void) static const struct of_device_id sifive_ccache_ids[] = { { .compatible = "sifive,fu540-c000-ccache" }, { .compatible = "sifive,fu740-c000-ccache" }, + { .compatible = "starfive,jh7100-ccache", .data = (void *)BIT(DATA_UNCORR) }, { .compatible = "sifive,ccache0" }, { /* end of table */ } }; @@ -210,11 +211,15 @@ static int __init sifive_ccache_init(void) struct device_node *np; struct resource res; int i, rc, intr_num; + const struct of_device_id *match; + unsigned long broken_irqs; - np = of_find_matching_node(NULL, sifive_ccache_ids); + np = of_find_matching_node_and_match(NULL, sifive_ccache_ids, &match); if (!np) return -ENODEV; + broken_irqs = (uintptr_t)match->data; + if (of_address_to_resource(np, 0, &res)) { rc = -ENODEV; goto err_node_put; @@ -240,6 +245,10 @@ static int __init sifive_ccache_init(void) for (i = 0; i < intr_num; i++) { g_irq[i] = irq_of_parse_and_map(np, i); + + if (broken_irqs & BIT(i)) + continue; + rc = request_irq(g_irq[i], ccache_int_handler, 0, "ccache_ecc", NULL); if (rc) { From patchwork Wed Oct 25 18:56:41 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13436549 X-Patchwork-Delegate: mail@conchuod.ie 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 89DA1C25B6F for ; Wed, 25 Oct 2023 18:56:57 +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:Cc:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=D5V/QJA3+oBusonRaln1gLh8/i2QNbM0yRiIKbWY7Wc=; b=M/rE/ikIty88GC t4nf+A/dC+hkN/OJ16Y0H/zN94vkm+vm2Pj0+QWErCQKkLxAUgxfor2XVKWQnWzYpPRRbsEBF+sM3 S4npKb+hw08u2jW69bt91CyqO+j0f4U8Lzqerd+cIGU0s0T5tbvI/sNGTR/kKZ0EgYW3q3Y0jtlGW dq9degU6a6VXJdxcnJQkU6hDqNq1/IT1wIy/kWO0+yajZxJroQ2HXOH3eq+aWn9ESRaeWoSEmW5PH Ua5tm6w33k7t//oRLYHbdf7ejkOzjmEQt4p2Bym6sifJZz0e7LR9dBALxCIUudPtx3SYkRSzn1pW4 6iXb7EDlA1S2iF8fzGUw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvj3k-00CuVe-1P; Wed, 25 Oct 2023 18:56:52 +0000 Received: from smtp-relay-internal-1.canonical.com ([185.125.188.123]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qvj3e-00CuTB-2u for linux-riscv@lists.infradead.org; Wed, 25 Oct 2023 18:56:48 +0000 Received: from mail-qt1-f197.google.com (mail-qt1-f197.google.com [209.85.160.197]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id 6E316413B6 for ; Wed, 25 Oct 2023 18:56:45 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1698260205; bh=FFiHmR7ukRwdZCsC7cixmRTY2MvrJS7s0z/YTGkE2iM=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=tJht2Jw7MEkN/cCOzA/3zFCdHQwj03EOjOqXKSF8COqifzQ8J/rNBbmE5C/p1Nk/O /x9xXh3xbDk96ylILOqe28eDsg3Xq6MKxrScjl1T+b3IxV8EuZIefjHkJj1TmTubym wWeaiMFhOWssNnz31ae2aD1ArGkIyzhsIVSkn/Wb0KORHFB3SZzSE1YzZet5lw/lIP 8kxUpeLhl1dfzvoUPWh2x2O898jDagoKVXLP//b0ArZmxSbBtm88NxamKBavSswLlt q/H8h04yFtng4AKDBTPc+CR6964PB3yMEpnuIqOXDj+CuGal7utHqvyUuxd3EjV+FA w+cdZgpDzAbMA== Received: by mail-qt1-f197.google.com with SMTP id d75a77b69052e-41e16b279ffso1453281cf.0 for ; Wed, 25 Oct 2023 11:56:45 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698260202; x=1698865002; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=FFiHmR7ukRwdZCsC7cixmRTY2MvrJS7s0z/YTGkE2iM=; b=h03UhMJjVUZDDLo6W3rWEPf+S9XFHDBG44vl4tBTVSY0Ri8+uA1dnTbzV5+7juzznW zM6/5bKhJAhrHTtz8ZHPSG4KZYtIMFuPOpJ2HFg0b3ctJZ6W0V3/qhKhRDJzjK9Ppktt YIeecTRbCVlffyKeSAeuVdHzzRroWdB4XZCOJ4bGZ9TWDSN/C2RoDCJ6HLPJTfbGsmNw 7HQ61uWBMtAMq4yqxxE0uYMxMTlyniXPvddHmlxTe55JZZGxIv/5uUc9guI+w/pAOzbz AmMdEpQYW+YvApz5c3Tyz/LrKgfy9KSPLhVV3t3JQ+3xvxSaJqauYM5t7uraAxaQTXHF iOfg== X-Gm-Message-State: AOJu0Yw7qIQVsy0bAggyoiTm/mZAczE8rBBicyliWmN86gczELOzlzDZ 6EelOIDI8Csku5jPLbx1D3kKy/Dkm4J06a5IipdckX7QNQHtFLhegpQTAocQXOv7PKAy8R9cvQR b++UQV7tpNqQSiJcFpl3PCcMmg8NBTzX/mcSS/LwLa3eQLyORzoZaU/Jr7mCxVE2AF+Ifpw== X-Received: by 2002:a05:622a:14e:b0:41e:172f:6e78 with SMTP id v14-20020a05622a014e00b0041e172f6e78mr15135517qtw.29.1698260202169; Wed, 25 Oct 2023 11:56:42 -0700 (PDT) X-Google-Smtp-Source: AGHT+IGRHDA8d43i/0eqTtRETVi4ef1AAWHZvlYua8G+9qwUeJ5hvjbzmci7qiMP/aXUn13Et1Ecrw6N0+hOCNM2Ze0= MIME-Version: 1.0 X-Received: by 2002:a05:622a:14e:b0:41e:172f:6e78 with SMTP id v14-20020a05622a014e00b0041e172f6e78mr15135502qtw.29.1698260201944; Wed, 25 Oct 2023 11:56:41 -0700 (PDT) Received: from 348282803490 named unknown by gmailapi.google.com with HTTPREST; Wed, 25 Oct 2023 11:56:41 -0700 From: Emil Renner Berthing Date: Wed, 25 Oct 2023 11:56:41 -0700 Message-ID: Subject: [PATCH 3/4] dt-bindings: cache: sifive,ccache0: Add sifive,cache-ops property To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Palmer Dabbelt , Paul Walmsley , Emil Renner Berthing X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231025_115647_065850_4ADC2C26 X-CRM114-Status: UNSURE ( 7.70 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This cache controller also supports flushing cache lines by writing their address to a register. This can be used for cache management on SoCs with non-coherent DMAs that predate the RISC-V Zicbom extension such as the StarFive JH7100 SoC. Signed-off-by: Emil Renner Berthing --- Documentation/devicetree/bindings/cache/sifive,ccache0.yaml | 5 +++++ 1 file changed, 5 insertions(+) - $ref: /schemas/cache-controller.yaml# diff --git a/Documentation/devicetree/bindings/cache/sifive,ccache0.yaml b/Documentation/devicetree/bindings/cache/sifive,ccache0.yaml index 7e8cebe21584..36ae6f48ce0b 100644 --- a/Documentation/devicetree/bindings/cache/sifive,ccache0.yaml +++ b/Documentation/devicetree/bindings/cache/sifive,ccache0.yaml @@ -81,6 +81,11 @@ properties: The reference to the reserved-memory for the L2 Loosely Integrated Memory region. The reserved memory node should be defined as per the bindings in reserved-memory.txt. + sifive,cache-ops: + type: boolean + description: | + Use this cache controller for non-standard cache management operations. + allOf: From patchwork Wed Oct 25 18:56:43 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Emil Renner Berthing X-Patchwork-Id: 13436550 X-Patchwork-Delegate: mail@conchuod.ie 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 89D56C25B6E for ; Wed, 25 Oct 2023 18:56:57 +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:Cc:To:Subject:Message-ID:Date:From: MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=ea+huAAdMOVzoVhHDPaD4ihVw3EyLPui2YuaehOac/A=; b=MBMy/0ak1+Av5k 51Bnq5dNrvRH0vm6fbnt+XHagkDJTYSWEpyXihr0G2clZYlHB9+C7Gb1horhmSREAKKUFOw8atIvL KRqRpbwNVmEMGm3xZZl0ooBG3XaNWnpoyfW4babnxnO+D2KOq8bB8A97RRi2nUtzU7A7Z6aTMdBlR ICCmfKqGN18t344ws+rUu8D3ooLpnZbXyv0vMsR67aGdoFrw182NeiS0eOw9Go6qoMxzn5K6EEPCZ hiU/tRgRUAWZsOoZ2vlm1+t/p8vzV7gcgOuJ13LSbFUeVS/MpfI2lTzVcHsQfaCRw7aZWlmYGgSZc L6vvhBVRX9lwkgsY19Zg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1qvj3l-00CuWQ-08; Wed, 25 Oct 2023 18:56:53 +0000 Received: from smtp-relay-internal-0.canonical.com ([185.125.188.122]) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1qvj3g-00CuTz-22 for linux-riscv@lists.infradead.org; Wed, 25 Oct 2023 18:56:50 +0000 Received: from mail-qv1-f72.google.com (mail-qv1-f72.google.com [209.85.219.72]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-0.canonical.com (Postfix) with ESMTPS id D3CBD3FD42 for ; Wed, 25 Oct 2023 18:56:46 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1698260206; bh=72yTSynUrDUHeNGfbDrBCEgB1J8riTYEUtHwwC8rPyQ=; h=MIME-Version:From:Date:Message-ID:Subject:To:Cc:Content-Type; b=If+kDKHeuT2EMsw92xqfmlqXDH3ramsZx0OPNFo05CzPW6IzPJXEgCM9sqx28lSet iO/k+Ed6G8bYm24NN9bCSmPCKB90vXyjsUewYsZET2bIfnPL1C7dyKPUCYh/qsOJQI SGqWhbY6wiSTH8A0JeQ0L7yK7xsDlFLCuJ3+eHTVkOpZI2bLp5Qwi6noWjYlZw7Uic X0T3HlHZmN4ds6obzGV0kVkXRaof/mnXeUiIpbm9JeywgNEtvcJE4BvzvifW9KWRSK qHwddJUubiP4KK9FC+GAN/g7v7bphg8b2xhrKXwYj5MQ2oXbwH/qarlI00hMv04Xhb ux4UWtt4U7GLA== Received: by mail-qv1-f72.google.com with SMTP id 6a1803df08f44-66cfda4c191so1251336d6.0 for ; Wed, 25 Oct 2023 11:56:46 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698260204; x=1698865004; h=cc:to:subject:message-id:date:from:mime-version:x-gm-message-state :from:to:cc:subject:date:message-id:reply-to; bh=72yTSynUrDUHeNGfbDrBCEgB1J8riTYEUtHwwC8rPyQ=; b=WMg0wYeO1gGgMZcsfYchAjyg5V3seAV+WnkqxYMXKOSdmks+mjcBIEEXrH/CzeDuv9 SkOTxCNtDN4a7DP6N8g6d5JNDEvZDOcN5pkdOaLeS5OEfWDYaICxuD50oHIGDipoJLk7 xTTg8R0IqUm1A/v1kp52NG6T7Lb9dv/76KU9QpFcrMNEctUhUgpH9Og8Ln3lSH29Obs5 AVrE9Y2BTzCay5WKqP75GtKgZk89A5I1ObxJ1gOp/jlGOh6ptbgFxSUZMxGj2tw/V+UD 1QVF8SufQHMlCWz0GXs4GB96L3+xulVSesoo6FPRGA5gICpJV6m8jiEre+K7fWv0TceQ ntBQ== X-Gm-Message-State: AOJu0Yy0R4arMDmV8OHbFBbgAw/8hG8a1MmmXy5/xTi9/gphoF3k+zx0 9CEuK7Prbuu32vvbOZiRICpJ6kzcjL5BFw6Qimyn/cOelxbqVsw9uuDATdn+yVIvyWmieRxhbrT oghlZBAmzOOGM7WsExz9/Hl7lDmADtdjXADF5ErB2RU8p9qMeW/LFVWB+E///V7OCqiT0sg== X-Received: by 2002:a05:6214:500a:b0:66d:1ff3:31ed with SMTP id jo10-20020a056214500a00b0066d1ff331edmr18230020qvb.52.1698260204378; Wed, 25 Oct 2023 11:56:44 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEqrp3yXMtVysnlSo/32Nx/YVY6NylQz5OO3JSRKcqHPaoXNSn7AoCmimrkLCz7k8X5K09lEujMXAozvhm6Dhg= MIME-Version: 1.0 X-Received: by 2002:a05:6214:500a:b0:66d:1ff3:31ed with SMTP id jo10-20020a056214500a00b0066d1ff331edmr18230005qvb.52.1698260204165; Wed, 25 Oct 2023 11:56:44 -0700 (PDT) Received: from 348282803490 named unknown by gmailapi.google.com with HTTPREST; Wed, 25 Oct 2023 11:56:43 -0700 From: emil.renner.berthing@canonical.com Date: Wed, 25 Oct 2023 11:56:43 -0700 Message-ID: Subject: [PATCH 4/4] soc: sifive: ccache: Support cache management operations To: linux-riscv@lists.infradead.org, devicetree@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Conor Dooley , Rob Herring , Krzysztof Kozlowski , Palmer Dabbelt , Paul Walmsley , Emil Renner Berthing X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231025_115648_811280_D9F9B120 X-CRM114-Status: GOOD ( 12.12 ) X-BeenThere: linux-riscv@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-riscv" Errors-To: linux-riscv-bounces+linux-riscv=archiver.kernel.org@lists.infradead.org This cache controller also supports flushing cache lines by writing their address to a register. This can be used for cache management on SoCs with non-coherent DMAs that predate the RISC-V Zicbom extension such as the StarFive JH7100 SoC. Signed-off-by: Emil Renner Berthing --- drivers/soc/sifive/sifive_ccache.c | 45 +++++++++++++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) return readl(ccache_base + SIFIVE_CCACHE_WAYENABLE) & 0xFF; @@ -258,6 +293,14 @@ static int __init sifive_ccache_init(void) } of_node_put(np); +#ifdef CONFIG_RISCV_NONSTANDARD_CACHE_OPS + if (of_property_read_bool(np, "sifive,cache-ops")) { + riscv_cbom_block_size = SIFIVE_CCACHE_LINE_SIZE; + riscv_noncoherent_supported(); + riscv_noncoherent_register_cache_ops(&ccache_mgmt_ops); + } +#endif + ccache_config_read(); ccache_cache_ops.get_priv_group = ccache_get_priv_group; @@ -278,4 +321,4 @@ static int __init sifive_ccache_init(void) return rc; } -device_initcall(sifive_ccache_init); +arch_initcall(sifive_ccache_init); diff --git a/drivers/soc/sifive/sifive_ccache.c b/drivers/soc/sifive/sifive_ccache.c index 676468c35859..9bf94c22cad9 100644 --- a/drivers/soc/sifive/sifive_ccache.c +++ b/drivers/soc/sifive/sifive_ccache.c @@ -8,13 +8,16 @@ #define pr_fmt(fmt) "CCACHE: " fmt +#include #include #include #include #include #include #include +#include #include +#include #include #define SIFIVE_CCACHE_DIRECCFIX_LOW 0x100 @@ -39,10 +42,14 @@ #define SIFIVE_CCACHE_CONFIG_SETS_MASK GENMASK_ULL(23, 16) #define SIFIVE_CCACHE_CONFIG_BLKS_MASK GENMASK_ULL(31, 24) +#define SIFIVE_CCACHE_FLUSH64 0x200 +#define SIFIVE_CCACHE_FLUSH32 0x240 + #define SIFIVE_CCACHE_WAYENABLE 0x08 #define SIFIVE_CCACHE_ECCINJECTERR 0x40 #define SIFIVE_CCACHE_MAX_ECCINTR 4 +#define SIFIVE_CCACHE_LINE_SIZE 64 static void __iomem *ccache_base; static int g_irq[SIFIVE_CCACHE_MAX_ECCINTR]; @@ -125,6 +132,34 @@ int unregister_sifive_ccache_error_notifier(struct notifier_block *nb) } EXPORT_SYMBOL_GPL(unregister_sifive_ccache_error_notifier); +#ifdef CONFIG_RISCV_NONSTANDARD_CACHE_OPS +static void ccache_flush_range(phys_addr_t start, size_t len) +{ + phys_addr_t end = start + len; + phys_addr_t line; + + if (!len) + return; + + mb(); + for (line = ALIGN_DOWN(start, SIFIVE_CCACHE_LINE_SIZE); line < end; + line += SIFIVE_CCACHE_LINE_SIZE) { +#ifdef CONFIG_32BIT + writel(line >> 4, ccache_base + SIFIVE_CCACHE_FLUSH32); +#else + writeq(line, ccache_base + SIFIVE_CCACHE_FLUSH64); +#endif + mb(); + } +} + +static const struct riscv_nonstd_cache_ops ccache_mgmt_ops __initdata = { + .wback = &ccache_flush_range, + .inv = &ccache_flush_range, + .wback_inv = &ccache_flush_range, +}; +#endif /* CONFIG_RISCV_NONSTANDARD_CACHE_OPS */ + static int ccache_largest_wayenabled(void) {