From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtpout-02.galae.net (smtpout-02.galae.net [185.246.84.56]) (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 41FBA3C5DC5 for ; Fri, 3 Apr 2026 16:06:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.246.84.56 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775232406; cv=none; b=uKukPSuUd4W3lULQ8czLrvmfo5gmOXskRFtZ3plNtZaq2dLArVDPwatGSBvCXFRQXukIaUwo4d8MiAqR6gQcNcE+Klvz+c4xbKHfjRs0Mk9QGGdHFxm0NCGHcXj3zD9gSKjHq4/r8PcmhUncQMgQS/jGkfFS8kX7nZZhCkSx3/Q= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1775232406; c=relaxed/simple; bh=t0EHngMNYsB2IiM9j2tQRnef+d8tab6F5xgT1UMQNwg=; h=From:To:Cc:Subject:In-Reply-To:References:Date:Message-ID: MIME-Version:Content-Type; b=fnDPgyGG2ManMSaDlJiqTEaGD3bk8PBpwKd82AB67HEk4o6aySA61RMl9E51RrBMoz3JlwV39YaG1clKQKTifLUb40aeVvYSvM0FomRKBvRNhkOiqIEERi4mDLkd9tY494CIkaWIbJlMBGSRWwWnUFmdAQCzAX8RwO4Blxtj0ts= 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=2Tx1mKPq; arc=none smtp.client-ip=185.246.84.56 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 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=bootlin.com header.i=@bootlin.com header.b="2Tx1mKPq" Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id AD9191A312B; Fri, 3 Apr 2026 16:06:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 703EC603C1; Fri, 3 Apr 2026 16:06:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 049E3104500F9; Fri, 3 Apr 2026 18:06:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1775232401; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=KrVx7jihaMo4JfVPFc6GDwNKRrjQQHnDzJIXkqNJIFg=; b=2Tx1mKPqr6MGr+MBrfMLLJ7EKQyPlAHd+lPXQZazym6imMuJ10BcFwZxJ3Tkdz4VOmXNLl fqbziwHYlYvdSeJn99Qj3FsRy9ciSZwNxpNUVTYNdtBLaWRk++Ji2j3HvP7fO4hdJBPSZW 1HWLavfhPgrYou6npZxg0jcOwPUuxa/eKtL1BPcodUfuEu7aOAHgPmTsxBHm3NFdHmBYo8 zoUb0sGSk/Whv5/D3OC6A4bfoRFLjd6jnoZBJmJs/STJIO66Ud7kxgvqFfyeOWc7oMIlPy 30Hdqch5+DaKmbe6L4E/VP09lKdFP2wiOm2awo2HDAw84feMgnaz3f69IZFyLg== From: Miquel Raynal To: Cc: , , , , , , , , , , , Subject: Re: [PATCH v3 17/27] mtd: spi-nor: debugfs: Add locking support In-Reply-To: (Takahiro Kuwano's message of "Thu, 2 Apr 2026 05:40:55 +0000") References: <20260317-winbond-v6-18-rc1-spi-nor-swp-v3-0-2ca9ea4e7b9b@bootlin.com> <20260317-winbond-v6-18-rc1-spi-nor-swp-v3-17-2ca9ea4e7b9b@bootlin.com> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Fri, 03 Apr 2026 18:06:33 +0200 Message-ID: <87a4vk58qe.fsf@bootlin.com> Precedence: bulk X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: quoted-printable X-Last-TLS-Session-Version: TLSv1.3 Hi Takahiro, >> +u64 spi_nor_get_min_prot_length_sr(struct spi_nor *nor); >> +void spi_nor_get_locked_range_sr(struct spi_nor *nor, const u8 *sr, lof= f_t *ofs, u64 *len); >> +bool spi_nor_is_locked_sr(struct spi_nor *nor, loff_t ofs, u64 len, con= st u8 *sr); >> + > > It would be better to have generic helper functions rather than using SR-= based > functions directly. The locking_ops is vendor/chip specific and can provi= de > other locking mechanism than SR-based block protection. For instance, Inf= ineon, > Micron, Macronix (and maybe other vendors) offer protection mechanisms th= at can > protect sectors individually with volatile or non-volatile manner. I get what you mean, thanks for pointing this out. Unfortunately it's not that straightforward. As of today, there are the "default" locking ops (SR based) and a few others, chip specific. For debugging purposes, these "other" ops do not provide any kind of useful feedback regarding what has actually been locked. Only SR based chips provide this, it is useful, I want to use it. So I'm going to expose a new boolean to filter out whether we have locking support *and* if yes, whether we can use SR based functions, this should also address this concern: > Don't we need to check 'SNOR_F_HAS_LOCK' flag here? We will still need to expose the SR specific helpers, though, but at least we will no longer get inconsistencies with chips not featuring the default SR approach. >> + seq_puts(s, "\nlocked sectors\n"); >> + seq_puts(s, " region (in hex) | status | #blocks\n"); >> + seq_puts(s, " ------------------+----------+--------\n"); >> + >> + spi_nor_get_locked_range_sr(nor, nor->dfs_sr_cache, &lock_start,= &lock_length); >> + if (!lock_length || lock_length =3D=3D params->size) { >> + seq_printf(s, " %08llx-%08llx | %s | %llu\n", 0ULL, para= ms->size - 1, >> + lock_length ? " locked" : "unlocked", params= ->size / min_prot_len); > > div_u64() is needed.=20 > I got undefined reference to `__aeabi_uldivmod' for my 32-bit ARM platfor= m. > Same for following four seq_printf(). Good catch, I will fix this too. Thanks, Miqu=C3=A8l From mboxrd@z Thu Jan 1 00:00:00 1970 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 07297E8537A for ; Fri, 3 Apr 2026 16:06:59 +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:MIME-Version:Message-ID:Date:References :In-Reply-To:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=Gl8Mipw3suLvB8Ivywcow3qQlk2CftJmU5M+n36DLk0=; b=aS02/Pl7r/+IGC 7B8FR3lwLjZ0Eg6uXzQtqks9hwhJx/U18nkUl5appyzBBgrFoei7D3Q2aEU+Cm52AhGBgC+rZi3Y0 dJ1I4UJ3GPt/OTRHlRB32m0MWchrtsCRke9XV8+t5hGe18zjy+sGbCwEcSrGMXKgR92YE9slAtakU cYt8x6U54ViS9NcHiEQSRzBt8lk1DcR5dtQDM1rXnEYBAv/G0C1FQA4jcclH4FoT83WDwgSRTw9pY 6VcW3t0nPulV9ZzdOD6nOPngA5CaVpi1E6HFsdzD1FvKB5C0b3XPqO0FDWR3f7461s8o99tU4wEew ezRk9EAKJ6MKeTHZyRMg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1w8h2r-00000002FtY-3OcZ; Fri, 03 Apr 2026 16:06:53 +0000 Received: from smtpout-02.galae.net ([185.246.84.56]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1w8h2m-00000002Fsw-19HG for linux-mtd@lists.infradead.org; Fri, 03 Apr 2026 16:06:50 +0000 Received: from smtpout-01.galae.net (smtpout-01.galae.net [212.83.139.233]) by smtpout-02.galae.net (Postfix) with ESMTPS id AD9191A312B; Fri, 3 Apr 2026 16:06:42 +0000 (UTC) Received: from mail.galae.net (mail.galae.net [212.83.136.155]) by smtpout-01.galae.net (Postfix) with ESMTPS id 703EC603C1; Fri, 3 Apr 2026 16:06:42 +0000 (UTC) Received: from [127.0.0.1] (localhost [127.0.0.1]) by localhost (Mailerdaemon) with ESMTPSA id 049E3104500F9; Fri, 3 Apr 2026 18:06:34 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=dkim; t=1775232401; h=from:subject:date:message-id:to:cc:mime-version:content-type: content-transfer-encoding:in-reply-to:references; bh=KrVx7jihaMo4JfVPFc6GDwNKRrjQQHnDzJIXkqNJIFg=; b=2Tx1mKPqr6MGr+MBrfMLLJ7EKQyPlAHd+lPXQZazym6imMuJ10BcFwZxJ3Tkdz4VOmXNLl fqbziwHYlYvdSeJn99Qj3FsRy9ciSZwNxpNUVTYNdtBLaWRk++Ji2j3HvP7fO4hdJBPSZW 1HWLavfhPgrYou6npZxg0jcOwPUuxa/eKtL1BPcodUfuEu7aOAHgPmTsxBHm3NFdHmBYo8 zoUb0sGSk/Whv5/D3OC6A4bfoRFLjd6jnoZBJmJs/STJIO66Ud7kxgvqFfyeOWc7oMIlPy 30Hdqch5+DaKmbe6L4E/VP09lKdFP2wiOm2awo2HDAw84feMgnaz3f69IZFyLg== From: Miquel Raynal To: Cc: , , , , , , , , , , , Subject: Re: [PATCH v3 17/27] mtd: spi-nor: debugfs: Add locking support In-Reply-To: (Takahiro Kuwano's message of "Thu, 2 Apr 2026 05:40:55 +0000") References: <20260317-winbond-v6-18-rc1-spi-nor-swp-v3-0-2ca9ea4e7b9b@bootlin.com> <20260317-winbond-v6-18-rc1-spi-nor-swp-v3-17-2ca9ea4e7b9b@bootlin.com> User-Agent: mu4e 1.12.7; emacs 30.2 Date: Fri, 03 Apr 2026 18:06:33 +0200 Message-ID: <87a4vk58qe.fsf@bootlin.com> MIME-Version: 1.0 X-Last-TLS-Session-Version: TLSv1.3 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20260403_090648_803125_82A5A1D4 X-CRM114-Status: GOOD ( 12.08 ) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: base64 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org SGkgVGFrYWhpcm8sCgo+PiArdTY0IHNwaV9ub3JfZ2V0X21pbl9wcm90X2xlbmd0aF9zcihzdHJ1 Y3Qgc3BpX25vciAqbm9yKTsKPj4gK3ZvaWQgc3BpX25vcl9nZXRfbG9ja2VkX3JhbmdlX3NyKHN0 cnVjdCBzcGlfbm9yICpub3IsIGNvbnN0IHU4ICpzciwgbG9mZl90ICpvZnMsIHU2NCAqbGVuKTsK Pj4gK2Jvb2wgc3BpX25vcl9pc19sb2NrZWRfc3Ioc3RydWN0IHNwaV9ub3IgKm5vciwgbG9mZl90 IG9mcywgdTY0IGxlbiwgY29uc3QgdTggKnNyKTsKPj4gKwo+Cj4gSXQgd291bGQgYmUgYmV0dGVy IHRvIGhhdmUgZ2VuZXJpYyBoZWxwZXIgZnVuY3Rpb25zIHJhdGhlciB0aGFuIHVzaW5nIFNSLWJh c2VkCj4gZnVuY3Rpb25zIGRpcmVjdGx5LiBUaGUgbG9ja2luZ19vc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