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

docs: packing: move it to core-api book and adjust markups

The packing.txt file was misplaced, as docs should be part of
a documentation book, and not at the root dir.

So, move it to the core-api directory and add to its index.

Also, ensure that the file will be properly parsed and the bitmap
ascii artwork will use a monotonic font.

Fixes: 554aae35007e ("lib: Add support for generic packing operations")
Signed-off-by: Mauro Carvalho Chehab <mchehab+samsung@kernel.org>
Reviewed-by: Vladimir Oltean <olteanv@gmail.com>
Tested-by: Vladimir Oltean <olteanv@gmail.com>
Reviewed-by: Mike Rapoport <rppt@linux.ibm.com>
Signed-off-by: Jonathan Corbet <corbet@lwn.net>

authored by

Mauro Carvalho Chehab and committed by
Jonathan Corbet
1ec779b9 f6ae22d6

+51 -33
+1
Documentation/core-api/index.rst
··· 25 25 librs 26 26 genalloc 27 27 errseq 28 + packing 28 29 printk-formats 29 30 circular-buffers 30 31 generic-radix-tree
+49 -32
Documentation/packing.txt Documentation/core-api/packing.rst
··· 30 30 ------------ 31 31 32 32 This API deals with 2 basic operations: 33 + 33 34 - Packing a CPU-usable number into a memory buffer (with hardware 34 35 constraints/quirks) 35 36 - Unpacking a memory buffer (which has hardware constraints/quirks) ··· 50 49 51 50 1. Normally (no quirks), we would do it like this: 52 51 53 - 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 54 - 7 6 5 4 55 - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 56 - 3 2 1 0 52 + :: 53 + 54 + 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 55 + 7 6 5 4 56 + 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 57 + 3 2 1 0 57 58 58 59 That is, the MSByte (7) of the CPU-usable u64 sits at memory offset 0, and the 59 60 LSByte (0) of the u64 sits at memory offset 7. ··· 66 63 67 64 2. If QUIRK_MSB_ON_THE_RIGHT is set, we do it like this: 68 65 69 - 56 57 58 59 60 61 62 63 48 49 50 51 52 53 54 55 40 41 42 43 44 45 46 47 32 33 34 35 36 37 38 39 70 - 7 6 5 4 71 - 24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 72 - 3 2 1 0 66 + :: 67 + 68 + 56 57 58 59 60 61 62 63 48 49 50 51 52 53 54 55 40 41 42 43 44 45 46 47 32 33 34 35 36 37 38 39 69 + 7 6 5 4 70 + 24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 71 + 3 2 1 0 73 72 74 73 That is, QUIRK_MSB_ON_THE_RIGHT does not affect byte positioning, but 75 74 inverts bit offsets inside a byte. ··· 79 74 80 75 3. If QUIRK_LITTLE_ENDIAN is set, we do it like this: 81 76 82 - 39 38 37 36 35 34 33 32 47 46 45 44 43 42 41 40 55 54 53 52 51 50 49 48 63 62 61 60 59 58 57 56 83 - 4 5 6 7 84 - 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24 85 - 0 1 2 3 77 + :: 78 + 79 + 39 38 37 36 35 34 33 32 47 46 45 44 43 42 41 40 55 54 53 52 51 50 49 48 63 62 61 60 59 58 57 56 80 + 4 5 6 7 81 + 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24 82 + 0 1 2 3 86 83 87 84 Therefore, QUIRK_LITTLE_ENDIAN means that inside the memory region, every 88 85 byte from each 4-byte word is placed at its mirrored position compared to ··· 93 86 4. If QUIRK_MSB_ON_THE_RIGHT and QUIRK_LITTLE_ENDIAN are both set, we do it 94 87 like this: 95 88 96 - 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 97 - 4 5 6 7 98 - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 99 - 0 1 2 3 89 + :: 90 + 91 + 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 92 + 4 5 6 7 93 + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 94 + 0 1 2 3 100 95 101 96 102 97 5. If just QUIRK_LSW32_IS_FIRST is set, we do it like this: 103 98 104 - 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 105 - 3 2 1 0 106 - 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 107 - 7 6 5 4 99 + :: 100 + 101 + 31 30 29 28 27 26 25 24 23 22 21 20 19 18 17 16 15 14 13 12 11 10 9 8 7 6 5 4 3 2 1 0 102 + 3 2 1 0 103 + 63 62 61 60 59 58 57 56 55 54 53 52 51 50 49 48 47 46 45 44 43 42 41 40 39 38 37 36 35 34 33 32 104 + 7 6 5 4 108 105 109 106 In this case the 8 byte memory region is interpreted as follows: first 110 107 4 bytes correspond to the least significant 4-byte word, next 4 bytes to ··· 118 107 6. If QUIRK_LSW32_IS_FIRST and QUIRK_MSB_ON_THE_RIGHT are set, we do it like 119 108 this: 120 109 121 - 24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 122 - 3 2 1 0 123 - 56 57 58 59 60 61 62 63 48 49 50 51 52 53 54 55 40 41 42 43 44 45 46 47 32 33 34 35 36 37 38 39 124 - 7 6 5 4 110 + :: 111 + 112 + 24 25 26 27 28 29 30 31 16 17 18 19 20 21 22 23 8 9 10 11 12 13 14 15 0 1 2 3 4 5 6 7 113 + 3 2 1 0 114 + 56 57 58 59 60 61 62 63 48 49 50 51 52 53 54 55 40 41 42 43 44 45 46 47 32 33 34 35 36 37 38 39 115 + 7 6 5 4 125 116 126 117 127 118 7. If QUIRK_LSW32_IS_FIRST and QUIRK_LITTLE_ENDIAN are set, it looks like 128 119 this: 129 120 130 - 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24 131 - 0 1 2 3 132 - 39 38 37 36 35 34 33 32 47 46 45 44 43 42 41 40 55 54 53 52 51 50 49 48 63 62 61 60 59 58 57 56 133 - 4 5 6 7 121 + :: 122 + 123 + 7 6 5 4 3 2 1 0 15 14 13 12 11 10 9 8 23 22 21 20 19 18 17 16 31 30 29 28 27 26 25 24 124 + 0 1 2 3 125 + 39 38 37 36 35 34 33 32 47 46 45 44 43 42 41 40 55 54 53 52 51 50 49 48 63 62 61 60 59 58 57 56 126 + 4 5 6 7 134 127 135 128 136 129 8. If QUIRK_LSW32_IS_FIRST, QUIRK_LITTLE_ENDIAN and QUIRK_MSB_ON_THE_RIGHT 137 130 are set, it looks like this: 138 131 139 - 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 140 - 0 1 2 3 141 - 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 142 - 4 5 6 7 132 + :: 133 + 134 + 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 135 + 0 1 2 3 136 + 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 137 + 4 5 6 7 143 138 144 139 145 140 We always think of our offsets as if there were no quirk, and we translate
+1 -1
MAINTAINERS
··· 12099 12099 S: Supported 12100 12100 F: lib/packing.c 12101 12101 F: include/linux/packing.h 12102 - F: Documentation/packing.txt 12102 + F: Documentation/core-api/packing.rst 12103 12103 12104 12104 PADATA PARALLEL EXECUTION MECHANISM 12105 12105 M: Steffen Klassert <steffen.klassert@secunet.com>