Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp1411418lqe; Mon, 8 Apr 2024 08:11:02 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCUdWWN/frJb2q7DbdUtvJgJgncqD0HgySdQ+GV3eb8pPtxVmwCwR4z9ApDegj01OZKX1aZVsowhir9Ik0v71Z8gh0oXMinhsITi4Eus8Q== X-Google-Smtp-Source: AGHT+IHY+fZ9f0nO6m1BGgdPgqpXlG6Io+BiFliQY77va2GCDiZm8BdlW+cvX3PQunnx/3I8mOai X-Received: by 2002:a05:6a20:ce4b:b0:1a7:175:2cac with SMTP id id11-20020a056a20ce4b00b001a701752cacmr9585004pzb.13.1712589062212; Mon, 08 Apr 2024 08:11:02 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712589062; cv=pass; d=google.com; s=arc-20160816; b=NLsSgCo5h5cQjUv5HMoCtXu5eqGunUu3Yjmy3dtXsng2Zg/WDgBDhlRRdKNuWwTQAu Iq2jXTJDjG3UIrvlNT1ubPrzi79yxpETIOW6yVFrcfvbibxtO1PpPptYwM/7Oo9ASI1S KihmqZyf7ZlnHNPFyuuemDzqZr9Do/skE/Cshq70c0eL7dHdTmXqTi2EiPyJ2VLWXwOL LJjjm3JxTk+vSGfWEB+miheBbKprUHEfRhK+CWRr9Zts4YMMRQwuMFyLbWL+18/1VMd1 tUU3yLkj5Z81vdQtNoYK//C1UPKnIDc4Lz//x463RNBX1/vRDfpMnU4RdnD5KIxtYX8o lgtQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=in-reply-to:references:to:cc:subject:from:message-id:date :content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:dkim-signature; bh=1ZlC/UZKOWqyEBpP3eksr4VHpijr8KpH0sG0zM7Z4oM=; fh=PO/yX8OCDCYcvlgWL+TkO2NKKNlgiMCdb2+J8Sylcck=; b=S7DJTXXcLqCf38iCjgY+MYCqWel7J01DJ2M115rLve5twvUmryKcBjk8KMpjFHGFcb Xa4ngGJwOsQTrJkP21OCUs/Qnq04mPd7qVMQytKKoYnePiutrwueCgGeRPk8KtMZI8+M rS8ILm+Qvz0kLH3/K3S3P/OkpEmBCG8YKt4bp6gEjvkUOQ7Mk9hu3sfsp3KkT8jEk7W2 faEeIau8Z2sX4cg7Vwl9vpektSYSl0Ciq8ZDs4/Hdr2lXaqdacip/Kp5g0p907kkw8mn rjfsam6aAnqzfwbdbTqqW22o6ZS0qZIryCHzlCscoHJA0eJNPxbVoR9gWDAk26IumFBG acxg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NLcU8zB4; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-135530-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from sy.mirrors.kernel.org (sy.mirrors.kernel.org. [147.75.48.161]) by mx.google.com with ESMTPS id f17-20020a056a0022d100b006ecee76ce97si6596215pfj.404.2024.04.08.08.11.01 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 08 Apr 2024 08:11:02 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-135530-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) client-ip=147.75.48.161; Authentication-Results: mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=NLcU8zB4; arc=pass (i=1 spf=pass spfdomain=bootlin.com dkim=pass dkdomain=bootlin.com dmarc=pass fromdomain=bootlin.com); spf=pass (google.com: domain of linux-kernel+bounces-135530-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.48.161 as permitted sender) smtp.mailfrom="linux-kernel+bounces-135530-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by sy.mirrors.kernel.org (Postfix) with ESMTPS id 2E98DB24328 for ; Mon, 8 Apr 2024 14:39:12 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 3B26D13EFE3; Mon, 8 Apr 2024 14:39:03 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="NLcU8zB4" Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 6D28D13CFAF; Mon, 8 Apr 2024 14:38:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=217.70.183.198 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712587142; cv=none; b=c4zwLkS4MhLPAHgFzRq1PnOTN7i7DSpJt04yHQZ1KKjV3zfqGnJzxn99Zjy5tCe7Hvjs51rIYAU+PwTqA9Zbs+b/VSvpPkvuMX04daaxhEiHxdupKrty0Dx/Vbu2Tbg1rpftahzUDRYVIzYTw40c3UXiuHwjHTfUcYJe3WdNS8c= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712587142; c=relaxed/simple; bh=3wDoUF5pxGrcrqOJXtZo0C1ZtYn3BHT7grHApLKhOXI=; h=Mime-Version:Content-Type:Date:Message-Id:From:Subject:Cc:To: References:In-Reply-To; b=Lg1X0MTlHU9choB/T5Kf31ptNZW4t+YH0ncxnu13eQTrdCu9mvoR2vD5Puv6GpkECD7dhYGlpPZDgj+LUaAXjOSKduPYqcxLKad6MZ8pF9+SNuf0OFK9LqsPjwfdBDoDXs93gm0eFOu83tJCGP64gNuYRSrbuMv/mQchZ/cY2P4= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com; spf=pass smtp.mailfrom=bootlin.com; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b=NLcU8zB4; arc=none smtp.client-ip=217.70.183.198 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=bootlin.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=bootlin.com Received: by mail.gandi.net (Postfix) with ESMTPSA id C7BC8C0007; Mon, 8 Apr 2024 14:38:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1712587137; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=1ZlC/UZKOWqyEBpP3eksr4VHpijr8KpH0sG0zM7Z4oM=; b=NLcU8zB4415/RLIr9hLOQwFYzyp0qixe6CGQnkNxYsiHM9sH2mdiYPpE5Qhvul+24BKNDZ O/y1mKm4OHtBD760iW4Bt5lmHzSvtq9f33UdtSeJAvbU0W1SOITnjmj2d/Iz8i9pN0LMNE 4DO4+u6p4+cIjA+wPnwtniTvGP5XMnzrOx2iWbMs6ylPNeMQXz2BhyU2lyuMmvJLybn/aq GwE/Dy7IoKBkZDgIbpcxMOfJv1/h7waJBqvQHcG+dzR4e6kX9Ssm9mF5OcK4mOOZK/qQ0x zReKPpD9/VzAFA2uG/igcaSPGqGcOz0NmpKEwj2RQIRquelGSqItmd90P8f9iw== Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset=UTF-8 Date: Mon, 08 Apr 2024 16:38:56 +0200 Message-Id: From: =?utf-8?q?Th=C3=A9o_Lebrun?= Subject: Re: [PATCH v2 05/11] spi: cadence-qspi: add FIFO depth detection quirk Cc: "Rob Herring" , "Krzysztof Kozlowski" , "Conor Dooley" , "Vaishnav Achath" , "Thomas Bogendoerfer" , "Rob Herring" , , , , , "Vladimir Kondratiev" , "Gregory CLEMENT" , "Thomas Petazzoni" , "Tawfik Bayouk" To: "Mark Brown" X-Mailer: aerc 0.15.2 References: <20240405-cdns-qspi-mbly-v2-0-956679866d6d@bootlin.com> <20240405-cdns-qspi-mbly-v2-5-956679866d6d@bootlin.com> <551bea0a-1c9e-4e04-87db-c643fdaee85e@sirena.org.uk> In-Reply-To: <551bea0a-1c9e-4e04-87db-c643fdaee85e@sirena.org.uk> X-GND-Sasl: theo.lebrun@bootlin.com Hello, On Mon Apr 8, 2024 at 4:10 PM CEST, Mark Brown wrote: > On Fri, Apr 05, 2024 at 05:02:15PM +0200, Th=C3=A9o Lebrun wrote: > > > Use hardware ability to read the FIFO depth thanks to > > CQSPI_REG_SRAMPARTITION that is partially read-only. Keep current > > behavior identical for existing compatibles. > > The behaviour is not identical here - we now unconditionally probe the > FIFO depth on all hardware, the difference with the quirk is that we > will ignore any DT property specifying the depth. You are correct of course. Wording is incorrect. I wanted to highlight that FIFO depth does not change for existing HW and still relies as before on devicetree value. > > - if (of_property_read_u32(np, "cdns,fifo-depth", &cqspi->fifo_depth)) = { > > + if (!(ddata && ddata->quirks & CQSPI_DETECT_FIFO_DEPTH) && > > + of_property_read_u32(np, "cdns,fifo-depth", &cqspi->fifo_depth)) = { > > dev_err(dev, "couldn't determine fifo-depth\n"); > > It's not obvious from just the code that we do handle having a FIFO > depth property and detection in the detection code, at least a comment > would be good. I see. Will add comment or rework code to make more straight forward, or both. > > +static void cqspi_controller_detect_fifo_depth(struct cqspi_st *cqspi) > > +{ > > + const struct cqspi_driver_platdata *ddata =3D cqspi->ddata; > > + struct device *dev =3D &cqspi->pdev->dev; > > + u32 reg, fifo_depth; > > + > > + /* > > + * Bits N-1:0 are writable while bits 31:N are read as zero, with 2^N > > + * the FIFO depth. > > + */ > > + writel(U32_MAX, cqspi->iobase + CQSPI_REG_SRAMPARTITION); > > + reg =3D readl(cqspi->iobase + CQSPI_REG_SRAMPARTITION); > > + fifo_depth =3D reg + 1; > > + > > + if (ddata && ddata->quirks & CQSPI_DETECT_FIFO_DEPTH) { > > + cqspi->fifo_depth =3D fifo_depth; > > + dev_dbg(dev, "using FIFO depth of %u\n", fifo_depth); > > + } else if (fifo_depth !=3D cqspi->fifo_depth) { > > + dev_warn(dev, "detected FIFO depth (%u) different from config (%u)\n= ", > > + fifo_depth, cqspi->fifo_depth); > > + } > > It's not obvious to me that we should ignore an explicitly specified > property if the quirk is present DT value isn't expected for compatibles with CQSPI_DETECT_FIFO_DEPTH quirk, therefore we do not ignore a specified property. Bindings agree: prop is false with EyeQ5 compatible. > - if anything I'd more expect to see > the new warning in that case, possibly with a higher severity if we're > saying that the quirk means we're more confident that the data reported > by the hardware is reliable. I think what I'd expect is that we always > use an explicitly specified depth (hopefully the user was specifying it > for a reason?). The goal was a simpler devicetree on Mobileye platform. This is why we add this behavior flag. You prefer the property to be always present? This is a only a nice-to-have, you tell me what you prefer. I wasn't sure all HW behaved in the same way wrt read-only bits in SRAMPARTITION, and I do not have access to other platforms exploiting this driver. This is why I kept behavior reserved for EyeQ5-integrated IP block. > Pulling all the above together can we just drop the quirk and always do > the detection, or leave the quirk as just controlling the severity with > which we log any difference between detected and explicitly configured > depths? If we do not simplify devicetree, then I'd vote for dropping this patch entirely. Adding code for detecting such an edge-case doesn't sound useful. Especially since this kind of error should only occur to people adding new hardware support; those probably do not need a nice user-facing error message. What do you think? Regards, -- Th=C3=A9o Lebrun, Bootlin Embedded Linux and Kernel engineering https://bootlin.com