Received: by 10.223.185.116 with SMTP id b49csp1081561wrg; Sat, 3 Mar 2018 15:02:29 -0800 (PST) X-Google-Smtp-Source: AG47ELvL+HtA9BOdWPJCaQevXjJShZYwb0KUpXTCZc41WXUbPgX1xEgfhut9FQpyFwvBwO2QYXxa X-Received: by 2002:a17:902:6b04:: with SMTP id o4-v6mr825949plk.201.1520118149177; Sat, 03 Mar 2018 15:02:29 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1520118149; cv=none; d=google.com; s=arc-20160816; b=I6AECgdKI4h7QH9uUuovGP1Jbtho7QQ89p/zK47BdWzrkStrznSToeQYviBH0O1ra1 VYWhY6+RczukoSVKy2PiCYVeHK3p98XPbyAmpiqZtzlod+6xQjhdwCEi2I3/Mlcf3wRX +Iw4YXXrl71AS2cYyxVUDEKIQiu8HwvXSIFX+uGSt//5YkT0PaU4okHw+rlrv5N9U5se 8ZlrA6gx7n5u1OmPcWSwSrYvn3te/njYTOLrywCHcAu7MV62Gc6moDUqwULXPIAlQOrC Cy3yylsD2Q6Xw8/S1Eyz1xEyPCnXon2SsD8qvH3ELifJjmrifYVKo9ZBtZTyx8f9xZ/V PSSA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:content-transfer-encoding :spamdiagnosticmetadata:spamdiagnosticoutput:content-language :accept-language:in-reply-to:references:message-id:date:thread-index :thread-topic:subject:cc:to:from:dkim-signature :arc-authentication-results; bh=0Ot0czLW9REkyELrVhC96Y1w0+iNBZ1Yh373iKzWKHk=; b=EjGZ+uOPi13y5x08zgdEOIDYs8sippc0o5UPKEIR1TnhQg/NhebTmKv9ibJvkIxlq2 RXufVsFsclaDOxiDsc3Yprhu/Z13OmxKFCsLDQ6/c0nugnWa9MT8tKJ/bLk88hGk/nSO FHvl04Mqjev06hR5IuN2AXhN/Ke+nDc6Np8a7vdew+Dm/xzSc4Kn0WdeIpLHW4c80Hnt +i9RZAYwFZZEc6JZxDgheFL2ZBvEF2qkebjwFiGZUnCKbHAlnTX72O4ZcZPMuE39DTu4 2Ut6Vw+nKmpX97i650++gVlo/aPkcuWKiH6X7hvH58fBjkeMkr0Nz0frd88ugWlbA/Hj sn0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=le9EJ0qi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l11-v6si7136774pln.323.2018.03.03.15.02.15; Sat, 03 Mar 2018 15:02:29 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@microsoft.com header.s=selector1 header.b=le9EJ0qi; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=REJECT dis=NONE) header.from=microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934710AbeCCWkt (ORCPT + 99 others); Sat, 3 Mar 2018 17:40:49 -0500 Received: from mail-co1nam03on0111.outbound.protection.outlook.com ([104.47.40.111]:9680 "EHLO NAM03-CO1-obe.outbound.protection.outlook.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S933046AbeCCWkq (ORCPT ); Sat, 3 Mar 2018 17:40:46 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=0Ot0czLW9REkyELrVhC96Y1w0+iNBZ1Yh373iKzWKHk=; b=le9EJ0qim3q1NDpFYoaINO24tE+hh0yoDA/o9nZOrqdBd+vePTz3UD7PPjP84jJqbtY3m8sMvf4neC2xVaLUIC2xtf2IRTx2X9q7aDRwrO7wbR+upwqTTsu6FmxFXl3bW4duTzQyhHc+Ij190WKzhvTiyCiLmAcxHJp5k0Ph0Bc= Received: from MW2PR2101MB1034.namprd21.prod.outlook.com (52.132.149.10) by MW2PR2101MB0939.namprd21.prod.outlook.com (52.132.146.12) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.567.5; Sat, 3 Mar 2018 22:40:43 +0000 Received: from MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0]) by MW2PR2101MB1034.namprd21.prod.outlook.com ([fe80::1d56:338f:e2b:cec0%3]) with mapi id 15.20.0567.006; Sat, 3 Mar 2018 22:40:43 +0000 From: Sasha Levin To: "linux-kernel@vger.kernel.org" , "stable@vger.kernel.org" CC: Miquel Raynal , Boris Brezillon , Sasha Levin Subject: [PATCH AUTOSEL for 4.4 092/115] mtd: nand: fix interpretation of NAND_CMD_NONE in nand_command[_lp]() Thread-Topic: [PATCH AUTOSEL for 4.4 092/115] mtd: nand: fix interpretation of NAND_CMD_NONE in nand_command[_lp]() Thread-Index: AQHTsz9odobplVk5AkentklOhsmXoQ== Date: Sat, 3 Mar 2018 22:31:44 +0000 Message-ID: <20180303223010.27106-92-alexander.levin@microsoft.com> References: <20180303223010.27106-1-alexander.levin@microsoft.com> In-Reply-To: <20180303223010.27106-1-alexander.levin@microsoft.com> Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: x-originating-ip: [52.168.54.252] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;MW2PR2101MB0939;7:OTraSLsFsJVL+UCZ8ilQTwUatBfl90fHG6SFblMx6hXXZaPh/JvKeV813OgNzUs64eU9BNM7cSZgzfvkpQL9VUfqynYZ9IZBjKfE1H4FXFi+2Q2c1ZY/lXR0s8hKcgup9n7huQvhFYk/+qowL57PMw/fuuVDcmaJyclhCzghM1NZw5SJ2tAlztwVE8CmroD7QsAoJyo2UaLHB2FXNF2m4J6Lsdrcucac6vjh4lqDG3hcS7OTlUjRwgdyMWe5m6PF x-ms-office365-filtering-ht: Tenant x-ms-office365-filtering-correlation-id: 91104ef6-d4e5-4acc-cb07-08d58157cc30 x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(7020095)(4652020)(48565401081)(5600026)(4604075)(3008032)(4534165)(4627221)(201703031133081)(201702281549075)(2017052603307)(7193020);SRVR:MW2PR2101MB0939; x-ms-traffictypediagnostic: MW2PR2101MB0939: authentication-results: spf=none (sender IP is ) smtp.mailfrom=Alexander.Levin@microsoft.com; x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(28532068793085)(89211679590171)(58145275503218); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(8211001083)(61425038)(6040501)(2401047)(8121501046)(5005006)(3231220)(944501244)(52105095)(3002001)(10201501046)(93006095)(93001095)(6055026)(61426038)(61427038)(6041288)(201703131423095)(201702281528075)(20161123555045)(201703061421075)(201703061406153)(20161123560045)(20161123564045)(20161123558120)(20161123562045)(6072148)(201708071742011);SRVR:MW2PR2101MB0939;BCL:0;PCL:0;RULEID:;SRVR:MW2PR2101MB0939; x-forefront-prvs: 0600F93FE1 x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(396003)(346002)(366004)(376002)(39380400002)(39860400002)(189003)(199004)(86612001)(76176011)(478600001)(81166006)(81156014)(72206003)(5660300001)(8936002)(25786009)(59450400001)(26005)(6506007)(102836004)(316002)(22452003)(6486002)(8676002)(14454004)(4326008)(6436002)(107886003)(10090500001)(6512007)(53936002)(36756003)(10290500003)(86362001)(575784001)(2900100001)(3660700001)(305945005)(2950100002)(5250100002)(99286004)(3280700002)(97736004)(54906003)(110136005)(2501003)(186003)(106356001)(7736002)(66066001)(3846002)(2906002)(6116002)(105586002)(68736007)(1076002)(22906009)(217873001);DIR:OUT;SFP:1102;SCL:1;SRVR:MW2PR2101MB0939;H:MW2PR2101MB1034.namprd21.prod.outlook.com;FPR:;SPF:None;PTR:InfoNoRecords;MX:1;A:1;LANG:en; received-spf: None (protection.outlook.com: microsoft.com does not designate permitted sender hosts) x-microsoft-antispam-message-info: cUBroAtVsEUIOeP9Fh+ddiqjy10NKflEUZsqDBqRrya3l/NjBfPwUyUMckh7KDDy3hyOCsfkks7I428mEx90HphAf7c8AdU9SQbw3nrK6qFIu3xznW3kvkYKtyoN4TxYYt+472GAriqSnvuOXGdaUwCGXWQKcsWMtRpts2AKeXw= spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable MIME-Version: 1.0 X-OriginatorOrg: microsoft.com X-MS-Exchange-CrossTenant-Network-Message-Id: 91104ef6-d4e5-4acc-cb07-08d58157cc30 X-MS-Exchange-CrossTenant-originalarrivaltime: 03 Mar 2018 22:31:44.5270 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: 72f988bf-86f1-41af-91ab-2d7cd011db47 X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW2PR2101MB0939 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Miquel Raynal [ Upstream commit df467899da0b71465760b4e35127bce837244eee ] Some drivers (like nand_hynix.c) call ->cmdfunc() with NAND_CMD_NONE and a column address and expect the controller to only send address cycles. Right now, the default ->cmdfunc() implementations provided by the core do not filter out the command cycle in this case and forwards the request to the controller driver through the ->cmd_ctrl() method. The thing is, NAND controller drivers can get this wrong and send a command cycle with a NAND_CMD_NONE opcode and since NAND_CMD_NONE is -1, and the command field is usually casted to an u8, we end up sending the 0xFF command which is actually a RESET operation. Add conditions in nand_command[_lp]() functions to sending the initial command cycle when command =3D=3D NAND_CMD_NONE. Signed-off-by: Miquel Raynal Signed-off-by: Boris Brezillon Signed-off-by: Sasha Levin --- drivers/mtd/nand/nand_base.c | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/nand/nand_base.c b/drivers/mtd/nand/nand_base.c index 27864c0863ef..8406f346b0be 100644 --- a/drivers/mtd/nand/nand_base.c +++ b/drivers/mtd/nand/nand_base.c @@ -626,7 +626,8 @@ static void nand_command(struct mtd_info *mtd, unsigned= int command, chip->cmd_ctrl(mtd, readcmd, ctrl); ctrl &=3D ~NAND_CTRL_CHANGE; } - chip->cmd_ctrl(mtd, command, ctrl); + if (command !=3D NAND_CMD_NONE) + chip->cmd_ctrl(mtd, command, ctrl); =20 /* Address cycle, when necessary */ ctrl =3D NAND_CTRL_ALE | NAND_CTRL_CHANGE; @@ -655,6 +656,7 @@ static void nand_command(struct mtd_info *mtd, unsigned= int command, */ switch (command) { =20 + case NAND_CMD_NONE: case NAND_CMD_PAGEPROG: case NAND_CMD_ERASE1: case NAND_CMD_ERASE2: @@ -717,7 +719,9 @@ static void nand_command_lp(struct mtd_info *mtd, unsig= ned int command, } =20 /* Command latch cycle */ - chip->cmd_ctrl(mtd, command, NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); + if (command !=3D NAND_CMD_NONE) + chip->cmd_ctrl(mtd, command, + NAND_NCE | NAND_CLE | NAND_CTRL_CHANGE); =20 if (column !=3D -1 || page_addr !=3D -1) { int ctrl =3D NAND_CTRL_CHANGE | NAND_NCE | NAND_ALE; @@ -750,6 +754,7 @@ static void nand_command_lp(struct mtd_info *mtd, unsig= ned int command, */ switch (command) { =20 + case NAND_CMD_NONE: case NAND_CMD_CACHEDPROG: case NAND_CMD_PAGEPROG: case NAND_CMD_ERASE1: --=20 2.14.1