Received: by 2002:a05:7412:8d10:b0:f3:1519:9f41 with SMTP id bj16csp1022767rdb; Wed, 6 Dec 2023 06:44:18 -0800 (PST) X-Google-Smtp-Source: AGHT+IFb1okAonPbtofDchJuK/g4FiONjC2Ry3tEcroRo3Zgc5wIah5wyDDRdjX+6vqTx8Kini9U X-Received: by 2002:a17:903:1105:b0:1d0:c445:801b with SMTP id n5-20020a170903110500b001d0c445801bmr813953plh.71.1701873858097; Wed, 06 Dec 2023 06:44:18 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1701873858; cv=none; d=google.com; s=arc-20160816; b=UaHBi/XSJp5Gn4O5pKwYnHYlihW5byjGRw1aTxVm4GQB3zIuq50X2unTCPkw5VGvkm j0EoR3PxMoB+Ie/kwOpyagKVSYzENWdoT6tYagpY6+JRqYW3SWkfjQWTaefFTyyea1PX 1GkEJ2TXz43P2S6tl1aSO6Ucn57b2FrT7njee0a39kYirtpJ2p6jfP/330CYCV4KkYLJ d9lavrq30REhEkme80Jl96kO/b0P+4OgkLrXh+Rk13vp3XQY7QlJpCQu5WWltO7xDfuC 7qn1sOz2xViTyjkWVmwi8GT/8np4yIDgqMvVchSwk4Ft6lrIDLNTPyGh6oBfkVyQS+lt 9kDQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:in-reply-to:references :cc:to:from:content-language:subject:user-agent:mime-version:date :message-id:dkim-signature; bh=G/sUNB5ZgX1IJ9770bfc42rc11+iIaUcvTzWeH8l1S8=; fh=ll7tLx59plBwmdcmg5VTZUsxxAbRlIbv40xyLBAqor0=; b=QhkW61/xVl7eOYya4A64y8tgBxqevI6JzTQOZIT8LPZv/PM+oJxPb+6xRNlPXwMMQF ZOL57c1peiFb+/NZdSw+CkQR6lLzxz16Vzhtzny3cqM99qp/9CHoOoqbSMVGzFsSa/Jy lN+5ZsgD7/w4XWGQ4tZ8J9O9cy/f0f8gXCHri5fvF1kOc+QKnvK9tlbj/zgW97ZlJcn0 +7X+oMsv1PBwBR0aISOALU7MTEQFAOyhjpgT/RBlsTbcpvEQG9BmQT2gZjoxOQVPkzJb Tw1kq1RFtWqvFR2hHZ8I3qjW8jYRwGz4s/rxtB0arMOfDjROk6Fd1U4pncd2Lc0xSRA3 Klmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vGvVur4r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id p7-20020a1709028a8700b001c383a64ebesi11130635plo.319.2023.12.06.06.44.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 06 Dec 2023 06:44:18 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) client-ip=2620:137:e000::3:4; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=vGvVur4r; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:4 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id 2D14880215B9; Wed, 6 Dec 2023 06:44:15 -0800 (PST) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.11 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1378982AbjLFOn5 (ORCPT + 99 others); Wed, 6 Dec 2023 09:43:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57986 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1378943AbjLFOny (ORCPT ); Wed, 6 Dec 2023 09:43:54 -0500 Received: from mail-ed1-x52f.google.com (mail-ed1-x52f.google.com [IPv6:2a00:1450:4864:20::52f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5D539D4B for ; Wed, 6 Dec 2023 06:44:00 -0800 (PST) Received: by mail-ed1-x52f.google.com with SMTP id 4fb4d7f45d1cf-54bfa9b3ffaso8933743a12.1 for ; Wed, 06 Dec 2023 06:44:00 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1701873839; x=1702478639; darn=vger.kernel.org; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :from:to:cc:subject:date:message-id:reply-to; bh=G/sUNB5ZgX1IJ9770bfc42rc11+iIaUcvTzWeH8l1S8=; b=vGvVur4r9oz4kLtWFKhmAyZhH+/d0IpjaC/ioKvsnKpC2Rv9wyPoIclSTqA3uOeEO+ sNPBIFzf7CG//QMVUuf+fjaDQLxP5R8umXWN5JJLgA0sSZSVKkAlBhcLtFw3s1bfSsW6 ZX3cOL0tXCpwPc6pTYqyhrYYsHkegDNH7rO0RUwLZ0CdQsBpsgjnbpXv1p20bLBOhehG KkeKgdVuRW6l7iyRheNjKV9df9lbok5JHqsY8h1a7RVd+Iw803VUisssTNS+t66pnK+3 CPjs8nvu1w80J1DUUbS447RlJeI4EN7LDZyfrrQqwTJ8rC/ecX8HldyKXTLua+Tx8wrA 99SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1701873839; x=1702478639; h=content-transfer-encoding:in-reply-to:references:cc:to:from :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=G/sUNB5ZgX1IJ9770bfc42rc11+iIaUcvTzWeH8l1S8=; b=rSsKFKYe/UrhZXiwYuX+v06/RyOa5UuudYRQK97PzGWlwiKAFDonR+cbCRJKEg79Pa J9U+to/tZUWP+3hiqQQ0iOhAxSmjbISULYUKsH3vCvBr/KQHW0glx6V6VHe2+K6PHeFZ sLbSISSSRmMh+1IQ4OZa976oFkP0iUDyTBwvipbZZO7mXcnOjpJeyEnThCpwpKxfSPIi bBheaZf/ONE/QKugw6uuMg2moQOCGN0BSrx9+qK/+8KWNsuPJJOUPRO/OE6XIjxQc2UY +09M+f3UrtZXY/f51/NnGlOi1dxm3J4LLXPsGDuVnNO7yK8OX/jEEm9kw8SitHlGxK97 0aUw== X-Gm-Message-State: AOJu0YwTVLv3PAsW40Ly1+P4jrMJ0CR4DCmLjatj4Gdbmm3niuuvDsiU PcAF2IG3gETWHaP4tfG3fJPfEA== X-Received: by 2002:a50:d0cc:0:b0:54c:4837:9a9c with SMTP id g12-20020a50d0cc000000b0054c48379a9cmr758869edf.67.1701873838794; Wed, 06 Dec 2023 06:43:58 -0800 (PST) Received: from [192.168.2.107] ([79.115.63.75]) by smtp.gmail.com with ESMTPSA id bo24-20020a0564020b3800b0054cc22af09esm49861edb.46.2023.12.06.06.43.56 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 06 Dec 2023 06:43:58 -0800 (PST) Message-ID: <9f577482-30d9-4e1d-9469-812d323b18c6@linaro.org> Date: Wed, 6 Dec 2023 14:43:56 +0000 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v11 07/10] mtd: spi-nor: Add stacked memories support in spi-nor Content-Language: en-US From: Tudor Ambarus To: Amit Kumar Mahapatra , broonie@kernel.org, pratyush@kernel.org, miquel.raynal@bootlin.com, richard@nod.at, vigneshr@ti.com, sbinding@opensource.cirrus.com, lee@kernel.org, james.schulman@cirrus.com, david.rhodes@cirrus.com, rf@opensource.cirrus.com, perex@perex.cz, tiwai@suse.com Cc: linux-spi@vger.kernel.org, linux-kernel@vger.kernel.org, michael@walle.cc, linux-mtd@lists.infradead.org, nicolas.ferre@microchip.com, alexandre.belloni@bootlin.com, claudiu.beznea@tuxon.dev, michal.simek@amd.com, linux-arm-kernel@lists.infradead.org, alsa-devel@alsa-project.org, patches@opensource.cirrus.com, linux-sound@vger.kernel.org, git@amd.com, amitrkcian2002@gmail.com References: <20231125092137.2948-1-amit.kumar-mahapatra@amd.com> <20231125092137.2948-8-amit.kumar-mahapatra@amd.com> In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-0.9 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,T_SCC_BODY_TEXT_LINE autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on howler.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (howler.vger.email [0.0.0.0]); Wed, 06 Dec 2023 06:44:15 -0800 (PST) On 12/6/23 14:30, Tudor Ambarus wrote: > Hi, Amit, > > On 11/25/23 09:21, Amit Kumar Mahapatra wrote: >> Each flash that is connected in stacked mode should have a separate >> parameter structure. So, the flash parameter member(*params) of the spi_nor >> structure is changed to an array (*params[2]). The array is used to store >> the parameters of each flash connected in stacked configuration. >> >> The current implementation assumes that a maximum of two flashes are >> connected in stacked mode and both the flashes are of same make but can >> differ in sizes. So, except the sizes all other flash parameters of both >> the flashes are identical. > > Do you plan to add support for different flashes in stacked mode? If > not, wouldn't it be simpler to have just an array of flash sizes instead > of duplicating the entire params struct? > >> >> SPI-NOR is not aware of the chip_select values, for any incoming request >> SPI-NOR will decide the flash index with the help of individual flash size >> and the configuration type (single/stacked). SPI-NOR will pass on the flash >> index information to the SPI core & SPI driver by setting the appropriate >> bit in nor->spimem->spi->cs_index_mask. For example, if nth bit of >> nor->spimem->spi->cs_index_mask is set then the driver would >> assert/de-assert spi->chip_slect[n]. >> >> Signed-off-by: Amit Kumar Mahapatra >> --- >> drivers/mtd/spi-nor/core.c | 272 +++++++++++++++++++++++++++++------- >> drivers/mtd/spi-nor/core.h | 4 + >> include/linux/mtd/spi-nor.h | 15 +- >> 3 files changed, 240 insertions(+), 51 deletions(-) >> >> diff --git a/drivers/mtd/spi-nor/core.c b/drivers/mtd/spi-nor/core.c >> index 93ae69b7ff83..e990be7c7eb6 100644 >> --- a/drivers/mtd/spi-nor/core.c >> +++ b/drivers/mtd/spi-nor/core.c > > cut > >> @@ -2905,7 +3007,10 @@ static void spi_nor_init_fixup_flags(struct spi_nor *nor) >> static int spi_nor_late_init_params(struct spi_nor *nor) >> { >> struct spi_nor_flash_parameter *params = spi_nor_get_params(nor, 0); >> - int ret; >> + struct device_node *np = spi_nor_get_flash_node(nor); >> + u64 flash_size[SNOR_FLASH_CNT_MAX]; >> + u32 idx = 0; >> + int rc, ret; >> >> if (nor->manufacturer && nor->manufacturer->fixups && >> nor->manufacturer->fixups->late_init) { >> @@ -2937,6 +3042,44 @@ static int spi_nor_late_init_params(struct spi_nor *nor) >> if (params->n_banks > 1) >> params->bank_size = div64_u64(params->size, params->n_banks); >> >> + nor->num_flash = 0; >> + >> + /* >> + * The flashes that are connected in stacked mode should be of same make. >> + * Except the flash size all other properties are identical for all the >> + * flashes connected in stacked mode. >> + * The flashes that are connected in parallel mode should be identical. >> + */ >> + while (idx < SNOR_FLASH_CNT_MAX) { >> + rc = of_property_read_u64_index(np, "stacked-memories", idx, &flash_size[idx]); also, it's not clear to me why you read this property multiple times. Have you sent a device tree patch somewhere? It will help me understand what you're trying to achieve. > > This is a little late in my opinion, as we don't have any sanity check > on the flashes that are stacked on top of the first. We shall at least > read and compare the ID for all. > > Cheers, > ta