From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CA7CFC433FE for ; Fri, 8 Oct 2021 14:39:00 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AACB561177 for ; Fri, 8 Oct 2021 14:39:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S242482AbhJHOky (ORCPT ); Fri, 8 Oct 2021 10:40:54 -0400 Received: from first.geanix.com ([116.203.34.67]:37352 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S242084AbhJHOku (ORCPT ); Fri, 8 Oct 2021 10:40:50 -0400 Received: from zen.. (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id 2F2A1C3B5E; Fri, 8 Oct 2021 14:38:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1633703933; bh=vjjcfVjWx7Ob+Sq25WOnNjK0E6WF3cckWINU+c59prs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gw2E9/HJrreFjsFKMC6Zhdz2o42lTnhAfJe9S2caISKRvQwy5JutzBgXXCaFnniVP hq/diGaEbXywBLdMHfr6U3g4En6PIrATV5PnxSG8UpPOTlAE84YjEZTobdH7d2HDpm TQiYJ6MfZ4+2mmf8sIfsRUZT7lspLhMZSi8y3yfdzvHJ9TPd0DS9i5lU8buWKuXs+A G26oPsZLPHr9wCf7IW1Mw/MiVyTDBM4jebaK+NUWx5T8mr4rNtIzxYVpUBKgcvUuYo DJtSXTgHOAmLSBy/Hv11nWnSC//TVjoZCobBPwKHeOAdef9DlpHzKhtz+5zL1QsQh1 PQ5wZfC1eW+Fg== From: Sean Nyekjaer To: Boris Brezillon Cc: Sean Nyekjaer , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Boris Brezillon , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/2] mtd: rawnand: remove suspended check Date: Fri, 8 Oct 2021 16:38:25 +0200 Message-Id: <20211008143825.3717116-2-sean@geanix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008141524.20ca8219@collabora.com> References: <20211008143825.3717116-1-sean@geanix.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Rawnand access is protected in upper mtd layer when mtd devices are suspended. So remove this obsolute check/lock Fixes: 013e6292aaf5 ("mtd: rawnand: Simplify the locking") Signed-off-by: Sean Nyekjaer --- Hmm what to do in nand_sync()? Fine as is? drivers/mtd/nand/raw/nand_base.c | 50 ++++++++------------------------ include/linux/mtd/rawnand.h | 5 +--- 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 3d6c6e880520..f1f85866c87a 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -332,19 +332,11 @@ static int nand_isbad_bbm(struct nand_chip *chip, loff_t ofs) * @chip: NAND chip structure * * Lock the device and its controller for exclusive access - * - * Return: -EBUSY if the chip has been suspended, 0 otherwise */ -static int nand_get_device(struct nand_chip *chip) +static void nand_get_device(struct nand_chip *chip) { mutex_lock(&chip->lock); - if (chip->suspended) { - mutex_unlock(&chip->lock); - return -EBUSY; - } mutex_lock(&chip->controller->lock); - - return 0; } /** @@ -573,10 +565,7 @@ static int nand_block_markbad_lowlevel(struct nand_chip *chip, loff_t ofs) nand_erase_nand(chip, &einfo, 0); /* Write bad block marker to OOB */ - ret = nand_get_device(chip); - if (ret) - return ret; - + nand_get_device(chip); ret = nand_markbad_bbm(chip, ofs); nand_release_device(chip); } @@ -3756,9 +3745,7 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from, ops->mode != MTD_OPS_RAW) return -ENOTSUPP; - ret = nand_get_device(chip); - if (ret) - return ret; + nand_get_device(chip); if (!ops->datbuf) ret = nand_do_read_oob(chip, from, ops); @@ -4349,9 +4336,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, ops->retlen = 0; - ret = nand_get_device(chip); - if (ret) - return ret; + nand_get_device(chip); switch (ops->mode) { case MTD_OPS_PLACE_OOB: @@ -4410,10 +4395,8 @@ int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr, if (nand_region_is_secured(chip, instr->addr, instr->len)) return -EIO; - /* Grab the lock and see if the device is available */ - ret = nand_get_device(chip); - if (ret) - return ret; + /* Grab the lock */ + nand_get_device(chip); /* Shift to get first page */ page = (int)(instr->addr >> chip->page_shift); @@ -4499,8 +4482,8 @@ static void nand_sync(struct mtd_info *mtd) pr_debug("%s: called\n", __func__); - /* Grab the lock and see if the device is available */ - WARN_ON(nand_get_device(chip)); + /* Grab the lock */ + nand_get_device(chip); /* Release it and go back */ nand_release_device(chip); } @@ -4517,9 +4500,7 @@ static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) int ret; /* Select the NAND device */ - ret = nand_get_device(chip); - if (ret) - return ret; + nand_get_device(chip); nand_select_target(chip, chipnr); @@ -4565,8 +4546,6 @@ static int nand_suspend(struct mtd_info *mtd) mutex_lock(&chip->lock); if (chip->ops.suspend) ret = chip->ops.suspend(chip); - if (!ret) - chip->suspended = 1; mutex_unlock(&chip->lock); return ret; @@ -4580,15 +4559,10 @@ static void nand_resume(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); + mutex_lock(&chip->lock); - if (chip->suspended) { - if (chip->ops.resume) - chip->ops.resume(chip); - chip->suspended = 0; - } else { - pr_err("%s called for a chip which is not in suspended state\n", - __func__); - } + if (chip->ops.resume) + chip->ops.resume(chip); mutex_unlock(&chip->lock); } diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index b2f9dd3cbd69..1198a6548912 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1237,9 +1237,7 @@ struct nand_secure_region { * @pagecache.page: Page number currently in the cache. -1 means no page is * currently cached * @buf_align: Minimum buffer alignment required by a platform - * @lock: Lock protecting the suspended field. Also used to serialize accesses - * to the NAND device - * @suspended: Set to 1 when the device is suspended, 0 when it's not + * @lock: Lock to serialize accesses to the NAND device * @cur_cs: Currently selected target. -1 means no target selected, otherwise we * should always have cur_cs >= 0 && cur_cs < nanddev_ntargets(). * NAND Controller drivers should not modify this value, but they're @@ -1293,7 +1291,6 @@ struct nand_chip { /* Internals */ struct mutex lock; - unsigned int suspended : 1; int cur_cs; int read_retries; struct nand_secure_region *secure_regions; -- 2.33.0 From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C841EC433FE for ; Fri, 8 Oct 2021 14:39:40 +0000 (UTC) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id 8E2A860F58 for ; Fri, 8 Oct 2021 14:39:40 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.1 mail.kernel.org 8E2A860F58 Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=geanix.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=lists.infradead.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:References:In-Reply-To: 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: List-Owner; bh=+6xrRKoWVlJehfBFxqZbrIJ0fX/3By50Wqzen2dKo6A=; b=vz0e6FoKRFnnUm 4uB8uWJ5dn7gXV/QQry7tDnd7DIcegWTxlFS474EwxWYqGsrxhK/ogGjGcvLyGPAlK8fhBwbBV1Gs Fcjfr8//NAI0UqfNZURkzP2E60zLxfwHbcOxenC/5ynl5YitD/cW19IgLLJFWa2FV37EqFIa7N5qw K8qOyVzsEcq99qTtMG4HyLADdiYWmBQdWOso+MHrHaRohJtgmil9jfSSrL/KnNr08w1+wZDhkQ7qi S6zvtEEaTyEvmz1pDKb3pwmLOELHwivFaODrctvUeNrigLAyyWYCWKaaOA2R/ADNaS7v0LGYXBbom OVn9hrAoaKo6FKCB323Q==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYr1l-0037IE-2y; Fri, 08 Oct 2021 14:39:13 +0000 Received: from first.geanix.com ([116.203.34.67]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1mYr1T-0037CN-Iu for linux-mtd@lists.infradead.org; Fri, 08 Oct 2021 14:38:59 +0000 Received: from zen.. (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id 2F2A1C3B5E; Fri, 8 Oct 2021 14:38:53 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1633703933; bh=vjjcfVjWx7Ob+Sq25WOnNjK0E6WF3cckWINU+c59prs=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=gw2E9/HJrreFjsFKMC6Zhdz2o42lTnhAfJe9S2caISKRvQwy5JutzBgXXCaFnniVP hq/diGaEbXywBLdMHfr6U3g4En6PIrATV5PnxSG8UpPOTlAE84YjEZTobdH7d2HDpm TQiYJ6MfZ4+2mmf8sIfsRUZT7lspLhMZSi8y3yfdzvHJ9TPd0DS9i5lU8buWKuXs+A G26oPsZLPHr9wCf7IW1Mw/MiVyTDBM4jebaK+NUWx5T8mr4rNtIzxYVpUBKgcvUuYo DJtSXTgHOAmLSBy/Hv11nWnSC//TVjoZCobBPwKHeOAdef9DlpHzKhtz+5zL1QsQh1 PQ5wZfC1eW+Fg== From: Sean Nyekjaer To: Boris Brezillon Cc: Sean Nyekjaer , Miquel Raynal , Richard Weinberger , Vignesh Raghavendra , Boris Brezillon , linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [RFC PATCH 2/2] mtd: rawnand: remove suspended check Date: Fri, 8 Oct 2021 16:38:25 +0200 Message-Id: <20211008143825.3717116-2-sean@geanix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211008141524.20ca8219@collabora.com> References: <20211008143825.3717116-1-sean@geanix.com> MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20211008_073855_978245_DD1F6398 X-CRM114-Status: GOOD ( 20.86 ) 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: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-mtd" Errors-To: linux-mtd-bounces+linux-mtd=archiver.kernel.org@lists.infradead.org Rawnand access is protected in upper mtd layer when mtd devices are suspended. So remove this obsolute check/lock Fixes: 013e6292aaf5 ("mtd: rawnand: Simplify the locking") Signed-off-by: Sean Nyekjaer --- Hmm what to do in nand_sync()? Fine as is? drivers/mtd/nand/raw/nand_base.c | 50 ++++++++------------------------ include/linux/mtd/rawnand.h | 5 +--- 2 files changed, 13 insertions(+), 42 deletions(-) diff --git a/drivers/mtd/nand/raw/nand_base.c b/drivers/mtd/nand/raw/nand_base.c index 3d6c6e880520..f1f85866c87a 100644 --- a/drivers/mtd/nand/raw/nand_base.c +++ b/drivers/mtd/nand/raw/nand_base.c @@ -332,19 +332,11 @@ static int nand_isbad_bbm(struct nand_chip *chip, loff_t ofs) * @chip: NAND chip structure * * Lock the device and its controller for exclusive access - * - * Return: -EBUSY if the chip has been suspended, 0 otherwise */ -static int nand_get_device(struct nand_chip *chip) +static void nand_get_device(struct nand_chip *chip) { mutex_lock(&chip->lock); - if (chip->suspended) { - mutex_unlock(&chip->lock); - return -EBUSY; - } mutex_lock(&chip->controller->lock); - - return 0; } /** @@ -573,10 +565,7 @@ static int nand_block_markbad_lowlevel(struct nand_chip *chip, loff_t ofs) nand_erase_nand(chip, &einfo, 0); /* Write bad block marker to OOB */ - ret = nand_get_device(chip); - if (ret) - return ret; - + nand_get_device(chip); ret = nand_markbad_bbm(chip, ofs); nand_release_device(chip); } @@ -3756,9 +3745,7 @@ static int nand_read_oob(struct mtd_info *mtd, loff_t from, ops->mode != MTD_OPS_RAW) return -ENOTSUPP; - ret = nand_get_device(chip); - if (ret) - return ret; + nand_get_device(chip); if (!ops->datbuf) ret = nand_do_read_oob(chip, from, ops); @@ -4349,9 +4336,7 @@ static int nand_write_oob(struct mtd_info *mtd, loff_t to, ops->retlen = 0; - ret = nand_get_device(chip); - if (ret) - return ret; + nand_get_device(chip); switch (ops->mode) { case MTD_OPS_PLACE_OOB: @@ -4410,10 +4395,8 @@ int nand_erase_nand(struct nand_chip *chip, struct erase_info *instr, if (nand_region_is_secured(chip, instr->addr, instr->len)) return -EIO; - /* Grab the lock and see if the device is available */ - ret = nand_get_device(chip); - if (ret) - return ret; + /* Grab the lock */ + nand_get_device(chip); /* Shift to get first page */ page = (int)(instr->addr >> chip->page_shift); @@ -4499,8 +4482,8 @@ static void nand_sync(struct mtd_info *mtd) pr_debug("%s: called\n", __func__); - /* Grab the lock and see if the device is available */ - WARN_ON(nand_get_device(chip)); + /* Grab the lock */ + nand_get_device(chip); /* Release it and go back */ nand_release_device(chip); } @@ -4517,9 +4500,7 @@ static int nand_block_isbad(struct mtd_info *mtd, loff_t offs) int ret; /* Select the NAND device */ - ret = nand_get_device(chip); - if (ret) - return ret; + nand_get_device(chip); nand_select_target(chip, chipnr); @@ -4565,8 +4546,6 @@ static int nand_suspend(struct mtd_info *mtd) mutex_lock(&chip->lock); if (chip->ops.suspend) ret = chip->ops.suspend(chip); - if (!ret) - chip->suspended = 1; mutex_unlock(&chip->lock); return ret; @@ -4580,15 +4559,10 @@ static void nand_resume(struct mtd_info *mtd) { struct nand_chip *chip = mtd_to_nand(mtd); + mutex_lock(&chip->lock); - if (chip->suspended) { - if (chip->ops.resume) - chip->ops.resume(chip); - chip->suspended = 0; - } else { - pr_err("%s called for a chip which is not in suspended state\n", - __func__); - } + if (chip->ops.resume) + chip->ops.resume(chip); mutex_unlock(&chip->lock); } diff --git a/include/linux/mtd/rawnand.h b/include/linux/mtd/rawnand.h index b2f9dd3cbd69..1198a6548912 100644 --- a/include/linux/mtd/rawnand.h +++ b/include/linux/mtd/rawnand.h @@ -1237,9 +1237,7 @@ struct nand_secure_region { * @pagecache.page: Page number currently in the cache. -1 means no page is * currently cached * @buf_align: Minimum buffer alignment required by a platform - * @lock: Lock protecting the suspended field. Also used to serialize accesses - * to the NAND device - * @suspended: Set to 1 when the device is suspended, 0 when it's not + * @lock: Lock to serialize accesses to the NAND device * @cur_cs: Currently selected target. -1 means no target selected, otherwise we * should always have cur_cs >= 0 && cur_cs < nanddev_ntargets(). * NAND Controller drivers should not modify this value, but they're @@ -1293,7 +1291,6 @@ struct nand_chip { /* Internals */ struct mutex lock; - unsigned int suspended : 1; int cur_cs; int read_retries; struct nand_secure_region *secure_regions; -- 2.33.0 ______________________________________________________ Linux MTD discussion mailing list http://lists.infradead.org/mailman/listinfo/linux-mtd/