Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

Merge tag 'driver-core-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core

Pull driver core updates from Greg KH:
"Here is the big set of driver core and debug printk changes for
6.1-rc1. Included in here is:

- dynamic debug updates for the core and the drm subsystem. The drm
changes have all been acked by the relevant maintainers

- kernfs fixes for syzbot reported problems

- kernfs refactors and updates for cgroup requirements

- magic number cleanups and removals from the kernel tree (they were
not being used and they really did not actually do anything)

- other tiny cleanups

All of these have been in linux-next for a while with no reported
issues"

* tag 'driver-core-6.1-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/gregkh/driver-core: (74 commits)
docs: filesystems: sysfs: Make text and code for ->show() consistent
Documentation: NBD_REQUEST_MAGIC isn't a magic number
a.out: restore CMAGIC
device property: Add const qualifier to device_get_match_data() parameter
drm_print: add _ddebug descriptor to drm_*dbg prototypes
drm_print: prefer bare printk KERN_DEBUG on generic fn
drm_print: optimize drm_debug_enabled for jump-label
drm-print: add drm_dbg_driver to improve namespace symmetry
drm-print.h: include dyndbg header
drm_print: wrap drm_*_dbg in dyndbg descriptor factory macro
drm_print: interpose drm_*dbg with forwarding macros
drm: POC drm on dyndbg - use in core, 2 helpers, 3 drivers.
drm_print: condense enum drm_debug_category
debugfs: use DEFINE_SHOW_ATTRIBUTE to define debugfs_regset32_fops
driver core: use IS_ERR_OR_NULL() helper in device_create_groups_vargs()
Documentation: ENI155_MAGIC isn't a magic number
Documentation: NBD_REPLY_MAGIC isn't a magic number
nbd: remove define-only NBD_MAGIC, previously magic number
Documentation: FW_HEADER_MAGIC isn't a magic number
Documentation: EEPROM_MAGIC_VALUE isn't a magic number
...

+1320 -696
+128 -118
Documentation/admin-guide/dynamic-debug-howto.rst
··· 5 5 Introduction 6 6 ============ 7 7 8 - This document describes how to use the dynamic debug (dyndbg) feature. 8 + Dynamic debug allows you to dynamically enable/disable kernel 9 + debug-print code to obtain additional kernel information. 9 10 10 - Dynamic debug is designed to allow you to dynamically enable/disable 11 - kernel code to obtain additional kernel information. Currently, if 12 - ``CONFIG_DYNAMIC_DEBUG`` is set, then all ``pr_debug()``/``dev_dbg()`` and 13 - ``print_hex_dump_debug()``/``print_hex_dump_bytes()`` calls can be dynamically 14 - enabled per-callsite. 11 + If ``/proc/dynamic_debug/control`` exists, your kernel has dynamic 12 + debug. You'll need root access (sudo su) to use this. 15 13 16 - If you do not want to enable dynamic debug globally (i.e. in some embedded 17 - system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic 18 - debug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any 19 - modules which you'd like to dynamically debug later. 14 + Dynamic debug provides: 20 15 21 - If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is just 22 - shortcut for ``print_hex_dump(KERN_DEBUG)``. 16 + * a Catalog of all *prdbgs* in your kernel. 17 + ``cat /proc/dynamic_debug/control`` to see them. 23 18 24 - For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is 25 - its ``prefix_str`` argument, if it is constant string; or ``hexdump`` 26 - in case ``prefix_str`` is built dynamically. 27 - 28 - Dynamic debug has even more useful features: 29 - 30 - * Simple query language allows turning on and off debugging 31 - statements by matching any combination of 0 or 1 of: 19 + * a Simple query/command language to alter *prdbgs* by selecting on 20 + any combination of 0 or 1 of: 32 21 33 22 - source filename 34 23 - function name 35 24 - line number (including ranges of line numbers) 36 25 - module name 37 26 - format string 38 - 39 - * Provides a debugfs control file: ``<debugfs>/dynamic_debug/control`` 40 - which can be read to display the complete list of known debug 41 - statements, to help guide you 42 - 43 - Controlling dynamic debug Behaviour 44 - =================================== 45 - 46 - The behaviour of ``pr_debug()``/``dev_dbg()`` are controlled via writing to a 47 - control file in the 'debugfs' filesystem. Thus, you must first mount 48 - the debugfs filesystem, in order to make use of this feature. 49 - Subsequently, we refer to the control file as: 50 - ``<debugfs>/dynamic_debug/control``. For example, if you want to enable 51 - printing from source file ``svcsock.c``, line 1603 you simply do:: 52 - 53 - nullarbor:~ # echo 'file svcsock.c line 1603 +p' > 54 - <debugfs>/dynamic_debug/control 55 - 56 - If you make a mistake with the syntax, the write will fail thus:: 57 - 58 - nullarbor:~ # echo 'file svcsock.c wtf 1 +p' > 59 - <debugfs>/dynamic_debug/control 60 - -bash: echo: write error: Invalid argument 61 - 62 - Note, for systems without 'debugfs' enabled, the control file can be 63 - found in ``/proc/dynamic_debug/control``. 27 + - class name (as known/declared by each module) 64 28 65 29 Viewing Dynamic Debug Behaviour 66 30 =============================== 67 31 68 - You can view the currently configured behaviour of all the debug 69 - statements via:: 32 + You can view the currently configured behaviour in the *prdbg* catalog:: 70 33 71 - nullarbor:~ # cat <debugfs>/dynamic_debug/control 34 + :#> head -n7 /proc/dynamic_debug/control 72 35 # filename:lineno [module]function flags format 73 - net/sunrpc/svc_rdma.c:323 [svcxprt_rdma]svc_rdma_cleanup =_ "SVCRDMA Module Removed, deregister RPC RDMA transport\012" 74 - net/sunrpc/svc_rdma.c:341 [svcxprt_rdma]svc_rdma_init =_ "\011max_inline : %d\012" 75 - net/sunrpc/svc_rdma.c:340 [svcxprt_rdma]svc_rdma_init =_ "\011sq_depth : %d\012" 76 - net/sunrpc/svc_rdma.c:338 [svcxprt_rdma]svc_rdma_init =_ "\011max_requests : %d\012" 77 - ... 36 + init/main.c:1179 [main]initcall_blacklist =_ "blacklisting initcall %s\012 37 + init/main.c:1218 [main]initcall_blacklisted =_ "initcall %s blacklisted\012" 38 + init/main.c:1424 [main]run_init_process =_ " with arguments:\012" 39 + init/main.c:1426 [main]run_init_process =_ " %s\012" 40 + init/main.c:1427 [main]run_init_process =_ " with environment:\012" 41 + init/main.c:1429 [main]run_init_process =_ " %s\012" 78 42 43 + The 3rd space-delimited column shows the current flags, preceded by 44 + a ``=`` for easy use with grep/cut. ``=p`` shows enabled callsites. 79 45 80 - You can also apply standard Unix text manipulation filters to this 81 - data, e.g.:: 46 + Controlling dynamic debug Behaviour 47 + =================================== 82 48 83 - nullarbor:~ # grep -i rdma <debugfs>/dynamic_debug/control | wc -l 84 - 62 49 + The behaviour of *prdbg* sites are controlled by writing 50 + query/commands to the control file. Example:: 85 51 86 - nullarbor:~ # grep -i tcp <debugfs>/dynamic_debug/control | wc -l 87 - 42 52 + # grease the interface 53 + :#> alias ddcmd='echo $* > /proc/dynamic_debug/control' 88 54 89 - The third column shows the currently enabled flags for each debug 90 - statement callsite (see below for definitions of the flags). The 91 - default value, with no flags enabled, is ``=_``. So you can view all 92 - the debug statement callsites with any non-default flags:: 55 + :#> ddcmd '-p; module main func run* +p' 56 + :#> grep =p /proc/dynamic_debug/control 57 + init/main.c:1424 [main]run_init_process =p " with arguments:\012" 58 + init/main.c:1426 [main]run_init_process =p " %s\012" 59 + init/main.c:1427 [main]run_init_process =p " with environment:\012" 60 + init/main.c:1429 [main]run_init_process =p " %s\012" 93 61 94 - nullarbor:~ # awk '$3 != "=_"' <debugfs>/dynamic_debug/control 95 - # filename:lineno [module]function flags format 96 - net/sunrpc/svcsock.c:1603 [sunrpc]svc_send p "svc_process: st_sendto returned %d\012" 62 + Error messages go to console/syslog:: 63 + 64 + :#> ddcmd mode foo +p 65 + dyndbg: unknown keyword "mode" 66 + dyndbg: query parse failed 67 + bash: echo: write error: Invalid argument 68 + 69 + If debugfs is also enabled and mounted, ``dynamic_debug/control`` is 70 + also under the mount-dir, typically ``/sys/kernel/debug/``. 97 71 98 72 Command Language Reference 99 73 ========================== 100 74 101 - At the lexical level, a command comprises a sequence of words separated 75 + At the basic lexical level, a command is a sequence of words separated 102 76 by spaces or tabs. So these are all equivalent:: 103 77 104 - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > 105 - <debugfs>/dynamic_debug/control 106 - nullarbor:~ # echo -n ' file svcsock.c line 1603 +p ' > 107 - <debugfs>/dynamic_debug/control 108 - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > 109 - <debugfs>/dynamic_debug/control 78 + :#> ddcmd file svcsock.c line 1603 +p 79 + :#> ddcmd "file svcsock.c line 1603 +p" 80 + :#> ddcmd ' file svcsock.c line 1603 +p ' 110 81 111 82 Command submissions are bounded by a write() system call. 112 83 Multiple commands can be written together, separated by ``;`` or ``\n``:: 113 84 114 - ~# echo "func pnpacpi_get_resources +p; func pnp_assign_mem +p" \ 115 - > <debugfs>/dynamic_debug/control 85 + :#> ddcmd "func pnpacpi_get_resources +p; func pnp_assign_mem +p" 86 + :#> ddcmd <<"EOC" 87 + func pnpacpi_get_resources +p 88 + func pnp_assign_mem +p 89 + EOC 90 + :#> cat query-batch-file > /proc/dynamic_debug/control 116 91 117 - If your query set is big, you can batch them too:: 92 + You can also use wildcards in each query term. The match rule supports 93 + ``*`` (matches zero or more characters) and ``?`` (matches exactly one 94 + character). For example, you can match all usb drivers:: 118 95 119 - ~# cat query-batch-file > <debugfs>/dynamic_debug/control 96 + :#> ddcmd file "drivers/usb/*" +p # "" to suppress shell expansion 120 97 121 - Another way is to use wildcards. The match rule supports ``*`` (matches 122 - zero or more characters) and ``?`` (matches exactly one character). For 123 - example, you can match all usb drivers:: 124 - 125 - ~# echo "file drivers/usb/* +p" > <debugfs>/dynamic_debug/control 126 - 127 - At the syntactical level, a command comprises a sequence of match 128 - specifications, followed by a flags change specification:: 98 + Syntactically, a command is pairs of keyword values, followed by a 99 + flags change or setting:: 129 100 130 101 command ::= match-spec* flags-spec 131 102 132 - The match-spec's are used to choose a subset of the known pr_debug() 133 - callsites to which to apply the flags-spec. Think of them as a query 134 - with implicit ANDs between each pair. Note that an empty list of 135 - match-specs will select all debug statement callsites. 103 + The match-spec's select *prdbgs* from the catalog, upon which to apply 104 + the flags-spec, all constraints are ANDed together. An absent keyword 105 + is the same as keyword "*". 136 106 137 - A match specification comprises a keyword, which controls the 138 - attribute of the callsite to be compared, and a value to compare 139 - against. Possible keywords are::: 107 + 108 + A match specification is a keyword, which selects the attribute of 109 + the callsite to be compared, and a value to compare against. Possible 110 + keywords are::: 140 111 141 112 match-spec ::= 'func' string | 142 113 'file' string | 143 114 'module' string | 144 115 'format' string | 116 + 'class' string | 145 117 'line' line-range 146 118 147 119 line-range ::= lineno | ··· 175 203 format "nfsd: SETATTR" // a neater way to match a format with whitespace 176 204 format 'nfsd: SETATTR' // yet another way to match a format with whitespace 177 205 206 + class 207 + The given class_name is validated against each module, which may 208 + have declared a list of known class_names. If the class_name is 209 + found for a module, callsite & class matching and adjustment 210 + proceeds. Examples:: 211 + 212 + class DRM_UT_KMS # a DRM.debug category 213 + class JUNK # silent non-match 214 + // class TLD_* # NOTICE: no wildcard in class names 215 + 178 216 line 179 217 The given line number or range of line numbers is compared 180 218 against the line number of each ``pr_debug()`` callsite. A single ··· 210 228 The flags are:: 211 229 212 230 p enables the pr_debug() callsite. 213 - f Include the function name in the printed message 214 - l Include line number in the printed message 215 - m Include module name in the printed message 216 - t Include thread ID in messages not generated from interrupt context 217 - _ No flags are set. (Or'd with others on input) 231 + _ enables no flags. 218 232 219 - For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only ``p`` flag 220 - have meaning, other flags ignored. 233 + Decorator flags add to the message-prefix, in order: 234 + t Include thread ID, or <intr> 235 + m Include module name 236 + f Include the function name 237 + l Include line number 221 238 222 - For display, the flags are preceded by ``=`` 223 - (mnemonic: what the flags are currently equal to). 239 + For ``print_hex_dump_debug()`` and ``print_hex_dump_bytes()``, only 240 + the ``p`` flag has meaning, other flags are ignored. 224 241 225 242 Note the regexp ``^[-+=][flmpt_]+$`` matches a flags specification. 226 243 To clear all flags at once, use ``=_`` or ``-flmpt``. ··· 294 313 enabled by ``-DDEBUG`` flag during compilation) can be disabled later via 295 314 the debugfs interface if the debug messages are no longer needed:: 296 315 297 - echo "module module_name -p" > <debugfs>/dynamic_debug/control 316 + echo "module module_name -p" > /proc/dynamic_debug/control 298 317 299 318 Examples 300 319 ======== ··· 302 321 :: 303 322 304 323 // enable the message at line 1603 of file svcsock.c 305 - nullarbor:~ # echo -n 'file svcsock.c line 1603 +p' > 306 - <debugfs>/dynamic_debug/control 324 + :#> ddcmd 'file svcsock.c line 1603 +p' 307 325 308 326 // enable all the messages in file svcsock.c 309 - nullarbor:~ # echo -n 'file svcsock.c +p' > 310 - <debugfs>/dynamic_debug/control 327 + :#> ddcmd 'file svcsock.c +p' 311 328 312 329 // enable all the messages in the NFS server module 313 - nullarbor:~ # echo -n 'module nfsd +p' > 314 - <debugfs>/dynamic_debug/control 330 + :#> ddcmd 'module nfsd +p' 315 331 316 332 // enable all 12 messages in the function svc_process() 317 - nullarbor:~ # echo -n 'func svc_process +p' > 318 - <debugfs>/dynamic_debug/control 333 + :#> ddcmd 'func svc_process +p' 319 334 320 335 // disable all 12 messages in the function svc_process() 321 - nullarbor:~ # echo -n 'func svc_process -p' > 322 - <debugfs>/dynamic_debug/control 336 + :#> ddcmd 'func svc_process -p' 323 337 324 338 // enable messages for NFS calls READ, READLINK, READDIR and READDIR+. 325 - nullarbor:~ # echo -n 'format "nfsd: READ" +p' > 326 - <debugfs>/dynamic_debug/control 339 + :#> ddcmd 'format "nfsd: READ" +p' 327 340 328 341 // enable messages in files of which the paths include string "usb" 329 - nullarbor:~ # echo -n 'file *usb* +p' > <debugfs>/dynamic_debug/control 342 + :#> ddcmd 'file *usb* +p' > /proc/dynamic_debug/control 330 343 331 344 // enable all messages 332 - nullarbor:~ # echo -n '+p' > <debugfs>/dynamic_debug/control 345 + :#> ddcmd '+p' > /proc/dynamic_debug/control 333 346 334 347 // add module, function to all enabled messages 335 - nullarbor:~ # echo -n '+mf' > <debugfs>/dynamic_debug/control 348 + :#> ddcmd '+mf' > /proc/dynamic_debug/control 336 349 337 350 // boot-args example, with newlines and comments for readability 338 351 Kernel command line: ... ··· 339 364 dyndbg="file init/* +p #cmt ; func parse_one +p" 340 365 // enable pr_debugs in 2 functions in a module loaded later 341 366 pc87360.dyndbg="func pc87360_init_device +p; func pc87360_find +p" 367 + 368 + Kernel Configuration 369 + ==================== 370 + 371 + Dynamic Debug is enabled via kernel config items:: 372 + 373 + CONFIG_DYNAMIC_DEBUG=y # build catalog, enables CORE 374 + CONFIG_DYNAMIC_DEBUG_CORE=y # enable mechanics only, skip catalog 375 + 376 + If you do not want to enable dynamic debug globally (i.e. in some embedded 377 + system), you may set ``CONFIG_DYNAMIC_DEBUG_CORE`` as basic support of dynamic 378 + debug and add ``ccflags := -DDYNAMIC_DEBUG_MODULE`` into the Makefile of any 379 + modules which you'd like to dynamically debug later. 380 + 381 + 382 + Kernel *prdbg* API 383 + ================== 384 + 385 + The following functions are cataloged and controllable when dynamic 386 + debug is enabled:: 387 + 388 + pr_debug() 389 + dev_dbg() 390 + print_hex_dump_debug() 391 + print_hex_dump_bytes() 392 + 393 + Otherwise, they are off by default; ``ccflags += -DDEBUG`` or 394 + ``#define DEBUG`` in a source file will enable them appropriately. 395 + 396 + If ``CONFIG_DYNAMIC_DEBUG`` is not set, ``print_hex_dump_debug()`` is 397 + just a shortcut for ``print_hex_dump(KERN_DEBUG)``. 398 + 399 + For ``print_hex_dump_debug()``/``print_hex_dump_bytes()``, format string is 400 + its ``prefix_str`` argument, if it is constant string; or ``hexdump`` 401 + in case ``prefix_str`` is built dynamically.
-1
Documentation/driver-api/driver-model/devres.rst
··· 311 311 devm_ioremap() 312 312 devm_ioremap_uc() 313 313 devm_ioremap_wc() 314 - devm_ioremap_np() 315 314 devm_ioremap_resource() : checks resource, requests memory region, ioremaps 316 315 devm_ioremap_resource_wc() 317 316 devm_platform_ioremap_resource() : calls devm_ioremap_resource() for platform device
+1 -1
Documentation/filesystems/sysfs.rst
··· 263 263 static ssize_t show_name(struct device *dev, struct device_attribute *attr, 264 264 char *buf) 265 265 { 266 - return scnprintf(buf, PAGE_SIZE, "%s\n", dev->name); 266 + return sysfs_emit(buf, "%s\n", dev->name); 267 267 } 268 268 269 269 static ssize_t store_name(struct device *dev, struct device_attribute *attr,
-65
Documentation/process/magic-number.rst
··· 69 69 Magic Name Number Structure File 70 70 ===================== ================ ======================== ========================================== 71 71 PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h`` 72 - CMAGIC 0x0111 user ``include/linux/a.out.h`` 73 - MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h`` 74 72 APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c`` 75 - DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c`` 76 - DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` 77 73 FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` 78 - FF_MAGIC 0x4646 fc_info ``drivers/net/iph5526_novram.c`` 79 - PTY_MAGIC 0x5001 ``drivers/char/pty.c`` 80 - PPP_MAGIC 0x5002 ppp ``include/linux/if_pppvar.h`` 81 - SSTATE_MAGIC 0x5302 serial_state ``include/linux/serial.h`` 82 74 SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h`` 83 - STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 84 - SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 85 - AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 86 75 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` 87 - USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` 88 - FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c`` 89 - USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth ``drivers/usb/class/bluetty.c`` 90 - RFCOMM_TTY_MAGIC 0x6d02 ``net/bluetooth/rfcomm/tty.c`` 91 - USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port ``drivers/usb/serial/usb-serial.h`` 92 - CG_MAGIC 0x00090255 ufs_cylinder_group ``include/linux/ufs_fs.h`` 93 - LSEMAGIC 0x05091998 lse ``drivers/fc4/fc.c`` 94 - RIEBL_MAGIC 0x09051990 ``drivers/net/atarilance.c`` 95 - NBD_REQUEST_MAGIC 0x12560953 nbd_request ``include/linux/nbd.h`` 96 - RED_MAGIC2 0x170fc2a5 (any) ``mm/slab.c`` 97 76 BAYCOM_MAGIC 0x19730510 baycom_state ``drivers/net/baycom_epp.c`` 98 - ISDN_X25IFACE_MAGIC 0x1e75a2b9 isdn_x25iface_proto_data ``drivers/isdn/isdn_x25iface.h`` 99 - ECP_MAGIC 0x21504345 cdkecpsig ``include/linux/cdk.h`` 100 - LSOMAGIC 0x27091997 lso ``drivers/fc4/fc.c`` 101 - LSMAGIC 0x2a3b4d2a ls ``drivers/fc4/fc.c`` 102 - WANPIPE_MAGIC 0x414C4453 sdla_{dump,exec} ``include/linux/wanpipe.h`` 103 - CS_CARD_MAGIC 0x43525553 cs_card ``sound/oss/cs46xx.c`` 104 - LABELCL_MAGIC 0x4857434c labelcl_info_s ``include/asm/ia64/sn/labelcl.h`` 105 - ISDN_ASYNC_MAGIC 0x49344C01 modem_info ``include/linux/isdn.h`` 106 - CTC_ASYNC_MAGIC 0x49344C01 ctc_tty_info ``drivers/s390/net/ctctty.c`` 107 - ISDN_NET_MAGIC 0x49344C02 isdn_net_local_s ``drivers/isdn/i4l/isdn_net_lib.h`` 108 - SAVEKMSG_MAGIC2 0x4B4D5347 savekmsg ``arch/*/amiga/config.c`` 109 - CS_STATE_MAGIC 0x4c4f4749 cs_state ``sound/oss/cs46xx.c`` 110 - SLAB_C_MAGIC 0x4f17a36d kmem_cache ``mm/slab.c`` 111 - COW_MAGIC 0x4f4f4f4d cow_header_v1 ``arch/um/drivers/ubd_user.c`` 112 - I810_CARD_MAGIC 0x5072696E i810_card ``sound/oss/i810_audio.c`` 113 - TRIDENT_CARD_MAGIC 0x5072696E trident_card ``sound/oss/trident.c`` 114 - ROUTER_MAGIC 0x524d4157 wan_device [in ``wanrouter.h`` pre 3.9] 115 - SAVEKMSG_MAGIC1 0x53415645 savekmsg ``arch/*/amiga/config.c`` 116 - GDA_MAGIC 0x58464552 gda ``arch/mips/include/asm/sn/gda.h`` 117 - RED_MAGIC1 0x5a2cf071 (any) ``mm/slab.c`` 118 - EEPROM_MAGIC_VALUE 0x5ab478d2 lanai_dev ``drivers/atm/lanai.c`` 119 77 HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h`` 120 - PCXX_MAGIC 0x5c6df104 channel ``drivers/char/pcxx.h`` 121 78 KV_MAGIC 0x5f4b565f kernel_vars_s ``arch/mips/include/asm/sn/klkernvars.h`` 122 - I810_STATE_MAGIC 0x63657373 i810_state ``sound/oss/i810_audio.c`` 123 - TRIDENT_STATE_MAGIC 0x63657373 trient_state ``sound/oss/trident.c`` 124 - M3_CARD_MAGIC 0x646e6f50 m3_card ``sound/oss/maestro3.c`` 125 - FW_HEADER_MAGIC 0x65726F66 fw_header ``drivers/atm/fore200e.h`` 126 - SLOT_MAGIC 0x67267321 slot ``drivers/hotplug/cpqphp.h`` 127 - SLOT_MAGIC 0x67267322 slot ``drivers/hotplug/acpiphp.h`` 128 - LO_MAGIC 0x68797548 nbd_device ``include/linux/nbd.h`` 129 - M3_STATE_MAGIC 0x734d724d m3_state ``sound/oss/maestro3.c`` 130 - VMALLOC_MAGIC 0x87654320 snd_alloc_track ``sound/core/memory.c`` 131 - KMALLOC_MAGIC 0x87654321 snd_alloc_track ``sound/core/memory.c`` 132 - PWC_MAGIC 0x89DC10AB pwc_device ``drivers/usb/media/pwc.h`` 133 - NBD_REPLY_MAGIC 0x96744668 nbd_reply ``include/linux/nbd.h`` 134 - ENI155_MAGIC 0xa54b872d midway_eprom ``drivers/atm/eni.h`` 135 79 CODA_MAGIC 0xC0DAC0DA coda_file_info ``fs/coda/coda_fs_i.h`` 136 80 YAM_MAGIC 0xF10A7654 yam_port ``drivers/net/hamradio/yam.c`` 137 81 CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` 138 82 QUEUE_MAGIC_FREE 0xf7e1c9a3 queue_entry ``drivers/scsi/arm/queue.c`` 139 83 QUEUE_MAGIC_USED 0xf7e1cc33 queue_entry ``drivers/scsi/arm/queue.c`` 140 - HTB_CMAGIC 0xFEFAFEF1 htb_class ``net/sched/sch_htb.c`` 141 84 NMI_MAGIC 0x48414d4d455201 nmi_s ``arch/mips/include/asm/sn/nmi.h`` 142 85 ===================== ================ ======================== ========================================== 143 - 144 - Note that there are also defined special per-driver magic numbers in sound 145 - memory management. See ``include/sound/sndmagic.h`` for complete list of them. Many 146 - OSS sound drivers have their magic numbers constructed from the soundcard PCI 147 - ID - these are not listed here as well. 148 - 149 - HFS is another larger user of magic numbers - you can find them in 150 - ``fs/hfs/hfs.h``.
-66
Documentation/translations/it_IT/process/magic-number.rst
··· 75 75 Nome magico Numero Struttura File 76 76 ===================== ================ ======================== ========================================== 77 77 PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h`` 78 - CMAGIC 0x0111 user ``include/linux/a.out.h`` 79 - MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h`` 80 78 APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c`` 81 - DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c`` 82 - DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` 83 79 FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` 84 - FF_MAGIC 0x4646 fc_info ``drivers/net/iph5526_novram.c`` 85 - PTY_MAGIC 0x5001 ``drivers/char/pty.c`` 86 - PPP_MAGIC 0x5002 ppp ``include/linux/if_pppvar.h`` 87 - SSTATE_MAGIC 0x5302 serial_state ``include/linux/serial.h`` 88 80 SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h`` 89 - STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 90 - SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 91 - AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 92 81 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` 93 - USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` 94 - FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c`` 95 - USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth ``drivers/usb/class/bluetty.c`` 96 - RFCOMM_TTY_MAGIC 0x6d02 ``net/bluetooth/rfcomm/tty.c`` 97 - USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port ``drivers/usb/serial/usb-serial.h`` 98 - CG_MAGIC 0x00090255 ufs_cylinder_group ``include/linux/ufs_fs.h`` 99 - LSEMAGIC 0x05091998 lse ``drivers/fc4/fc.c`` 100 - RIEBL_MAGIC 0x09051990 ``drivers/net/atarilance.c`` 101 - NBD_REQUEST_MAGIC 0x12560953 nbd_request ``include/linux/nbd.h`` 102 - RED_MAGIC2 0x170fc2a5 (any) ``mm/slab.c`` 103 82 BAYCOM_MAGIC 0x19730510 baycom_state ``drivers/net/baycom_epp.c`` 104 - ISDN_X25IFACE_MAGIC 0x1e75a2b9 isdn_x25iface_proto_data ``drivers/isdn/isdn_x25iface.h`` 105 - ECP_MAGIC 0x21504345 cdkecpsig ``include/linux/cdk.h`` 106 - LSOMAGIC 0x27091997 lso ``drivers/fc4/fc.c`` 107 - LSMAGIC 0x2a3b4d2a ls ``drivers/fc4/fc.c`` 108 - WANPIPE_MAGIC 0x414C4453 sdla_{dump,exec} ``include/linux/wanpipe.h`` 109 - CS_CARD_MAGIC 0x43525553 cs_card ``sound/oss/cs46xx.c`` 110 - LABELCL_MAGIC 0x4857434c labelcl_info_s ``include/asm/ia64/sn/labelcl.h`` 111 - ISDN_ASYNC_MAGIC 0x49344C01 modem_info ``include/linux/isdn.h`` 112 - CTC_ASYNC_MAGIC 0x49344C01 ctc_tty_info ``drivers/s390/net/ctctty.c`` 113 - ISDN_NET_MAGIC 0x49344C02 isdn_net_local_s ``drivers/isdn/i4l/isdn_net_lib.h`` 114 - SAVEKMSG_MAGIC2 0x4B4D5347 savekmsg ``arch/*/amiga/config.c`` 115 - CS_STATE_MAGIC 0x4c4f4749 cs_state ``sound/oss/cs46xx.c`` 116 - SLAB_C_MAGIC 0x4f17a36d kmem_cache ``mm/slab.c`` 117 - COW_MAGIC 0x4f4f4f4d cow_header_v1 ``arch/um/drivers/ubd_user.c`` 118 - I810_CARD_MAGIC 0x5072696E i810_card ``sound/oss/i810_audio.c`` 119 - TRIDENT_CARD_MAGIC 0x5072696E trident_card ``sound/oss/trident.c`` 120 - ROUTER_MAGIC 0x524d4157 wan_device [in ``wanrouter.h`` pre 3.9] 121 - SAVEKMSG_MAGIC1 0x53415645 savekmsg ``arch/*/amiga/config.c`` 122 - GDA_MAGIC 0x58464552 gda ``arch/mips/include/asm/sn/gda.h`` 123 - RED_MAGIC1 0x5a2cf071 (any) ``mm/slab.c`` 124 - EEPROM_MAGIC_VALUE 0x5ab478d2 lanai_dev ``drivers/atm/lanai.c`` 125 83 HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h`` 126 - PCXX_MAGIC 0x5c6df104 channel ``drivers/char/pcxx.h`` 127 84 KV_MAGIC 0x5f4b565f kernel_vars_s ``arch/mips/include/asm/sn/klkernvars.h`` 128 - I810_STATE_MAGIC 0x63657373 i810_state ``sound/oss/i810_audio.c`` 129 - TRIDENT_STATE_MAGIC 0x63657373 trient_state ``sound/oss/trident.c`` 130 - M3_CARD_MAGIC 0x646e6f50 m3_card ``sound/oss/maestro3.c`` 131 - FW_HEADER_MAGIC 0x65726F66 fw_header ``drivers/atm/fore200e.h`` 132 - SLOT_MAGIC 0x67267321 slot ``drivers/hotplug/cpqphp.h`` 133 - SLOT_MAGIC 0x67267322 slot ``drivers/hotplug/acpiphp.h`` 134 - LO_MAGIC 0x68797548 nbd_device ``include/linux/nbd.h`` 135 - M3_STATE_MAGIC 0x734d724d m3_state ``sound/oss/maestro3.c`` 136 - VMALLOC_MAGIC 0x87654320 snd_alloc_track ``sound/core/memory.c`` 137 - KMALLOC_MAGIC 0x87654321 snd_alloc_track ``sound/core/memory.c`` 138 - PWC_MAGIC 0x89DC10AB pwc_device ``drivers/usb/media/pwc.h`` 139 - NBD_REPLY_MAGIC 0x96744668 nbd_reply ``include/linux/nbd.h`` 140 - ENI155_MAGIC 0xa54b872d midway_eprom ``drivers/atm/eni.h`` 141 85 CODA_MAGIC 0xC0DAC0DA coda_file_info ``fs/coda/coda_fs_i.h`` 142 86 YAM_MAGIC 0xF10A7654 yam_port ``drivers/net/hamradio/yam.c`` 143 87 CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` 144 88 QUEUE_MAGIC_FREE 0xf7e1c9a3 queue_entry ``drivers/scsi/arm/queue.c`` 145 89 QUEUE_MAGIC_USED 0xf7e1cc33 queue_entry ``drivers/scsi/arm/queue.c`` 146 - HTB_CMAGIC 0xFEFAFEF1 htb_class ``net/sched/sch_htb.c`` 147 90 NMI_MAGIC 0x48414d4d455201 nmi_s ``arch/mips/include/asm/sn/nmi.h`` 148 91 ===================== ================ ======================== ========================================== 149 - 150 - Da notare che ci sono anche dei numeri magici specifici per driver nel 151 - *sound memory management*. Consultate ``include/sound/sndmagic.h`` per una 152 - lista completa. Molti driver audio OSS hanno i loro numeri magici costruiti a 153 - partire dall'identificativo PCI della scheda audio - nemmeno questi sono 154 - elencati in questo file. 155 - 156 - Il file-system HFS è un altro grande utilizzatore di numeri magici - potete 157 - trovarli qui ``fs/hfs/hfs.h``.
-66
Documentation/translations/zh_CN/process/magic-number.rst
··· 58 58 魔术数名 数字 结构 文件 59 59 ===================== ================ ======================== ========================================== 60 60 PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h`` 61 - CMAGIC 0x0111 user ``include/linux/a.out.h`` 62 - MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h`` 63 61 APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c`` 64 - DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c`` 65 - DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` 66 62 FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` 67 - FF_MAGIC 0x4646 fc_info ``drivers/net/iph5526_novram.c`` 68 - PTY_MAGIC 0x5001 ``drivers/char/pty.c`` 69 - PPP_MAGIC 0x5002 ppp ``include/linux/if_pppvar.h`` 70 - SSTATE_MAGIC 0x5302 serial_state ``include/linux/serial.h`` 71 63 SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h`` 72 - STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 73 - SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 74 - AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 75 64 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` 76 - USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` 77 - FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c`` 78 - USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth ``drivers/usb/class/bluetty.c`` 79 - RFCOMM_TTY_MAGIC 0x6d02 ``net/bluetooth/rfcomm/tty.c`` 80 - USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port ``drivers/usb/serial/usb-serial.h`` 81 - CG_MAGIC 0x00090255 ufs_cylinder_group ``include/linux/ufs_fs.h`` 82 - LSEMAGIC 0x05091998 lse ``drivers/fc4/fc.c`` 83 - GDTIOCTL_MAGIC 0x06030f07 gdth_iowr_str ``drivers/scsi/gdth_ioctl.h`` 84 - RIEBL_MAGIC 0x09051990 ``drivers/net/atarilance.c`` 85 - NBD_REQUEST_MAGIC 0x12560953 nbd_request ``include/linux/nbd.h`` 86 - RED_MAGIC2 0x170fc2a5 (any) ``mm/slab.c`` 87 65 BAYCOM_MAGIC 0x19730510 baycom_state ``drivers/net/baycom_epp.c`` 88 - ISDN_X25IFACE_MAGIC 0x1e75a2b9 isdn_x25iface_proto_data ``drivers/isdn/isdn_x25iface.h`` 89 - ECP_MAGIC 0x21504345 cdkecpsig ``include/linux/cdk.h`` 90 - LSOMAGIC 0x27091997 lso ``drivers/fc4/fc.c`` 91 - LSMAGIC 0x2a3b4d2a ls ``drivers/fc4/fc.c`` 92 - WANPIPE_MAGIC 0x414C4453 sdla_{dump,exec} ``include/linux/wanpipe.h`` 93 - CS_CARD_MAGIC 0x43525553 cs_card ``sound/oss/cs46xx.c`` 94 - LABELCL_MAGIC 0x4857434c labelcl_info_s ``include/asm/ia64/sn/labelcl.h`` 95 - ISDN_ASYNC_MAGIC 0x49344C01 modem_info ``include/linux/isdn.h`` 96 - CTC_ASYNC_MAGIC 0x49344C01 ctc_tty_info ``drivers/s390/net/ctctty.c`` 97 - ISDN_NET_MAGIC 0x49344C02 isdn_net_local_s ``drivers/isdn/i4l/isdn_net_lib.h`` 98 - SAVEKMSG_MAGIC2 0x4B4D5347 savekmsg ``arch/*/amiga/config.c`` 99 - CS_STATE_MAGIC 0x4c4f4749 cs_state ``sound/oss/cs46xx.c`` 100 - SLAB_C_MAGIC 0x4f17a36d kmem_cache ``mm/slab.c`` 101 - COW_MAGIC 0x4f4f4f4d cow_header_v1 ``arch/um/drivers/ubd_user.c`` 102 - I810_CARD_MAGIC 0x5072696E i810_card ``sound/oss/i810_audio.c`` 103 - TRIDENT_CARD_MAGIC 0x5072696E trident_card ``sound/oss/trident.c`` 104 - ROUTER_MAGIC 0x524d4157 wan_device [in ``wanrouter.h`` pre 3.9] 105 - SAVEKMSG_MAGIC1 0x53415645 savekmsg ``arch/*/amiga/config.c`` 106 - GDA_MAGIC 0x58464552 gda ``arch/mips/include/asm/sn/gda.h`` 107 - RED_MAGIC1 0x5a2cf071 (any) ``mm/slab.c`` 108 - EEPROM_MAGIC_VALUE 0x5ab478d2 lanai_dev ``drivers/atm/lanai.c`` 109 66 HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h`` 110 - PCXX_MAGIC 0x5c6df104 channel ``drivers/char/pcxx.h`` 111 67 KV_MAGIC 0x5f4b565f kernel_vars_s ``arch/mips/include/asm/sn/klkernvars.h`` 112 - I810_STATE_MAGIC 0x63657373 i810_state ``sound/oss/i810_audio.c`` 113 - TRIDENT_STATE_MAGIC 0x63657373 trient_state ``sound/oss/trident.c`` 114 - M3_CARD_MAGIC 0x646e6f50 m3_card ``sound/oss/maestro3.c`` 115 - FW_HEADER_MAGIC 0x65726F66 fw_header ``drivers/atm/fore200e.h`` 116 - SLOT_MAGIC 0x67267321 slot ``drivers/hotplug/cpqphp.h`` 117 - SLOT_MAGIC 0x67267322 slot ``drivers/hotplug/acpiphp.h`` 118 - LO_MAGIC 0x68797548 nbd_device ``include/linux/nbd.h`` 119 - M3_STATE_MAGIC 0x734d724d m3_state ``sound/oss/maestro3.c`` 120 - VMALLOC_MAGIC 0x87654320 snd_alloc_track ``sound/core/memory.c`` 121 - KMALLOC_MAGIC 0x87654321 snd_alloc_track ``sound/core/memory.c`` 122 - PWC_MAGIC 0x89DC10AB pwc_device ``drivers/usb/media/pwc.h`` 123 - NBD_REPLY_MAGIC 0x96744668 nbd_reply ``include/linux/nbd.h`` 124 - ENI155_MAGIC 0xa54b872d midway_eprom ``drivers/atm/eni.h`` 125 68 CODA_MAGIC 0xC0DAC0DA coda_file_info ``fs/coda/coda_fs_i.h`` 126 - DPMEM_MAGIC 0xc0ffee11 gdt_pci_sram ``drivers/scsi/gdth.h`` 127 69 YAM_MAGIC 0xF10A7654 yam_port ``drivers/net/hamradio/yam.c`` 128 70 CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` 129 71 QUEUE_MAGIC_FREE 0xf7e1c9a3 queue_entry ``drivers/scsi/arm/queue.c`` 130 72 QUEUE_MAGIC_USED 0xf7e1cc33 queue_entry ``drivers/scsi/arm/queue.c`` 131 - HTB_CMAGIC 0xFEFAFEF1 htb_class ``net/sched/sch_htb.c`` 132 73 NMI_MAGIC 0x48414d4d455201 nmi_s ``arch/mips/include/asm/sn/nmi.h`` 133 74 ===================== ================ ======================== ========================================== 134 - 135 - 136 - 请注意,在声音记忆管理中仍然有一些特殊的为每个驱动定义的魔术值。查看include/sound/sndmagic.h来获取他们完整的列表信息。很多OSS声音驱动拥有自己从声卡PCI ID构建的魔术值-他们也没有被列在这里。 137 - 138 - IrDA子系统也使用了大量的自己的魔术值,查看include/net/irda/irda.h来获取他们完整的信息。 139 - 140 - HFS是另外一个比较大的使用魔术值的文件系统-你可以在fs/hfs/hfs.h中找到他们。
-67
Documentation/translations/zh_TW/process/magic-number.rst
··· 61 61 魔術數名 數字 結構 文件 62 62 ===================== ================ ======================== ========================================== 63 63 PG_MAGIC 'P' pg_{read,write}_hdr ``include/linux/pg.h`` 64 - CMAGIC 0x0111 user ``include/linux/a.out.h`` 65 - MKISS_DRIVER_MAGIC 0x04bf mkiss_channel ``drivers/net/mkiss.h`` 66 64 APM_BIOS_MAGIC 0x4101 apm_user ``arch/x86/kernel/apm_32.c`` 67 - DB_MAGIC 0x4442 fc_info ``drivers/net/iph5526_novram.c`` 68 - DL_MAGIC 0x444d fc_info ``drivers/net/iph5526_novram.c`` 69 65 FASYNC_MAGIC 0x4601 fasync_struct ``include/linux/fs.h`` 70 - FF_MAGIC 0x4646 fc_info ``drivers/net/iph5526_novram.c`` 71 - PTY_MAGIC 0x5001 ``drivers/char/pty.c`` 72 - PPP_MAGIC 0x5002 ppp ``include/linux/if_pppvar.h`` 73 - SSTATE_MAGIC 0x5302 serial_state ``include/linux/serial.h`` 74 66 SLIP_MAGIC 0x5302 slip ``drivers/net/slip.h`` 75 - STRIP_MAGIC 0x5303 strip ``drivers/net/strip.c`` 76 - SIXPACK_MAGIC 0x5304 sixpack ``drivers/net/hamradio/6pack.h`` 77 - AX25_MAGIC 0x5316 ax_disp ``drivers/net/mkiss.h`` 78 67 MGSLPC_MAGIC 0x5402 mgslpc_info ``drivers/char/pcmcia/synclink_cs.c`` 79 - USB_SERIAL_MAGIC 0x6702 usb_serial ``drivers/usb/serial/usb-serial.h`` 80 - FULL_DUPLEX_MAGIC 0x6969 ``drivers/net/ethernet/dec/tulip/de2104x.c`` 81 - USB_BLUETOOTH_MAGIC 0x6d02 usb_bluetooth ``drivers/usb/class/bluetty.c`` 82 - RFCOMM_TTY_MAGIC 0x6d02 ``net/bluetooth/rfcomm/tty.c`` 83 - USB_SERIAL_PORT_MAGIC 0x7301 usb_serial_port ``drivers/usb/serial/usb-serial.h`` 84 - CG_MAGIC 0x00090255 ufs_cylinder_group ``include/linux/ufs_fs.h`` 85 - LSEMAGIC 0x05091998 lse ``drivers/fc4/fc.c`` 86 - GDTIOCTL_MAGIC 0x06030f07 gdth_iowr_str ``drivers/scsi/gdth_ioctl.h`` 87 - RIEBL_MAGIC 0x09051990 ``drivers/net/atarilance.c`` 88 - NBD_REQUEST_MAGIC 0x12560953 nbd_request ``include/linux/nbd.h`` 89 - RED_MAGIC2 0x170fc2a5 (any) ``mm/slab.c`` 90 68 BAYCOM_MAGIC 0x19730510 baycom_state ``drivers/net/baycom_epp.c`` 91 - ISDN_X25IFACE_MAGIC 0x1e75a2b9 isdn_x25iface_proto_data ``drivers/isdn/isdn_x25iface.h`` 92 - ECP_MAGIC 0x21504345 cdkecpsig ``include/linux/cdk.h`` 93 - LSOMAGIC 0x27091997 lso ``drivers/fc4/fc.c`` 94 - LSMAGIC 0x2a3b4d2a ls ``drivers/fc4/fc.c`` 95 - WANPIPE_MAGIC 0x414C4453 sdla_{dump,exec} ``include/linux/wanpipe.h`` 96 - CS_CARD_MAGIC 0x43525553 cs_card ``sound/oss/cs46xx.c`` 97 - LABELCL_MAGIC 0x4857434c labelcl_info_s ``include/asm/ia64/sn/labelcl.h`` 98 - ISDN_ASYNC_MAGIC 0x49344C01 modem_info ``include/linux/isdn.h`` 99 - CTC_ASYNC_MAGIC 0x49344C01 ctc_tty_info ``drivers/s390/net/ctctty.c`` 100 - ISDN_NET_MAGIC 0x49344C02 isdn_net_local_s ``drivers/isdn/i4l/isdn_net_lib.h`` 101 - SAVEKMSG_MAGIC2 0x4B4D5347 savekmsg ``arch/*/amiga/config.c`` 102 - CS_STATE_MAGIC 0x4c4f4749 cs_state ``sound/oss/cs46xx.c`` 103 - SLAB_C_MAGIC 0x4f17a36d kmem_cache ``mm/slab.c`` 104 - COW_MAGIC 0x4f4f4f4d cow_header_v1 ``arch/um/drivers/ubd_user.c`` 105 - I810_CARD_MAGIC 0x5072696E i810_card ``sound/oss/i810_audio.c`` 106 - TRIDENT_CARD_MAGIC 0x5072696E trident_card ``sound/oss/trident.c`` 107 - ROUTER_MAGIC 0x524d4157 wan_device [in ``wanrouter.h`` pre 3.9] 108 - SAVEKMSG_MAGIC1 0x53415645 savekmsg ``arch/*/amiga/config.c`` 109 - GDA_MAGIC 0x58464552 gda ``arch/mips/include/asm/sn/gda.h`` 110 - RED_MAGIC1 0x5a2cf071 (any) ``mm/slab.c`` 111 - EEPROM_MAGIC_VALUE 0x5ab478d2 lanai_dev ``drivers/atm/lanai.c`` 112 69 HDLCDRV_MAGIC 0x5ac6e778 hdlcdrv_state ``include/linux/hdlcdrv.h`` 113 - PCXX_MAGIC 0x5c6df104 channel ``drivers/char/pcxx.h`` 114 70 KV_MAGIC 0x5f4b565f kernel_vars_s ``arch/mips/include/asm/sn/klkernvars.h`` 115 - I810_STATE_MAGIC 0x63657373 i810_state ``sound/oss/i810_audio.c`` 116 - TRIDENT_STATE_MAGIC 0x63657373 trient_state ``sound/oss/trident.c`` 117 - M3_CARD_MAGIC 0x646e6f50 m3_card ``sound/oss/maestro3.c`` 118 - FW_HEADER_MAGIC 0x65726F66 fw_header ``drivers/atm/fore200e.h`` 119 - SLOT_MAGIC 0x67267321 slot ``drivers/hotplug/cpqphp.h`` 120 - SLOT_MAGIC 0x67267322 slot ``drivers/hotplug/acpiphp.h`` 121 - LO_MAGIC 0x68797548 nbd_device ``include/linux/nbd.h`` 122 - M3_STATE_MAGIC 0x734d724d m3_state ``sound/oss/maestro3.c`` 123 - VMALLOC_MAGIC 0x87654320 snd_alloc_track ``sound/core/memory.c`` 124 - KMALLOC_MAGIC 0x87654321 snd_alloc_track ``sound/core/memory.c`` 125 - PWC_MAGIC 0x89DC10AB pwc_device ``drivers/usb/media/pwc.h`` 126 - NBD_REPLY_MAGIC 0x96744668 nbd_reply ``include/linux/nbd.h`` 127 - ENI155_MAGIC 0xa54b872d midway_eprom ``drivers/atm/eni.h`` 128 71 CODA_MAGIC 0xC0DAC0DA coda_file_info ``fs/coda/coda_fs_i.h`` 129 - DPMEM_MAGIC 0xc0ffee11 gdt_pci_sram ``drivers/scsi/gdth.h`` 130 72 YAM_MAGIC 0xF10A7654 yam_port ``drivers/net/hamradio/yam.c`` 131 73 CCB_MAGIC 0xf2691ad2 ccb ``drivers/scsi/ncr53c8xx.c`` 132 74 QUEUE_MAGIC_FREE 0xf7e1c9a3 queue_entry ``drivers/scsi/arm/queue.c`` 133 75 QUEUE_MAGIC_USED 0xf7e1cc33 queue_entry ``drivers/scsi/arm/queue.c`` 134 - HTB_CMAGIC 0xFEFAFEF1 htb_class ``net/sched/sch_htb.c`` 135 76 NMI_MAGIC 0x48414d4d455201 nmi_s ``arch/mips/include/asm/sn/nmi.h`` 136 77 ===================== ================ ======================== ========================================== 137 - 138 - 139 - 請注意,在聲音記憶管理中仍然有一些特殊的爲每個驅動定義的魔術值。查看include/sound/sndmagic.h來獲取他們完整的列表信息。很多OSS聲音驅動擁有自己從音效卡PCI ID構建的魔術值-他們也沒有被列在這裡。 140 - 141 - IrDA子系統也使用了大量的自己的魔術值,查看include/net/irda/irda.h來獲取他們完整的信息。 142 - 143 - HFS是另外一個比較大的使用魔術值的文件系統-你可以在fs/hfs/hfs.h中找到他們。 144 -
+2
MAINTAINERS
··· 7235 7235 S: Maintained 7236 7236 F: include/linux/dynamic_debug.h 7237 7237 F: lib/dynamic_debug.c 7238 + M: Jim Cromie <jim.cromie@gmail.com> 7239 + F: lib/test_dynamic_debug.c 7238 7240 7239 7241 DYNAMIC INTERRUPT MODERATION 7240 7242 M: Tal Gilboa <talgi@nvidia.com>
-2
arch/mips/include/asm/sn/gda.h
··· 16 16 17 17 #include <asm/sn/addrs.h> 18 18 19 - #define GDA_MAGIC 0x58464552 20 - 21 19 /* 22 20 * GDA Version History 23 21 *
-2
drivers/base/base.h
··· 154 154 const struct attribute_group **groups); 155 155 void device_driver_detach(struct device *dev); 156 156 157 - extern char *make_class_name(const char *name, struct kobject *kobj); 158 - 159 157 extern int devres_release_all(struct device *dev); 160 158 extern void device_block_probing(void); 161 159 extern void device_unblock_probing(void);
+1 -1
drivers/base/class.c
··· 260 260 */ 261 261 void class_destroy(struct class *cls) 262 262 { 263 - if ((cls == NULL) || (IS_ERR(cls))) 263 + if (IS_ERR_OR_NULL(cls)) 264 264 return; 265 265 266 266 class_unregister(cls);
+2 -2
drivers/base/core.c
··· 2509 2509 rc = kobject_synth_uevent(&dev->kobj, buf, count); 2510 2510 2511 2511 if (rc) { 2512 - dev_err(dev, "uevent: failed to send synthetic uevent\n"); 2512 + dev_err(dev, "uevent: failed to send synthetic uevent: %d\n", rc); 2513 2513 return rc; 2514 2514 } 2515 2515 ··· 4170 4170 struct device *dev = NULL; 4171 4171 int retval = -ENODEV; 4172 4172 4173 - if (class == NULL || IS_ERR(class)) 4173 + if (IS_ERR_OR_NULL(class)) 4174 4174 goto error; 4175 4175 4176 4176 dev = kzalloc(sizeof(*dev), GFP_KERNEL);
+1 -1
drivers/base/dd.c
··· 836 836 if (strlen(buf) >= ASYNC_DRV_NAMES_MAX_LEN) 837 837 pr_warn("Too long list of driver names for 'driver_async_probe'!\n"); 838 838 839 - strlcpy(async_probe_drv_names, buf, ASYNC_DRV_NAMES_MAX_LEN); 839 + strscpy(async_probe_drv_names, buf, ASYNC_DRV_NAMES_MAX_LEN); 840 840 async_probe_default = parse_option_str(async_probe_drv_names, "*"); 841 841 842 842 return 1;
+81 -2
drivers/base/devcoredump.c
··· 25 25 struct device devcd_dev; 26 26 void *data; 27 27 size_t datalen; 28 + /* 29 + * Here, mutex is required to serialize the calls to del_wk work between 30 + * user/kernel space which happens when devcd is added with device_add() 31 + * and that sends uevent to user space. User space reads the uevents, 32 + * and calls to devcd_data_write() which try to modify the work which is 33 + * not even initialized/queued from devcoredump. 34 + * 35 + * 36 + * 37 + * cpu0(X) cpu1(Y) 38 + * 39 + * dev_coredump() uevent sent to user space 40 + * device_add() ======================> user space process Y reads the 41 + * uevents writes to devcd fd 42 + * which results into writes to 43 + * 44 + * devcd_data_write() 45 + * mod_delayed_work() 46 + * try_to_grab_pending() 47 + * del_timer() 48 + * debug_assert_init() 49 + * INIT_DELAYED_WORK() 50 + * schedule_delayed_work() 51 + * 52 + * 53 + * Also, mutex alone would not be enough to avoid scheduling of 54 + * del_wk work after it get flush from a call to devcd_free() 55 + * mentioned as below. 56 + * 57 + * disabled_store() 58 + * devcd_free() 59 + * mutex_lock() devcd_data_write() 60 + * flush_delayed_work() 61 + * mutex_unlock() 62 + * mutex_lock() 63 + * mod_delayed_work() 64 + * mutex_unlock() 65 + * So, delete_work flag is required. 66 + */ 67 + struct mutex mutex; 68 + bool delete_work; 28 69 struct module *owner; 29 70 ssize_t (*read)(char *buffer, loff_t offset, size_t count, 30 71 void *data, size_t datalen); ··· 125 84 struct device *dev = kobj_to_dev(kobj); 126 85 struct devcd_entry *devcd = dev_to_devcd(dev); 127 86 128 - mod_delayed_work(system_wq, &devcd->del_wk, 0); 87 + mutex_lock(&devcd->mutex); 88 + if (!devcd->delete_work) { 89 + devcd->delete_work = true; 90 + mod_delayed_work(system_wq, &devcd->del_wk, 0); 91 + } 92 + mutex_unlock(&devcd->mutex); 129 93 130 94 return count; 131 95 } ··· 158 112 { 159 113 struct devcd_entry *devcd = dev_to_devcd(dev); 160 114 115 + mutex_lock(&devcd->mutex); 116 + if (!devcd->delete_work) 117 + devcd->delete_work = true; 118 + 161 119 flush_delayed_work(&devcd->del_wk); 120 + mutex_unlock(&devcd->mutex); 162 121 return 0; 163 122 } 164 123 ··· 172 121 { 173 122 return sysfs_emit(buf, "%d\n", devcd_disabled); 174 123 } 124 + 125 + /* 126 + * 127 + * disabled_store() worker() 128 + * class_for_each_device(&devcd_class, 129 + * NULL, NULL, devcd_free) 130 + * ... 131 + * ... 132 + * while ((dev = class_dev_iter_next(&iter)) 133 + * devcd_del() 134 + * device_del() 135 + * put_device() <- last reference 136 + * error = fn(dev, data) devcd_dev_release() 137 + * devcd_free(dev, data) kfree(devcd) 138 + * mutex_lock(&devcd->mutex); 139 + * 140 + * 141 + * In the above diagram, It looks like disabled_store() would be racing with parallely 142 + * running devcd_del() and result in memory abort while acquiring devcd->mutex which 143 + * is called after kfree of devcd memory after dropping its last reference with 144 + * put_device(). However, this will not happens as fn(dev, data) runs 145 + * with its own reference to device via klist_node so it is not its last reference. 146 + * so, above situation would not occur. 147 + */ 175 148 176 149 static ssize_t disabled_store(struct class *class, struct class_attribute *attr, 177 150 const char *buf, size_t count) ··· 353 278 devcd->read = read; 354 279 devcd->free = free; 355 280 devcd->failing_dev = get_device(dev); 281 + devcd->delete_work = false; 356 282 283 + mutex_init(&devcd->mutex); 357 284 device_initialize(&devcd->devcd_dev); 358 285 359 286 dev_set_name(&devcd->devcd_dev, "devcd%d", 360 287 atomic_inc_return(&devcd_count)); 361 288 devcd->devcd_dev.class = &devcd_class; 362 289 290 + mutex_lock(&devcd->mutex); 363 291 if (device_add(&devcd->devcd_dev)) 364 292 goto put_device; 365 293 ··· 379 301 380 302 INIT_DELAYED_WORK(&devcd->del_wk, devcd_del); 381 303 schedule_delayed_work(&devcd->del_wk, DEVCD_TIMEOUT); 382 - 304 + mutex_unlock(&devcd->mutex); 383 305 return; 384 306 put_device: 385 307 put_device(&devcd->devcd_dev); 308 + mutex_unlock(&devcd->mutex); 386 309 put_module: 387 310 module_put(owner); 388 311 free:
+3 -1
drivers/base/devres.c
··· 117 117 if (unlikely(!dr)) 118 118 return NULL; 119 119 120 - memset(dr, 0, offsetof(struct devres, data)); 120 + /* No need to clear memory twice */ 121 + if (!(gfp & __GFP_ZERO)) 122 + memset(dr, 0, offsetof(struct devres, data)); 121 123 122 124 INIT_LIST_HEAD(&dr->node.entry); 123 125 dr->node.release = release;
+2 -2
drivers/base/property.c
··· 17 17 #include <linux/property.h> 18 18 #include <linux/phy.h> 19 19 20 - struct fwnode_handle *dev_fwnode(struct device *dev) 20 + struct fwnode_handle *dev_fwnode(const struct device *dev) 21 21 { 22 22 return IS_ENABLED(CONFIG_OF) && dev->of_node ? 23 23 of_fwnode_handle(dev->of_node) : dev->fwnode; ··· 1200 1200 } 1201 1201 EXPORT_SYMBOL(fwnode_graph_parse_endpoint); 1202 1202 1203 - const void *device_get_match_data(struct device *dev) 1203 + const void *device_get_match_data(const struct device *dev) 1204 1204 { 1205 1205 return fwnode_call_ptr_op(dev_fwnode(dev), device_get_match_data, dev); 1206 1206 }
-2
drivers/block/nbd.c
··· 157 157 158 158 #define nbd_name(nbd) ((nbd)->disk->disk_name) 159 159 160 - #define NBD_MAGIC 0x68797548 161 - 162 160 #define NBD_DEF_BLKSIZE_BITS 10 163 161 164 162 static unsigned int nbds_max = 16;
+12
drivers/gpu/drm/Kconfig
··· 51 51 52 52 If in doubt, say "N". 53 53 54 + config DRM_USE_DYNAMIC_DEBUG 55 + bool "use dynamic debug to implement drm.debug" 56 + default y 57 + depends on DRM 58 + depends on DYNAMIC_DEBUG || DYNAMIC_DEBUG_CORE 59 + depends on JUMP_LABEL 60 + help 61 + Use dynamic-debug to avoid drm_debug_enabled() runtime overheads. 62 + Due to callsite counts in DRM drivers (~4k in amdgpu) and 56 63 + bytes per callsite, the .data costs can be substantial, and 64 + are therefore configurable. 65 + 54 66 config DRM_KUNIT_TEST 55 67 tristate "KUnit tests for DRM" if !KUNIT_ALL_TESTS 56 68 depends on DRM && KUNIT
+2
drivers/gpu/drm/Makefile
··· 3 3 # Makefile for the drm device driver. This driver provides support for the 4 4 # Direct Rendering Infrastructure (DRI) in XFree86 4.1.0 and higher. 5 5 6 + CFLAGS-$(CONFIG_DRM_USE_DYNAMIC_DEBUG) += -DDYNAMIC_DEBUG_MODULE 7 + 6 8 drm-y := drm_aperture.o drm_auth.o drm_cache.o \ 7 9 drm_file.o drm_gem.o drm_ioctl.o \ 8 10 drm_drv.o \
+14
drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c
··· 38 38 #include <linux/mmu_notifier.h> 39 39 #include <linux/suspend.h> 40 40 #include <linux/cc_platform.h> 41 + #include <linux/fb.h> 42 + #include <linux/dynamic_debug.h> 41 43 42 44 #include "amdgpu.h" 43 45 #include "amdgpu_irq.h" ··· 187 185 int amdgpu_vcnfw_log; 188 186 189 187 static void amdgpu_drv_delayed_reset_work_handler(struct work_struct *work); 188 + 189 + DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, 190 + "DRM_UT_CORE", 191 + "DRM_UT_DRIVER", 192 + "DRM_UT_KMS", 193 + "DRM_UT_PRIME", 194 + "DRM_UT_ATOMIC", 195 + "DRM_UT_VBL", 196 + "DRM_UT_STATE", 197 + "DRM_UT_LEASE", 198 + "DRM_UT_DP", 199 + "DRM_UT_DRMRES"); 190 200 191 201 struct amdgpu_mgpu_info mgpu_info = { 192 202 .mutex = __MUTEX_INITIALIZER(mgpu_info.mutex),
+13
drivers/gpu/drm/display/drm_dp_helper.c
··· 30 30 #include <linux/sched.h> 31 31 #include <linux/seq_file.h> 32 32 #include <linux/string_helpers.h> 33 + #include <linux/dynamic_debug.h> 33 34 34 35 #include <drm/display/drm_dp_helper.h> 35 36 #include <drm/display/drm_dp_mst_helper.h> ··· 40 39 #include <drm/drm_panel.h> 41 40 42 41 #include "drm_dp_helper_internal.h" 42 + 43 + DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, 44 + "DRM_UT_CORE", 45 + "DRM_UT_DRIVER", 46 + "DRM_UT_KMS", 47 + "DRM_UT_PRIME", 48 + "DRM_UT_ATOMIC", 49 + "DRM_UT_VBL", 50 + "DRM_UT_STATE", 51 + "DRM_UT_LEASE", 52 + "DRM_UT_DP", 53 + "DRM_UT_DRMRES"); 43 54 44 55 struct dp_aux_backlight { 45 56 struct backlight_device *base;
+13
drivers/gpu/drm/drm_crtc_helper.c
··· 32 32 #include <linux/export.h> 33 33 #include <linux/kernel.h> 34 34 #include <linux/moduleparam.h> 35 + #include <linux/dynamic_debug.h> 35 36 36 37 #include <drm/drm_atomic.h> 37 38 #include <drm/drm_atomic_helper.h> ··· 50 49 #include <drm/drm_vblank.h> 51 50 52 51 #include "drm_crtc_helper_internal.h" 52 + 53 + DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, 54 + "DRM_UT_CORE", 55 + "DRM_UT_DRIVER", 56 + "DRM_UT_KMS", 57 + "DRM_UT_PRIME", 58 + "DRM_UT_ATOMIC", 59 + "DRM_UT_VBL", 60 + "DRM_UT_STATE", 61 + "DRM_UT_LEASE", 62 + "DRM_UT_DP", 63 + "DRM_UT_DRMRES"); 53 64 54 65 /** 55 66 * DOC: overview
+36 -12
drivers/gpu/drm/drm_print.c
··· 23 23 * Rob Clark <robdclark@gmail.com> 24 24 */ 25 25 26 - #define DEBUG /* for pr_debug() */ 27 - 28 26 #include <linux/stdarg.h> 29 27 30 28 #include <linux/io.h> 31 29 #include <linux/moduleparam.h> 32 30 #include <linux/seq_file.h> 33 31 #include <linux/slab.h> 32 + #include <linux/dynamic_debug.h> 34 33 35 34 #include <drm/drm.h> 36 35 #include <drm/drm_drv.h> ··· 39 40 * __drm_debug: Enable debug output. 40 41 * Bitmask of DRM_UT_x. See include/drm/drm_print.h for details. 41 42 */ 42 - unsigned int __drm_debug; 43 + unsigned long __drm_debug; 43 44 EXPORT_SYMBOL(__drm_debug); 44 45 45 46 MODULE_PARM_DESC(debug, "Enable debug output, where each bit enables a debug category.\n" ··· 51 52 "\t\tBit 5 (0x20) will enable VBL messages (vblank code)\n" 52 53 "\t\tBit 7 (0x80) will enable LEASE messages (leasing code)\n" 53 54 "\t\tBit 8 (0x100) will enable DP messages (displayport code)"); 54 - module_param_named(debug, __drm_debug, int, 0600); 55 + 56 + #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) 57 + module_param_named(debug, __drm_debug, ulong, 0600); 58 + #else 59 + /* classnames must match vals of enum drm_debug_category */ 60 + DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, 61 + "DRM_UT_CORE", 62 + "DRM_UT_DRIVER", 63 + "DRM_UT_KMS", 64 + "DRM_UT_PRIME", 65 + "DRM_UT_ATOMIC", 66 + "DRM_UT_VBL", 67 + "DRM_UT_STATE", 68 + "DRM_UT_LEASE", 69 + "DRM_UT_DP", 70 + "DRM_UT_DRMRES"); 71 + 72 + static struct ddebug_class_param drm_debug_bitmap = { 73 + .bits = &__drm_debug, 74 + .flags = "p", 75 + .map = &drm_debug_classes, 76 + }; 77 + module_param_cb(debug, &param_ops_dyndbg_classes, &drm_debug_bitmap, 0600); 78 + #endif 55 79 56 80 void __drm_puts_coredump(struct drm_printer *p, const char *str) 57 81 { ··· 184 162 185 163 void __drm_printfn_debug(struct drm_printer *p, struct va_format *vaf) 186 164 { 187 - pr_debug("%s %pV", p->prefix, vaf); 165 + /* pr_debug callsite decorations are unhelpful here */ 166 + printk(KERN_DEBUG "%s %pV", p->prefix, vaf); 188 167 } 189 168 EXPORT_SYMBOL(__drm_printfn_debug); 190 169 ··· 279 256 } 280 257 EXPORT_SYMBOL(drm_dev_printk); 281 258 282 - void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, 283 - const char *format, ...) 259 + void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, 260 + enum drm_debug_category category, const char *format, ...) 284 261 { 285 262 struct va_format vaf; 286 263 va_list args; 287 264 288 - if (!drm_debug_enabled(category)) 265 + if (!__drm_debug_enabled(category)) 289 266 return; 290 267 268 + /* we know we are printing for either syslog, tracefs, or both */ 291 269 va_start(args, format); 292 270 vaf.fmt = format; 293 271 vaf.va = &args; ··· 302 278 303 279 va_end(args); 304 280 } 305 - EXPORT_SYMBOL(drm_dev_dbg); 281 + EXPORT_SYMBOL(__drm_dev_dbg); 306 282 307 - void __drm_dbg(enum drm_debug_category category, const char *format, ...) 283 + void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const char *format, ...) 308 284 { 309 285 struct va_format vaf; 310 286 va_list args; 311 287 312 - if (!drm_debug_enabled(category)) 288 + if (!__drm_debug_enabled(category)) 313 289 return; 314 290 315 291 va_start(args, format); ··· 321 297 322 298 va_end(args); 323 299 } 324 - EXPORT_SYMBOL(__drm_dbg); 300 + EXPORT_SYMBOL(___drm_dbg); 325 301 326 302 void __drm_err(const char *format, ...) 327 303 {
+12
drivers/gpu/drm/i915/i915_params.c
··· 29 29 #include "i915_params.h" 30 30 #include "i915_drv.h" 31 31 32 + DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, 33 + "DRM_UT_CORE", 34 + "DRM_UT_DRIVER", 35 + "DRM_UT_KMS", 36 + "DRM_UT_PRIME", 37 + "DRM_UT_ATOMIC", 38 + "DRM_UT_VBL", 39 + "DRM_UT_STATE", 40 + "DRM_UT_LEASE", 41 + "DRM_UT_DP", 42 + "DRM_UT_DRMRES"); 43 + 32 44 #define i915_param_named(name, T, perm, desc) \ 33 45 module_param_named(name, i915_modparams.name, T, perm); \ 34 46 MODULE_PARM_DESC(name, desc)
+13
drivers/gpu/drm/nouveau/nouveau_drm.c
··· 28 28 #include <linux/pm_runtime.h> 29 29 #include <linux/vga_switcheroo.h> 30 30 #include <linux/mmu_notifier.h> 31 + #include <linux/dynamic_debug.h> 31 32 32 33 #include <drm/drm_aperture.h> 33 34 #include <drm/drm_crtc_helper.h> ··· 70 69 #include "nouveau_platform.h" 71 70 #include "nouveau_svm.h" 72 71 #include "nouveau_dmem.h" 72 + 73 + DECLARE_DYNDBG_CLASSMAP(drm_debug_classes, DD_CLASS_TYPE_DISJOINT_BITS, 0, 74 + "DRM_UT_CORE", 75 + "DRM_UT_DRIVER", 76 + "DRM_UT_KMS", 77 + "DRM_UT_PRIME", 78 + "DRM_UT_ATOMIC", 79 + "DRM_UT_VBL", 80 + "DRM_UT_STATE", 81 + "DRM_UT_LEASE", 82 + "DRM_UT_DP", 83 + "DRM_UT_DRMRES"); 73 84 74 85 MODULE_PARM_DESC(config, "option string to pass to driver core"); 75 86 static char *nouveau_config;
+3 -13
fs/debugfs/file.c
··· 1121 1121 } 1122 1122 EXPORT_SYMBOL_GPL(debugfs_print_regs32); 1123 1123 1124 - static int debugfs_show_regset32(struct seq_file *s, void *data) 1124 + static int debugfs_regset32_show(struct seq_file *s, void *data) 1125 1125 { 1126 1126 struct debugfs_regset32 *regset = s->private; 1127 1127 ··· 1136 1136 return 0; 1137 1137 } 1138 1138 1139 - static int debugfs_open_regset32(struct inode *inode, struct file *file) 1140 - { 1141 - return single_open(file, debugfs_show_regset32, inode->i_private); 1142 - } 1143 - 1144 - static const struct file_operations fops_regset32 = { 1145 - .open = debugfs_open_regset32, 1146 - .read = seq_read, 1147 - .llseek = seq_lseek, 1148 - .release = single_release, 1149 - }; 1139 + DEFINE_SHOW_ATTRIBUTE(debugfs_regset32); 1150 1140 1151 1141 /** 1152 1142 * debugfs_create_regset32 - create a debugfs file that returns register values ··· 1157 1167 struct dentry *parent, 1158 1168 struct debugfs_regset32 *regset) 1159 1169 { 1160 - debugfs_create_file(name, mode, parent, regset, &fops_regset32); 1170 + debugfs_create_file(name, mode, parent, regset, &debugfs_regset32_fops); 1161 1171 } 1162 1172 EXPORT_SYMBOL_GPL(debugfs_create_regset32); 1163 1173
+30 -7
fs/debugfs/inode.c
··· 82 82 kuid_t uid; 83 83 kgid_t gid; 84 84 umode_t mode; 85 + /* Opt_* bitfield. */ 86 + unsigned int opts; 85 87 }; 86 88 87 89 enum { ··· 113 111 kgid_t gid; 114 112 char *p; 115 113 114 + opts->opts = 0; 116 115 opts->mode = DEBUGFS_DEFAULT_MODE; 117 116 118 117 while ((p = strsep(&data, ",")) != NULL) { ··· 148 145 * but traditionally debugfs has ignored all mount options 149 146 */ 150 147 } 148 + 149 + opts->opts |= BIT(token); 151 150 } 152 151 153 152 return 0; 154 153 } 155 154 156 - static int debugfs_apply_options(struct super_block *sb) 155 + static void _debugfs_apply_options(struct super_block *sb, bool remount) 157 156 { 158 157 struct debugfs_fs_info *fsi = sb->s_fs_info; 159 158 struct inode *inode = d_inode(sb->s_root); 160 159 struct debugfs_mount_opts *opts = &fsi->mount_opts; 161 160 162 - inode->i_mode &= ~S_IALLUGO; 163 - inode->i_mode |= opts->mode; 161 + /* 162 + * On remount, only reset mode/uid/gid if they were provided as mount 163 + * options. 164 + */ 164 165 165 - inode->i_uid = opts->uid; 166 - inode->i_gid = opts->gid; 166 + if (!remount || opts->opts & BIT(Opt_mode)) { 167 + inode->i_mode &= ~S_IALLUGO; 168 + inode->i_mode |= opts->mode; 169 + } 167 170 168 - return 0; 171 + if (!remount || opts->opts & BIT(Opt_uid)) 172 + inode->i_uid = opts->uid; 173 + 174 + if (!remount || opts->opts & BIT(Opt_gid)) 175 + inode->i_gid = opts->gid; 176 + } 177 + 178 + static void debugfs_apply_options(struct super_block *sb) 179 + { 180 + _debugfs_apply_options(sb, false); 181 + } 182 + 183 + static void debugfs_apply_options_remount(struct super_block *sb) 184 + { 185 + _debugfs_apply_options(sb, true); 169 186 } 170 187 171 188 static int debugfs_remount(struct super_block *sb, int *flags, char *data) ··· 198 175 if (err) 199 176 goto fail; 200 177 201 - debugfs_apply_options(sb); 178 + debugfs_apply_options_remount(sb); 202 179 203 180 fail: 204 181 return err;
+73 -34
fs/kernfs/dir.c
··· 472 472 lockdep_assert_held_write(&root->kernfs_rwsem); 473 473 WARN_ON_ONCE(kernfs_active(kn)); 474 474 475 + /* 476 + * Skip draining if already fully drained. This avoids draining and its 477 + * lockdep annotations for nodes which have never been activated 478 + * allowing embedding kernfs_remove() in create error paths without 479 + * worrying about draining. 480 + */ 481 + if (atomic_read(&kn->active) == KN_DEACTIVATED_BIAS && 482 + !kernfs_should_drain_open_files(kn)) 483 + return; 484 + 475 485 up_write(&root->kernfs_rwsem); 476 486 477 487 if (kernfs_lockdep(kn)) { ··· 490 480 lock_contended(&kn->dep_map, _RET_IP_); 491 481 } 492 482 493 - /* but everyone should wait for draining */ 494 483 wait_event(root->deactivate_waitq, 495 484 atomic_read(&kn->active) == KN_DEACTIVATED_BIAS); 496 485 ··· 498 489 rwsem_release(&kn->dep_map, _RET_IP_); 499 490 } 500 491 501 - kernfs_drain_open_files(kn); 492 + if (kernfs_should_drain_open_files(kn)) 493 + kernfs_drain_open_files(kn); 502 494 503 495 down_write(&root->kernfs_rwsem); 504 496 } ··· 705 695 goto err_unlock; 706 696 } 707 697 708 - /* 709 - * ACTIVATED is protected with kernfs_mutex but it was clear when 710 - * @kn was added to idr and we just wanna see it set. No need to 711 - * grab kernfs_mutex. 712 - */ 713 - if (unlikely(!(kn->flags & KERNFS_ACTIVATED) || 714 - !atomic_inc_not_zero(&kn->count))) 698 + if (unlikely(!kernfs_active(kn) || !atomic_inc_not_zero(&kn->count))) 715 699 goto err_unlock; 716 700 717 701 spin_unlock(&kernfs_idr_lock); ··· 747 743 goto out_unlock; 748 744 749 745 ret = -ENOENT; 750 - if (parent->flags & KERNFS_EMPTY_DIR) 751 - goto out_unlock; 752 - 753 - if ((parent->flags & KERNFS_ACTIVATED) && !kernfs_active(parent)) 746 + if (parent->flags & (KERNFS_REMOVING | KERNFS_EMPTY_DIR)) 754 747 goto out_unlock; 755 748 756 749 kn->hash = kernfs_name_hash(kn->name, kn->ns); ··· 1305 1304 return pos->parent; 1306 1305 } 1307 1306 1307 + static void kernfs_activate_one(struct kernfs_node *kn) 1308 + { 1309 + lockdep_assert_held_write(&kernfs_root(kn)->kernfs_rwsem); 1310 + 1311 + kn->flags |= KERNFS_ACTIVATED; 1312 + 1313 + if (kernfs_active(kn) || (kn->flags & (KERNFS_HIDDEN | KERNFS_REMOVING))) 1314 + return; 1315 + 1316 + WARN_ON_ONCE(kn->parent && RB_EMPTY_NODE(&kn->rb)); 1317 + WARN_ON_ONCE(atomic_read(&kn->active) != KN_DEACTIVATED_BIAS); 1318 + 1319 + atomic_sub(KN_DEACTIVATED_BIAS, &kn->active); 1320 + } 1321 + 1308 1322 /** 1309 1323 * kernfs_activate - activate a node which started deactivated 1310 1324 * @kn: kernfs_node whose subtree is to be activated ··· 1341 1325 down_write(&root->kernfs_rwsem); 1342 1326 1343 1327 pos = NULL; 1344 - while ((pos = kernfs_next_descendant_post(pos, kn))) { 1345 - if (pos->flags & KERNFS_ACTIVATED) 1346 - continue; 1328 + while ((pos = kernfs_next_descendant_post(pos, kn))) 1329 + kernfs_activate_one(pos); 1347 1330 1348 - WARN_ON_ONCE(pos->parent && RB_EMPTY_NODE(&pos->rb)); 1349 - WARN_ON_ONCE(atomic_read(&pos->active) != KN_DEACTIVATED_BIAS); 1331 + up_write(&root->kernfs_rwsem); 1332 + } 1350 1333 1351 - atomic_sub(KN_DEACTIVATED_BIAS, &pos->active); 1352 - pos->flags |= KERNFS_ACTIVATED; 1334 + /** 1335 + * kernfs_show - show or hide a node 1336 + * @kn: kernfs_node to show or hide 1337 + * @show: whether to show or hide 1338 + * 1339 + * If @show is %false, @kn is marked hidden and deactivated. A hidden node is 1340 + * ignored in future activaitons. If %true, the mark is removed and activation 1341 + * state is restored. This function won't implicitly activate a new node in a 1342 + * %KERNFS_ROOT_CREATE_DEACTIVATED root which hasn't been activated yet. 1343 + * 1344 + * To avoid recursion complexities, directories aren't supported for now. 1345 + */ 1346 + void kernfs_show(struct kernfs_node *kn, bool show) 1347 + { 1348 + struct kernfs_root *root = kernfs_root(kn); 1349 + 1350 + if (WARN_ON_ONCE(kernfs_type(kn) == KERNFS_DIR)) 1351 + return; 1352 + 1353 + down_write(&root->kernfs_rwsem); 1354 + 1355 + if (show) { 1356 + kn->flags &= ~KERNFS_HIDDEN; 1357 + if (kn->flags & KERNFS_ACTIVATED) 1358 + kernfs_activate_one(kn); 1359 + } else { 1360 + kn->flags |= KERNFS_HIDDEN; 1361 + if (kernfs_active(kn)) 1362 + atomic_add(KN_DEACTIVATED_BIAS, &kn->active); 1363 + kernfs_drain(kn); 1353 1364 } 1354 1365 1355 1366 up_write(&root->kernfs_rwsem); ··· 1401 1358 1402 1359 pr_debug("kernfs %s: removing\n", kn->name); 1403 1360 1404 - /* prevent any new usage under @kn by deactivating all nodes */ 1361 + /* prevent new usage by marking all nodes removing and deactivating */ 1405 1362 pos = NULL; 1406 - while ((pos = kernfs_next_descendant_post(pos, kn))) 1363 + while ((pos = kernfs_next_descendant_post(pos, kn))) { 1364 + pos->flags |= KERNFS_REMOVING; 1407 1365 if (kernfs_active(pos)) 1408 1366 atomic_add(KN_DEACTIVATED_BIAS, &pos->active); 1367 + } 1409 1368 1410 1369 /* deactivate and unlink the subtree node-by-node */ 1411 1370 do { 1412 1371 pos = kernfs_leftmost_descendant(kn); 1413 1372 1414 1373 /* 1415 - * kernfs_drain() drops kernfs_rwsem temporarily and @pos's 1374 + * kernfs_drain() may drop kernfs_rwsem temporarily and @pos's 1416 1375 * base ref could have been put by someone else by the time 1417 1376 * the function returns. Make sure it doesn't go away 1418 1377 * underneath us. 1419 1378 */ 1420 1379 kernfs_get(pos); 1421 1380 1422 - /* 1423 - * Drain iff @kn was activated. This avoids draining and 1424 - * its lockdep annotations for nodes which have never been 1425 - * activated and allows embedding kernfs_remove() in create 1426 - * error paths without worrying about draining. 1427 - */ 1428 - if (kn->flags & KERNFS_ACTIVATED) 1429 - kernfs_drain(pos); 1430 - else 1431 - WARN_ON_ONCE(atomic_read(&kn->active) != KN_DEACTIVATED_BIAS); 1381 + kernfs_drain(pos); 1432 1382 1433 1383 /* 1434 1384 * kernfs_unlink_sibling() succeeds once per node. Use it ··· 1621 1585 down_write(&root->kernfs_rwsem); 1622 1586 1623 1587 kn = kernfs_find_ns(parent, name, ns); 1624 - if (kn) 1588 + if (kn) { 1589 + kernfs_get(kn); 1625 1590 __kernfs_remove(kn); 1591 + kernfs_put(kn); 1592 + } 1626 1593 1627 1594 up_write(&root->kernfs_rwsem); 1628 1595
+73 -80
fs/kernfs/file.c
··· 23 23 atomic_t event; 24 24 wait_queue_head_t poll; 25 25 struct list_head files; /* goes through kernfs_open_file.list */ 26 + unsigned int nr_mmapped; 27 + unsigned int nr_to_release; 26 28 }; 27 29 28 30 /* ··· 59 57 } 60 58 61 59 /** 62 - * kernfs_deref_open_node - Get kernfs_open_node corresponding to @kn. 63 - * 64 - * @of: associated kernfs_open_file instance. 65 - * @kn: target kernfs_node. 66 - * 67 - * Fetch and return ->attr.open of @kn if @of->list is non empty. 68 - * If @of->list is not empty we can safely assume that @of is on 69 - * @kn->attr.open->files list and this guarantees that @kn->attr.open 70 - * will not vanish i.e. dereferencing outside RCU read-side critical 71 - * section is safe here. 72 - * 73 - * The caller needs to make sure that @of->list is not empty. 60 + * of_on - Return the kernfs_open_node of the specified kernfs_open_file 61 + * @of: taret kernfs_open_file 74 62 */ 75 - static struct kernfs_open_node * 76 - kernfs_deref_open_node(struct kernfs_open_file *of, struct kernfs_node *kn) 63 + static struct kernfs_open_node *of_on(struct kernfs_open_file *of) 77 64 { 78 - struct kernfs_open_node *on; 79 - 80 - on = rcu_dereference_check(kn->attr.open, !list_empty(&of->list)); 81 - 82 - return on; 65 + return rcu_dereference_protected(of->kn->attr.open, 66 + !list_empty(&of->list)); 83 67 } 84 68 85 69 /** 86 - * kernfs_deref_open_node_protected - Get kernfs_open_node corresponding to @kn 70 + * kernfs_deref_open_node_locked - Get kernfs_open_node corresponding to @kn 87 71 * 88 72 * @kn: target kernfs_node. 89 73 * ··· 84 96 * The caller needs to make sure that kernfs_open_file_mutex is held. 85 97 */ 86 98 static struct kernfs_open_node * 87 - kernfs_deref_open_node_protected(struct kernfs_node *kn) 99 + kernfs_deref_open_node_locked(struct kernfs_node *kn) 88 100 { 89 101 return rcu_dereference_protected(kn->attr.open, 90 102 lockdep_is_held(kernfs_open_file_mutex_ptr(kn))); ··· 195 207 static int kernfs_seq_show(struct seq_file *sf, void *v) 196 208 { 197 209 struct kernfs_open_file *of = sf->private; 198 - struct kernfs_open_node *on = kernfs_deref_open_node(of, of->kn); 199 210 200 - if (!on) 201 - return -EINVAL; 202 - 203 - of->event = atomic_read(&on->event); 211 + of->event = atomic_read(&of_on(of)->event); 204 212 205 213 return of->kn->attr.ops->seq_show(sf, v); 206 214 } ··· 219 235 struct kernfs_open_file *of = kernfs_of(iocb->ki_filp); 220 236 ssize_t len = min_t(size_t, iov_iter_count(iter), PAGE_SIZE); 221 237 const struct kernfs_ops *ops; 222 - struct kernfs_open_node *on; 223 238 char *buf; 224 239 225 240 buf = of->prealloc_buf; ··· 240 257 goto out_free; 241 258 } 242 259 243 - on = kernfs_deref_open_node(of, of->kn); 244 - if (!on) { 245 - len = -EINVAL; 246 - mutex_unlock(&of->mutex); 247 - goto out_free; 248 - } 249 - 250 - of->event = atomic_read(&on->event); 260 + of->event = atomic_read(&of_on(of)->event); 251 261 252 262 ops = kernfs_ops(of->kn); 253 263 if (ops->read) ··· 529 553 530 554 rc = 0; 531 555 of->mmapped = true; 556 + of_on(of)->nr_mmapped++; 532 557 of->vm_ops = vma->vm_ops; 533 558 vma->vm_ops = &kernfs_vm_ops; 534 559 out_put: ··· 557 580 static int kernfs_get_open_node(struct kernfs_node *kn, 558 581 struct kernfs_open_file *of) 559 582 { 560 - struct kernfs_open_node *on, *new_on = NULL; 561 - struct mutex *mutex = NULL; 583 + struct kernfs_open_node *on; 584 + struct mutex *mutex; 562 585 563 586 mutex = kernfs_open_file_mutex_lock(kn); 564 - on = kernfs_deref_open_node_protected(kn); 587 + on = kernfs_deref_open_node_locked(kn); 565 588 566 - if (on) { 567 - list_add_tail(&of->list, &on->files); 568 - mutex_unlock(mutex); 569 - return 0; 570 - } else { 589 + if (!on) { 571 590 /* not there, initialize a new one */ 572 - new_on = kmalloc(sizeof(*new_on), GFP_KERNEL); 573 - if (!new_on) { 591 + on = kzalloc(sizeof(*on), GFP_KERNEL); 592 + if (!on) { 574 593 mutex_unlock(mutex); 575 594 return -ENOMEM; 576 595 } 577 - atomic_set(&new_on->event, 1); 578 - init_waitqueue_head(&new_on->poll); 579 - INIT_LIST_HEAD(&new_on->files); 580 - list_add_tail(&of->list, &new_on->files); 581 - rcu_assign_pointer(kn->attr.open, new_on); 596 + atomic_set(&on->event, 1); 597 + init_waitqueue_head(&on->poll); 598 + INIT_LIST_HEAD(&on->files); 599 + rcu_assign_pointer(kn->attr.open, on); 582 600 } 583 - mutex_unlock(mutex); 584 601 602 + list_add_tail(&of->list, &on->files); 603 + if (kn->flags & KERNFS_HAS_RELEASE) 604 + on->nr_to_release++; 605 + 606 + mutex_unlock(mutex); 585 607 return 0; 586 608 } 587 609 ··· 589 613 * 590 614 * @kn: target kernfs_node 591 615 * @of: associated kernfs_open_file 616 + * @open_failed: ->open() failed, cancel ->release() 592 617 * 593 618 * Unlink @of from list of @kn's associated open files. If list of 594 619 * associated open files becomes empty, disassociate and free ··· 599 622 * None. 600 623 */ 601 624 static void kernfs_unlink_open_file(struct kernfs_node *kn, 602 - struct kernfs_open_file *of) 625 + struct kernfs_open_file *of, 626 + bool open_failed) 603 627 { 604 628 struct kernfs_open_node *on; 605 - struct mutex *mutex = NULL; 629 + struct mutex *mutex; 606 630 607 631 mutex = kernfs_open_file_mutex_lock(kn); 608 632 609 - on = kernfs_deref_open_node_protected(kn); 633 + on = kernfs_deref_open_node_locked(kn); 610 634 if (!on) { 611 635 mutex_unlock(mutex); 612 636 return; 613 637 } 614 638 615 - if (of) 639 + if (of) { 640 + if (kn->flags & KERNFS_HAS_RELEASE) { 641 + WARN_ON_ONCE(of->released == open_failed); 642 + if (open_failed) 643 + on->nr_to_release--; 644 + } 645 + if (of->mmapped) 646 + on->nr_mmapped--; 616 647 list_del(&of->list); 648 + } 617 649 618 650 if (list_empty(&on->files)) { 619 651 rcu_assign_pointer(kn->attr.open, NULL); ··· 749 763 return 0; 750 764 751 765 err_put_node: 752 - kernfs_unlink_open_file(kn, of); 766 + kernfs_unlink_open_file(kn, of, true); 753 767 err_seq_release: 754 768 seq_release(inode, file); 755 769 err_free: ··· 781 795 */ 782 796 kn->attr.ops->release(of); 783 797 of->released = true; 798 + of_on(of)->nr_to_release--; 784 799 } 785 800 } 786 801 ··· 789 802 { 790 803 struct kernfs_node *kn = inode->i_private; 791 804 struct kernfs_open_file *of = kernfs_of(filp); 792 - struct mutex *mutex = NULL; 793 805 794 806 if (kn->flags & KERNFS_HAS_RELEASE) { 807 + struct mutex *mutex; 808 + 795 809 mutex = kernfs_open_file_mutex_lock(kn); 796 810 kernfs_release_file(kn, of); 797 811 mutex_unlock(mutex); 798 812 } 799 813 800 - kernfs_unlink_open_file(kn, of); 814 + kernfs_unlink_open_file(kn, of, false); 801 815 seq_release(inode, filp); 802 816 kfree(of->prealloc_buf); 803 817 kfree(of); ··· 806 818 return 0; 807 819 } 808 820 821 + bool kernfs_should_drain_open_files(struct kernfs_node *kn) 822 + { 823 + struct kernfs_open_node *on; 824 + bool ret; 825 + 826 + /* 827 + * @kn being deactivated guarantees that @kn->attr.open can't change 828 + * beneath us making the lockless test below safe. 829 + */ 830 + WARN_ON_ONCE(atomic_read(&kn->active) != KN_DEACTIVATED_BIAS); 831 + 832 + rcu_read_lock(); 833 + on = rcu_dereference(kn->attr.open); 834 + ret = on && (on->nr_mmapped || on->nr_to_release); 835 + rcu_read_unlock(); 836 + 837 + return ret; 838 + } 839 + 809 840 void kernfs_drain_open_files(struct kernfs_node *kn) 810 841 { 811 842 struct kernfs_open_node *on; 812 843 struct kernfs_open_file *of; 813 - struct mutex *mutex = NULL; 814 - 815 - if (!(kn->flags & (KERNFS_HAS_MMAP | KERNFS_HAS_RELEASE))) 816 - return; 817 - 818 - /* 819 - * lockless opportunistic check is safe below because no one is adding to 820 - * ->attr.open at this point of time. This check allows early bail out 821 - * if ->attr.open is already NULL. kernfs_unlink_open_file makes 822 - * ->attr.open NULL only while holding kernfs_open_file_mutex so below 823 - * check under kernfs_open_file_mutex_ptr(kn) will ensure bailing out if 824 - * ->attr.open became NULL while waiting for the mutex. 825 - */ 826 - if (!rcu_access_pointer(kn->attr.open)) 827 - return; 844 + struct mutex *mutex; 828 845 829 846 mutex = kernfs_open_file_mutex_lock(kn); 830 - on = kernfs_deref_open_node_protected(kn); 847 + on = kernfs_deref_open_node_locked(kn); 831 848 if (!on) { 832 849 mutex_unlock(mutex); 833 850 return; ··· 841 848 list_for_each_entry(of, &on->files, list) { 842 849 struct inode *inode = file_inode(of->file); 843 850 844 - if (kn->flags & KERNFS_HAS_MMAP) 851 + if (of->mmapped) { 845 852 unmap_mapping_range(inode->i_mapping, 0, 0, 1); 853 + of->mmapped = false; 854 + on->nr_mmapped--; 855 + } 846 856 847 857 if (kn->flags & KERNFS_HAS_RELEASE) 848 858 kernfs_release_file(kn, of); 849 859 } 850 860 861 + WARN_ON_ONCE(on->nr_mmapped || on->nr_to_release); 851 862 mutex_unlock(mutex); 852 863 } 853 864 ··· 871 874 */ 872 875 __poll_t kernfs_generic_poll(struct kernfs_open_file *of, poll_table *wait) 873 876 { 874 - struct kernfs_node *kn = kernfs_dentry_node(of->file->f_path.dentry); 875 - struct kernfs_open_node *on = kernfs_deref_open_node(of, kn); 876 - 877 - if (!on) 878 - return EPOLLERR; 877 + struct kernfs_open_node *on = of_on(of); 879 878 880 879 poll_wait(of->file, &on->poll, wait); 881 880
+1
fs/kernfs/kernfs-internal.h
··· 157 157 */ 158 158 extern const struct file_operations kernfs_file_fops; 159 159 160 + bool kernfs_should_drain_open_files(struct kernfs_node *kn); 160 161 void kernfs_drain_open_files(struct kernfs_node *kn); 161 162 162 163 /*
+3
include/asm-generic/vmlinux.lds.h
··· 353 353 *(__tracepoints) \ 354 354 /* implement dynamic printk debug */ \ 355 355 . = ALIGN(8); \ 356 + __start___dyndbg_classes = .; \ 357 + KEEP(*(__dyndbg_classes)) \ 358 + __stop___dyndbg_classes = .; \ 356 359 __start___dyndbg = .; \ 357 360 KEEP(*(__dyndbg)) \ 358 361 __stop___dyndbg = .; \
+59 -19
include/drm/drm_print.h
··· 31 31 #include <linux/seq_file.h> 32 32 #include <linux/device.h> 33 33 #include <linux/debugfs.h> 34 + #include <linux/dynamic_debug.h> 34 35 35 36 #include <drm/drm.h> 36 37 37 38 /* Do *not* use outside of drm_print.[ch]! */ 38 - extern unsigned int __drm_debug; 39 + extern unsigned long __drm_debug; 39 40 40 41 /** 41 42 * DOC: print ··· 276 275 * 277 276 */ 278 277 enum drm_debug_category { 278 + /* These names must match those in DYNAMIC_DEBUG_CLASSBITS */ 279 279 /** 280 280 * @DRM_UT_CORE: Used in the generic drm code: drm_ioctl.c, drm_mm.c, 281 281 * drm_memory.c, ... 282 282 */ 283 - DRM_UT_CORE = 0x01, 283 + DRM_UT_CORE, 284 284 /** 285 285 * @DRM_UT_DRIVER: Used in the vendor specific part of the driver: i915, 286 286 * radeon, ... macro. 287 287 */ 288 - DRM_UT_DRIVER = 0x02, 288 + DRM_UT_DRIVER, 289 289 /** 290 290 * @DRM_UT_KMS: Used in the modesetting code. 291 291 */ 292 - DRM_UT_KMS = 0x04, 292 + DRM_UT_KMS, 293 293 /** 294 294 * @DRM_UT_PRIME: Used in the prime code. 295 295 */ 296 - DRM_UT_PRIME = 0x08, 296 + DRM_UT_PRIME, 297 297 /** 298 298 * @DRM_UT_ATOMIC: Used in the atomic code. 299 299 */ 300 - DRM_UT_ATOMIC = 0x10, 300 + DRM_UT_ATOMIC, 301 301 /** 302 302 * @DRM_UT_VBL: Used for verbose debug message in the vblank code. 303 303 */ 304 - DRM_UT_VBL = 0x20, 304 + DRM_UT_VBL, 305 305 /** 306 306 * @DRM_UT_STATE: Used for verbose atomic state debugging. 307 307 */ 308 - DRM_UT_STATE = 0x40, 308 + DRM_UT_STATE, 309 309 /** 310 310 * @DRM_UT_LEASE: Used in the lease code. 311 311 */ 312 - DRM_UT_LEASE = 0x80, 312 + DRM_UT_LEASE, 313 313 /** 314 314 * @DRM_UT_DP: Used in the DP code. 315 315 */ 316 - DRM_UT_DP = 0x100, 316 + DRM_UT_DP, 317 317 /** 318 318 * @DRM_UT_DRMRES: Used in the drm managed resources code. 319 319 */ 320 - DRM_UT_DRMRES = 0x200, 320 + DRM_UT_DRMRES 321 321 }; 322 322 323 - static inline bool drm_debug_enabled(enum drm_debug_category category) 323 + static inline bool drm_debug_enabled_raw(enum drm_debug_category category) 324 324 { 325 - return unlikely(__drm_debug & category); 325 + return unlikely(__drm_debug & BIT(category)); 326 326 } 327 + 328 + #define drm_debug_enabled_instrumented(category) \ 329 + ({ \ 330 + pr_debug("todo: is this frequent enough to optimize ?\n"); \ 331 + drm_debug_enabled_raw(category); \ 332 + }) 333 + 334 + #if defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) 335 + /* 336 + * the drm.debug API uses dyndbg, so each drm_*dbg macro/callsite gets 337 + * a descriptor, and only enabled callsites are reachable. They use 338 + * the private macro to avoid re-testing the enable-bit. 339 + */ 340 + #define __drm_debug_enabled(category) true 341 + #define drm_debug_enabled(category) drm_debug_enabled_instrumented(category) 342 + #else 343 + #define __drm_debug_enabled(category) drm_debug_enabled_raw(category) 344 + #define drm_debug_enabled(category) drm_debug_enabled_raw(category) 345 + #endif 327 346 328 347 /* 329 348 * struct device based logging ··· 354 333 __printf(3, 4) 355 334 void drm_dev_printk(const struct device *dev, const char *level, 356 335 const char *format, ...); 357 - __printf(3, 4) 358 - void drm_dev_dbg(const struct device *dev, enum drm_debug_category category, 359 - const char *format, ...); 336 + struct _ddebug; 337 + __printf(4, 5) 338 + void __drm_dev_dbg(struct _ddebug *desc, const struct device *dev, 339 + enum drm_debug_category category, const char *format, ...); 360 340 361 341 /** 362 342 * DRM_DEV_ERROR() - Error output. ··· 404 382 DRM_DEV_INFO(dev, fmt, ##__VA_ARGS__); \ 405 383 } \ 406 384 }) 385 + 386 + #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) 387 + #define drm_dev_dbg(dev, cat, fmt, ...) \ 388 + __drm_dev_dbg(NULL, dev, cat, fmt, ##__VA_ARGS__) 389 + #else 390 + #define drm_dev_dbg(dev, cat, fmt, ...) \ 391 + _dynamic_func_call_cls(cat, fmt, __drm_dev_dbg, \ 392 + dev, cat, fmt, ##__VA_ARGS__) 393 + #endif 407 394 408 395 /** 409 396 * DRM_DEV_DEBUG() - Debug output for generic drm code ··· 488 457 489 458 #define drm_dbg_core(drm, fmt, ...) \ 490 459 drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_CORE, fmt, ##__VA_ARGS__) 491 - #define drm_dbg(drm, fmt, ...) \ 460 + #define drm_dbg_driver(drm, fmt, ...) \ 492 461 drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRIVER, fmt, ##__VA_ARGS__) 493 462 #define drm_dbg_kms(drm, fmt, ...) \ 494 463 drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_KMS, fmt, ##__VA_ARGS__) ··· 507 476 #define drm_dbg_drmres(drm, fmt, ...) \ 508 477 drm_dev_dbg((drm) ? (drm)->dev : NULL, DRM_UT_DRMRES, fmt, ##__VA_ARGS__) 509 478 479 + #define drm_dbg(drm, fmt, ...) drm_dbg_driver(drm, fmt, ##__VA_ARGS__) 510 480 511 481 /* 512 482 * printk based logging ··· 515 483 * Prefer drm_device based logging over device or prink based logging. 516 484 */ 517 485 518 - __printf(2, 3) 519 - void __drm_dbg(enum drm_debug_category category, const char *format, ...); 486 + __printf(3, 4) 487 + void ___drm_dbg(struct _ddebug *desc, enum drm_debug_category category, const char *format, ...); 520 488 __printf(1, 2) 521 489 void __drm_err(const char *format, ...); 490 + 491 + #if !defined(CONFIG_DRM_USE_DYNAMIC_DEBUG) 492 + #define __drm_dbg(fmt, ...) ___drm_dbg(NULL, fmt, ##__VA_ARGS__) 493 + #else 494 + #define __drm_dbg(cat, fmt, ...) \ 495 + _dynamic_func_call_cls(cat, fmt, ___drm_dbg, \ 496 + cat, fmt, ##__VA_ARGS__) 497 + #endif 522 498 523 499 /* Macros to make printk easier */ 524 500
+1
include/linux/cgroup.h
··· 114 114 int cgroup_add_legacy_cftypes(struct cgroup_subsys *ss, struct cftype *cfts); 115 115 int cgroup_rm_cftypes(struct cftype *cfts); 116 116 void cgroup_file_notify(struct cgroup_file *cfile); 117 + void cgroup_file_show(struct cgroup_file *cfile, bool show); 117 118 118 119 int task_cgroup_path(struct task_struct *task, char *buf, size_t buflen); 119 120 int cgroupstats_build(struct cgroupstats *stats, struct dentry *dentry);
+146 -28
include/linux/dynamic_debug.h
··· 6 6 #include <linux/jump_label.h> 7 7 #endif 8 8 9 + #include <linux/build_bug.h> 10 + 9 11 /* 10 12 * An instance of this structure is created in a special 11 13 * ELF section at every dynamic debug callsite. At runtime, ··· 23 21 const char *filename; 24 22 const char *format; 25 23 unsigned int lineno:18; 24 + #define CLS_BITS 6 25 + unsigned int class_id:CLS_BITS; 26 + #define _DPRINTK_CLASS_DFLT ((1 << CLS_BITS) - 1) 26 27 /* 27 28 * The flags field controls the behaviour at the callsite. 28 29 * The bits here are changed dynamically when the user ··· 56 51 #endif 57 52 } __attribute__((aligned(8))); 58 53 54 + enum class_map_type { 55 + DD_CLASS_TYPE_DISJOINT_BITS, 56 + /** 57 + * DD_CLASS_TYPE_DISJOINT_BITS: classes are independent, one per bit. 58 + * expecting hex input. Built for drm.debug, basis for other types. 59 + */ 60 + DD_CLASS_TYPE_LEVEL_NUM, 61 + /** 62 + * DD_CLASS_TYPE_LEVEL_NUM: input is numeric level, 0-N. 63 + * N turns on just bits N-1 .. 0, so N=0 turns all bits off. 64 + */ 65 + DD_CLASS_TYPE_DISJOINT_NAMES, 66 + /** 67 + * DD_CLASS_TYPE_DISJOINT_NAMES: input is a CSV of [+-]CLASS_NAMES, 68 + * classes are independent, like _DISJOINT_BITS. 69 + */ 70 + DD_CLASS_TYPE_LEVEL_NAMES, 71 + /** 72 + * DD_CLASS_TYPE_LEVEL_NAMES: input is a CSV of [+-]CLASS_NAMES, 73 + * intended for names like: INFO,DEBUG,TRACE, with a module prefix 74 + * avoid EMERG,ALERT,CRIT,ERR,WARNING: they're not debug 75 + */ 76 + }; 59 77 78 + struct ddebug_class_map { 79 + struct list_head link; 80 + struct module *mod; 81 + const char *mod_name; /* needed for builtins */ 82 + const char **class_names; 83 + const int length; 84 + const int base; /* index of 1st .class_id, allows split/shared space */ 85 + enum class_map_type map_type; 86 + }; 87 + 88 + /** 89 + * DECLARE_DYNDBG_CLASSMAP - declare classnames known by a module 90 + * @_var: a struct ddebug_class_map, passed to module_param_cb 91 + * @_type: enum class_map_type, chooses bits/verbose, numeric/symbolic 92 + * @_base: offset of 1st class-name. splits .class_id space 93 + * @classes: class-names used to control class'd prdbgs 94 + */ 95 + #define DECLARE_DYNDBG_CLASSMAP(_var, _maptype, _base, ...) \ 96 + static const char *_var##_classnames[] = { __VA_ARGS__ }; \ 97 + static struct ddebug_class_map __aligned(8) __used \ 98 + __section("__dyndbg_classes") _var = { \ 99 + .mod = THIS_MODULE, \ 100 + .mod_name = KBUILD_MODNAME, \ 101 + .base = _base, \ 102 + .map_type = _maptype, \ 103 + .length = NUM_TYPE_ARGS(char*, __VA_ARGS__), \ 104 + .class_names = _var##_classnames, \ 105 + } 106 + #define NUM_TYPE_ARGS(eltype, ...) \ 107 + (sizeof((eltype[]){__VA_ARGS__}) / sizeof(eltype)) 108 + 109 + /* encapsulate linker provided built-in (or module) dyndbg data */ 110 + struct _ddebug_info { 111 + struct _ddebug *descs; 112 + struct ddebug_class_map *classes; 113 + unsigned int num_descs; 114 + unsigned int num_classes; 115 + }; 116 + 117 + struct ddebug_class_param { 118 + union { 119 + unsigned long *bits; 120 + unsigned int *lvl; 121 + }; 122 + char flags[8]; 123 + const struct ddebug_class_map *map; 124 + }; 60 125 61 126 #if defined(CONFIG_DYNAMIC_DEBUG_CORE) 62 127 63 - /* exported for module authors to exercise >control */ 64 - int dynamic_debug_exec_queries(const char *query, const char *modname); 128 + int ddebug_add_module(struct _ddebug_info *dyndbg, const char *modname); 65 129 66 - int ddebug_add_module(struct _ddebug *tab, unsigned int n, 67 - const char *modname); 68 130 extern int ddebug_remove_module(const char *mod_name); 69 131 extern __printf(2, 3) 70 132 void __dynamic_pr_debug(struct _ddebug *descriptor, const char *fmt, ...); ··· 159 87 const struct ib_device *ibdev, 160 88 const char *fmt, ...); 161 89 162 - #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ 90 + #define DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, cls, fmt) \ 163 91 static struct _ddebug __aligned(8) \ 164 92 __section("__dyndbg") name = { \ 165 93 .modname = KBUILD_MODNAME, \ ··· 168 96 .format = (fmt), \ 169 97 .lineno = __LINE__, \ 170 98 .flags = _DPRINTK_FLAGS_DEFAULT, \ 99 + .class_id = cls, \ 171 100 _DPRINTK_KEY_INIT \ 172 - } 101 + }; \ 102 + BUILD_BUG_ON_MSG(cls > _DPRINTK_CLASS_DFLT, \ 103 + "classid value overflow") 104 + 105 + #define DEFINE_DYNAMIC_DEBUG_METADATA(name, fmt) \ 106 + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(name, _DPRINTK_CLASS_DFLT, fmt) 173 107 174 108 #ifdef CONFIG_JUMP_LABEL 175 109 ··· 206 128 207 129 #endif /* CONFIG_JUMP_LABEL */ 208 130 209 - #define __dynamic_func_call(id, fmt, func, ...) do { \ 210 - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ 211 - if (DYNAMIC_DEBUG_BRANCH(id)) \ 212 - func(&id, ##__VA_ARGS__); \ 213 - } while (0) 214 - 215 - #define __dynamic_func_call_no_desc(id, fmt, func, ...) do { \ 216 - DEFINE_DYNAMIC_DEBUG_METADATA(id, fmt); \ 131 + /* 132 + * Factory macros: ($prefix)dynamic_func_call($suffix) 133 + * 134 + * Lower layer (with __ prefix) gets the callsite metadata, and wraps 135 + * the func inside a debug-branch/static-key construct. Upper layer 136 + * (with _ prefix) does the UNIQUE_ID once, so that lower can ref the 137 + * name/label multiple times, and tie the elements together. 138 + * Multiple flavors: 139 + * (|_cls): adds in _DPRINT_CLASS_DFLT as needed 140 + * (|_no_desc): former gets callsite descriptor as 1st arg (for prdbgs) 141 + */ 142 + #define __dynamic_func_call_cls(id, cls, fmt, func, ...) do { \ 143 + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ 217 144 if (DYNAMIC_DEBUG_BRANCH(id)) \ 218 - func(__VA_ARGS__); \ 145 + func(&id, ##__VA_ARGS__); \ 219 146 } while (0) 147 + #define __dynamic_func_call(id, fmt, func, ...) \ 148 + __dynamic_func_call_cls(id, _DPRINTK_CLASS_DFLT, fmt, \ 149 + func, ##__VA_ARGS__) 150 + 151 + #define __dynamic_func_call_cls_no_desc(id, cls, fmt, func, ...) do { \ 152 + DEFINE_DYNAMIC_DEBUG_METADATA_CLS(id, cls, fmt); \ 153 + if (DYNAMIC_DEBUG_BRANCH(id)) \ 154 + func(__VA_ARGS__); \ 155 + } while (0) 156 + #define __dynamic_func_call_no_desc(id, fmt, func, ...) \ 157 + __dynamic_func_call_cls_no_desc(id, _DPRINTK_CLASS_DFLT, \ 158 + fmt, func, ##__VA_ARGS__) 220 159 221 160 /* 222 161 * "Factory macro" for generating a call to func, guarded by a ··· 243 148 * the varargs. Note that fmt is repeated in invocations of this 244 149 * macro. 245 150 */ 151 + #define _dynamic_func_call_cls(cls, fmt, func, ...) \ 152 + __dynamic_func_call_cls(__UNIQUE_ID(ddebug), cls, fmt, func, ##__VA_ARGS__) 246 153 #define _dynamic_func_call(fmt, func, ...) \ 247 - __dynamic_func_call(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) 154 + _dynamic_func_call_cls(_DPRINTK_CLASS_DFLT, fmt, func, ##__VA_ARGS__) 155 + 248 156 /* 249 157 * A variant that does the same, except that the descriptor is not 250 158 * passed as the first argument to the function; it is only called 251 159 * with precisely the macro's varargs. 252 160 */ 253 - #define _dynamic_func_call_no_desc(fmt, func, ...) \ 254 - __dynamic_func_call_no_desc(__UNIQUE_ID(ddebug), fmt, func, ##__VA_ARGS__) 161 + #define _dynamic_func_call_cls_no_desc(cls, fmt, func, ...) \ 162 + __dynamic_func_call_cls_no_desc(__UNIQUE_ID(ddebug), cls, fmt, \ 163 + func, ##__VA_ARGS__) 164 + #define _dynamic_func_call_no_desc(fmt, func, ...) \ 165 + _dynamic_func_call_cls_no_desc(_DPRINTK_CLASS_DFLT, fmt, \ 166 + func, ##__VA_ARGS__) 167 + 168 + #define dynamic_pr_debug_cls(cls, fmt, ...) \ 169 + _dynamic_func_call_cls(cls, fmt, __dynamic_pr_debug, \ 170 + pr_fmt(fmt), ##__VA_ARGS__) 255 171 256 172 #define dynamic_pr_debug(fmt, ...) \ 257 - _dynamic_func_call(fmt, __dynamic_pr_debug, \ 173 + _dynamic_func_call(fmt, __dynamic_pr_debug, \ 258 174 pr_fmt(fmt), ##__VA_ARGS__) 259 175 260 176 #define dynamic_dev_dbg(dev, fmt, ...) \ 261 - _dynamic_func_call(fmt,__dynamic_dev_dbg, \ 177 + _dynamic_func_call(fmt, __dynamic_dev_dbg, \ 262 178 dev, fmt, ##__VA_ARGS__) 263 179 264 180 #define dynamic_netdev_dbg(dev, fmt, ...) \ ··· 287 181 KERN_DEBUG, prefix_str, prefix_type, \ 288 182 rowsize, groupsize, buf, len, ascii) 289 183 184 + struct kernel_param; 185 + int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp); 186 + int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp); 187 + 188 + /* for test only, generally expect drm.debug style macro wrappers */ 189 + #define __pr_debug_cls(cls, fmt, ...) do { \ 190 + BUILD_BUG_ON_MSG(!__builtin_constant_p(cls), \ 191 + "expecting constant class int/enum"); \ 192 + dynamic_pr_debug_cls(cls, fmt, ##__VA_ARGS__); \ 193 + } while (0) 194 + 290 195 #else /* !CONFIG_DYNAMIC_DEBUG_CORE */ 291 196 292 197 #include <linux/string.h> 293 198 #include <linux/errno.h> 294 199 #include <linux/printk.h> 295 200 296 - static inline int ddebug_add_module(struct _ddebug *tab, unsigned int n, 297 - const char *modname) 201 + static inline int ddebug_add_module(struct _ddebug_info *dinfo, const char *modname) 298 202 { 299 203 return 0; 300 204 } ··· 317 201 static inline int ddebug_dyndbg_module_param_cb(char *param, char *val, 318 202 const char *modname) 319 203 { 320 - if (strstr(param, "dyndbg")) { 204 + if (!strcmp(param, "dyndbg")) { 321 205 /* avoid pr_warn(), which wants pr_fmt() fully defined */ 322 206 printk(KERN_WARNING "dyndbg param is supported only in " 323 207 "CONFIG_DYNAMIC_DEBUG builds\n"); ··· 337 221 rowsize, groupsize, buf, len, ascii); \ 338 222 } while (0) 339 223 340 - static inline int dynamic_debug_exec_queries(const char *query, const char *modname) 341 - { 342 - pr_warn("kernel not built with CONFIG_DYNAMIC_DEBUG_CORE\n"); 343 - return 0; 344 - } 224 + struct kernel_param; 225 + static inline int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) 226 + { return 0; } 227 + static inline int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) 228 + { return 0; } 345 229 346 230 #endif /* !CONFIG_DYNAMIC_DEBUG_CORE */ 231 + 232 + extern const struct kernel_param_ops param_ops_dyndbg_classes; 347 233 348 234 #endif
-2
include/linux/io.h
··· 59 59 resource_size_t size); 60 60 void __iomem *devm_ioremap_wc(struct device *dev, resource_size_t offset, 61 61 resource_size_t size); 62 - void __iomem *devm_ioremap_np(struct device *dev, resource_size_t offset, 63 - resource_size_t size); 64 62 void devm_iounmap(struct device *dev, void __iomem *addr); 65 63 int check_signature(const volatile void __iomem *io_addr, 66 64 const unsigned char *signature, int length);
+3
include/linux/kernfs.h
··· 108 108 KERNFS_HAS_SEQ_SHOW = 0x0040, 109 109 KERNFS_HAS_MMAP = 0x0080, 110 110 KERNFS_LOCKDEP = 0x0100, 111 + KERNFS_HIDDEN = 0x0200, 111 112 KERNFS_SUICIDAL = 0x0400, 112 113 KERNFS_SUICIDED = 0x0800, 113 114 KERNFS_EMPTY_DIR = 0x1000, 114 115 KERNFS_HAS_RELEASE = 0x2000, 116 + KERNFS_REMOVING = 0x4000, 115 117 }; 116 118 117 119 /* @flags for kernfs_create_root() */ ··· 431 429 const char *name, 432 430 struct kernfs_node *target); 433 431 void kernfs_activate(struct kernfs_node *kn); 432 + void kernfs_show(struct kernfs_node *kn, bool show); 434 433 void kernfs_remove(struct kernfs_node *kn); 435 434 void kernfs_break_active_protection(struct kernfs_node *kn); 436 435 void kernfs_unbreak_active_protection(struct kernfs_node *kn);
+2 -2
include/linux/property.h
··· 32 32 DEV_DMA_COHERENT, 33 33 }; 34 34 35 - struct fwnode_handle *dev_fwnode(struct device *dev); 35 + struct fwnode_handle *dev_fwnode(const struct device *dev); 36 36 37 37 bool device_property_present(struct device *dev, const char *propname); 38 38 int device_property_read_u8_array(struct device *dev, const char *propname, ··· 387 387 388 388 enum dev_dma_attr device_get_dma_attr(struct device *dev); 389 389 390 - const void *device_get_match_data(struct device *dev); 390 + const void *device_get_match_data(const struct device *dev); 391 391 392 392 int device_get_phy_mode(struct device *dev); 393 393 int fwnode_get_phy_mode(struct fwnode_handle *fwnode);
+20
kernel/cgroup/cgroup.c
··· 4372 4372 } 4373 4373 4374 4374 /** 4375 + * cgroup_file_show - show or hide a hidden cgroup file 4376 + * @cfile: target cgroup_file obtained by setting cftype->file_offset 4377 + * @show: whether to show or hide 4378 + */ 4379 + void cgroup_file_show(struct cgroup_file *cfile, bool show) 4380 + { 4381 + struct kernfs_node *kn; 4382 + 4383 + spin_lock_irq(&cgroup_file_kn_lock); 4384 + kn = cfile->kn; 4385 + kernfs_get(kn); 4386 + spin_unlock_irq(&cgroup_file_kn_lock); 4387 + 4388 + if (kn) 4389 + kernfs_show(kn, show); 4390 + 4391 + kernfs_put(kn); 4392 + } 4393 + 4394 + /** 4375 4395 * css_next_child - find the next child of a given css 4376 4396 * @pos: the current position (%NULL to initiate traversal) 4377 4397 * @parent: css whose children to walk
+2 -2
kernel/module/internal.h
··· 53 53 extern const s32 __start___kcrctab[]; 54 54 extern const s32 __start___kcrctab_gpl[]; 55 55 56 + #include <linux/dynamic_debug.h> 56 57 struct load_info { 57 58 const char *name; 58 59 /* pointer to module in temporary copy, freed at end of load_module() */ ··· 63 62 Elf_Shdr *sechdrs; 64 63 char *secstrings, *strtab; 65 64 unsigned long symoffs, stroffs, init_typeoffs, core_typeoffs; 66 - struct _ddebug *debug; 67 - unsigned int num_debug; 65 + struct _ddebug_info dyndbg; 68 66 bool sig_ok; 69 67 #ifdef CONFIG_KALLSYMS 70 68 unsigned long mod_kallsyms_init_off;
+11 -9
kernel/module/main.c
··· 1594 1594 } 1595 1595 } 1596 1596 1597 - static void dynamic_debug_setup(struct module *mod, struct _ddebug *debug, unsigned int num) 1597 + static void dynamic_debug_setup(struct module *mod, struct _ddebug_info *dyndbg) 1598 1598 { 1599 - if (!debug) 1599 + if (!dyndbg->num_descs) 1600 1600 return; 1601 - ddebug_add_module(debug, num, mod->name); 1601 + ddebug_add_module(dyndbg, mod->name); 1602 1602 } 1603 1603 1604 - static void dynamic_debug_remove(struct module *mod, struct _ddebug *debug) 1604 + static void dynamic_debug_remove(struct module *mod, struct _ddebug_info *dyndbg) 1605 1605 { 1606 - if (debug) 1606 + if (dyndbg->num_descs) 1607 1607 ddebug_remove_module(mod->name); 1608 1608 } 1609 1609 ··· 2107 2107 if (section_addr(info, "__obsparm")) 2108 2108 pr_warn("%s: Ignoring obsolete parameters\n", mod->name); 2109 2109 2110 - info->debug = section_objs(info, "__dyndbg", 2111 - sizeof(*info->debug), &info->num_debug); 2110 + info->dyndbg.descs = section_objs(info, "__dyndbg", 2111 + sizeof(*info->dyndbg.descs), &info->dyndbg.num_descs); 2112 + info->dyndbg.classes = section_objs(info, "__dyndbg_classes", 2113 + sizeof(*info->dyndbg.classes), &info->dyndbg.num_classes); 2112 2114 2113 2115 return 0; 2114 2116 } ··· 2801 2799 } 2802 2800 2803 2801 init_build_id(mod, info); 2804 - dynamic_debug_setup(mod, info->debug, info->num_debug); 2802 + dynamic_debug_setup(mod, &info->dyndbg); 2805 2803 2806 2804 /* Ftrace init must be called in the MODULE_STATE_UNFORMED state */ 2807 2805 ftrace_module_init(mod); ··· 2865 2863 2866 2864 ddebug_cleanup: 2867 2865 ftrace_release_mod(mod); 2868 - dynamic_debug_remove(mod, info->debug); 2866 + dynamic_debug_remove(mod, &info->dyndbg); 2869 2867 synchronize_rcu(); 2870 2868 kfree(mod->args); 2871 2869 free_arch_cleanup:
+10
lib/Kconfig.debug
··· 2572 2572 2573 2573 If unsure, say N. 2574 2574 2575 + config TEST_DYNAMIC_DEBUG 2576 + tristate "Test DYNAMIC_DEBUG" 2577 + depends on DYNAMIC_DEBUG 2578 + help 2579 + This module registers a tracer callback to count enabled 2580 + pr_debugs in a 'do_debugging' function, then alters their 2581 + enablements, calls the function, and compares counts. 2582 + 2583 + If unsure, say N. 2584 + 2575 2585 config TEST_KMOD 2576 2586 tristate "kmod stress tester" 2577 2587 depends on m
+1
lib/Makefile
··· 83 83 obj-$(CONFIG_TEST_USER_COPY) += test_user_copy.o 84 84 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_keys.o 85 85 obj-$(CONFIG_TEST_STATIC_KEYS) += test_static_key_base.o 86 + obj-$(CONFIG_TEST_DYNAMIC_DEBUG) += test_dynamic_debug.o 86 87 obj-$(CONFIG_TEST_PRINTF) += test_printf.o 87 88 obj-$(CONFIG_TEST_SCANF) += test_scanf.o 88 89 obj-$(CONFIG_TEST_BITMAP) += test_bitmap.o
-15
lib/devres.c
··· 104 104 EXPORT_SYMBOL(devm_ioremap_wc); 105 105 106 106 /** 107 - * devm_ioremap_np - Managed ioremap_np() 108 - * @dev: Generic device to remap IO address for 109 - * @offset: Resource address to map 110 - * @size: Size of map 111 - * 112 - * Managed ioremap_np(). Map is automatically unmapped on driver detach. 113 - */ 114 - void __iomem *devm_ioremap_np(struct device *dev, resource_size_t offset, 115 - resource_size_t size) 116 - { 117 - return __devm_ioremap(dev, offset, size, DEVM_IOREMAP_NP); 118 - } 119 - EXPORT_SYMBOL(devm_ioremap_np); 120 - 121 - /** 122 107 * devm_iounmap - Managed iounmap() 123 108 * @dev: Generic device to unmap for 124 109 * @addr: Address to unmap
+381 -73
lib/dynamic_debug.c
··· 41 41 42 42 extern struct _ddebug __start___dyndbg[]; 43 43 extern struct _ddebug __stop___dyndbg[]; 44 + extern struct ddebug_class_map __start___dyndbg_classes[]; 45 + extern struct ddebug_class_map __stop___dyndbg_classes[]; 44 46 45 47 struct ddebug_table { 46 - struct list_head link; 48 + struct list_head link, maps; 47 49 const char *mod_name; 48 50 unsigned int num_ddebugs; 49 51 struct _ddebug *ddebugs; ··· 56 54 const char *module; 57 55 const char *function; 58 56 const char *format; 57 + const char *class_string; 59 58 unsigned int first_lineno, last_lineno; 60 59 }; 61 60 62 61 struct ddebug_iter { 63 62 struct ddebug_table *table; 64 - unsigned int idx; 63 + int idx; 65 64 }; 66 65 67 66 struct flag_settings { ··· 137 134 fmtlen--; 138 135 } 139 136 140 - v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u\n", 141 - msg, 142 - query->function ?: "", 143 - query->filename ?: "", 144 - query->module ?: "", 145 - fmtlen, query->format ?: "", 146 - query->first_lineno, query->last_lineno); 137 + v3pr_info("%s: func=\"%s\" file=\"%s\" module=\"%s\" format=\"%.*s\" lineno=%u-%u class=%s\n", 138 + msg, 139 + query->function ?: "", 140 + query->filename ?: "", 141 + query->module ?: "", 142 + fmtlen, query->format ?: "", 143 + query->first_lineno, query->last_lineno, query->class_string); 147 144 } 148 145 146 + static struct ddebug_class_map *ddebug_find_valid_class(struct ddebug_table const *dt, 147 + const char *class_string, int *class_id) 148 + { 149 + struct ddebug_class_map *map; 150 + int idx; 151 + 152 + list_for_each_entry(map, &dt->maps, link) { 153 + idx = match_string(map->class_names, map->length, class_string); 154 + if (idx >= 0) { 155 + *class_id = idx + map->base; 156 + return map; 157 + } 158 + } 159 + *class_id = -ENOENT; 160 + return NULL; 161 + } 162 + 163 + #define __outvar /* filled by callee */ 149 164 /* 150 165 * Search the tables for _ddebug's which match the given `query' and 151 166 * apply the `flags' and `mask' to them. Returns number of matching ··· 177 156 struct ddebug_table *dt; 178 157 unsigned int newflags; 179 158 unsigned int nfound = 0; 180 - struct flagsbuf fbuf; 159 + struct flagsbuf fbuf, nbuf; 160 + struct ddebug_class_map *map = NULL; 161 + int __outvar valid_class; 181 162 182 163 /* search for matching ddebugs */ 183 164 mutex_lock(&ddebug_lock); ··· 190 167 !match_wildcard(query->module, dt->mod_name)) 191 168 continue; 192 169 170 + if (query->class_string) { 171 + map = ddebug_find_valid_class(dt, query->class_string, &valid_class); 172 + if (!map) 173 + continue; 174 + } else { 175 + /* constrain query, do not touch class'd callsites */ 176 + valid_class = _DPRINTK_CLASS_DFLT; 177 + } 178 + 193 179 for (i = 0; i < dt->num_ddebugs; i++) { 194 180 struct _ddebug *dp = &dt->ddebugs[i]; 181 + 182 + /* match site against query-class */ 183 + if (dp->class_id != valid_class) 184 + continue; 195 185 196 186 /* match against the source filename */ 197 187 if (query->filename && ··· 247 211 continue; 248 212 #ifdef CONFIG_JUMP_LABEL 249 213 if (dp->flags & _DPRINTK_FLAGS_PRINT) { 250 - if (!(modifiers->flags & _DPRINTK_FLAGS_PRINT)) 214 + if (!(newflags & _DPRINTK_FLAGS_PRINT)) 251 215 static_branch_disable(&dp->key.dd_key_true); 252 - } else if (modifiers->flags & _DPRINTK_FLAGS_PRINT) 216 + } else if (newflags & _DPRINTK_FLAGS_PRINT) { 253 217 static_branch_enable(&dp->key.dd_key_true); 218 + } 254 219 #endif 220 + v4pr_info("changed %s:%d [%s]%s %s => %s\n", 221 + trim_prefix(dp->filename), dp->lineno, 222 + dt->mod_name, dp->function, 223 + ddebug_describe_flags(dp->flags, &fbuf), 224 + ddebug_describe_flags(newflags, &nbuf)); 255 225 dp->flags = newflags; 256 - v4pr_info("changed %s:%d [%s]%s =%s\n", 257 - trim_prefix(dp->filename), dp->lineno, 258 - dt->mod_name, dp->function, 259 - ddebug_describe_flags(dp->flags, &fbuf)); 260 226 } 261 227 } 262 228 mutex_unlock(&ddebug_lock); ··· 421 383 return -EINVAL; 422 384 } 423 385 424 - if (modname) 425 - /* support $modname.dyndbg=<multiple queries> */ 426 - query->module = modname; 427 - 428 386 for (i = 0; i < nwords; i += 2) { 429 387 char *keyword = words[i]; 430 388 char *arg = words[i+1]; ··· 454 420 } else if (!strcmp(keyword, "line")) { 455 421 if (parse_linerange(query, arg)) 456 422 return -EINVAL; 423 + } else if (!strcmp(keyword, "class")) { 424 + rc = check_set(&query->class_string, arg, "class"); 457 425 } else { 458 426 pr_err("unknown keyword \"%s\"\n", keyword); 459 427 return -EINVAL; ··· 463 427 if (rc) 464 428 return rc; 465 429 } 430 + if (!query->module && modname) 431 + /* 432 + * support $modname.dyndbg=<multiple queries>, when 433 + * not given in the query itself 434 + */ 435 + query->module = modname; 436 + 466 437 vpr_info_dq(query, "parsed"); 467 438 return 0; 468 439 } ··· 596 553 return nfound; 597 554 } 598 555 599 - /** 600 - * dynamic_debug_exec_queries - select and change dynamic-debug prints 601 - * @query: query-string described in admin-guide/dynamic-debug-howto 602 - * @modname: string containing module name, usually &module.mod_name 603 - * 604 - * This uses the >/proc/dynamic_debug/control reader, allowing module 605 - * authors to modify their dynamic-debug callsites. The modname is 606 - * canonically struct module.mod_name, but can also be null or a 607 - * module-wildcard, for example: "drm*". 608 - */ 609 - int dynamic_debug_exec_queries(const char *query, const char *modname) 556 + /* apply a new bitmap to the sys-knob's current bit-state */ 557 + static int ddebug_apply_class_bitmap(const struct ddebug_class_param *dcp, 558 + unsigned long *new_bits, unsigned long *old_bits) 610 559 { 611 - int rc; 612 - char *qry; /* writable copy of query */ 560 + #define QUERY_SIZE 128 561 + char query[QUERY_SIZE]; 562 + const struct ddebug_class_map *map = dcp->map; 563 + int matches = 0; 564 + int bi, ct; 613 565 614 - if (!query) { 615 - pr_err("non-null query/command string expected\n"); 566 + v2pr_info("apply: 0x%lx to: 0x%lx\n", *new_bits, *old_bits); 567 + 568 + for (bi = 0; bi < map->length; bi++) { 569 + if (test_bit(bi, new_bits) == test_bit(bi, old_bits)) 570 + continue; 571 + 572 + snprintf(query, QUERY_SIZE, "class %s %c%s", map->class_names[bi], 573 + test_bit(bi, new_bits) ? '+' : '-', dcp->flags); 574 + 575 + ct = ddebug_exec_queries(query, NULL); 576 + matches += ct; 577 + 578 + v2pr_info("bit_%d: %d matches on class: %s -> 0x%lx\n", bi, 579 + ct, map->class_names[bi], *new_bits); 580 + } 581 + return matches; 582 + } 583 + 584 + /* stub to later conditionally add "$module." prefix where not already done */ 585 + #define KP_NAME(kp) kp->name 586 + 587 + #define CLASSMAP_BITMASK(width) ((1UL << (width)) - 1) 588 + 589 + /* accept comma-separated-list of [+-] classnames */ 590 + static int param_set_dyndbg_classnames(const char *instr, const struct kernel_param *kp) 591 + { 592 + const struct ddebug_class_param *dcp = kp->arg; 593 + const struct ddebug_class_map *map = dcp->map; 594 + unsigned long curr_bits, old_bits; 595 + char *cl_str, *p, *tmp; 596 + int cls_id, totct = 0; 597 + bool wanted; 598 + 599 + cl_str = tmp = kstrdup(instr, GFP_KERNEL); 600 + p = strchr(cl_str, '\n'); 601 + if (p) 602 + *p = '\0'; 603 + 604 + /* start with previously set state-bits, then modify */ 605 + curr_bits = old_bits = *dcp->bits; 606 + vpr_info("\"%s\" > %s:0x%lx\n", cl_str, KP_NAME(kp), curr_bits); 607 + 608 + for (; cl_str; cl_str = p) { 609 + p = strchr(cl_str, ','); 610 + if (p) 611 + *p++ = '\0'; 612 + 613 + if (*cl_str == '-') { 614 + wanted = false; 615 + cl_str++; 616 + } else { 617 + wanted = true; 618 + if (*cl_str == '+') 619 + cl_str++; 620 + } 621 + cls_id = match_string(map->class_names, map->length, cl_str); 622 + if (cls_id < 0) { 623 + pr_err("%s unknown to %s\n", cl_str, KP_NAME(kp)); 624 + continue; 625 + } 626 + 627 + /* have one or more valid class_ids of one *_NAMES type */ 628 + switch (map->map_type) { 629 + case DD_CLASS_TYPE_DISJOINT_NAMES: 630 + /* the +/- pertains to a single bit */ 631 + if (test_bit(cls_id, &curr_bits) == wanted) { 632 + v3pr_info("no change on %s\n", cl_str); 633 + continue; 634 + } 635 + curr_bits ^= BIT(cls_id); 636 + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, dcp->bits); 637 + *dcp->bits = curr_bits; 638 + v2pr_info("%s: changed bit %d:%s\n", KP_NAME(kp), cls_id, 639 + map->class_names[cls_id]); 640 + break; 641 + case DD_CLASS_TYPE_LEVEL_NAMES: 642 + /* cls_id = N in 0..max. wanted +/- determines N or N-1 */ 643 + old_bits = CLASSMAP_BITMASK(*dcp->lvl); 644 + curr_bits = CLASSMAP_BITMASK(cls_id + (wanted ? 1 : 0 )); 645 + 646 + totct += ddebug_apply_class_bitmap(dcp, &curr_bits, &old_bits); 647 + *dcp->lvl = (cls_id + (wanted ? 1 : 0)); 648 + v2pr_info("%s: changed bit-%d: \"%s\" %lx->%lx\n", KP_NAME(kp), cls_id, 649 + map->class_names[cls_id], old_bits, curr_bits); 650 + break; 651 + default: 652 + pr_err("illegal map-type value %d\n", map->map_type); 653 + } 654 + } 655 + kfree(tmp); 656 + vpr_info("total matches: %d\n", totct); 657 + return 0; 658 + } 659 + 660 + /** 661 + * param_set_dyndbg_classes - class FOO >control 662 + * @instr: string echo>d to sysfs, input depends on map_type 663 + * @kp: kp->arg has state: bits/lvl, map, map_type 664 + * 665 + * Enable/disable prdbgs by their class, as given in the arguments to 666 + * DECLARE_DYNDBG_CLASSMAP. For LEVEL map-types, enforce relative 667 + * levels by bitpos. 668 + * 669 + * Returns: 0 or <0 if error. 670 + */ 671 + int param_set_dyndbg_classes(const char *instr, const struct kernel_param *kp) 672 + { 673 + const struct ddebug_class_param *dcp = kp->arg; 674 + const struct ddebug_class_map *map = dcp->map; 675 + unsigned long inrep, new_bits, old_bits; 676 + int rc, totct = 0; 677 + 678 + switch (map->map_type) { 679 + 680 + case DD_CLASS_TYPE_DISJOINT_NAMES: 681 + case DD_CLASS_TYPE_LEVEL_NAMES: 682 + /* handle [+-]classnames list separately, we are done here */ 683 + return param_set_dyndbg_classnames(instr, kp); 684 + 685 + case DD_CLASS_TYPE_DISJOINT_BITS: 686 + case DD_CLASS_TYPE_LEVEL_NUM: 687 + /* numeric input, accept and fall-thru */ 688 + rc = kstrtoul(instr, 0, &inrep); 689 + if (rc) { 690 + pr_err("expecting numeric input: %s > %s\n", instr, KP_NAME(kp)); 691 + return -EINVAL; 692 + } 693 + break; 694 + default: 695 + pr_err("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); 616 696 return -EINVAL; 617 697 } 618 - qry = kstrndup(query, PAGE_SIZE, GFP_KERNEL); 619 - if (!qry) 620 - return -ENOMEM; 621 698 622 - rc = ddebug_exec_queries(qry, modname); 623 - kfree(qry); 624 - return rc; 699 + /* only _BITS,_NUM (numeric) map-types get here */ 700 + switch (map->map_type) { 701 + case DD_CLASS_TYPE_DISJOINT_BITS: 702 + /* expect bits. mask and warn if too many */ 703 + if (inrep & ~CLASSMAP_BITMASK(map->length)) { 704 + pr_warn("%s: input: 0x%lx exceeds mask: 0x%lx, masking\n", 705 + KP_NAME(kp), inrep, CLASSMAP_BITMASK(map->length)); 706 + inrep &= CLASSMAP_BITMASK(map->length); 707 + } 708 + v2pr_info("bits:%lx > %s\n", inrep, KP_NAME(kp)); 709 + totct += ddebug_apply_class_bitmap(dcp, &inrep, dcp->bits); 710 + *dcp->bits = inrep; 711 + break; 712 + case DD_CLASS_TYPE_LEVEL_NUM: 713 + /* input is bitpos, of highest verbosity to be enabled */ 714 + if (inrep > map->length) { 715 + pr_warn("%s: level:%ld exceeds max:%d, clamping\n", 716 + KP_NAME(kp), inrep, map->length); 717 + inrep = map->length; 718 + } 719 + old_bits = CLASSMAP_BITMASK(*dcp->lvl); 720 + new_bits = CLASSMAP_BITMASK(inrep); 721 + v2pr_info("lvl:%ld bits:0x%lx > %s\n", inrep, new_bits, KP_NAME(kp)); 722 + totct += ddebug_apply_class_bitmap(dcp, &new_bits, &old_bits); 723 + *dcp->lvl = inrep; 724 + break; 725 + default: 726 + pr_warn("%s: bad map type: %d\n", KP_NAME(kp), map->map_type); 727 + } 728 + vpr_info("%s: total matches: %d\n", KP_NAME(kp), totct); 729 + return 0; 625 730 } 626 - EXPORT_SYMBOL_GPL(dynamic_debug_exec_queries); 731 + EXPORT_SYMBOL(param_set_dyndbg_classes); 732 + 733 + /** 734 + * param_get_dyndbg_classes - classes reader 735 + * @buffer: string description of controlled bits -> classes 736 + * @kp: kp->arg has state: bits, map 737 + * 738 + * Reads last written state, underlying prdbg state may have been 739 + * altered by direct >control. Displays 0x for DISJOINT, 0-N for 740 + * LEVEL Returns: #chars written or <0 on error 741 + */ 742 + int param_get_dyndbg_classes(char *buffer, const struct kernel_param *kp) 743 + { 744 + const struct ddebug_class_param *dcp = kp->arg; 745 + const struct ddebug_class_map *map = dcp->map; 746 + 747 + switch (map->map_type) { 748 + 749 + case DD_CLASS_TYPE_DISJOINT_NAMES: 750 + case DD_CLASS_TYPE_DISJOINT_BITS: 751 + return scnprintf(buffer, PAGE_SIZE, "0x%lx\n", *dcp->bits); 752 + 753 + case DD_CLASS_TYPE_LEVEL_NAMES: 754 + case DD_CLASS_TYPE_LEVEL_NUM: 755 + return scnprintf(buffer, PAGE_SIZE, "%d\n", *dcp->lvl); 756 + default: 757 + return -1; 758 + } 759 + } 760 + EXPORT_SYMBOL(param_get_dyndbg_classes); 761 + 762 + const struct kernel_param_ops param_ops_dyndbg_classes = { 763 + .set = param_set_dyndbg_classes, 764 + .get = param_get_dyndbg_classes, 765 + }; 766 + EXPORT_SYMBOL(param_ops_dyndbg_classes); 627 767 628 768 #define PREFIX_SIZE 64 629 769 ··· 1029 803 { 1030 804 if (list_empty(&ddebug_tables)) { 1031 805 iter->table = NULL; 1032 - iter->idx = 0; 1033 806 return NULL; 1034 807 } 1035 808 iter->table = list_entry(ddebug_tables.next, 1036 809 struct ddebug_table, link); 1037 - iter->idx = 0; 1038 - return &iter->table->ddebugs[iter->idx]; 810 + iter->idx = iter->table->num_ddebugs; 811 + return &iter->table->ddebugs[--iter->idx]; 1039 812 } 1040 813 1041 814 /* ··· 1047 822 { 1048 823 if (iter->table == NULL) 1049 824 return NULL; 1050 - if (++iter->idx == iter->table->num_ddebugs) { 825 + if (--iter->idx < 0) { 1051 826 /* iterate to next table */ 1052 - iter->idx = 0; 1053 827 if (list_is_last(&iter->table->link, &ddebug_tables)) { 1054 828 iter->table = NULL; 1055 829 return NULL; 1056 830 } 1057 831 iter->table = list_entry(iter->table->link.next, 1058 832 struct ddebug_table, link); 833 + iter->idx = iter->table->num_ddebugs; 834 + --iter->idx; 1059 835 } 1060 836 return &iter->table->ddebugs[iter->idx]; 1061 837 } ··· 1102 876 return dp; 1103 877 } 1104 878 879 + #define class_in_range(class_id, map) \ 880 + (class_id >= map->base && class_id < map->base + map->length) 881 + 882 + static const char *ddebug_class_name(struct ddebug_iter *iter, struct _ddebug *dp) 883 + { 884 + struct ddebug_class_map *map; 885 + 886 + list_for_each_entry(map, &iter->table->maps, link) 887 + if (class_in_range(dp->class_id, map)) 888 + return map->class_names[dp->class_id - map->base]; 889 + 890 + return NULL; 891 + } 892 + 1105 893 /* 1106 894 * Seq_ops show method. Called several times within a read() 1107 895 * call from userspace, with ddebug_lock held. Formats the ··· 1127 887 struct ddebug_iter *iter = m->private; 1128 888 struct _ddebug *dp = p; 1129 889 struct flagsbuf flags; 890 + char const *class; 1130 891 1131 892 if (p == SEQ_START_TOKEN) { 1132 893 seq_puts(m, ··· 1139 898 trim_prefix(dp->filename), dp->lineno, 1140 899 iter->table->mod_name, dp->function, 1141 900 ddebug_describe_flags(dp->flags, &flags)); 1142 - seq_escape(m, dp->format, "\t\r\n\""); 1143 - seq_puts(m, "\"\n"); 901 + seq_escape_str(m, dp->format, ESCAPE_SPACE, "\t\r\n\""); 902 + seq_puts(m, "\""); 903 + 904 + if (dp->class_id != _DPRINTK_CLASS_DFLT) { 905 + class = ddebug_class_name(iter, dp); 906 + if (class) 907 + seq_printf(m, " class:%s", class); 908 + else 909 + seq_printf(m, " class unknown, _id:%d", dp->class_id); 910 + } 911 + seq_puts(m, "\n"); 1144 912 1145 913 return 0; 1146 914 } ··· 1193 943 .proc_write = ddebug_proc_write 1194 944 }; 1195 945 946 + static void ddebug_attach_module_classes(struct ddebug_table *dt, 947 + struct ddebug_class_map *classes, 948 + int num_classes) 949 + { 950 + struct ddebug_class_map *cm; 951 + int i, j, ct = 0; 952 + 953 + for (cm = classes, i = 0; i < num_classes; i++, cm++) { 954 + 955 + if (!strcmp(cm->mod_name, dt->mod_name)) { 956 + 957 + v2pr_info("class[%d]: module:%s base:%d len:%d ty:%d\n", i, 958 + cm->mod_name, cm->base, cm->length, cm->map_type); 959 + 960 + for (j = 0; j < cm->length; j++) 961 + v3pr_info(" %d: %d %s\n", j + cm->base, j, 962 + cm->class_names[j]); 963 + 964 + list_add(&cm->link, &dt->maps); 965 + ct++; 966 + } 967 + } 968 + if (ct) 969 + vpr_info("module:%s attached %d classes\n", dt->mod_name, ct); 970 + } 971 + 1196 972 /* 1197 973 * Allocate a new ddebug_table for the given module 1198 974 * and add it to the global list. 1199 975 */ 1200 - int ddebug_add_module(struct _ddebug *tab, unsigned int n, 1201 - const char *name) 976 + static int __ddebug_add_module(struct _ddebug_info *di, unsigned int base, 977 + const char *modname) 1202 978 { 1203 979 struct ddebug_table *dt; 1204 980 981 + v3pr_info("add-module: %s.%d sites\n", modname, di->num_descs); 982 + if (!di->num_descs) { 983 + v3pr_info(" skip %s\n", modname); 984 + return 0; 985 + } 986 + 1205 987 dt = kzalloc(sizeof(*dt), GFP_KERNEL); 1206 988 if (dt == NULL) { 1207 - pr_err("error adding module: %s\n", name); 989 + pr_err("error adding module: %s\n", modname); 1208 990 return -ENOMEM; 1209 991 } 1210 992 /* ··· 1245 963 * member of struct module, which lives at least as long as 1246 964 * this struct ddebug_table. 1247 965 */ 1248 - dt->mod_name = name; 1249 - dt->num_ddebugs = n; 1250 - dt->ddebugs = tab; 966 + dt->mod_name = modname; 967 + dt->ddebugs = di->descs; 968 + dt->num_ddebugs = di->num_descs; 969 + 970 + INIT_LIST_HEAD(&dt->link); 971 + INIT_LIST_HEAD(&dt->maps); 972 + 973 + if (di->classes && di->num_classes) 974 + ddebug_attach_module_classes(dt, di->classes, di->num_classes); 1251 975 1252 976 mutex_lock(&ddebug_lock); 1253 - list_add(&dt->link, &ddebug_tables); 977 + list_add_tail(&dt->link, &ddebug_tables); 1254 978 mutex_unlock(&ddebug_lock); 1255 979 1256 - vpr_info("%3u debug prints in module %s\n", n, dt->mod_name); 980 + vpr_info("%3u debug prints in module %s\n", di->num_descs, modname); 1257 981 return 0; 982 + } 983 + 984 + int ddebug_add_module(struct _ddebug_info *di, const char *modname) 985 + { 986 + return __ddebug_add_module(di, 0, modname); 1258 987 } 1259 988 1260 989 /* helper for ddebug_dyndbg_(boot|module)_param_cb */ ··· 1376 1083 1377 1084 static int __init dynamic_debug_init(void) 1378 1085 { 1379 - struct _ddebug *iter, *iter_start; 1380 - const char *modname = NULL; 1086 + struct _ddebug *iter, *iter_mod_start; 1087 + int ret, i, mod_sites, mod_ct; 1088 + const char *modname; 1381 1089 char *cmdline; 1382 - int ret = 0; 1383 - int n = 0, entries = 0, modct = 0; 1090 + 1091 + struct _ddebug_info di = { 1092 + .descs = __start___dyndbg, 1093 + .classes = __start___dyndbg_classes, 1094 + .num_descs = __stop___dyndbg - __start___dyndbg, 1095 + .num_classes = __stop___dyndbg_classes - __start___dyndbg_classes, 1096 + }; 1384 1097 1385 1098 if (&__start___dyndbg == &__stop___dyndbg) { 1386 1099 if (IS_ENABLED(CONFIG_DYNAMIC_DEBUG)) { ··· 1397 1098 ddebug_init_success = 1; 1398 1099 return 0; 1399 1100 } 1400 - iter = __start___dyndbg; 1101 + 1102 + iter = iter_mod_start = __start___dyndbg; 1401 1103 modname = iter->modname; 1402 - iter_start = iter; 1403 - for (; iter < __stop___dyndbg; iter++) { 1404 - entries++; 1104 + i = mod_sites = mod_ct = 0; 1105 + 1106 + for (; iter < __stop___dyndbg; iter++, i++, mod_sites++) { 1107 + 1405 1108 if (strcmp(modname, iter->modname)) { 1406 - modct++; 1407 - ret = ddebug_add_module(iter_start, n, modname); 1109 + mod_ct++; 1110 + di.num_descs = mod_sites; 1111 + di.descs = iter_mod_start; 1112 + ret = __ddebug_add_module(&di, i - mod_sites, modname); 1408 1113 if (ret) 1409 1114 goto out_err; 1410 - n = 0; 1115 + 1116 + mod_sites = 0; 1411 1117 modname = iter->modname; 1412 - iter_start = iter; 1118 + iter_mod_start = iter; 1413 1119 } 1414 - n++; 1415 1120 } 1416 - ret = ddebug_add_module(iter_start, n, modname); 1121 + di.num_descs = mod_sites; 1122 + di.descs = iter_mod_start; 1123 + ret = __ddebug_add_module(&di, i - mod_sites, modname); 1417 1124 if (ret) 1418 1125 goto out_err; 1419 1126 1420 1127 ddebug_init_success = 1; 1421 1128 vpr_info("%d prdebugs in %d modules, %d KiB in ddebug tables, %d kiB in __dyndbg section\n", 1422 - entries, modct, (int)((modct * sizeof(struct ddebug_table)) >> 10), 1423 - (int)((entries * sizeof(struct _ddebug)) >> 10)); 1129 + i, mod_ct, (int)((mod_ct * sizeof(struct ddebug_table)) >> 10), 1130 + (int)((i * sizeof(struct _ddebug)) >> 10)); 1131 + 1132 + if (di.num_classes) 1133 + v2pr_info(" %d builtin ddebug class-maps\n", di.num_classes); 1424 1134 1425 1135 /* now that ddebug tables are loaded, process all boot args 1426 1136 * again to find and activate queries given in dyndbg params.
+165
lib/test_dynamic_debug.c
··· 1 + // SPDX-License-Identifier: GPL-2.0-only 2 + /* 3 + * Kernel module for testing dynamic_debug 4 + * 5 + * Authors: 6 + * Jim Cromie <jim.cromie@gmail.com> 7 + */ 8 + 9 + #define pr_fmt(fmt) "test_dd: " fmt 10 + 11 + #include <linux/module.h> 12 + 13 + /* run tests by reading or writing sysfs node: do_prints */ 14 + 15 + static void do_prints(void); /* device under test */ 16 + static int param_set_do_prints(const char *instr, const struct kernel_param *kp) 17 + { 18 + do_prints(); 19 + return 0; 20 + } 21 + static int param_get_do_prints(char *buffer, const struct kernel_param *kp) 22 + { 23 + do_prints(); 24 + return scnprintf(buffer, PAGE_SIZE, "did do_prints\n"); 25 + } 26 + static const struct kernel_param_ops param_ops_do_prints = { 27 + .set = param_set_do_prints, 28 + .get = param_get_do_prints, 29 + }; 30 + module_param_cb(do_prints, &param_ops_do_prints, NULL, 0600); 31 + 32 + /* 33 + * Using the CLASSMAP api: 34 + * - classmaps must have corresponding enum 35 + * - enum symbols must match/correlate with class-name strings in the map. 36 + * - base must equal enum's 1st value 37 + * - multiple maps must set their base to share the 0-30 class_id space !! 38 + * (build-bug-on tips welcome) 39 + * Additionally, here: 40 + * - tie together sysname, mapname, bitsname, flagsname 41 + */ 42 + #define DD_SYS_WRAP(_model, _flags) \ 43 + static unsigned long bits_##_model; \ 44 + static struct ddebug_class_param _flags##_model = { \ 45 + .bits = &bits_##_model, \ 46 + .flags = #_flags, \ 47 + .map = &map_##_model, \ 48 + }; \ 49 + module_param_cb(_flags##_##_model, &param_ops_dyndbg_classes, &_flags##_model, 0600) 50 + 51 + /* numeric input, independent bits */ 52 + enum cat_disjoint_bits { 53 + D2_CORE = 0, 54 + D2_DRIVER, 55 + D2_KMS, 56 + D2_PRIME, 57 + D2_ATOMIC, 58 + D2_VBL, 59 + D2_STATE, 60 + D2_LEASE, 61 + D2_DP, 62 + D2_DRMRES }; 63 + DECLARE_DYNDBG_CLASSMAP(map_disjoint_bits, DD_CLASS_TYPE_DISJOINT_BITS, 0, 64 + "D2_CORE", 65 + "D2_DRIVER", 66 + "D2_KMS", 67 + "D2_PRIME", 68 + "D2_ATOMIC", 69 + "D2_VBL", 70 + "D2_STATE", 71 + "D2_LEASE", 72 + "D2_DP", 73 + "D2_DRMRES"); 74 + DD_SYS_WRAP(disjoint_bits, p); 75 + DD_SYS_WRAP(disjoint_bits, T); 76 + 77 + /* symbolic input, independent bits */ 78 + enum cat_disjoint_names { LOW = 11, MID, HI }; 79 + DECLARE_DYNDBG_CLASSMAP(map_disjoint_names, DD_CLASS_TYPE_DISJOINT_NAMES, 10, 80 + "LOW", "MID", "HI"); 81 + DD_SYS_WRAP(disjoint_names, p); 82 + DD_SYS_WRAP(disjoint_names, T); 83 + 84 + /* numeric verbosity, V2 > V1 related */ 85 + enum cat_level_num { V0 = 14, V1, V2, V3, V4, V5, V6, V7 }; 86 + DECLARE_DYNDBG_CLASSMAP(map_level_num, DD_CLASS_TYPE_LEVEL_NUM, 14, 87 + "V0", "V1", "V2", "V3", "V4", "V5", "V6", "V7"); 88 + DD_SYS_WRAP(level_num, p); 89 + DD_SYS_WRAP(level_num, T); 90 + 91 + /* symbolic verbosity */ 92 + enum cat_level_names { L0 = 22, L1, L2, L3, L4, L5, L6, L7 }; 93 + DECLARE_DYNDBG_CLASSMAP(map_level_names, DD_CLASS_TYPE_LEVEL_NAMES, 22, 94 + "L0", "L1", "L2", "L3", "L4", "L5", "L6", "L7"); 95 + DD_SYS_WRAP(level_names, p); 96 + DD_SYS_WRAP(level_names, T); 97 + 98 + /* stand-in for all pr_debug etc */ 99 + #define prdbg(SYM) __pr_debug_cls(SYM, #SYM " msg\n") 100 + 101 + static void do_cats(void) 102 + { 103 + pr_debug("doing categories\n"); 104 + 105 + prdbg(LOW); 106 + prdbg(MID); 107 + prdbg(HI); 108 + 109 + prdbg(D2_CORE); 110 + prdbg(D2_DRIVER); 111 + prdbg(D2_KMS); 112 + prdbg(D2_PRIME); 113 + prdbg(D2_ATOMIC); 114 + prdbg(D2_VBL); 115 + prdbg(D2_STATE); 116 + prdbg(D2_LEASE); 117 + prdbg(D2_DP); 118 + prdbg(D2_DRMRES); 119 + } 120 + 121 + static void do_levels(void) 122 + { 123 + pr_debug("doing levels\n"); 124 + 125 + prdbg(V1); 126 + prdbg(V2); 127 + prdbg(V3); 128 + prdbg(V4); 129 + prdbg(V5); 130 + prdbg(V6); 131 + prdbg(V7); 132 + 133 + prdbg(L1); 134 + prdbg(L2); 135 + prdbg(L3); 136 + prdbg(L4); 137 + prdbg(L5); 138 + prdbg(L6); 139 + prdbg(L7); 140 + } 141 + 142 + static void do_prints(void) 143 + { 144 + do_cats(); 145 + do_levels(); 146 + } 147 + 148 + static int __init test_dynamic_debug_init(void) 149 + { 150 + pr_debug("init start\n"); 151 + do_prints(); 152 + pr_debug("init done\n"); 153 + return 0; 154 + } 155 + 156 + static void __exit test_dynamic_debug_exit(void) 157 + { 158 + pr_debug("exited\n"); 159 + } 160 + 161 + module_init(test_dynamic_debug_init); 162 + module_exit(test_dynamic_debug_exit); 163 + 164 + MODULE_AUTHOR("Jim Cromie <jim.cromie@gmail.com>"); 165 + MODULE_LICENSE("GPL");
-1
net/bluetooth/rfcomm/tty.c
··· 35 35 #include <net/bluetooth/hci_core.h> 36 36 #include <net/bluetooth/rfcomm.h> 37 37 38 - #define RFCOMM_TTY_MAGIC 0x6d02 /* magic number for rfcomm struct */ 39 38 #define RFCOMM_TTY_PORTS RFCOMM_MAX_DEV /* whole lotta rfcomm devices */ 40 39 #define RFCOMM_TTY_MAJOR 216 /* device node major id of the usb/bluetooth.c driver */ 41 40 #define RFCOMM_TTY_MINOR 0