Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp2802299rwd; Wed, 14 Jun 2023 07:31:57 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ53Xg3tiCzKJ9hkdfvjfZCAzvTQxb7b8W1FndlBwrIqcfLBx9pWHjFPXBVEMroQ22BYcOPU X-Received: by 2002:a17:906:d54a:b0:96f:5902:8c4d with SMTP id cr10-20020a170906d54a00b0096f59028c4dmr14659715ejc.27.1686753117033; Wed, 14 Jun 2023 07:31:57 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1686753117; cv=none; d=google.com; s=arc-20160816; b=YkBkKqrD3yCCztQP5bt/GXxKOSQJSstrI/2CuNIr1lfLWmFoJ0fLtIgsOZDQ+tt0vP sniEWPNrAQ03ujjPLZbf1OSdXifzuhEIC35huv4ZptBG9ykIAL18w0E0BNakEyJJrlHs 1OZWoho6RGmlZYXWmD4kKlWC2O0aCZm4D4oJY2r3+XdjChuXYv03Qg7wL03Lb/oO6A2k 9RusaZCj1KFCMwwdq8DLkKBXh6NNpwtRnuMz+3+Y3jZiEhncqMRwgkmNA3UP/1QS9A2s J+7VtQGd4f/QC0jbYVG/utBPaRMWsWMHa4EENIz2UkRK13xYk7xC5wZRpapORPSfsOg+ 3nvA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:subject:cc:to:from:date:references:in-reply-to :message-id:mime-version:user-agent:feedback-id:dkim-signature :dkim-signature; bh=ygaeAW7Oiem/w6eWfgDKB5f6lRa+uXyAf0nyR9QWZ04=; b=0MpQB7ObcInUvz9QUhj/aoHKe2NraZBdXwYb+MHkoXcv3kMSjQGwnLHF4iKbbT3RTd xK2xUD3sLyddOUzw5ORqpgs8lQ2DXATyi045kJeRhtfcPDgOrmSP9b1oFivUHa4eV0lF PK/nng5mNYtMesiSz/RercG6dWyhwUs7L+KvydDrxviy/xsmddcjSNuf0N+JCcK15IbY 9PkQHV9WXuXrWEeC3Xixv1nHWXfHSeQ8IxSdu9EsxGLB/C7uXPmOpoKwIfPebj9yTMz+ If3POlnXGyZ7JTKId+vN/cXcbK9EqVTB2fRokAw8iaxzTCgZaCrW3rAX0Da+vgpB0Kix ZFtQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=fxTAGXXF; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=clDQpDo3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id u6-20020a170906408600b0096f75d91dafsi5058837ejj.1039.2023.06.14.07.31.31; Wed, 14 Jun 2023 07:31:57 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@arndb.de header.s=fm1 header.b=fxTAGXXF; dkim=pass header.i=@messagingengine.com header.s=fm2 header.b=clDQpDo3; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S244916AbjFNNLg (ORCPT + 99 others); Wed, 14 Jun 2023 09:11:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60958 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S244878AbjFNNL3 (ORCPT ); Wed, 14 Jun 2023 09:11:29 -0400 Received: from wout1-smtp.messagingengine.com (wout1-smtp.messagingengine.com [64.147.123.24]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2EA8D184; Wed, 14 Jun 2023 06:11:14 -0700 (PDT) Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailout.west.internal (Postfix) with ESMTP id D41F33200924; Wed, 14 Jun 2023 09:11:09 -0400 (EDT) Received: from imap51 ([10.202.2.101]) by compute6.internal (MEProxy); Wed, 14 Jun 2023 09:11:11 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=arndb.de; h=cc :cc:content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:sender :subject:subject:to:to; s=fm1; t=1686748269; x=1686834669; bh=yg aeAW7Oiem/w6eWfgDKB5f6lRa+uXyAf0nyR9QWZ04=; b=fxTAGXXFTXOufJo2TO mE3XjaK1s19oZ0tNxGzsTfITsX4CXJyrAw0qV8fLGW5GksN0o9ugYnAx6scimgo5 /tAVKpb5aIIT6wyviErJoUSHyE2cfBBTBZsRxOuqeYoriDz4pgvbitHhXlo64eei RXF2CJH1Dzg3+KfdM2huW/YTr/xmGTaC6Ugq7/f1l/OBlrsayQ1TnFimBSml7tNF gGevmmLslKHcCTIwwtLHYr3b0a7wBlRHxwIO8TZkoxIW/unPKf/q1Qnzt2u6EaOX eSCVp/ueh6ZHZim2mp/cNidLMC/G79CSoFWI53aGOFevm+iX9R516RH6uqQkEX+d xcXQ== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:sender:subject :subject:to:to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender :x-sasl-enc; s=fm2; t=1686748269; x=1686834669; bh=ygaeAW7Oiem/w 6eWfgDKB5f6lRa+uXyAf0nyR9QWZ04=; b=clDQpDo3J4gwj9SNXUHNzGAT9LZOM gm+ziObp9W8LHKg5Dq4xU/FkaMAX3PXBRohpj5J+7ppYpSNd5+maeh1ZsQkSsEUJ puYaqexWDRZ6CkpxvMo4TSHcVu5QvtTwzhWqRBWRLhuvjN7YoX0hwx/TLfhzzY3e Db6p83Pr4C/ZsyzJ3RtMdke4cnH99R07rYrHTvGYbaMhcozjytbmdkBtS9BsjNIT FflKq7PHUyTu5ZESkPfBJJ5+M7+9cYnB94kLIBO7uEeDpoPQHiRSyQUjj+wto7DD Kq5kc8mrdy7u09Cc2nv+vEISQ9m0INS6sRmJP3LdvRponMW6ckHopyNHw== X-ME-Sender: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvhedrgedvtddgiedvucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepofgfggfkjghffffhvfevufgtsehttdertderredtnecuhfhrohhmpedftehr nhguuceuvghrghhmrghnnhdfuceorghrnhgusegrrhhnuggsrdguvgeqnecuggftrfgrth htvghrnhepffehueegteeihfegtefhjefgtdeugfegjeelheejueethfefgeeghfektdek teffnecuvehluhhsthgvrhfuihiivgeptdenucfrrghrrghmpehmrghilhhfrhhomheprg hrnhgusegrrhhnuggsrdguvg X-ME-Proxy: Feedback-ID: i56a14606:Fastmail Received: by mailuser.nyi.internal (Postfix, from userid 501) id 58595B60086; Wed, 14 Jun 2023 09:11:08 -0400 (EDT) X-Mailer: MessagingEngine.com Webmail Interface User-Agent: Cyrus-JMAP/3.9.0-alpha0-492-g08e3be04ba-fm-20230607.003-g08e3be04 Mime-Version: 1.0 Message-Id: <20d4d296-14d7-467d-826c-b5c9cdf4599a@app.fastmail.com> In-Reply-To: <20230614104759.228372-6-prabhakar.mahadev-lad.rj@bp.renesas.com> References: <20230614104759.228372-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20230614104759.228372-6-prabhakar.mahadev-lad.rj@bp.renesas.com> Date: Wed, 14 Jun 2023 15:10:45 +0200 From: "Arnd Bergmann" To: Prabhakar , "Conor.Dooley" , "Geert Uytterhoeven" , guoren , "Andrew Jones" , "Paul Walmsley" , "Palmer Dabbelt" , "Albert Ou" , "Samuel Holland" , linux-riscv@lists.infradead.org, "Christoph Hellwig" Cc: "Rob Herring" , "Krzysztof Kozlowski" , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linux-Renesas , "Biju Das" , "Lad, Prabhakar" Subject: Re: [PATCH v9 5/6] cache: Add L2 cache management for Andes AX45MP RISC-V core Content-Type: text/plain X-Spam-Status: No, score=-2.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_LOW,SPF_HELO_PASS, SPF_PASS,T_SCC_BODY_TEXT_LINE,URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Jun 14, 2023, at 12:47, Prabhakar wrote: > +static void ax45mp_dma_cache_inv(phys_addr_t paddr, unsigned long size) > +{ > + unsigned long start = (unsigned long)phys_to_virt(paddr); > + char cache_buf[2][AX45MP_CACHE_LINE_SIZE]; > + unsigned long end = start + size; > + unsigned long old_start = start; > + unsigned long old_end = end; > + unsigned long line_size; > + unsigned long flags; > + > + if (unlikely(start == end)) > + return; > + > + line_size = ax45mp_priv.ax45mp_cache_line_size; > + > + memset(&cache_buf, 0x0, sizeof(cache_buf)); > + start = start & (~(line_size - 1)); > + end = ((end + line_size - 1) & (~(line_size - 1))); > + > + local_irq_save(flags); > + if (unlikely(start != old_start)) > + memcpy(&cache_buf[0][0], (void *)start, line_size); > + > + if (unlikely(end != old_end)) > + memcpy(&cache_buf[1][0], (void *)(old_end & (~(line_size - 1))), > line_size); > + > + ax45mp_cpu_dcache_inval_range(start, end, line_size); > + > + if (unlikely(start != old_start)) > + memcpy((void *)start, &cache_buf[0][0], (old_start & (line_size - > 1))); > + > + local_irq_restore(flags); > +} I'm not quite sure what this does, maybe some comments would help. This looks like a novel method of preserving partial cache lines at the beginning (but not the end?) of an unaligned area. As far as I can tell, most dma_mapping implementations don't even try to do that at all, but the ones that do take a different approach by calling _wback_inv() on partial cache lines instead of calling _inv(). I'd say this does not belong into the low-level operations here, especially since the ZICBOM variant doesn't do this either. Arnd