Received: by 2002:a05:6a10:5bc5:0:0:0:0 with SMTP id os5csp4091464pxb; Tue, 2 Nov 2021 04:03:42 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyifz9mIwzzVZPyHKSGqxgayQRX16YOWg5fIb1Eh8SofJwCuWZXok31wR1uH4YEvce+2A1G X-Received: by 2002:a5d:8903:: with SMTP id b3mr26137160ion.44.1635851022726; Tue, 02 Nov 2021 04:03:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1635851022; cv=none; d=google.com; s=arc-20160816; b=gHBHryN37Yb4qfy8NkM2hGWIVtozoLlMhn48kPZnpNI+RgYj19yomsto0nzsUx1DKg +cvf8I4FZt/YqY9Me8c2QEIQN61VrOYhzPQMAMJstXN9qmx8vWfkBDToKEoDI4nmLybw wvYX0dQmV7IP0EWXmi4bnuE0qZMdmJM/AmTgj2inLNn5L8bw6L1mHBoWLPcJMtnmPYK4 a2/G7YTXePQvF+QOKSbANhwuI32gqYB+Ymjcxyp0VRoesED1JAZeCgDNIjMQlcIF1OMV nCVD39KqmJ1KQ9Wgwn1b5SI4FSnlxVfR2RJV/tRoRn6st7lxUsNxK2272Yqv9f/J2+WD sV+A== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=e+OsoDV0VNN4JyiSc8U4sEoectqSyWrQ+KeQZyCBr+E=; b=tL1XT4zCsHi5MXkMIZkgJfLTzmMskxqqns0eBy/BeIMnFygt8bVIamlZlm8/VafuIn qYnMCKXysCaAKxAKO3MbHAnAMjwOZIJeKlcRAY5hA9B0x0t2gp70+PZ3r3Mrg7+i9Gf8 2enGDWh+Pd4/inIlaEfL4JCkCM0qKDioPszt5xddEHCEV579th8Z79JEGEREB0Bx0UHa Ibhv8I9d7LbSFsNz45Zv7ETYYxoPVa/MwjVtqgn3MT+MOb7IZTRB44/ge5uaphJG8RnI SPSF6GTHhpiuCiHkRVi34oAV/+IKsQSIXB6CZrngKyP8hrzOZoHYnfREZ1Q5Mv557IEt kq2Q== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@geanix.com header.s=first header.b="V5e3/OIn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id x6si4372180iow.47.2021.11.02.04.03.31; Tue, 02 Nov 2021 04:03:42 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@geanix.com header.s=first header.b="V5e3/OIn"; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=geanix.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231278AbhKBLFA (ORCPT + 99 others); Tue, 2 Nov 2021 07:05:00 -0400 Received: from first.geanix.com ([116.203.34.67]:37542 "EHLO first.geanix.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230511AbhKBLEu (ORCPT ); Tue, 2 Nov 2021 07:04:50 -0400 Received: from zen.. (unknown [185.17.218.86]) by first.geanix.com (Postfix) with ESMTPSA id A20E3D747B; Tue, 2 Nov 2021 11:02:11 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=geanix.com; s=first; t=1635850931; bh=daO+Y1OCTBro/SQlNmjckPsesZNNVg/tJVluOHMiVlU=; h=From:To:Cc:Subject:Date:In-Reply-To:References; b=V5e3/OInDSgyW9RFiB6zJPegKINakabRLwOWSr5UPyjbbB/rpwkcLybXJXCt1EbnT pBYhwMqjrbm6OKcJmUVoe41kO9613Mb1KIrxiytJUdJZ7z47rW8irwOV4DIucJSYs4 f4ZYzN7AgefcikLssSSC2habX5cIb03T8XY2c/So8yamw0jmlKRxlTmDMDJAnSad3o NPfsLgif+9llt9cHi9izKuRLSyM87HGA6gCc7qfV1QtxuyuULToEPDA6XCC/7XAwxG gLO7AN8/WYmzFxR1+BcW4R114opUUrGQX2tiSvhIfUnSWWJezRI85woqzzx/6sBeFM fMURgjGrZC6Mg== 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: [PATCH v5 2/4] mtd: mtdconcat: don't use mtd_{suspend,resume}() Date: Tue, 2 Nov 2021 12:02:02 +0100 Message-Id: <20211102110204.3334609-3-sean@geanix.com> X-Mailer: git-send-email 2.33.0 In-Reply-To: <20211102110204.3334609-1-sean@geanix.com> References: <20211102110204.3334609-1-sean@geanix.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-3.1 required=4.0 tests=ALL_TRUSTED,BAYES_00, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,URIBL_BLOCKED autolearn=disabled version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on 13e2a5895688 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Boris Brezillon The MTD suspend logic will soon be adjusted to automatically wait for device wake-up before issuing IOs. In order to do that a new read-write lock will be added and taken in write-mode in the mtd_{suspend,resume}() path. Since mtdconcat.c itself is an MTD device, calling mtd_suspend/resume() on subdevices from the mtdconcat ->_{suspend,resume}() hook will lead to a nested lock, which lockdep will complain about if we don't add a proper annotation. Let's keep things simple and replace those mtd_{suspend,resume}(subdev) calls by subdev->_{suspend,resume}() ones to avoid this situation. Tested-by: Sean Nyekjaer Signed-off-by: Boris Brezillon Signed-off-by: Sean Nyekjaer --- drivers/mtd/mtdconcat.c | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/drivers/mtd/mtdconcat.c b/drivers/mtd/mtdconcat.c index f685a581df48..f4a4274489b4 100644 --- a/drivers/mtd/mtdconcat.c +++ b/drivers/mtd/mtdconcat.c @@ -566,9 +566,15 @@ static int concat_suspend(struct mtd_info *mtd) for (i = 0; i < concat->num_subdev; i++) { struct mtd_info *subdev = concat->subdev[i]; - if ((rc = mtd_suspend(subdev)) < 0) + /* + * Call the MTD hook directly to avoid a nested lock + * on ->suspend_lock. + */ + rc = subdev->_suspend ? subdev->_suspend(subdev) : 0; + if (rc < 0) return rc; } + return rc; } @@ -579,7 +585,12 @@ static void concat_resume(struct mtd_info *mtd) for (i = 0; i < concat->num_subdev; i++) { struct mtd_info *subdev = concat->subdev[i]; - mtd_resume(subdev); + /* + * Call the MTD hook directly to avoid a nested lock + * on ->resume_lock. + */ + if (subdev->_resume) + subdev->_resume(subdev); } } -- 2.33.0