From patchwork Mon Oct 10 04:55:47 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Zhang X-Patchwork-Id: 1687911 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=kVJFKKpY; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=LhRHZoda; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mm68920NHz23jr for ; Mon, 10 Oct 2022 15:56:41 +1100 (AEDT) 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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=HVj3o62EdbQy/ytax4dzLvXZ8zrHyhog20xylyG52AA=; b=kVJFKKpYZ3v6feht3wxfPjrMvs dwPTrzAeXb1r21KNeA3/vYji63NbO0UJqLa0kD8JelSPfwNFLxO4PCef8lqXiUqyLj2B4KUO1DKLs GgKT6voKCejgFInYUJg5NnxSNiXEMUu6SOlmthhEGL+2N4TBnMHsJsoD0x0kEZYTs2kdZyEik0SaQ R3vZgcyGcXePIR8ojdZMB8CksRF9yYsmLv9xOn71uBGGZxMghVzBWNegrBs889rb1OzkGHOSYL4S6 nsCV8EbySBvUIVhW1KSmGBbyNj1IA/UlvuMc4C77VlFTkeKxwqU3/wO7S8O7b2E0NqhXhFxtOuaPh 3oOxdHXQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ohkpd-00H1kL-JG; Mon, 10 Oct 2022 04:56:01 +0000 Received: from mail-pg1-x549.google.com ([2607:f8b0:4864:20::549]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ohkpa-00H1iX-Dr for linux-mtd@lists.infradead.org; Mon, 10 Oct 2022 04:56:00 +0000 Received: by mail-pg1-x549.google.com with SMTP id h2-20020a656382000000b0044b0f6c572fso5920165pgv.20 for ; Sun, 09 Oct 2022 21:55:57 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=lzwp40a62FGAnOoiZ5XoBxodmWLF61UQZ56kTVbia9E=; b=LhRHZodajX8y2Sx8JbDwzXp3+viYlr2Er7Erk6vEclxdP6hgm4I3icQMRRdPFOo+CB O0mMsk826UWFYYGzXvZJ/OsclscQh30gMMBJqvFMQU5R9V3F2LVm0mdZShlth43ecCFo lt956zbsUz6IRYYbWDMeBrW9MH4HBGdsJ5bzb75spGv/5sLdpyYpkJCPRXGEf+EhxAtt Z/rmURuLb0hO7I2gGSVTt/i/OMRN14hpYqOLG/reKOut2S8BX9zStwuT/stXtK4Deh+9 mHBIK2JKNf2lFGSX0C6XX/mHWl6WqmrUrbu/bQUlDjLB8MAAmQo0Xb5LdU6fSWi93MH3 KWGQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=lzwp40a62FGAnOoiZ5XoBxodmWLF61UQZ56kTVbia9E=; b=Opu/sXYm0BMRlQC5NkJ3JWQ+L9z1aHUl9hA9V02z+49GyFXF74mlK2Dvw85m2s3FfJ Hm/9KqccFggO7b48UadwkzGm5LvyWyYbMabzte/HrADTjQpr5ts/TAbh71nuwhLq5b5J dtvv42P8VSTxLymtF8uX3KbnoccesSFEgwtcXJ9boY20YyNuSE5lKNWjfEBT4GJyP4F+ ScKvbEd6DYgfZhYLj4dh1dIuvbVS9iIA0L3r7IHKqW2iOdHQDiWQ7ACHeJteL5ngQa4u mjpY/gi19+7QopTMjTPoPYIa4ecHapur5QJa0uQjQSv18Aqu0CFqsL/6Sck1vf3Snz3c GSCQ== X-Gm-Message-State: ACrzQf23/vd4owg2W8GHNI831ApcrrZlVePpfsS12Y5V/TXLHNoY6c74 H3ebDOVlWuV9IcOBgHZL1C9KHICi4Umk X-Google-Smtp-Source: AMsMyM6o8NER8Y3yaSbuhO2Np81zL46aICeiXFpwpKFZMksSRanKZiO1CdsUg0xkJCwFCFo3Pr7noLl9qEoS X-Received: from sgzhang.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d89]) (user=sgzhang job=sendgmr) by 2002:aa7:9250:0:b0:563:723f:7914 with SMTP id 16-20020aa79250000000b00563723f7914mr1753359pfp.12.1665377756870; Sun, 09 Oct 2022 21:55:56 -0700 (PDT) Date: Mon, 10 Oct 2022 04:55:47 +0000 In-Reply-To: <20221010045549.2221965-1-sgzhang@google.com> Mime-Version: 1.0 References: <20221010045549.2221965-1-sgzhang@google.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog Message-ID: <20221010045549.2221965-2-sgzhang@google.com> Subject: [PATCH v4 1/3] mtd: mtdoops: change printk() to counterpart pr_ functions From: Ray Zhang To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Ray Zhang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221009_215558_488503_8C9E090A X-CRM114-Status: GOOD ( 15.49 ) X-Spam-Score: -7.7 (-------) 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: To comply with latest kernel code requirement, change printk() to counterpart pr_ functions in mtdoops driver: - change printk(INFO) to pr_info() - change printk(DEBUG) to pr_debug() - change printk(W [...] Content analysis details: (-7.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:549 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 -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -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 -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender 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+incoming=patchwork.ozlabs.org@lists.infradead.org To comply with latest kernel code requirement, change printk() to counterpart pr_ functions in mtdoops driver: - change printk(INFO) to pr_info() - change printk(DEBUG) to pr_debug() - change printk(WARNING) to pr_warn() - change printk(ERR) to pr_err() Note that only if dynamic debugging is enabled or DEBUG is defined, printk(KERN_DEBUG) and pr_debug() are equivalent; Otherwise pr_debug() is no-op, causing different behavior. Signed-off-by: Ray Zhang --- drivers/mtd/mtdoops.c | 52 ++++++++++++++++++++++--------------------- 1 file changed, 27 insertions(+), 25 deletions(-) diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index 3d4a2ffb5b01..6b70331da3b6 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c @@ -7,6 +7,8 @@ * Author: Richard Purdie */ +#define pr_fmt(fmt) KBUILD_MODNAME ": " fmt + #include #include #include @@ -93,9 +95,9 @@ static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset) ret = mtd_erase(mtd, &erase); if (ret) { - printk(KERN_WARNING "mtdoops: erase of region [0x%llx, 0x%llx] on \"%s\" failed\n", - (unsigned long long)erase.addr, - (unsigned long long)erase.len, mtddev); + pr_warn("erase of region [0x%llx, 0x%llx] on \"%s\" failed\n", + (unsigned long long)erase.addr, + (unsigned long long)erase.len, mtddev); return ret; } @@ -120,8 +122,8 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt) return; } - printk(KERN_DEBUG "mtdoops: ready %d, %d (no erase)\n", - cxt->nextpage, cxt->nextcount); + pr_debug("ready %d, %d (no erase)\n", + cxt->nextpage, cxt->nextcount); } /* Scheduled work - when we can't proceed without erasing a block */ @@ -145,20 +147,20 @@ static void mtdoops_workfunc_erase(struct work_struct *work) while ((ret = mtd_block_isbad(mtd, cxt->nextpage * record_size)) > 0) { badblock: - printk(KERN_WARNING "mtdoops: bad block at %08lx\n", - cxt->nextpage * record_size); + pr_warn("bad block at %08lx\n", + cxt->nextpage * record_size); i++; cxt->nextpage = cxt->nextpage + (mtd->erasesize / record_size); if (cxt->nextpage >= cxt->oops_pages) cxt->nextpage = 0; if (i == cxt->oops_pages / (mtd->erasesize / record_size)) { - printk(KERN_ERR "mtdoops: all blocks bad!\n"); + pr_err("all blocks bad!\n"); return; } } if (ret < 0) { - printk(KERN_ERR "mtdoops: mtd_block_isbad failed, aborting\n"); + pr_err("mtd_block_isbad failed, aborting\n"); return; } @@ -166,15 +168,15 @@ static void mtdoops_workfunc_erase(struct work_struct *work) ret = mtdoops_erase_block(cxt, cxt->nextpage * record_size); if (ret >= 0) { - printk(KERN_DEBUG "mtdoops: ready %d, %d\n", - cxt->nextpage, cxt->nextcount); + pr_debug("ready %d, %d\n", + cxt->nextpage, cxt->nextcount); return; } if (ret == -EIO) { ret = mtd_block_markbad(mtd, cxt->nextpage * record_size); if (ret < 0 && ret != -EOPNOTSUPP) { - printk(KERN_ERR "mtdoops: block_markbad failed, aborting\n"); + pr_err("block_markbad failed, aborting\n"); return; } } @@ -201,7 +203,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic) ret = mtd_panic_write(mtd, cxt->nextpage * record_size, record_size, &retlen, cxt->oops_buf); if (ret == -EOPNOTSUPP) { - printk(KERN_ERR "mtdoops: Cannot write from panic without panic_write\n"); + pr_err("Cannot write from panic without panic_write\n"); goto out; } } else @@ -209,7 +211,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic) record_size, &retlen, cxt->oops_buf); if (retlen != record_size || ret < 0) - printk(KERN_ERR "mtdoops: write failure at %ld (%td of %ld written), error %d\n", + pr_err("write failure at %ld (%td of %ld written), error %d\n", cxt->nextpage * record_size, retlen, record_size, ret); mark_page_used(cxt, cxt->nextpage); memset(cxt->oops_buf, 0xff, record_size); @@ -244,7 +246,7 @@ static void find_next_position(struct mtdoops_context *cxt) &retlen, (u_char *)&hdr); if (retlen != sizeof(hdr) || (ret < 0 && !mtd_is_bitflip(ret))) { - printk(KERN_ERR "mtdoops: read failure at %ld (%zu of %zu read), err %d\n", + pr_err("read failure at %ld (%zu of %zu read), err %d\n", page * record_size, retlen, sizeof(hdr), ret); continue; } @@ -324,17 +326,17 @@ static void mtdoops_notify_add(struct mtd_info *mtd) return; if (mtd->size < mtd->erasesize * 2) { - printk(KERN_ERR "mtdoops: MTD partition %d not big enough for mtdoops\n", + pr_err("MTD partition %d not big enough for mtdoops\n", mtd->index); return; } if (mtd->erasesize < record_size) { - printk(KERN_ERR "mtdoops: eraseblock size of MTD partition %d too small\n", + pr_err("eraseblock size of MTD partition %d too small\n", mtd->index); return; } if (mtd->size > MTDOOPS_MAX_MTD_SIZE) { - printk(KERN_ERR "mtdoops: mtd%d is too large (limit is %d MiB)\n", + pr_err("mtd%d is too large (limit is %d MiB)\n", mtd->index, MTDOOPS_MAX_MTD_SIZE / 1024 / 1024); return; } @@ -345,7 +347,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd) DIV_ROUND_UP(mtdoops_pages, BITS_PER_LONG))); if (!cxt->oops_page_used) { - printk(KERN_ERR "mtdoops: could not allocate page array\n"); + pr_err("could not allocate page array\n"); return; } @@ -353,7 +355,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd) cxt->dump.dump = mtdoops_do_dump; err = kmsg_dump_register(&cxt->dump); if (err) { - printk(KERN_ERR "mtdoops: registering kmsg dumper failed, error %d\n", err); + pr_err("registering kmsg dumper failed, error %d\n", err); vfree(cxt->oops_page_used); cxt->oops_page_used = NULL; return; @@ -362,7 +364,7 @@ static void mtdoops_notify_add(struct mtd_info *mtd) cxt->mtd = mtd; cxt->oops_pages = (int)mtd->size / record_size; find_next_position(cxt); - printk(KERN_INFO "mtdoops: Attached to MTD device %d\n", mtd->index); + pr_info("Attached to MTD device %d\n", mtd->index); } static void mtdoops_notify_remove(struct mtd_info *mtd) @@ -373,7 +375,7 @@ static void mtdoops_notify_remove(struct mtd_info *mtd) return; if (kmsg_dump_unregister(&cxt->dump) < 0) - printk(KERN_WARNING "mtdoops: could not unregister kmsg_dumper\n"); + pr_warn("could not unregister kmsg_dumper\n"); cxt->mtd = NULL; flush_work(&cxt->work_erase); @@ -393,15 +395,15 @@ static int __init mtdoops_init(void) char *endp; if (strlen(mtddev) == 0) { - printk(KERN_ERR "mtdoops: mtd device (mtddev=name/number) must be supplied\n"); + pr_err("mtd device (mtddev=name/number) must be supplied\n"); return -EINVAL; } if ((record_size & 4095) != 0) { - printk(KERN_ERR "mtdoops: record_size must be a multiple of 4096\n"); + pr_err("record_size must be a multiple of 4096\n"); return -EINVAL; } if (record_size < 4096) { - printk(KERN_ERR "mtdoops: record_size must be over 4096 bytes\n"); + pr_err("record_size must be over 4096 bytes\n"); return -EINVAL; } From patchwork Mon Oct 10 04:55:48 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Zhang X-Patchwork-Id: 1687913 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=qyjgdQ08; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=KDpmZ7bo; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mm68B2r9qz23jr for ; Mon, 10 Oct 2022 15:56:42 +1100 (AEDT) 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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=loIsj7nmVYYW1WMHsZpHowIZnz5XLjwz3zJNcSDoTx4=; b=qyjgdQ08CVSm2ksQin9nbhcrmk ADMwXGLJXIcquNgC72LZMXsmjqlwmRfmtmZwiH0+tFU6lRLbhSsblGsuHHV2DsTTzilqH4Ndq2iwi KI6vyCzNbCQBqH/WAMZnw6SgzM+XKG2kzVmVU/IawYWooKDrI5DqN5NCmvfrl5UNhD5lnayUDBYuK HMTp/uz9X/GOGHII3iBKvgBhClNE6jeBz/tFdArF4RgDld9TalIq8l0eR/gO3sCJZ8zdpRETUXp3+ jix1aipkhHeUxpbDfO/j2T4MSg13mOEwGLqHB6zDx9Jgjdjxl9WXLnK/benm2AqjKKRE7yxFA9lQQ Ah42qIqQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ohkpg-00H1lc-9i; Mon, 10 Oct 2022 04:56:04 +0000 Received: from mail-pf1-x449.google.com ([2607:f8b0:4864:20::449]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ohkpd-00H1jv-KH for linux-mtd@lists.infradead.org; Mon, 10 Oct 2022 04:56:02 +0000 Received: by mail-pf1-x449.google.com with SMTP id k19-20020a056a00135300b0054096343fc6so5332568pfu.10 for ; Sun, 09 Oct 2022 21:56:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=n5rEc7KuSG8cmN4lQmoVLJoG9j0x/2DEKJaMbcZ2CU0=; b=KDpmZ7bo0zPf/eZT5qUzqYTXLyoYn9UO8veMeCOP+GKD5bNCFsHkzSkn0fAad0b5eA 4Dya3H+lLn4iThtp4uLKnWB91BdmG+kiqYpiDn+baNHRee7/vOQNyOx4waQPdYDCGs1X txyyGL7YLeI3OO9KSOm7Z81K9tb0GBJd3JUgkFLb/PyGcY7l9et9aIMkfvuuthbIFP14 PLenG6sCH9pQtufa1pmbd/fZPJfwX88bDVCo8FdCrAhDcbLlzGZA2J3OPAS/l+qQO4+b PE482p8VqUNPhseZ5eb8vF69d0+yl4GYTNsZkrSOmyQHAkbNOHyt/xJWsMSxozgV42ok b4/A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=n5rEc7KuSG8cmN4lQmoVLJoG9j0x/2DEKJaMbcZ2CU0=; b=OJIm9KKPZif3Yo9edYnyGsaLt39IfELL6ZgzFU0bOrLjjXwPqU3b/8DmKC5E5exvaB u2Rv2gHwW8/Yv5N+ArFRgGQPyiZiztnu2TqAWZRLyfHP19mMAwh44VCDOa7RMajQ13aZ OK8FoWrTMV+qWem9i0LrT6kGZfMPl7mwz0MN9wNvtTBOP7HiZj0Z2Dap02U2Bv6Slp4M 63Gou9cEfaPaRrxD2LH2d63qfMYxliNu/gnZwWEPyPEaxMql90eHBXS403Is4vXF3H8l ydUKQV0HkIfPbNX9ZXMcquqKMnImIfA9sUGK1Aq8qdGw95oehl+PiWKTwvja+fyK+rGp NAOw== X-Gm-Message-State: ACrzQf268ZoALjTzUcXfsM8wnbhUzQsMhHv6nsIFCFvoOPPlcF80GY04 pJMOzqxfH/6afQynL7Lm7DGDvu8aOLTw X-Google-Smtp-Source: AMsMyM5kMBxQ1/A4s0m7jJM202Q9cOw+L/nl5EWStZu/gB/QC2QJJRSuMVENxK9wo9rCobrjnJ8Q1q78ditE X-Received: from sgzhang.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d89]) (user=sgzhang job=sendgmr) by 2002:a17:903:22cc:b0:178:18a1:d16c with SMTP id y12-20020a17090322cc00b0017818a1d16cmr17345818plg.155.1665377759761; Sun, 09 Oct 2022 21:55:59 -0700 (PDT) Date: Mon, 10 Oct 2022 04:55:48 +0000 In-Reply-To: <20221010045549.2221965-1-sgzhang@google.com> Mime-Version: 1.0 References: <20221010045549.2221965-1-sgzhang@google.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog Message-ID: <20221010045549.2221965-3-sgzhang@google.com> Subject: [PATCH v4 2/3] mtd: mtdoops: add mtdoops_erase function and move mtdoops_inc_counter to after it From: Ray Zhang To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Ray Zhang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221009_215601_690925_694894AD X-CRM114-Status: GOOD ( 13.12 ) X-Spam-Score: -7.7 (-------) 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: Preparing for next patch with minimal code difference, add mtdoops_erase function and move mtdoops_inc_counter to after it, with no functional change. Signed-off-by: Ray Zhang --- drivers/mtd/mtdoops.c | 49 ++++++++++++++++++++++++ 1 file changed, 27 insertions(+), 22 deletions(-) Content analysis details: (-7.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:449 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 -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -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 -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender 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+incoming=patchwork.ozlabs.org@lists.infradead.org Preparing for next patch with minimal code difference, add mtdoops_erase function and move mtdoops_inc_counter to after it, with no functional change. Signed-off-by: Ray Zhang --- drivers/mtd/mtdoops.c | 49 ++++++++++++++++++++++++------------------- 1 file changed, 27 insertions(+), 22 deletions(-) diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index 6b70331da3b6..0226b9e9ea8f 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c @@ -108,29 +108,8 @@ static int mtdoops_erase_block(struct mtdoops_context *cxt, int offset) return 0; } -static void mtdoops_inc_counter(struct mtdoops_context *cxt) -{ - cxt->nextpage++; - if (cxt->nextpage >= cxt->oops_pages) - cxt->nextpage = 0; - cxt->nextcount++; - if (cxt->nextcount == 0xffffffff) - cxt->nextcount = 0; - - if (page_is_used(cxt, cxt->nextpage)) { - schedule_work(&cxt->work_erase); - return; - } - - pr_debug("ready %d, %d (no erase)\n", - cxt->nextpage, cxt->nextcount); -} - -/* Scheduled work - when we can't proceed without erasing a block */ -static void mtdoops_workfunc_erase(struct work_struct *work) +static void mtdoops_erase(struct mtdoops_context *cxt) { - struct mtdoops_context *cxt = - container_of(work, struct mtdoops_context, work_erase); struct mtd_info *mtd = cxt->mtd; int i = 0, j, ret, mod; @@ -183,6 +162,32 @@ static void mtdoops_workfunc_erase(struct work_struct *work) goto badblock; } +/* Scheduled work - when we can't proceed without erasing a block */ +static void mtdoops_workfunc_erase(struct work_struct *work) +{ + struct mtdoops_context *cxt = + container_of(work, struct mtdoops_context, work_erase); + mtdoops_erase(cxt); +} + +static void mtdoops_inc_counter(struct mtdoops_context *cxt) +{ + cxt->nextpage++; + if (cxt->nextpage >= cxt->oops_pages) + cxt->nextpage = 0; + cxt->nextcount++; + if (cxt->nextcount == 0xffffffff) + cxt->nextcount = 0; + + if (page_is_used(cxt, cxt->nextpage)) { + schedule_work(&cxt->work_erase); + return; + } + + pr_debug("ready %d, %d (no erase)\n", + cxt->nextpage, cxt->nextcount); +} + static void mtdoops_write(struct mtdoops_context *cxt, int panic) { struct mtd_info *mtd = cxt->mtd; From patchwork Mon Oct 10 04:55:49 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ray Zhang X-Patchwork-Id: 1687912 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=2607:7c80:54:3::133; helo=bombadil.infradead.org; envelope-from=linux-mtd-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=) Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=Ot/ciimU; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=google.com header.i=@google.com header.a=rsa-sha256 header.s=20210112 header.b=FkFgzyPb; dkim-atps=neutral Received: from bombadil.infradead.org (bombadil.infradead.org [IPv6:2607:7c80:54:3::133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (P-384) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4Mm68B2Vpjz1yqk for ; Mon, 10 Oct 2022 15:56:42 +1100 (AEDT) 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:Cc:To:From:Subject:Message-ID: References:Mime-Version:In-Reply-To:Date:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc :Resent-Message-ID:List-Owner; bh=AdgdOTg2m78PYyVdYFdlBSvpsEFzi1IL6FZcA424iPc=; b=Ot/ciimUlEYCz4Pz5BUykPqQTO obVQYpa6GxvL5mEdg/RNH7rDTOfoiMFxGn3Gcigy6nqRMRtiWcJGGS4DdtXH0HMptYHGebSORpaKk FtVzbWm+Ty+FqYygZ8LXMFcwEOT9RK/Rsbs+aY2TnqZAINaO1WTmuVfUzQOGz9IH6HmC3/YbbF4lN AFhCaDUFoWLAGe5E/yVs48aKPC3X24NBgrkg5Qco1M6JbEnqteGSIPDVMq7MUPrWPBRel8v6z2fA8 Zi5OHjhcCTZgsTtSdTLPXqU4Qjo5ccggLJDf3uFYSpQuoAerZ/rRbTCFb/SntTMUrCVBCvcjByfow mNi0W5fQ==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1ohkpk-00H1n9-2C; Mon, 10 Oct 2022 04:56:08 +0000 Received: from mail-pg1-x54a.google.com ([2607:f8b0:4864:20::54a]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1ohkpg-00H1lM-MT for linux-mtd@lists.infradead.org; Mon, 10 Oct 2022 04:56:06 +0000 Received: by mail-pg1-x54a.google.com with SMTP id p24-20020a63f458000000b0043cd718c49dso5887827pgk.15 for ; Sun, 09 Oct 2022 21:56:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:from:to:cc:subject:date:message-id:reply-to; bh=RxsdOmr/5R6O83izb+Qz14RQm/ox4oRe3Ga9GwIcpbE=; b=FkFgzyPbZsQ7hNEXjbL2xdIOWZkuMKYfOCsz8o7Aqg0eNxiBSOaNoOrR3Qf9uL60wM VTj6P7p0CFzx5wLDB3obZQ+zs+nrxxyBmcvR4DRDn00o63HqdvGDddgCThc2ABO6jHpw cm9uUOYCeB4KowxD+kNC8NY9xxoq25Ui7uTvS4Age3Yh6hkvwWal5xlAgOLCxDVcI4Id h9ltXeJuibrk4rUk6alMBIUx5VxBnrZ6OKB0LXzOyCqqd4IusJvjjf93Z8l+66nNTSjz PHYdAhYsKdcSUKvRSJx0N22y0DlAlXUJT/57ISO/kCHshWkQIpcznUevOsUJJS4GJR+9 I6dQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=RxsdOmr/5R6O83izb+Qz14RQm/ox4oRe3Ga9GwIcpbE=; b=0z6vXf7tHZi158DsJ2UoBucmDooCV173PM/4i5n/cdbwcG+ICO6RxXafXbtLVPReuD hqHBjkfQSLD8jyFATJ5Qx81M+ZanPQuXcjbN51f9JpTc0fWrBhWf7ky4dyhdt+ckNjnw MrRU8vTxVTFlIQBoddpAFmoJUmgCKyBT7y1s7dMiIA5xmCi2UNXhHS22WcF3tPj17KMx jbEGnNdqxc1YfDPrqCqQTf1k4JnuislR+zQqXwXkK8L4VNnudGfp2lwVqR7kbFwETP7s 3zFn9gF+FYVlccCm64cv/m0S1gGMaNoAeDY46wO/HCXpI2JNVdm6qv7hr8VslfldtZDY UKjg== X-Gm-Message-State: ACrzQf3q3JCG3ZJlCmGa6TOY/Iwh4RLEbBijLDoV5yTFrpWeSuZ/Aa3k iSvyznyy0RuzU3VgAfIOL5AeykBO/MMR X-Google-Smtp-Source: AMsMyM7IS1QJd/ZymReZAITcO7D6DJHSctw2xXHR0bqcwB2i2Av+jyamUKWzh6rkAS6jB/SEyZwKBlS8xhj8 X-Received: from sgzhang.c.googlers.com ([fda3:e722:ac3:cc00:7f:e700:c0a8:3d89]) (user=sgzhang job=sendgmr) by 2002:a17:90a:cd06:b0:203:ae0e:6a21 with SMTP id d6-20020a17090acd0600b00203ae0e6a21mr1584146pju.0.1665377762552; Sun, 09 Oct 2022 21:56:02 -0700 (PDT) Date: Mon, 10 Oct 2022 04:55:49 +0000 In-Reply-To: <20221010045549.2221965-1-sgzhang@google.com> Mime-Version: 1.0 References: <20221010045549.2221965-1-sgzhang@google.com> X-Mailer: git-send-email 2.38.0.rc1.362.ged0d419d3c-goog Message-ID: <20221010045549.2221965-4-sgzhang@google.com> Subject: [PATCH v4 3/3] mtd: mtdoops: panic caused mtdoops to call mtdoops_erase function immediately From: Ray Zhang To: Miquel Raynal , Richard Weinberger , Vignesh Raghavendra Cc: linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org, Ray Zhang X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221009_215604_762215_D6139286 X-CRM114-Status: GOOD ( 11.60 ) X-Spam-Score: -7.7 (-------) 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: The panic function disables the local interrupts, preemption, and all other processors. When the invoked mtdoops needs to erase a used page, calling schedule_work() to do it will not work. Instead, ju [...] Content analysis details: (-7.7 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 RCVD_IN_DNSWL_NONE RBL: Sender listed at https://www.dnswl.org/, no trust [2607:f8b0:4864:20:0:0:0:54a 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 -7.5 USER_IN_DEF_DKIM_WL From: address is in the default DKIM white-list -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 -0.0 DKIMWL_WL_MED DKIMwl.org - Medium trust sender 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+incoming=patchwork.ozlabs.org@lists.infradead.org The panic function disables the local interrupts, preemption, and all other processors. When the invoked mtdoops needs to erase a used page, calling schedule_work() to do it will not work. Instead, just call mtdoops_erase function immediately. Tested: ~# echo c > /proc/sysrq-trigger [ 171.654759] sysrq: Trigger a crash [ 171.658325] Kernel panic - not syncing: sysrq triggered crash ...... [ 172.406423] mtdoops: not ready 34, 35 (erase immediately) [ 172.432285] mtdoops: ready 34, 35 [ 172.435633] Rebooting in 10 seconds.. Signed-off-by: Ray Zhang --- drivers/mtd/mtdoops.c | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/drivers/mtd/mtdoops.c b/drivers/mtd/mtdoops.c index 0226b9e9ea8f..2f11585b5613 100644 --- a/drivers/mtd/mtdoops.c +++ b/drivers/mtd/mtdoops.c @@ -170,7 +170,7 @@ static void mtdoops_workfunc_erase(struct work_struct *work) mtdoops_erase(cxt); } -static void mtdoops_inc_counter(struct mtdoops_context *cxt) +static void mtdoops_inc_counter(struct mtdoops_context *cxt, int panic) { cxt->nextpage++; if (cxt->nextpage >= cxt->oops_pages) @@ -180,12 +180,20 @@ static void mtdoops_inc_counter(struct mtdoops_context *cxt) cxt->nextcount = 0; if (page_is_used(cxt, cxt->nextpage)) { - schedule_work(&cxt->work_erase); - return; + pr_debug("not ready %d, %d (erase %s)\n", + cxt->nextpage, cxt->nextcount, + panic ? "immediately" : "scheduled"); + if (panic) { + /* In case of panic, erase immediately */ + mtdoops_erase(cxt); + } else { + /* Otherwise, schedule work to erase it "nicely" */ + schedule_work(&cxt->work_erase); + } + } else { + pr_debug("ready %d, %d (no erase)\n", + cxt->nextpage, cxt->nextcount); } - - pr_debug("ready %d, %d (no erase)\n", - cxt->nextpage, cxt->nextcount); } static void mtdoops_write(struct mtdoops_context *cxt, int panic) @@ -221,7 +229,7 @@ static void mtdoops_write(struct mtdoops_context *cxt, int panic) mark_page_used(cxt, cxt->nextpage); memset(cxt->oops_buf, 0xff, record_size); - mtdoops_inc_counter(cxt); + mtdoops_inc_counter(cxt, panic); out: clear_bit(0, &cxt->oops_buf_busy); } @@ -286,7 +294,7 @@ static void find_next_position(struct mtdoops_context *cxt) cxt->nextcount = maxcount; } - mtdoops_inc_counter(cxt); + mtdoops_inc_counter(cxt, 0); } static void mtdoops_do_dump(struct kmsg_dumper *dumper,