From patchwork Wed Jun 6 10:13:27 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 925791 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infinera.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="F+SeSqZE"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="VXK6MUnn"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4114Kh6wLwzB3h4 for ; Wed, 6 Jun 2018 20:14:48 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=CJ38lfCEzYxulk2hxDGI71gFpXa/8BMRbKXEjvYIRDk=; b=F+SeSqZEsG6+ae7NMxP6mAJKcn Pke+6u3C62VQ5H3atT0QWqdMO/yWrwcrZaSJ/VKFe32voVtnYDaZX30qmvU2cir3AkBTjMThUJueF IBpfxJ9VfY9/T/+8px2SU8/QuCcNA4zNeRPC7S4w334aBCcURg6esIR8HkiJ0wBtAgzFNi9YOzxMn akrDd+xLDMSrijL5gd26ZRjB00zy8d98WaBzbvQUNOYjtj0zGsUPkW5bx3HL7rv7zf+IzR/nb4v3f 85cEYxo1bYytBws9ArxhQB9bICrxM+65zIHK6tQ+ADKWUZwK/B9sS6oScJnX9CEJKvCA7DmcBlzch iWXpbU7A==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSf-0006Ik-Mq; Wed, 06 Jun 2018 10:14:37 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSK-00060G-G8 for linux-mtd@bombadil.infradead.org; Wed, 06 Jun 2018 10:14:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=8gvNH+5sJg1WM4ECreJ6eNiFCo+UszsZ4KAX/yOX/f4=; b=VXK6MUnn3aJ3RPYzAnq4+7VS9 oHroKVkBLhxi+60KmkmdvepdWgwBsEYN6TFkV3ThTG2gUjd5lF3IrpbVuGez+P5T/eOQb5gVQx6Er YM8jfWdIfDg5v97u7aOiG2zA/kExNlzKl6uTt8LHNChzaR7mAxL76LK4U3Te1IWQTYT4vBgq9rT+o dO5SbFo+3j1d3ah+SBJPuXciAeY824wrfONxaUG8H5kjFw9Sm+UbCcoBlM2nD2osAy26FWBn9VMbp 0Bkm/j2DskURI4wjzKtLQtC08f597w0RLNBgkzQ6CXGp6HJSts30tZVL0/TEES9pEwYWS1I12sNNA n94cX1AuA==; Received: from smtp.transmode.se ([31.15.61.139]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSH-0003vv-3L for linux-mtd@lists.infradead.org; Wed, 06 Jun 2018 10:14:15 +0000 Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [10.210.72.209]) by smtp.transmode.se (Postfix) with ESMTP id D69B7118707C; Wed, 6 Jun 2018 12:13:41 +0200 (CEST) Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [127.0.0.1]) by gentoo-jocke.infinera.com (8.14.9/8.14.9) with ESMTP id w56ADfuQ011229; Wed, 6 Jun 2018 12:13:41 +0200 Received: (from jocke@localhost) by gentoo-jocke.infinera.com (8.14.9/8.14.9/Submit) id w56ADf3Z011228; Wed, 6 Jun 2018 12:13:41 +0200 From: Joakim Tjernlund To: "linux-mtd @ lists . infradead . org" , Boris Brezillon Subject: [PATCH v2 1/4] mtd: cfi_cmdset_0002: Use right chip in do_ppb_xxlock() Date: Wed, 6 Jun 2018 12:13:27 +0200 Message-Id: <20180606101330.11071-1-joakim.tjernlund@infinera.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180605172607.50acb34f@bbrezillon> References: <20180605172607.50acb34f@bbrezillon> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180606_111413_188756_3A59C568 X-CRM114-Status: GOOD ( 21.26 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , stable@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org do_ppb_xxlock() fails to add chip->start when quering for lock status(and chip_ready test), which caused false status reports. Fix by adding adr += chip->start and adjust call sites accordingly. Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking") Cc: stable@vger.kernel.org Signed-off-by: Joakim Tjernlund --- v2 - Spilt into several patches drivers/mtd/chips/cfi_cmdset_0002.c | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 53a976a8e614..8648b1adccd5 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -2554,8 +2554,9 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map, unsigned long timeo; int ret; + adr += chip->start; mutex_lock(&chip->mutex); - ret = get_chip(map, chip, adr + chip->start, FL_LOCKING); + ret = get_chip(map, chip, adr, FL_LOCKING); if (ret) { mutex_unlock(&chip->mutex); return ret; @@ -2573,8 +2574,8 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map, if (thunk == DO_XXLOCK_ONEBLOCK_LOCK) { chip->state = FL_LOCKING; - map_write(map, CMD(0xA0), chip->start + adr); - map_write(map, CMD(0x00), chip->start + adr); + map_write(map, CMD(0xA0), adr); + map_write(map, CMD(0x00), adr); } else if (thunk == DO_XXLOCK_ONEBLOCK_UNLOCK) { /* * Unlocking of one specific sector is not supported, so we @@ -2612,7 +2613,7 @@ static int __maybe_unused do_ppb_xxlock(struct map_info *map, map_write(map, CMD(0x00), chip->start); chip->state = FL_READY; - put_chip(map, chip, adr + chip->start); + put_chip(map, chip, adr); mutex_unlock(&chip->mutex); return ret; From patchwork Wed Jun 6 10:13:28 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 925792 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infinera.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="tZEk5O0C"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="SiBnbZcH"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4114LK6VCnzB3h4 for ; Wed, 6 Jun 2018 20:15:21 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=nOZ9cDm5P0DJrcEprTSLLORxwrXVk78OSfDxmDLcx48=; b=tZEk5O0CPLBdDdptUgWhyIBW1p ruxRss1YWehO3pJrdZhjYjmbkgI7iLqzCorIopqvVJ8C8v8GfWSvu7NREHX7Yz+n7CdKx6zx0Sw62 rufIzWNoEyOn1JX/18OTfeRRZ39+nc33JngxkBAP1ErISylUBfHh3rNwArVKuSY1Weux/qpjam5do LC/WECeA8WENXdKSNmUqF2SKcfHZYGS+y1W9uGdBpZ7XiL4lIiIv0cGN+/opgCMbe63DfaEjpqkvw j4wSbXhEZqz9yf7GpThT91+vAcOqXlUSe5Sr0QfIGaUfb/gMJ5wOUhntpF6ZcThCeye9gcf+yw5FQ 9RzpzXOQ==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVTF-00071v-DH; Wed, 06 Jun 2018 10:15:13 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSL-00062d-St for linux-mtd@bombadil.infradead.org; Wed, 06 Jun 2018 10:14:18 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=piUhdKb61qbh8eIibEwbgVlZQVsq7mjp4z7zYOHCI/U=; b=SiBnbZcHYeE/keo7/rDWFho0C b2WqbCccpATZkJgCXPqyDNwotill7uEJ99ju7D3VPR885jO8TQnrcDfbj4C/F5KUkyNCCGLQlJ7hn CXVNWQsEyBllydbnouyC870/GCMGbHRi+DgR1fMUdqPjo5x9M5Qz6tmqlQR9FfzuITCD4I+dCJMPQ abhHBLZUb+olcuXXrMZstjQF7cZMVU78vsk19BmrHFNJjeddobz1WBGW3k0qgQ7mNNJ4L4SH/vmVM 3mzmT3yHvv5LGM0GOjOqxA2EJ/yMDJf/ZSUiSCDaddaeDyb9+/jcW8vpOhzOiFfOA6cgM7FjISFyG Vmv2Oe2Fg==; Received: from smtp.transmode.se ([31.15.61.139]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSH-0003vy-3K for linux-mtd@lists.infradead.org; Wed, 06 Jun 2018 10:14:16 +0000 Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [10.210.72.209]) by smtp.transmode.se (Postfix) with ESMTP id ECE7F118A708; Wed, 6 Jun 2018 12:13:42 +0200 (CEST) Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [127.0.0.1]) by gentoo-jocke.infinera.com (8.14.9/8.14.9) with ESMTP id w56ADgHI011233; Wed, 6 Jun 2018 12:13:42 +0200 Received: (from jocke@localhost) by gentoo-jocke.infinera.com (8.14.9/8.14.9/Submit) id w56ADg9i011232; Wed, 6 Jun 2018 12:13:42 +0200 From: Joakim Tjernlund To: "linux-mtd @ lists . infradead . org" , Boris Brezillon Subject: [PATCH v2 2/4] mtd: cfi_cmdset_0002: fix SEGV unlocking multiple chips Date: Wed, 6 Jun 2018 12:13:28 +0200 Message-Id: <20180606101330.11071-2-joakim.tjernlund@infinera.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180606101330.11071-1-joakim.tjernlund@infinera.com> References: <20180605172607.50acb34f@bbrezillon> <20180606101330.11071-1-joakim.tjernlund@infinera.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180606_111413_198230_F7E36F7F X-CRM114-Status: GOOD ( 22.90 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , stable@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org cfi_ppb_unlock() tries to relock all sectors that was locked before unlocking the whole chip. This locking used the chip start address + the FULL offset from the first flash chip, thereby forming an illegal address. Correct by using the chip offset(adr). Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking") Cc: stable@vger.kernel.org Signed-off-by: Joakim Tjernlund --- v2 - Spilt into several patches drivers/mtd/chips/cfi_cmdset_0002.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index 8648b1adccd5..cb85cccc48c1 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -2536,7 +2536,7 @@ static int cfi_atmel_unlock(struct mtd_info *mtd, loff_t ofs, uint64_t len) struct ppb_lock { struct flchip *chip; - loff_t offset; + unsigned long adr; int locked; }; @@ -2672,7 +2672,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, */ if ((adr < ofs) || (adr >= (ofs + len))) { sect[sectors].chip = &cfi->chips[chipnum]; - sect[sectors].offset = offset; + sect[sectors].adr = adr; sect[sectors].locked = do_ppb_xxlock( map, &cfi->chips[chipnum], adr, 0, DO_XXLOCK_ONEBLOCK_GETLOCK); @@ -2716,7 +2716,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, */ for (i = 0; i < sectors; i++) { if (sect[i].locked) - do_ppb_xxlock(map, sect[i].chip, sect[i].offset, 0, + do_ppb_xxlock(map, sect[i].chip, sect[i].adr, 0, DO_XXLOCK_ONEBLOCK_LOCK); } From patchwork Wed Jun 6 10:13:29 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 925793 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infinera.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="osJdBM0w"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="C7UVHJy8"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4114Ls0GF3zB3h4 for ; Wed, 6 Jun 2018 20:15:49 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=Ftp7Qd2SeGsscE1xQiuMgzbImJMZSh/+1Id3l6ZxttA=; b=osJdBM0wk3dQVO5/wFqKnaSIfq PPAkKFPA8EL70OV5pWQd6OtfwJHwCU5Iy4BjxiCG+dIL1rGWxiniurELs/8pGxpcx+ID/MXe+bU2a u0I7m8iWN0v7Br1UdjRurIQkFwfY/8JQgKc662/9C80y3tAyghQXu2DwzF7ZkoQVaIILD+x6aDPSi HwcaiiPxSIsIwctW00MzyHs/ECB8oUmO56GSuRozsJ3AMLHtYKjJfYDkYBHoD2mUON4kwCmbCHxTp 1DjbHVZiDZEpBRX3wHJ31wRf6dWRxQwTeRzw2Z/OuZw4VBirm/lV8C/G3X2YVo3JTDAR71pMZkvUO sn5pSc+Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVTi-0008Jp-PV; Wed, 06 Jun 2018 10:15:42 +0000 Received: from merlin.infradead.org ([2001:8b0:10b:1231::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSQ-00067o-P6 for linux-mtd@bombadil.infradead.org; Wed, 06 Jun 2018 10:14:22 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=merlin.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=emame6Pfma7DNe7ENxBczDJJHjml1N9dFnUnsc6GCYY=; b=C7UVHJy8PWnmerenlQjuwrgsf 2iCZ4cZxxTl4w0GobzKv+mZam31bOtTzLgV8t+cKcZnnkmqu0kG29uRZmEh0pzoAiQx3SJ2UhI9CI 0XqLuInaYZoa/lsG3g8nJ6fGCKn2Xt3Vyuao4lNbEY5QxCx7bVpyy8nG4X+TB364aQtqGOl9OtcAd 1Ai4i59BfPwBmlJIpAXgKoWsFTevFdHuzNqEsSJpvzYOzhvV20dXzw8W775VDl4L1DExR5xBKZZ0X UC87+Ovfd9e3dkaLquk8KnsxraL8i79mLfkmbJVI129V6x1uaCLOrt3r+Js9DQKIs5b9+cRSHtcsT YOxcrJlUg==; Received: from smtp.transmode.se ([31.15.61.139]) by merlin.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSI-0005qx-13 for linux-mtd@lists.infradead.org; Wed, 06 Jun 2018 10:14:20 +0000 Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [10.210.72.209]) by smtp.transmode.se (Postfix) with ESMTP id E5732118A718; Wed, 6 Jun 2018 12:13:43 +0200 (CEST) Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [127.0.0.1]) by gentoo-jocke.infinera.com (8.14.9/8.14.9) with ESMTP id w56ADhBr011239; Wed, 6 Jun 2018 12:13:43 +0200 Received: (from jocke@localhost) by gentoo-jocke.infinera.com (8.14.9/8.14.9/Submit) id w56ADhnM011238; Wed, 6 Jun 2018 12:13:43 +0200 From: Joakim Tjernlund To: "linux-mtd @ lists . infradead . org" , Boris Brezillon Subject: [PATCH v2 3/4] mtd: cfi_cmdset_0002: Avoid point less unlocking/locking Date: Wed, 6 Jun 2018 12:13:29 +0200 Message-Id: <20180606101330.11071-3-joakim.tjernlund@infinera.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180606101330.11071-1-joakim.tjernlund@infinera.com> References: <20180605172607.50acb34f@bbrezillon> <20180606101330.11071-1-joakim.tjernlund@infinera.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180606_061414_283907_ED71EF56 X-CRM114-Status: GOOD ( 21.07 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on merlin.infradead.org summary: Content analysis details: (1.0 points) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , stable@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org cfi_ppb_unlock() walks all flash chips when unlocking sectors. testing lock status on each chip which causes relocking of already locked sectors. Test against offset to aviod this aliasing. Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking") Cc: stable@vger.kernel.org Signed-off-by: Joakim Tjernlund --- v2 - Spilt into several patches drivers/mtd/chips/cfi_cmdset_0002.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index cb85cccc48c1..b6273ce83de7 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -2670,7 +2670,7 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, * sectors shall be unlocked, so lets keep their locking * status at "unlocked" (locked=0) for the final re-locking. */ - if ((adr < ofs) || (adr >= (ofs + len))) { + if ((offset < ofs) || (offset >= (ofs + len))) { sect[sectors].chip = &cfi->chips[chipnum]; sect[sectors].adr = adr; sect[sectors].locked = do_ppb_xxlock( From patchwork Wed Jun 6 10:13:30 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Joakim Tjernlund X-Patchwork-Id: 925790 X-Patchwork-Delegate: boris.brezillon@free-electrons.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:e::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=infinera.com Authentication-Results: ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="KO8uKy8D"; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=infradead.org header.i=@infradead.org header.b="kvPV0u/a"; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:e::133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4114KC3kNDzB3h4 for ; Wed, 6 Jun 2018 20:14:23 +1000 (AEST) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20170209; h=Sender: Content-Transfer-Encoding:Content-Type:MIME-Version:Cc:List-Subscribe: List-Help:List-Post:List-Archive:List-Unsubscribe:List-Id:References: In-Reply-To:Message-Id:Date:Subject:To:From:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=k3PS5vqCHccT2Iqp+3lLxwijL+9noEjrP6LxTQ8Tv1U=; b=KO8uKy8D09fa3zrSGLTjz+Hh2O 3ILkF12MKoXiqYyI9ungz+2AoUeNhboeVEmg4fcbYq5ICH/6K1qZS39ZknpVsKfz7ez4KrnX0Wwpx r5Eerf27FewFuMEwOyGiEmSi9QLrOjNhy5j+JKpOaEJyZq6+XzZ3apk6Y8csgbC4+zrFQYzaY8SQX e/okjb3ZVqIinADJ594RkpHc5QN3jSH/2B9vPB/MyqgjKzMGCIKOu4G0EOZ9VII7X+ifdpwl69yjD mnPiBE9u1e0JnSkyLd5tD931eRVxl5anj1WM9t9bPmaz6YRqXNDje47uD7Ce6zmfh6BIoF6+W8ErI lCBMt+6Q==; Received: from localhost ([127.0.0.1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSN-00065h-5G; Wed, 06 Jun 2018 10:14:19 +0000 Received: from casper.infradead.org ([2001:8b0:10b:1236::1]) by bombadil.infradead.org with esmtps (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSK-00060C-FG for linux-mtd@bombadil.infradead.org; Wed, 06 Jun 2018 10:14:16 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=infradead.org; s=casper.20170209; h=References:In-Reply-To:Message-Id:Date: Subject:Cc:To:From:Sender:Reply-To:MIME-Version:Content-Type: Content-Transfer-Encoding:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Id: List-Help:List-Unsubscribe:List-Subscribe:List-Post:List-Owner:List-Archive; bh=ZkLentKNCHX0cJHotETwYft6PcR0VyqI+ndolTum4rc=; b=kvPV0u/ayKu7RZXXrlFIbZJ8O bVCIwh2DgRTRXNT9qRwH5gADWOUbUTkZwzmQVg85o7NjDef5scgjTbiUOT8IFa2IJ8JXFHH41Hcay qH8hEluSlrrsJriAq8DRkyNiOOJtiOsekGzIWT3t0Bkfk7M91ug89aPHMtLI+ebWcBrqtFLXul1C7 z1HagIdS6HfCK9SAfJgb2TtHxbDyux545JoYfAxEf2MMpYzIXYsYy/js1vZRlrjMK1ts7jlQ2ZR/A LozrZmnDXdTd5jQq9Dvr4qLKJTY0GtfFshcUV9XB6HGj35bPw36j21cm6gRTMCOdR47NIRtUqiJ0o yhqg9izag==; Received: from smtp.transmode.se ([31.15.61.139]) by casper.infradead.org with esmtp (Exim 4.90_1 #2 (Red Hat Linux)) id 1fQVSH-0003vu-3N for linux-mtd@lists.infradead.org; Wed, 06 Jun 2018 10:14:15 +0000 Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [10.210.72.209]) by smtp.transmode.se (Postfix) with ESMTP id F271A118ACD8; Wed, 6 Jun 2018 12:13:44 +0200 (CEST) Received: from gentoo-jocke.infinera.com (gentoo-jocke.infinera.com [127.0.0.1]) by gentoo-jocke.infinera.com (8.14.9/8.14.9) with ESMTP id w56ADinU011245; Wed, 6 Jun 2018 12:13:44 +0200 Received: (from jocke@localhost) by gentoo-jocke.infinera.com (8.14.9/8.14.9/Submit) id w56ADiuW011244; Wed, 6 Jun 2018 12:13:44 +0200 From: Joakim Tjernlund To: "linux-mtd @ lists . infradead . org" , Boris Brezillon Subject: [PATCH v2 4/4] mtd: cfi_cmdset_0002: Avoid walking all chips when unlocking. Date: Wed, 6 Jun 2018 12:13:30 +0200 Message-Id: <20180606101330.11071-4-joakim.tjernlund@infinera.com> X-Mailer: git-send-email 2.13.6 In-Reply-To: <20180606101330.11071-1-joakim.tjernlund@infinera.com> References: <20180605172607.50acb34f@bbrezillon> <20180606101330.11071-1-joakim.tjernlund@infinera.com> X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20180606_111413_185755_E12F733A X-CRM114-Status: GOOD ( 19.42 ) X-Spam-Score: 1.0 (+) X-Spam-Report: SpamAssassin version 3.4.1 on casper.infradead.org summary: Content analysis details: (1.0 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- 1.0 SPF_SOFTFAIL SPF: sender does not match SPF record (softfail) X-BeenThere: linux-mtd@lists.infradead.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: Linux MTD discussion mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Joakim Tjernlund , stable@vger.kernel.org MIME-Version: 1.0 Sender: "linux-mtd" Errors-To: linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org cfi_ppb_unlock() walks all flash chips when unlocking sectors, avoid walking chips unaffected by the unlock operation. Fixes: 1648eaaa1575 ("mtd: cfi_cmdset_0002: Support Persistent Protection Bits (PPB) locking") Cc: stable@vger.kernel.org Signed-off-by: Joakim Tjernlund --- v2 - Spilt into several patches drivers/mtd/chips/cfi_cmdset_0002.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drivers/mtd/chips/cfi_cmdset_0002.c b/drivers/mtd/chips/cfi_cmdset_0002.c index b6273ce83de7..62cd4ee280b3 100644 --- a/drivers/mtd/chips/cfi_cmdset_0002.c +++ b/drivers/mtd/chips/cfi_cmdset_0002.c @@ -2686,6 +2686,8 @@ static int __maybe_unused cfi_ppb_unlock(struct mtd_info *mtd, loff_t ofs, i++; if (adr >> cfi->chipshift) { + if (offset >= (ofs + len)) + break; adr = 0; chipnum++;