From patchwork Thu Oct 13 22:28:55 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Linus Walleij X-Patchwork-Id: 614760 Delivered-To: patch@linaro.org Received: by 2002:a17:522:c983:b0:460:3032:e3c4 with SMTP id kr3csp514881pvb; Thu, 13 Oct 2022 15:32:22 -0700 (PDT) X-Google-Smtp-Source: AMsMyM5GcKVjGtxXiyF71oQS/IIl2kSKNa7rHZIbNjDdK1ZCeZmezPlSb5hQd32cPpJm8KHzH6lh X-Received: by 2002:a17:90a:d390:b0:20d:3b10:3811 with SMTP id q16-20020a17090ad39000b0020d3b103811mr13835781pju.211.1665700332030; Thu, 13 Oct 2022 15:32:12 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1665700332; cv=none; d=google.com; s=arc-20160816; b=iPERl7TZfpD3ClyZVug9OUmw3dh19MuOhjLnqBgQsHmu+JEIUCajIXxpk+IdDn3keK kiPOlcmTG8gwgtCXEru+lgWV1fzd/p++4MLJwNjPYnLvsPj/8vnoSRqq1iyWUDBueT7N P+d/Z8kJeIxByeqJEQw3DfWjbaOAzDfNth4MJ6zRPQppwJRkW41n03UXKHFHqPgmmLVq dGvbT5pjIGJXdhNhU4+XsqczPWTV8TbDZOB4mUz0Qbh8ywYc+sNLaD3Xg209d/LOiGrz kZN0Bt8nAEJ+Niup6Fmtg7YMxElpTZqkBlgDohLNx9LB9CfrUxkgrJBmk1wyzihMD5PJ VdRw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=errors-to:sender:content-transfer-encoding:list-subscribe:list-help :list-post:list-archive:list-unsubscribe:list-id:precedence :mime-version:message-id:date:subject:cc:to:from:dkim-signature :dkim-signature; bh=L2Cg9PE5WfpXnG+UwWKoQFN3vnQi09JfdRIMcHWp8js=; b=gUUclPAg0OynDphwPo5er9guryVTjN/agtm2glW71SvpwSTNiNsumKliY89fydPGqh b7IhvaDcK568/8sVPKx4NZsuwWJiUR7lRzX0gS+k/SawBhFrM9Wnpr2Owzqadgjqq0qJ Mld4SJLtUrR+dx1we41ulsd5VU9ZfZJD5AE8rR+owNSGV9S6qp+Ji4QKveu/IOPlUs9g vp4dIApyFK9XmLKyjveym0pm0xwVK1TUihVgGc1jD8nDGVXhmSFxyC5hylEfte16wj5R sd9JuO5Xv7QfgUJC251rO2J8LCF7JQFoX1dp1CRTX1dK6ODgZet/Y13X+Zvu9ea0/azK tPBA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=TlQXcjHI; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EmILxCB7; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from bombadil.infradead.org (bombadil.infradead.org. [2607:7c80:54:3::133]) by mx.google.com with ESMTPS id s189-20020a632cc6000000b0043c5dfca83esi848751pgs.19.2022.10.13.15.32.11 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 15:32:12 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) client-ip=2607:7c80:54:3::133; Authentication-Results: mx.google.com; dkim=pass header.i=@lists.infradead.org header.s=bombadil.20210309 header.b=TlQXcjHI; dkim=neutral (body hash did not verify) header.i=@linaro.org header.s=google header.b=EmILxCB7; spf=pass (google.com: best guess record for domain of linux-mtd-bounces+patch=linaro.org@lists.infradead.org designates 2607:7c80:54:3::133 as permitted sender) smtp.mailfrom="linux-mtd-bounces+patch=linaro.org@lists.infradead.org"; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=linaro.org 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=L2Cg9PE5WfpXnG+UwWKoQFN3vnQi09JfdRIMcHWp8js=; b=TlQXcjHIp3UYdD Sl8vAL+F5Mi58hfhwAnZt0cGJDGajQq5vgNdFoAWKpoAvMXAKOr9XUtad/QaQGJHeseHdJF7bzKjh SeB/iNuzBnL+tjNpaLRscRl6vA+3xPSuEaaeQkXLYqezcfUnBUJalqnW3mXkO99eMgTog6P5FAkXo +Wg2n7j+iRcT3neUSxnXZjN15swGxEYd9EevIg5NP61DpgFHrTMp2LPzaEKybjdchGJp83qls9Buk YuMgPa8CeNqmQ7dlQ3GMg5mYXWO1PN1Rv7u+qASvquBTCpF39XX1ZAK4M0iDJZyKq3mZ3Oc/NE3Ye UDxj9Wpi6iVGfd1N972Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj6jH-00D6Cd-Kr; Thu, 13 Oct 2022 22:31:03 +0000 Received: from mail-lj1-x22a.google.com ([2a00:1450:4864:20::22a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oj6jE-00D6CI-S8 for linux-mtd@lists.infradead.org; Thu, 13 Oct 2022 22:31:02 +0000 Received: by mail-lj1-x22a.google.com with SMTP id j23so4010910lji.8 for ; Thu, 13 Oct 2022 15:30:59 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=Cio19eOorEpvC0IXTz19MRWiUl8flOGKJqR6efzpLpU=; b=EmILxCB7hEHCT0phtbWECct4UOAJS+2Bl4fvzOJIzlr8ApCs9+rg0olOVhNoonV99m mEGnCdEDMcZbOAMXvoqklhZNeR9m3tg6kfhBE/Lpupnn3oyH0Bi4WguENMzzxwDLfoQL EoK/1LnkDJ8tKqVcaA/6IPVIWxBlsQ+NNFkmiDhiWXE2N5vrp9oaCfuFKhFSmGop4zao Kq7+Y3z81fiHupANJUEcSNN4GzWdxYyb5HXGWjtSGtZvfKd3/KFhVdxehsTi3sZui1z9 vPBiusAMLViYw///lbuyNIympWbr+N/wvI62RP8/FS7nlXII3Xc3ARDvl5HZhEN505FV omVg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; 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=Cio19eOorEpvC0IXTz19MRWiUl8flOGKJqR6efzpLpU=; b=XS8NpEuSHod1A0RhNfWCKAhkjBZbRH+FQ+kokZcuMqrlUzJQFpIpQDh8V6EQPHYznz s97RvgIXu3Hxu7AQANkhTeT1ZCXYmfyOyyLlNBtJrDpeUJGdcRvH0++RlVKSvCl+4rDx T9VuOmpiUTLaj8bw3ZYrFNsBAtu6zrrn+7rhwJ/t/pn/qRl1v5UDy7gapu7GwBUlbyEr 96loW+0ELihxYOClxBbyzPcecThwN0DAvUMuGUM5JX8nR7Y4h83+2ENXuSIoxHnz4Obo Ab0wiff+HAozm+4JKI3z78lezRVe7YCkxamwKPF8jl5gyG2njKVMTVWIoXlZkIISSQFK ijFA== X-Gm-Message-State: ACrzQf390syQDj9Zx+WbTLqRQi+7Hzncmy5xg027ViJ/BTlJY1TAdFmZ nuf93frc/EwwSxd7PA2NYeI6sQ== X-Received: by 2002:a05:651c:88:b0:26d:fab0:3269 with SMTP id 8-20020a05651c008800b0026dfab03269mr755066ljq.193.1665700257945; Thu, 13 Oct 2022 15:30:57 -0700 (PDT) Received: from localhost.localdomain (c-fdcc225c.014-348-6c756e10.bbcust.telenor.se. [92.34.204.253]) by smtp.gmail.com with ESMTPSA id u7-20020ac24c27000000b0049ad315cfc3sm83296lfq.162.2022.10.13.15.30.57 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 13 Oct 2022 15:30:57 -0700 (PDT) From: Linus Walleij To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, Linus Walleij , =?utf-8?b?UmFmYcWCIE1pxYJlY2tp?= Subject: [PATCH] mtd: parsers: bcm47xxpart: Fix halfblock reads Date: Fri, 14 Oct 2022 00:28:55 +0200 Message-Id: <20221013222855.2384881-1-linus.walleij@linaro.org> X-Mailer: git-send-email 2.37.3 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221013_153100_972378_A2D33273 X-CRM114-Status: GOOD ( 15.28 ) 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: There is some code in the parser that tries to read 0x8000 bytes into a block to "read in the middle" of the block. Well that only works if the block is also 0x10000 bytes all the time, else we get th [...] 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:22a 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_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain 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+patch=linaro.org@lists.infradead.org There is some code in the parser that tries to read 0x8000 bytes into a block to "read in the middle" of the block. Well that only works if the block is also 0x10000 bytes all the time, else we get these parse errors as we reach the end of the flash: spi-nor spi0.0: mx25l1606e (2048 Kbytes) mtd_read error while parsing (offset: 0x200000): -22 mtd_read error while parsing (offset: 0x201000): -22 (...) Fix the code to do what I think was intended. Cc: Rafał Miłecki Signed-off-by: Linus Walleij --- drivers/mtd/parsers/bcm47xxpart.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/parsers/bcm47xxpart.c b/drivers/mtd/parsers/bcm47xxpart.c index 50fcf4c2174b..13daf9bffd08 100644 --- a/drivers/mtd/parsers/bcm47xxpart.c +++ b/drivers/mtd/parsers/bcm47xxpart.c @@ -233,11 +233,11 @@ static int bcm47xxpart_parse(struct mtd_info *master, } /* Read middle of the block */ - err = mtd_read(master, offset + 0x8000, 0x4, &bytes_read, + err = mtd_read(master, offset + (blocksize / 2), 0x4, &bytes_read, (uint8_t *)buf); if (err && !mtd_is_bitflip(err)) { pr_err("mtd_read error while parsing (offset: 0x%X): %d\n", - offset + 0x8000, err); + offset + (blocksize / 2), err); continue; }