From patchwork Wed Mar 20 00:11:39 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Marangi X-Patchwork-Id: 1913803 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=RRLFsOKh; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.a=rsa-sha256 header.s=20230601 header.b=M2tIhS9Q; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Tzptx1PDMz1yWy for ; Wed, 20 Mar 2024 11:12:22 +1100 (AEDT) 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:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=1IMtqaMYWu0ORgYqhnHHSEPO3Sho0qx3E16KNBQ5VpU=; b=RRLFsOKh76jmok ldzRTJl5xJYJkLhIpbaF2ccP7mqi1jHc6FqtxiaZ0p1tK5ZqfeBcwYUSX9cnT7upVIy3dKpZEut7R GCgh8r+OqyGJwcp1If+Sna+SKXDWBComHEHoeVoOYWFBOet2FCTfxJXJz/FGPQXMsFOSiX7xVszAC 4Q9T/eZP+l8+bPR9Kc7yyS+/yrnviztkyNWEDQ9MA36D7vgcu2jAGS032Uhubr1yCme4kNU/6kvuP gFP7T3/H5Cly/qfCzWwXXMGM50hQRUYjoLtou2hn2k5U3+S10PcDiGCCC6Y3wI4XR8Lp7WIfGsFBv tO+qCApgn+MtqzlAUuxw==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmjYo-0000000EiTI-0ocV; Wed, 20 Mar 2024 00:12:02 +0000 Received: from mail-wm1-x335.google.com ([2a00:1450:4864:20::335]) by bombadil.infradead.org with esmtps (Exim 4.97.1 #2 (Red Hat Linux)) id 1rmjYl-0000000EiSb-21FZ for linux-mtd@lists.infradead.org; Wed, 20 Mar 2024 00:12:00 +0000 Received: by mail-wm1-x335.google.com with SMTP id 5b1f17b1804b1-413f4cb646dso41068105e9.1 for ; Tue, 19 Mar 2024 17:11:56 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1710893515; x=1711498315; darn=lists.infradead.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=s5UeCuP+rHqrtuTgJs0v1PQXUHTqmsrEuVFHCUle14o=; b=M2tIhS9Qcvf+WM7UbHGlUF0NTzU6hLq8nQ7e1p+tCo2SQ1LjfVg4DRH3xKOkkGJCC/ 9wWPU71ATcRHCdp867Xn5nlEdHFa1FgZqwk8unGCZg8GiVxWgmLUHtwGNnXOaAh4LazS rtBjReBWb/r4618nPOA1YCs1qSKJJcLlsC6mO/ueec8nuLurhz6mpBooMtDC4UuKzjyV iJ2VKE7wZuf6R7L4AptBHrRlA1wfXsPblv+g2kzgNI9VAqApY/soxqgFCOz2POdubkfy eSsC23j/+GNxyjvHEpleFFOKUYUS4d1Iqu6sRhTF0v62NEW0GF85epVjOamMStQghKZg yf/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1710893515; x=1711498315; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=s5UeCuP+rHqrtuTgJs0v1PQXUHTqmsrEuVFHCUle14o=; b=EcoeQ282NGdtytZ7lym7WRSpgwhlaCftJHzwu0wRhjK1SrbT5mdzuBf3GmNLWvjw4s 5YYOWaC28JAzxrUuHwl+nKK5V8Dm8AIoFjLjGJXmIYmf8bSC+J25Quib+U29D4pKML5G uazXBoOkbIbNIH3/rkYWonriBVDZ3RmBf3bXd93yv6e3wJYiLXxwvA6geSoAmMq5EckB c08Ge99aGp14QrR1W0dbJ/FePgMnN6YAJ/SfoFM1JDl+pxppgtcsd+NitdNSzN0ehPLl /SaNtTsXBZaRSI0leg5fVVKqOjnirKUv1BO9ln2Bd3nGGZoL7wgIFieG5ZQpObke19hV dDnQ== X-Forwarded-Encrypted: i=1; AJvYcCWynupWaRxsaLe1hMb0se/V7heNimQjdEZm8mQ6rpN7Lh3DcuFSMA59B/cKWSovLeliH+bEXBq1xXcloXROna5sMnznGDM7LFpEitU5qw== X-Gm-Message-State: AOJu0Yz+KX7HBYKJLElaHyi10I5LHvqYdp7S7p9BfQBFUP/GNQvENHT+ cmV2QkN8IlEr/dmJq8isnT706fKd4uCbFDaPB+IljMEx/+iY/cOS X-Google-Smtp-Source: AGHT+IH3ETbAdh9odNtGmgi5+pc37TVausHqIdd+KaNxNGb33DnpvHbi2eNlp3wRouIqKjFQ5anQpA== X-Received: by 2002:a05:600c:3b0a:b0:414:cc0:e4d6 with SMTP id m10-20020a05600c3b0a00b004140cc0e4d6mr5937225wms.26.1710893515176; Tue, 19 Mar 2024 17:11:55 -0700 (PDT) Received: from localhost.localdomain (93-34-89-13.ip49.fastwebnet.it. [93.34.89.13]) by smtp.googlemail.com with ESMTPSA id f20-20020a05600c155400b00413eedd36a4sm371478wmg.39.2024.03.19.17.11.54 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 17:11:54 -0700 (PDT) From: Christian Marangi To: Manivannan Sadhasivam , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Sricharan Ramabadhran , Md Sadre Alam , linux-mtd@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-kernel@vger.kernel.org Cc: Christian Marangi , stable@vger.kernel.org Subject: [PATCH] mtd: rawnand: qcom: Fix broken misc_cmd_type in exec_op Date: Wed, 20 Mar 2024 01:11:39 +0100 Message-ID: <20240320001141.16560-1-ansuelsmth@gmail.com> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240319_171159_547670_68987F21 X-CRM114-Status: GOOD ( 13.57 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: misc_cmd_type in exec_op have multiple problems. With commit a82990c8a409 ("mtd: rawnand: qcom: Add read/read_start ops in exec_op path") it was reworked and generalized but actually dropped the handl [...] Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2a00:1450:4864:20:0:0:0:335 listed in] [list.dnswl.org] -0.0 SPF_PASS SPF: sender matches SPF record 0.0 SPF_HELO_NONE SPF: HELO does not publish an SPF Record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 0.0 FREEMAIL_FROM Sender email is commonly abused enduser mail provider [ansuelsmth(at)gmail.com] -0.0 T_SCC_BODY_TEXT_LINE No description available. 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: , Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org misc_cmd_type in exec_op have multiple problems. With commit a82990c8a409 ("mtd: rawnand: qcom: Add read/read_start ops in exec_op path") it was reworked and generalized but actually dropped the handling of the RESET_DEVICE command. The rework itself was correct with supporting case where a single misc command is handled, but became problematic by the addition of exiting early if we didn't had an ERASE or an OP_PROGRAM_PAGE operation. Also additional logic was added without clear explaination causing the erase command to be broken on testing it on a ipq806x nandc. Add some additional logic to restore RESET_DEVICE command handling and fix erase command. Fixes: a82990c8a409 ("mtd: rawnand: qcom: Add read/read_start ops in exec_op path") Cc: stable@vger.kernel.org Signed-off-by: Christian Marangi --- drivers/mtd/nand/raw/qcom_nandc.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/nand/raw/qcom_nandc.c b/drivers/mtd/nand/raw/qcom_nandc.c index b079605c84d3..b8cff9240b28 100644 --- a/drivers/mtd/nand/raw/qcom_nandc.c +++ b/drivers/mtd/nand/raw/qcom_nandc.c @@ -2815,7 +2815,7 @@ static int qcom_misc_cmd_type_exec(struct nand_chip *chip, const struct nand_sub host->cfg0_raw & ~(7 << CW_PER_PAGE)); nandc_set_reg(chip, NAND_DEV0_CFG1, host->cfg1_raw); instrs = 3; - } else { + } else if (q_op.cmd_reg != OP_RESET_DEVICE) { return 0; } @@ -2830,9 +2830,8 @@ static int qcom_misc_cmd_type_exec(struct nand_chip *chip, const struct nand_sub nandc_set_reg(chip, NAND_EXEC_CMD, 1); write_reg_dma(nandc, NAND_FLASH_CMD, instrs, NAND_BAM_NEXT_SGL); - (q_op.cmd_reg == OP_BLOCK_ERASE) ? write_reg_dma(nandc, NAND_DEV0_CFG0, - 2, NAND_BAM_NEXT_SGL) : read_reg_dma(nandc, - NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL); + if (q_op.cmd_reg == OP_BLOCK_ERASE) + write_reg_dma(nandc, NAND_DEV0_CFG0, 2, NAND_BAM_NEXT_SGL); write_reg_dma(nandc, NAND_EXEC_CMD, 1, NAND_BAM_NEXT_SGL); read_reg_dma(nandc, NAND_FLASH_STATUS, 1, NAND_BAM_NEXT_SGL);