Received: by 2002:ab2:620c:0:b0:1ef:ffd0:ce49 with SMTP id o12csp1214583lqt; Tue, 19 Mar 2024 17:12:09 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVeCxS8CrtvzeUeIpVmCpT6sjg9acb9WAiEqiE9ClNFbgBSDbTVjQmNJOIeL06YiDzsEYFEk5N4leydPnIqr039q4ELV8EqhPAiNDr//g== X-Google-Smtp-Source: AGHT+IEm0ftiF08X38HMW417m09phGJ23ibkk2SyTzngsRyN9FZ0+TcvlmBBfH/vekRDgxwEUACO X-Received: by 2002:a17:902:d490:b0:1e0:1bf6:1f89 with SMTP id c16-20020a170902d49000b001e01bf61f89mr6075400plg.0.1710893528743; Tue, 19 Mar 2024 17:12:08 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1710893528; cv=pass; d=google.com; s=arc-20160816; b=skdez7Zvackcjg/DJtuJI2IysukyL6D6Le2gTQIChOcTjQGMAnSlUNwUt5xgdO71Lz 8dRaaveu3aW8DHnTOfnZzUacDgUaiz30ybSq5KU2npDLvXpH5hZo2wYQrlSSpLbY6mEZ 0dW7Tn8ZCel5L1efewdkpDr5qTF3Gy6fQwZX9FRbn+Z4iE5K19cX79SK+H/Ox+2iIudg gQafStCZg03Qgb1ioll1tZOt8bgtyp8jxELPjCJ6VoQtdY6omqxppowvYeq/1TS/+AlC 5TGbixRIKpyk8gJlg4UDmsfdB+oF3F4LJlUp2T6yIshMOZUCLsQejPlrYWK6Jf6xINHy 6xSQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:message-id:date:subject:cc:to :from:dkim-signature; bh=s5UeCuP+rHqrtuTgJs0v1PQXUHTqmsrEuVFHCUle14o=; fh=DdfD6Z20BnzB3h/X94wIcRebu5ACyPVvQchzU37ITzk=; b=sgqgD/DcP2kvLwsw8zvkuMgUJ5ZTpF80V/8Qa1wXPvVpqkzvjY5diweFNBtLK+Duns H4KUCwu7qxpbZ3bxjk0nPiTSZAJnhYljI6eYw7UtDaJxX3U98Gidpo7QQlTJIEqdjaX2 IuygEVcdyDEKx/7mt85ad4cU6LQszZLDxBcKDrfRe7ABbVUcb+fihRZhirdVZiJrIX1/ 5Diyt6jBEuiGy9C/vVZe5thcQWp+dAl4ivd2WcJlN3+jTHJtAWTDOhaLCKdNE2E82xB0 +Q6c2xHqAMpJjjejd4OCY6/rbwScAR3XgTW/T8kE6mSgQ05GTFnUKDxgUzfRYtKLJgmA m4Sg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FBmv1DkD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-108252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [2604:1380:45e3:2400::1]) by mx.google.com with ESMTPS id f4-20020a170902ce8400b001ddcc1543d4si11924350plg.64.2024.03.19.17.12.08 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 19 Mar 2024 17:12:08 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-108252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) client-ip=2604:1380:45e3:2400::1; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20230601 header.b=FBmv1DkD; arc=pass (i=1 spf=pass spfdomain=gmail.com dkim=pass dkdomain=gmail.com dmarc=pass fromdomain=gmail.com); spf=pass (google.com: domain of linux-kernel+bounces-108252-linux.lists.archive=gmail.com@vger.kernel.org designates 2604:1380:45e3:2400::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-108252-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 6CDAB28419B for ; Wed, 20 Mar 2024 00:12:08 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 77C537F8; Wed, 20 Mar 2024 00:11:59 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="FBmv1DkD" Received: from mail-wm1-f44.google.com (mail-wm1-f44.google.com [209.85.128.44]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 0B37B29A9; Wed, 20 Mar 2024 00:11:56 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.128.44 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710893518; cv=none; b=bAOVpxbgkRJX5NAsmbaw0cMqkHcXg8JErDJn58H+0W7u0VPyHOmnjkHNpMSXY0umTIbQariXINE3LLfv/h1SmKtNdEaFYceAxxsI8wkTb9qsowY37lqXEtV2BZb9Tv0M+i3aVhSejaYnKgN+JNZRanUpb9ifnQQkTmAyJ2/za48= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1710893518; c=relaxed/simple; bh=tT/cnq29qDS361LtzVLG3+TjD7UVyvgFr5D6DtgnviA=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=vEjI12F1DaaBJfWdbdF7eiriolBfXd2BQrkXnLS348yNaEyjN0XNTW3cKsJuo+Jhg66NU47nJOuIDoy9nWP8mZbDgpYVg9SUAA6heb80uWi1GKTrFWd43TR+znhutgYePb6jrswEIQZ21YOtzi+qOGJR+e6xfIRGpESswWrftv8= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=FBmv1DkD; arc=none smtp.client-ip=209.85.128.44 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Received: by mail-wm1-f44.google.com with SMTP id 5b1f17b1804b1-41462295004so12199095e9.0; 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=vger.kernel.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=FBmv1DkDhrVDBdi9RyurOfG+9db0yxQQ4e4Ir0e+h4lQl0wcbANLE/7W4VW94yUtMU 37HhmZvDx2mgAQkvDo4V2MDdylidsbrxTgW8JBugdKLY5m6Resb6pEh7n1xed24V7lpq OvXIZdJT2D9TcsfWeRWejyTmlhi8JgOvLEkL2eoYxfI7m0tPK6qy0COsdRjFOiSLHHQ9 tENer/uf4De+SNsZb/1/BkTXcNyjRIaH9fV1FLscvjYqS/HtkQMkeFuYXjbr+UdyasS5 aQQNf+iv3urA5dYeHT9Rs1aAO+x0dsJnVWeHRV+xcAlsfSuhQ9VKOH7QKcCOy3Y/6HRR KLdQ== 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=kGnbOoRZwzVxWPsdw2QvfR6z9/8Gds5Q5hxRZyMi8A7LpvPN9N42gjm5M4WXSWm9bQ crd/u399iSOG54lS2TouACsYoB+narTE6SdYHjuFaQY11wROwzxZ+wbz2gvQDMnAAFoe hn1N9VUENloqjOVL99p4ClIZaIhcWPqGjEIovA5KJ5aTr1fkliCJpHtl5dn5d5ed2uG1 se9ayI80FmCy/AVsYvo9XJlmwiuLmZbeHppGa/mJd85WmUxq/f+g3ulkSNLr+FhYL4ZR NcRxi93wBWfE2JS/xALNjeyDHwgj5Sal9TYml9Du4o8zfkBqx+i2o9LyCcJBDViLUquK Or/Q== X-Forwarded-Encrypted: i=1; AJvYcCVxSszq1F9tjY3N0UGWwVdDMhULL1wqwy/bq9kmUNqDV4UDcKJFQyzVMIPjnLxtJZoNHNc/hcXy+8ZH+PSwrQz83COJ+AUqcb0CqZVBfA2n64hu+L7rGOUDImQfH6OYrcyLrR8wAqliJiYENkqyDtLZ25TsgzZZ1vSNy5nE3ds6P5ydMw== X-Gm-Message-State: AOJu0YwDwi5l7aNkGLA2dNDJUXkeJktKHR1JMe4Sd8gEaeQ+KawBtvBX GdZtNIUoYgFqfZs2VYn3+mX7+FMOZGrRGtkQsn/n06XjLRgpOvWs 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 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit 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); -- 2.43.0