Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   1) /* SPDX-License-Identifier: GPL-2.0-or-later */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   3)  * Copyright (c) International Business Machines Corp., 2006
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Author: Artem Bityutskiy (Битюцкий Артём)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8) #ifndef __UBI_DEBUG_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9) #define __UBI_DEBUG_H__
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) void ubi_dump_flash(struct ubi_device *ubi, int pnum, int offset, int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) void ubi_dump_ec_hdr(const struct ubi_ec_hdr *ec_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) void ubi_dump_vid_hdr(const struct ubi_vid_hdr *vid_hdr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/random.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #define ubi_assert(expr)  do {                                               \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) 	if (unlikely(!(expr))) {                                             \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) 		pr_crit("UBI assert failed in %s at %u (pid %d)\n",          \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 		       __func__, __LINE__, current->pid);                    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) 		dump_stack();                                                \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) 	}                                                                    \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) } while (0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) #define ubi_dbg_print_hex_dump(l, ps, pt, r, g, b, len, a)                   \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) 		print_hex_dump(l, ps, pt, r, g, b, len, a)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) #define ubi_dbg_msg(type, fmt, ...) \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 	pr_debug("UBI DBG " type " (pid %d): " fmt "\n", current->pid,       \
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) 		 ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) /* General debugging messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) #define dbg_gen(fmt, ...) ubi_dbg_msg("gen", fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) /* Messages from the eraseblock association sub-system */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) #define dbg_eba(fmt, ...) ubi_dbg_msg("eba", fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) /* Messages from the wear-leveling sub-system */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) #define dbg_wl(fmt, ...)  ubi_dbg_msg("wl", fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) /* Messages from the input/output sub-system */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) #define dbg_io(fmt, ...)  ubi_dbg_msg("io", fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) /* Initialization and build messages */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) #define dbg_bld(fmt, ...) ubi_dbg_msg("bld", fmt, ##__VA_ARGS__)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) void ubi_dump_vol_info(const struct ubi_volume *vol);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) void ubi_dump_vtbl_record(const struct ubi_vtbl_record *r, int idx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) void ubi_dump_av(const struct ubi_ainf_volume *av);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) void ubi_dump_aeb(const struct ubi_ainf_peb *aeb, int type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) void ubi_dump_mkvol_req(const struct ubi_mkvol_req *req);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) int ubi_self_check_all_ff(struct ubi_device *ubi, int pnum, int offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 			  int len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) int ubi_debugfs_init(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) void ubi_debugfs_exit(void);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) int ubi_debugfs_init_dev(struct ubi_device *ubi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) void ubi_debugfs_exit_dev(struct ubi_device *ubi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56)  * ubi_dbg_is_bgt_disabled - if the background thread is disabled.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57)  * @ubi: UBI device description object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59)  * Returns non-zero if the UBI background thread is disabled for testing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60)  * purposes.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) static inline int ubi_dbg_is_bgt_disabled(const struct ubi_device *ubi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  64) 	return ubi->dbg.disable_bgt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  65) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  66) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68)  * ubi_dbg_is_bitflip - if it is time to emulate a bit-flip.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69)  * @ubi: UBI device description object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71)  * Returns non-zero if a bit-flip should be emulated, otherwise returns zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) static inline int ubi_dbg_is_bitflip(const struct ubi_device *ubi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	if (ubi->dbg.emulate_bitflips)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 		return !(prandom_u32() % 200);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81)  * ubi_dbg_is_write_failure - if it is time to emulate a write failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82)  * @ubi: UBI device description object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84)  * Returns non-zero if a write failure should be emulated, otherwise returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85)  * zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) static inline int ubi_dbg_is_write_failure(const struct ubi_device *ubi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (ubi->dbg.emulate_io_failures)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		return !(prandom_u32() % 500);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) /**
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95)  * ubi_dbg_is_erase_failure - if its time to emulate an erase failure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96)  * @ubi: UBI device description object
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98)  * Returns non-zero if an erase failure should be emulated, otherwise returns
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99)  * zero.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static inline int ubi_dbg_is_erase_failure(const struct ubi_device *ubi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 	if (ubi->dbg.emulate_io_failures)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		return !(prandom_u32() % 400);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) static inline int ubi_dbg_chk_io(const struct ubi_device *ubi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 	return ubi->dbg.chk_io;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) static inline int ubi_dbg_chk_gen(const struct ubi_device *ubi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 	return ubi->dbg.chk_gen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) static inline int ubi_dbg_chk_fastmap(const struct ubi_device *ubi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 	return ubi->dbg.chk_fastmap;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) static inline void ubi_enable_dbg_chk_fastmap(struct ubi_device *ubi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 	ubi->dbg.chk_fastmap = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) int ubi_dbg_power_cut(struct ubi_device *ubi, int caller);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) #endif /* !__UBI_DEBUG_H__ */