From: WeiXiong Liao <liaoweixiong@allwinnertech.com>
To: Kees Cook <keescook@chromium.org>,
Anton Vorontsov <anton@enomsg.org>,
Colin Cross <ccross@android.com>, Tony Luck <tony.luck@intel.com>,
Jonathan Corbet <corbet@lwn.net>,
Miquel Raynal <miquel.raynal@bootlin.com>,
Richard Weinberger <richard@nod.at>,
Vignesh Raghavendra <vigneshr@ti.com>,
Mauro Carvalho Chehab <mchehab+samsung@kernel.org>,
Rob Herring <robh@kernel.org>,
"David S. Miller" <davem@davemloft.net>,
Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
Jonathan Cameron <Jonathan.Cameron@huawei.com>
Cc: WeiXiong Liao <liaoweixiong@allwinnertech.com>,
linux-mtd@lists.infradead.org, linux-kernel@vger.kernel.org,
linux-doc@vger.kernel.org
Subject: [PATCH v3 03/11] pstore/blk: respect for driver to pick pstore front-ends
Date: Wed, 25 Mar 2020 16:54:58 +0800 [thread overview]
Message-ID: <1585126506-18635-4-git-send-email-liaoweixiong@allwinnertech.com> (raw)
In-Reply-To: <1585126506-18635-1-git-send-email-liaoweixiong@allwinnertech.com>
For most devices, not all psotre front-ends are supported. Pstore/blk
should provide a way for drivers to list the supported front-ends.
Signed-off-by: WeiXiong Liao <liaoweixiong@allwinnertech.com>
---
fs/pstore/pstore_blk.c | 18 ++++++++++++++----
include/linux/pstore_blk.h | 4 +++-
2 files changed, 17 insertions(+), 5 deletions(-)
diff --git a/fs/pstore/pstore_blk.c b/fs/pstore/pstore_blk.c
index 2fbdd4563e5c..f3ce7bbd9077 100644
--- a/fs/pstore/pstore_blk.c
+++ b/fs/pstore/pstore_blk.c
@@ -65,6 +65,9 @@
*
* @total_size: The total size in bytes pstore/blk can use. It must be greater
* than 4096 and be multiple of 4096.
+ * @flags: Refer to macro starting with PSTORE_FLAGS defined in
+ * linux/pstore.h. It means what front-ends this device support.
+ * Zero means all recorders for compatible.
* @read: The general read operation. Both of the function parameters
* @size and @offset are relative value to bock device (not the
* whole disk).
@@ -77,6 +80,7 @@
*/
struct psblk_device {
unsigned long total_size;
+ unsigned int flags;
psz_read_op read;
psz_write_op write;
psz_write_op panic_write;
@@ -102,8 +106,11 @@ static int psblk_register_do(struct psblk_device *dev)
return -ENOMEM;
}
-#define verify_size(name, alignsize) { \
- long _##name_ = (name); \
+ /* zero means all recorders for compatible */
+ if (!dev->flags)
+ dev->flags = UINT_MAX;
+#define verify_size(name, alignsize, enable) { \
+ long _##name_ = (enable) ? (name) : 0; \
_##name_ = _##name_ <= 0 ? 0 : (_##name_ * 1024); \
if (_##name_ & ((alignsize) - 1)) { \
pr_info(#name " must align to %d\n", \
@@ -114,7 +121,7 @@ static int psblk_register_do(struct psblk_device *dev)
psz_info->name = _##name_; \
}
- verify_size(oops_size, 4096);
+ verify_size(oops_size, 4096, dev->flags & PSTORE_FLAGS_DMESG);
#undef verify_size
dump_oops = dump_oops <= 0 ? 0 : 1;
@@ -311,6 +318,7 @@ static struct bdev_info *psblk_get_bdev_info(void)
* psblk_register_blkdev() - register block device to pstore/blk
*
* @major: the major device number of registering device
+ * @flags: refer to macro starting with PSTORE_FLAGS defined in linux/pstore.h
* @panic_write: the interface for panic case.
*
* Only the matching major to @blkdev can register.
@@ -321,7 +329,8 @@ static struct bdev_info *psblk_get_bdev_info(void)
* * 0 - OK
* * Others - something error.
*/
-int psblk_register_blkdev(unsigned int major, psblk_panic_write_op panic_write)
+int psblk_register_blkdev(unsigned int major, unsigned int flags,
+ psblk_panic_write_op panic_write)
{
struct block_device *bdev;
struct psblk_device dev = {0};
@@ -352,6 +361,7 @@ int psblk_register_blkdev(unsigned int major, psblk_panic_write_op panic_write)
blkdev_panic_write = panic_write;
dev.total_size = psblk_bdev_size(bdev);
+ dev.flags = flags;
dev.panic_write = panic_write ? psblk_blk_panic_write : NULL;
dev.read = psblk_generic_blk_read;
dev.write = psblk_generic_blk_write;
diff --git a/include/linux/pstore_blk.h b/include/linux/pstore_blk.h
index 5ff465e3953e..d8f609e60288 100644
--- a/include/linux/pstore_blk.h
+++ b/include/linux/pstore_blk.h
@@ -4,6 +4,7 @@
#define __PSTORE_BLK_H_
#include <linux/types.h>
+#include <linux/pstore.h>
#include <linux/pstore_zone.h>
/**
@@ -20,7 +21,8 @@
typedef int (*psblk_panic_write_op)(const char *buf, sector_t start_sect,
sector_t sects);
-int psblk_register_blkdev(unsigned int major, psblk_panic_write_op panic_write);
+int psblk_register_blkdev(unsigned int major, unsigned int flags,
+ psblk_panic_write_op panic_write);
void psblk_unregister_blkdev(unsigned int major);
int psblk_blkdev_info(dev_t *devt, sector_t *nr_sects, sector_t *start_sect);
--
1.9.1
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2020-03-25 8:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2020-03-25 8:54 [PATCH v3 00/11] pstore: mtd: support crash log to block and mtd device WeiXiong Liao
2020-03-25 8:54 ` [PATCH v3 01/11] pstore/zone: a common layer to manage storage as zones WeiXiong Liao
2020-04-14 1:42 ` WeiXiong Liao
2020-03-25 8:54 ` [PATCH v3 02/11] pstore/blk: new support logger for block devices WeiXiong Liao
2020-05-08 6:07 ` Kees Cook
2020-05-08 12:46 ` WeiXiong Liao
2020-03-25 8:54 ` WeiXiong Liao [this message]
2020-03-25 8:54 ` [PATCH v3 04/11] pstore/blk: pstore/zone: support pmsg recorder WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 05/11] pstore/blk: blkoops: support console recorder WeiXiong Liao
2020-04-14 2:13 ` WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 06/11] pstore/blk: blkoops: support ftrace recorder WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 07/11] Documentation: create document for pstore/blk WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 08/11] pstore/zone: skip broken zone for MTD device WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 09/11] pstore/blk: a way to get user configure about pstore front-ends WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 10/11] pstore/zone: pstore/blk: support non-block devices WeiXiong Liao
2020-03-25 8:55 ` [PATCH v3 11/11] mtd: new support oops logger based on pstore/blk WeiXiong Liao
2020-05-07 19:45 ` [PATCH v3 00/11] pstore: mtd: support crash log to block and mtd device Kees Cook
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1585126506-18635-4-git-send-email-liaoweixiong@allwinnertech.com \
--to=liaoweixiong@allwinnertech.com \
--cc=Jonathan.Cameron@huawei.com \
--cc=anton@enomsg.org \
--cc=ccross@android.com \
--cc=corbet@lwn.net \
--cc=davem@davemloft.net \
--cc=gregkh@linuxfoundation.org \
--cc=keescook@chromium.org \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=mchehab+samsung@kernel.org \
--cc=miquel.raynal@bootlin.com \
--cc=richard@nod.at \
--cc=robh@kernel.org \
--cc=tony.luck@intel.com \
--cc=vigneshr@ti.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).