Received: by 2002:a05:6358:3188:b0:123:57c1:9b43 with SMTP id q8csp19193728rwd; Wed, 28 Jun 2023 06:21:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ7UVk/Z2y34xBLS0suXqZ9rX8/jlyoJfL0DwdJpyaak4bHcB+EaBFsms+JBRDGMY4cmXhiP X-Received: by 2002:a05:6a20:748c:b0:11f:39e2:d08c with SMTP id p12-20020a056a20748c00b0011f39e2d08cmr38751683pzd.30.1687958515561; Wed, 28 Jun 2023 06:21:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1687958515; cv=none; d=google.com; s=arc-20160816; b=1HrwKyG/u3ZJxNEy8+iipDAbNS4OqwbQYMLZ4kUHwyfxwiHZ8zZcrG1vtHQzszB18X uHMueAMsNbkiRNBsWRmHMVAJRPJWkCCMITR2czP1pi6xUQkcEIHz5IgF+3IglYbxTuSU 99eGTXJObQ4Kd4VmwxJ6yja2PHanW/vVnlmeaaS+L4rFMRbnV1wy7wZnMgSOrEpXk7kn rzfvCv/8+CQ1VcKtlzdwZen5lo3c6sFZgy18lH9to4F+7gS/amkc1hXOZKEVrBenymmk O21JJ2ED7mYhJqlGe4nZDiu8k/8pV/c2M9bLzrkx5ZLYqU7zqa2ohYEK8c1iOgwnEbib d4yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:cc:to:subject :message-id:date:from:in-reply-to:references:mime-version :dkim-signature; bh=EmAJ4kybVwJdt2vlA7P+ww38r+1sb7umIggV1gZPfIc=; fh=hVZX//kGdD9GxOVKdLBKWSbD79CKLeR8Ig30Tpr/duw=; b=A4LGNgufn3ZMV+sxqM3DNY3pMM82ZfxLSEXRTEFNbwTe2A5vxyE15x+9x/HH7c7+MF kduqMSO38Fl6NaUFoL4bxg9vk+hwJTA+HMeAaqjFCjDVbVmd3WPFwYddiMA6xLMiPc9r oeQpHLttlxe7Zw+A63PRPLRlY4d/oQuydeIuNH5HU33Xsl/ECDRO+54zCahddLrfvu20 YbysPGs/h927EqECvqNW0zJWZc25GXqcVRei6OkVk3XOBXHGscBmT4xJKLuF2BiBeCI6 lEe8IJfiNdDG66f0wo/2kFzc8lGdJhL1t1u/MWw0LFaY0DmCiJvCzU3Ag2R3i1oFQdIx JdQA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20221208 header.b=TH62gIf3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id k23-20020a63ba17000000b0055ac5fed594si7485551pgf.366.2023.06.28.06.21.42; Wed, 28 Jun 2023 06:21:55 -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=@gmail.com header.s=20221208 header.b=TH62gIf3; 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; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231294AbjF1M6p (ORCPT + 99 others); Wed, 28 Jun 2023 08:58:45 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43392 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230238AbjF1M6J (ORCPT ); Wed, 28 Jun 2023 08:58:09 -0400 Received: from mail-io1-xd34.google.com (mail-io1-xd34.google.com [IPv6:2607:f8b0:4864:20::d34]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D45821FFE; Wed, 28 Jun 2023 05:58:07 -0700 (PDT) Received: by mail-io1-xd34.google.com with SMTP id ca18e2360f4ac-77a62a84855so237979339f.1; Wed, 28 Jun 2023 05:58:07 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20221208; t=1687957087; x=1690549087; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:from:to:cc:subject:date :message-id:reply-to; bh=EmAJ4kybVwJdt2vlA7P+ww38r+1sb7umIggV1gZPfIc=; b=TH62gIf3kGj2Mt+ts7Y630wN71DXW47CEhU3g2Pwmabuz3PXytPQ+L5Z5vUmfzd6tq XX0K8zmrpoR4BlYFswV/u0sf4deJ+qP51K5HmjwsQUKQbe8NWmP8rAMTv/y1qvlfhswi 7CW3NrPDN3CvIDMFcbjXS0c4nN1j+Cca6liM/YmFCe/6hiOwC9Uid2twZQmsbo66y65p tjEXGKewk/oH/q31S0lN7KDx2E9WT4nFBWDXkAIK4wAt9D4gmsPinno/+w3jHdTsWKvF sEToXu2u7v6U1qdh32oUFrXkeMs0SW64cwg0f8r8L+RH6/dqj9BC6o4rrMLkjw8XfNzl 7dLg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20221208; t=1687957087; x=1690549087; h=content-transfer-encoding:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=EmAJ4kybVwJdt2vlA7P+ww38r+1sb7umIggV1gZPfIc=; b=Dsmz1dweJyMZv/X6IUyqHL4jBX5NK+W3t07y0N+Hn+sZYeK5z4vFCecnBrAActMgdi N/MrAVMj9ZEzaTvTx0+8m9D7I/v9ktsJhvp9vnAlMUuqUQrSRW6nYkp41k2mWK1xAiSE Dn5HY4HxPjFM/bA3wo8kbOex2ZkyAYHqbsHbZxdLYhONLl2lD0Nc0sy1yXVhTAynY7Up 2KYo7vq/BFJiXyRZF66mgot0eNdgY0OXtEGCWeXGMLiLyhRxYUq5USJ4SNrnXDRUAMxA /CW36bU+XENzpeaZgKQeANaA7IES/NoagIhIlOQEMQ9rxmVc1BY9hXsAeto91qi6WWKf hB7g== X-Gm-Message-State: AC+VfDyM9N8Vs3ASGn2OrCfxqwPfCqgI8XKal1pMKNRqAvvSkj1uEUAm Lb5AfTBXWTHqJDHkRN8q3uDbSWYuhEDX8jn+jQ8= X-Received: by 2002:a6b:f203:0:b0:783:7298:55ef with SMTP id q3-20020a6bf203000000b00783729855efmr5556608ioh.11.1687957087169; Wed, 28 Jun 2023 05:58:07 -0700 (PDT) MIME-Version: 1.0 References: <20230614104759.228372-1-prabhakar.mahadev-lad.rj@bp.renesas.com> <20230614104759.228372-6-prabhakar.mahadev-lad.rj@bp.renesas.com> <20d4d296-14d7-467d-826c-b5c9cdf4599a@app.fastmail.com> In-Reply-To: <20d4d296-14d7-467d-826c-b5c9cdf4599a@app.fastmail.com> From: "Lad, Prabhakar" Date: Wed, 28 Jun 2023 13:57:40 +0100 Message-ID: Subject: Re: [PATCH v9 5/6] cache: Add L2 cache management for Andes AX45MP RISC-V core To: Arnd Bergmann Cc: "Conor.Dooley" , Geert Uytterhoeven , guoren , Andrew Jones , Paul Walmsley , Palmer Dabbelt , Albert Ou , Samuel Holland , linux-riscv@lists.infradead.org, Christoph Hellwig , Rob Herring , Krzysztof Kozlowski , devicetree@vger.kernel.org, linux-kernel@vger.kernel.org, Linux-Renesas , Biju Das , "Lad, Prabhakar" Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FREEMAIL_FROM, RCVD_IN_DNSWL_NONE,SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE 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 Hi Arnd, Thank you for the review. On Wed, Jun 14, 2023 at 2:11=E2=80=AFPM Arnd Bergmann wrote= : > > 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 =3D (unsigned long)phys_to_virt(paddr); > > + char cache_buf[2][AX45MP_CACHE_LINE_SIZE]; > > + unsigned long end =3D start + size; > > + unsigned long old_start =3D start; > > + unsigned long old_end =3D end; > > + unsigned long line_size; > > + unsigned long flags; > > + > > + if (unlikely(start =3D=3D end)) > > + return; > > + > > + line_size =3D ax45mp_priv.ax45mp_cache_line_size; > > + > > + memset(&cache_buf, 0x0, sizeof(cache_buf)); > > + start =3D start & (~(line_size - 1)); > > + end =3D ((end + line_size - 1) & (~(line_size - 1))); > > + > > + local_irq_save(flags); > > + if (unlikely(start !=3D old_start)) > > + memcpy(&cache_buf[0][0], (void *)start, line_size); > > + > > + if (unlikely(end !=3D 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 !=3D old_start)) > > + memcpy((void *)start, &cache_buf[0][0], (old_start & (lin= e_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. > I missed this earlier, (I removed the preserving of cache line from then end and left the beginning part. Samuel pointed to earlier on these patches if the cache-line-size is 64 we dont need to do this). Preserving cache lines is not needed at all, Ive verified this and just doing a _inval() is sufficient. I'll update this and send a new version. Cheers, Prabhakar > 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