Received: by 2002:a05:7412:3784:b0:e2:908c:2ebd with SMTP id jk4csp1380978rdb; Mon, 2 Oct 2023 07:58:17 -0700 (PDT) X-Google-Smtp-Source: AGHT+IEa2p1NpAX0Ewi3cHPn23YZYROqsD+c9vCtj3voCwHFRWi1A2ptOwfr1cOseK/I5mqAbYNT X-Received: by 2002:a05:6a21:614:b0:13d:17cc:5bca with SMTP id ll20-20020a056a21061400b0013d17cc5bcamr8863095pzb.18.1696258696825; Mon, 02 Oct 2023 07:58:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1696258696; cv=none; d=google.com; s=arc-20160816; b=K0uT7dv60YAXTtIH4V6U0wjpfuAiV8kAmRWBhluLHjyzIBe/3l/uEovb0f6zlhR3sc K+Fr+aRhbkvham3Kq4pY1EIfad0kxwFf85Y5g+cy8FRv/eqzjGwDQMvvouQcbwXOcGjs MgivcN2xASgCmqpV7KiSJW8IpADYqzloGQcz+I3npKIq5Ki22/GLZZVs+3m9TuRDKrYk 2TuufeCssr+7fmsN05qPwXNjN1Hq4+YFCX8DtxljY+XCRXk8dcILFVO0pquPCLQJJx+U 4TmokW6ZME3YYov7Pgq7DDaG4Qhv2QhZ7nHvNzLiQ5yfrzPZu5B4yDandBuBZogBCaff EE8w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :organization:references:in-reply-to:message-id:subject:cc:to:from :date:dkim-signature; bh=nNMuGJL44gj1ZB3e/uIcPx32jrKTbp3WUjy5cGFxIrI=; fh=uhR+oAvRGfDuobu/e7ROFq3vnC0ZMz2+vciDXiqI+Zw=; b=LFkR2M/puFDA1g+7MR6J2U/sykVxKH4aeHLFLS0qFI4PHwJmI9JHNku2pHsucgLHYw XjrcE4VceEDRQw2lBdPFVecLKQMvWWclalOBwLmZVX/Nw2ADVLrlJXtGf9LaIxF6aRku Qkk8KRb69mFUvUqrQQjsEGTyms6jYvcQhAURyT9LL7b6BcAKk2FmMrnE57YMNwaIVRJ7 bGhJc1RKMnCCjOIhK9cwNWfGw1ibNmow+Wn3UD+G3Jp7Ngo7ufpq6sGHYUiHegO6rWX1 kN4oQ5YrA3TNYWJTFaasA0PW3vR6ZXxzz9iXMmZc5Vhcj3DQXG1VR3g4Bx+ULowvbHjZ iF+Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@bootlin.com header.s=gm1 header.b=UaYnoZbI; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Return-Path: Received: from howler.vger.email (howler.vger.email. [2620:137:e000::3:4]) by mx.google.com with ESMTPS id e14-20020a17090301ce00b001c73e443f8csi10334848plh.162.2023.10.02.07.58.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 02 Oct 2023 07:58:16 -0700 (PDT) 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=@bootlin.com header.s=gm1 header.b=UaYnoZbI; 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=REJECT sp=REJECT dis=NONE) header.from=bootlin.com Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by howler.vger.email (Postfix) with ESMTP id ABCF6807D8C2; Mon, 2 Oct 2023 05:35:39 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at howler.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236804AbjJBMfg (ORCPT + 99 others); Mon, 2 Oct 2023 08:35:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:38582 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236623AbjJBMfg (ORCPT ); Mon, 2 Oct 2023 08:35:36 -0400 Received: from relay6-d.mail.gandi.net (relay6-d.mail.gandi.net [217.70.183.198]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B38B383 for ; Mon, 2 Oct 2023 05:35:32 -0700 (PDT) Received: by mail.gandi.net (Postfix) with ESMTPSA id 023FAC000C; Mon, 2 Oct 2023 12:35:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=bootlin.com; s=gm1; t=1696250131; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=nNMuGJL44gj1ZB3e/uIcPx32jrKTbp3WUjy5cGFxIrI=; b=UaYnoZbI9nCRnp+/H4oltdkSs70wxX+I01PxntZGZZYeYIJCrGKSNK5eg7y892Qh6Eolct 30aCRk5yz1i4cV5BBApon3dVHnya7+DDwsjYzfDsxW5UGL0Y38C3656zFcjExO3zNvfsKx XzBkxnFwIGfE3b8uN4lCuP0/OCwHinymBiscuCF3/vXjTyhyV+uWtatIj1ZJP/Zwx36rhD ONhPESCrNSzZruBIJtCyK73GNT1cY9eQmyP89tNSMqjw9DOx2cS3sclxSqwDmH9735hEsd oTriY9YKyORJbbr24sw1CqZEczeb6FagqrBM8fcpCtTsKynVd3umVkFdRi5PAw== Date: Mon, 2 Oct 2023 14:35:27 +0200 From: Miquel Raynal To: dregan@mail.com Cc: bcm-kernel-feedback-list@broadcom.com, linux-mtd@lists.infradead.org, f.fainelli@gmail.com, rafal@milecki.pl, joel.peshkin@broadcom.com, computersforpeace@gmail.com, dan.beygelman@broadcom.com, william.zhang@broadcom.com, frieder.schrempf@kontron.de, linux-kernel@vger.kernel.org, vigneshr@ti.com, richard@nod.at, bbrezillon@kernel.org, kdasu.kdev@gmail.com Subject: Re: [PATCH v2] mtd: rawnand: brcmnand: Initial exec_op implementation Message-ID: <20231002143527.4ccf254a@xps-13> In-Reply-To: References: <20230922162424.4a7b27ec@xps-13> Organization: Bootlin X-Mailer: Claws Mail 4.0.0 (GTK+ 3.24.33; x86_64-pc-linux-gnu) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable X-GND-Sasl: miquel.raynal@bootlin.com X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_BLOCKED, RCVD_IN_MSPIKE_H5,RCVD_IN_MSPIKE_WL,SPF_HELO_PASS,SPF_PASS autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net 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]); Mon, 02 Oct 2023 05:35:39 -0700 (PDT) Hi David, dregan@mail.com wrote on Sat, 30 Sep 2023 03:57:35 +0200: > Initial exec_op implementation for Broadcom STB, Broadband and iProc SoC > This adds exec_op and removes the legacy interface. >=20 > Signed-off-by: David Regan > Reviewed-by: William Zhang >=20 > --- >=20 ... > +static int brcmnand_parser_exec_matched_op(struct nand_chip *chip, > + const struct nand_subop *subop) > +{ > + struct brcmnand_host *host =3D nand_get_controller_data(chip); > + struct brcmnand_controller *ctrl =3D host->ctrl; > + struct mtd_info *mtd =3D nand_to_mtd(chip); > + const struct nand_op_instr *instr =3D &subop->instrs[0]; > + unsigned int i; > + int ret =3D 0; > + > + for (i =3D 0; i < subop->ninstrs; i++) { > + instr =3D &subop->instrs[i]; > + > + if ((instr->type =3D=3D NAND_OP_CMD_INSTR) && > + (instr->ctx.cmd.opcode =3D=3D NAND_CMD_STATUS)) > + ctrl->status_cmd =3D 1; > + else if (ctrl->status_cmd && (instr->type =3D=3D NAND_OP_DATA_IN_INSTR= )) { > + /* > + * need to fake the nand device write protect because nand_base does a > + * nand_check_wp which calls nand_status_op NAND_CMD_STATUS which che= cks > + * that the nand is not write protected before an operation starts. > + * The problem with this is it's done outside exec_op so the nand is > + * write protected and this check will fail until the write or erase > + * or write back operation actually happens where we turn off wp. > + */ > + u8 *in; > + > + ctrl->status_cmd =3D 0; > + > + instr =3D &subop->instrs[i]; > + in =3D instr->ctx.data.buf.in; > + in[0] =3D brcmnand_status(host) | NAND_STATUS_WP; /* hide WP status */ I don't understand why you are faking the WP bit. If it's set, brcmnand_status() should return it and you should not care about it. If it's not however, can you please give me the path used when we have this issue? Either we need to modify the core or we need to provide additional helpers in this driver to circumvent the faulty path. > + } else if (instr->type =3D=3D NAND_OP_WAITRDY_INSTR) { > + ret =3D bcmnand_ctrl_poll_status(host, NAND_CTRL_RDY, NAND_CTRL_RDY, = 0); > + if (ctrl->wp_cmd) { > + ctrl->wp_cmd =3D 0; > + brcmnand_wp(mtd, 1); This ideally should disappear. > + } > + } else { /* otherwise pass to low level implementation */ > + if ((instr->type =3D=3D NAND_OP_CMD_INSTR) && > + (instr->ctx.cmd.opcode =3D=3D NAND_CMD_RESET)) { > + brcmnand_status(host); > + ctrl->status_cmd =3D 0; > + ctrl->wp_cmd =3D 0; > + brcmnand_wp(mtd, 1); Same > + } > + > + if ((instr->type =3D=3D NAND_OP_CMD_INSTR) && > + ((instr->ctx.cmd.opcode =3D=3D NAND_CMD_ERASE1) || > + (instr->ctx.cmd.opcode =3D=3D NAND_CMD_SEQIN))) { > + brcmnand_wp(mtd, 0); > + ctrl->wp_cmd =3D 1; Same > + } > + > + ret =3D brcmnand_exec_instr(host, instr, i =3D=3D (subop->ninstrs - 1= )); > + } > + } > + > + return ret; > +} Thanks, Miqu=C3=A8l