Received: by 2002:a05:7412:2a8c:b0:e2:908c:2ebd with SMTP id u12csp1075649rdh; Mon, 25 Sep 2023 02:26:53 -0700 (PDT) X-Google-Smtp-Source: AGHT+IFcgEHkAU57VPn3PRFeOhpVYd6Cs5k0IVocDHL7iFfA4SAzFHsNXTyVyttsWsvqi34l1xsH X-Received: by 2002:a05:6a00:b48:b0:690:c5cf:91f5 with SMTP id p8-20020a056a000b4800b00690c5cf91f5mr5329839pfo.18.1695634013006; Mon, 25 Sep 2023 02:26:53 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1695634012; cv=none; d=google.com; s=arc-20160816; b=yFnM8LlIKzm9/ey1Nmkkdsoe8eb/EexxU7I4nttyo0YxXtSI87En/oJSbGodD/V2bH HqyjqOQRLbi31bctX4J1FGWPUBbB4TRp/XkKtsetQRPNDNFxVo7qckIU735lwoGktGmc rhBZk3QFB1wbRG2ArTcg9etO6BaleK2AgPrB+azxVPLKLiH8Sa/VLNk97P9ycy7PGJ4z aW+rXDqK44xnku3eEx+x7Rs3eOs3BeHB2IEppWe0F0W7dLg+IdBIzD2SEjIu+Gcpla9p wdh/v3BT9jHYNklzjAJMxf+5Se631YSBynmDfi7yhtGs/GfGzwqIOmOu1Vsh3D2bJPK/ LUWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:thread-index:thread-topic :content-transfer-encoding:mime-version:subject:references :in-reply-to:message-id:cc:to:from:date; bh=86VnfdXVWd/cMHHxahGtV5mnfo8LpyupJbUv4PFfLYE=; fh=PWiRaquxiH2ZOJwhKoTRvjyTLoXHIejTeonWel/s9po=; b=NJd2xL0VXtBdRI3rkb9CcSAD9UlLCC5fHTW8YX/+xEGuehVuTYHgF/AVMzyZKKnFTB nZjQHr/wRNlNowRt1MLf0vRkd9fVzmfffwYb0DPzc4BLLYfOW+oryjEtPII6Svb3VDM5 Mksm5bzKcXM0VXXCroT3wWGPatrPJQuH5v+vtZZ1py6nxle4KY1eC8PQ/L/087IoT+v6 fSCwmowAtKBVyqTr7xsG30J7kpzxri1nHrsqJk3XkRsoJtkj0S4zza7n1jo2xg1oqQN9 TejnLKrbgmb9x76i3FbweePqCTV2r7z5bphcMIjfB3M/qI34XQXXjfx/cE31HsdZn87E qQxw== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from morse.vger.email (morse.vger.email. [2620:137:e000::3:1]) by mx.google.com with ESMTPS id s7-20020a056a00178700b00690258a9766si10205712pfg.373.2023.09.25.02.26.52 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 25 Sep 2023 02:26:52 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) client-ip=2620:137:e000::3:1; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:1 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by morse.vger.email (Postfix) with ESMTP id 59CAE8049F02; Mon, 25 Sep 2023 02:14:59 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at morse.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232804AbjIYJO7 convert rfc822-to-8bit (ORCPT + 99 others); Mon, 25 Sep 2023 05:14:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40012 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232574AbjIYJO6 (ORCPT ); Mon, 25 Sep 2023 05:14:58 -0400 Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7B87DAB for ; Mon, 25 Sep 2023 02:14:49 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id D28EB635DB51; Mon, 25 Sep 2023 11:14:40 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id cwlQYeZ-qSy9; Mon, 25 Sep 2023 11:14:40 +0200 (CEST) Received: from localhost (localhost [127.0.0.1]) by lithops.sigma-star.at (Postfix) with ESMTP id 80AE3622F591; Mon, 25 Sep 2023 11:14:40 +0200 (CEST) Received: from lithops.sigma-star.at ([127.0.0.1]) by localhost (lithops.sigma-star.at [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id wy4TAeGHhR-E; Mon, 25 Sep 2023 11:14:40 +0200 (CEST) Received: from lithops.sigma-star.at (lithops.sigma-star.at [195.201.40.130]) by lithops.sigma-star.at (Postfix) with ESMTP id 5D5FD635DB51; Mon, 25 Sep 2023 11:14:40 +0200 (CEST) Date: Mon, 25 Sep 2023 11:14:40 +0200 (CEST) From: Richard Weinberger To: ZhaoLong Wang Cc: Vignesh Raghavendra , linux-mtd , linux-kernel , chengzhihao1 , yi zhang , yangerkun@huawei.com, Miquel Raynal Message-ID: <495954216.80155.1695633280285.JavaMail.zimbra@nod.at> In-Reply-To: <20230925104938.3f7b4284@xps-13> References: <20230923005856.2538223-1-wangzhaolong1@huawei.com> <20230925104938.3f7b4284@xps-13> Subject: Re: [RFC] mtd: Fix error code loss in mtdchar_read() function. MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8BIT X-Originating-IP: [195.201.40.130] X-Mailer: Zimbra 8.8.12_GA_3807 (ZimbraWebClient - FF97 (Linux)/8.8.12_GA_3809) Thread-Topic: Fix error code loss in mtdchar_read() function. Thread-Index: TtuXiU41OYpt7ia3mZdS86/izvLuwg== X-Spam-Status: No, score=-0.8 required=5.0 tests=HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on morse.vger.email 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 (morse.vger.email [0.0.0.0]); Mon, 25 Sep 2023 02:14:59 -0700 (PDT) ----- Ursprüngliche Mail ----- >> 'total_retlen' is 0, not the error code. > > Actually after looking at the code, I have no strong opinion > regarding whether we should return 0 or an error code in this case. > > There is this comment right above, and I'm not sure it is still up to > date because I believe many drivers just don't provide the data upon > ECC error: > > /* Nand returns -EBADMSG on ECC errors, but it returns > * the data. For our userspace tools it is important > * to dump areas with ECC errors! > * For kernel internal usage it also might return -EUCLEAN > * to signal the caller that a bitflip has occurred and has > * been corrected by the ECC algorithm. > * Userspace software which accesses NAND this way > * must be aware of the fact that it deals with NAND > */ > >> This problem causes the user-space program to encounter EOF when it has >> not finished reading the mtd partion, and this also violates the read >> system call standard in POSIX. This is a special purpose device file and not a regular file. Please explain in detail why this violates POSIX and which program breaks. As pointed out by Miquel, the comment makes it clean that this behavior is on purpose. If we return now all of a sudden -EBADMSG for the described scenario we might even break existing MTD userspace. Thanks, //richard