Greg Kroah-Hartman | b244131 | 2017-11-01 15:07:57 +0100 | [diff] [blame] | 1 | // SPDX-License-Identifier: GPL-2.0 |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 2 | /* |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 3 | * Hypervisor filesystem for Linux on s390. Diag 204 and 224 |
| 4 | * implementation. |
| 5 | * |
Michael Holzheu | f55495b | 2008-12-25 13:39:39 +0100 | [diff] [blame] | 6 | * Copyright IBM Corp. 2006, 2008 |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 7 | * Author(s): Michael Holzheu <holzheu@de.ibm.com> |
| 8 | */ |
| 9 | |
Michael Holzheu | f55495b | 2008-12-25 13:39:39 +0100 | [diff] [blame] | 10 | #define KMSG_COMPONENT "hypfs" |
| 11 | #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt |
| 12 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 13 | #include <linux/types.h> |
| 14 | #include <linux/errno.h> |
Heiko Carstens | 33b26d7 | 2009-03-31 19:16:02 +0200 | [diff] [blame] | 15 | #include <linux/slab.h> |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 16 | #include <linux/string.h> |
| 17 | #include <linux/vmalloc.h> |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 18 | #include <linux/mm.h> |
Martin Schwidefsky | 1ec2772 | 2015-08-20 17:28:44 +0200 | [diff] [blame] | 19 | #include <asm/diag.h> |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 20 | #include <asm/ebcdic.h> |
| 21 | #include "hypfs.h" |
| 22 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 23 | #define TMP_SIZE 64 /* size of temporary buffers */ |
| 24 | |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 25 | #define DBFS_D204_HDR_VERSION 0 |
| 26 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 27 | static char *diag224_cpu_names; /* diag 224 name table */ |
| 28 | static enum diag204_sc diag204_store_sc; /* used subcode for store */ |
| 29 | static enum diag204_format diag204_info_type; /* used diag 204 data format */ |
| 30 | |
| 31 | static void *diag204_buf; /* 4K aligned buffer for diag204 data */ |
| 32 | static void *diag204_buf_vmalloc; /* vmalloc pointer for diag204 data */ |
| 33 | static int diag204_buf_pages; /* number of pages for diag204 data */ |
| 34 | |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 35 | static struct dentry *dbfs_d204_file; |
| 36 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 37 | /* |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 38 | * DIAG 204 member access functions. |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 39 | * |
| 40 | * Since we have two different diag 204 data formats for old and new s390 |
| 41 | * machines, we do not access the structs directly, but use getter functions for |
| 42 | * each struct member instead. This should make the code more readable. |
| 43 | */ |
| 44 | |
| 45 | /* Time information block */ |
| 46 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 47 | static inline int info_blk_hdr__size(enum diag204_format type) |
| 48 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 49 | if (type == DIAG204_INFO_SIMPLE) |
| 50 | return sizeof(struct diag204_info_blk_hdr); |
| 51 | else /* DIAG204_INFO_EXT */ |
| 52 | return sizeof(struct diag204_x_info_blk_hdr); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 53 | } |
| 54 | |
| 55 | static inline __u8 info_blk_hdr__npar(enum diag204_format type, void *hdr) |
| 56 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 57 | if (type == DIAG204_INFO_SIMPLE) |
| 58 | return ((struct diag204_info_blk_hdr *)hdr)->npar; |
| 59 | else /* DIAG204_INFO_EXT */ |
| 60 | return ((struct diag204_x_info_blk_hdr *)hdr)->npar; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 61 | } |
| 62 | |
| 63 | static inline __u8 info_blk_hdr__flags(enum diag204_format type, void *hdr) |
| 64 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 65 | if (type == DIAG204_INFO_SIMPLE) |
| 66 | return ((struct diag204_info_blk_hdr *)hdr)->flags; |
| 67 | else /* DIAG204_INFO_EXT */ |
| 68 | return ((struct diag204_x_info_blk_hdr *)hdr)->flags; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 69 | } |
| 70 | |
| 71 | static inline __u16 info_blk_hdr__pcpus(enum diag204_format type, void *hdr) |
| 72 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 73 | if (type == DIAG204_INFO_SIMPLE) |
| 74 | return ((struct diag204_info_blk_hdr *)hdr)->phys_cpus; |
| 75 | else /* DIAG204_INFO_EXT */ |
| 76 | return ((struct diag204_x_info_blk_hdr *)hdr)->phys_cpus; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 77 | } |
| 78 | |
| 79 | /* Partition header */ |
| 80 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 81 | static inline int part_hdr__size(enum diag204_format type) |
| 82 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 83 | if (type == DIAG204_INFO_SIMPLE) |
| 84 | return sizeof(struct diag204_part_hdr); |
| 85 | else /* DIAG204_INFO_EXT */ |
| 86 | return sizeof(struct diag204_x_part_hdr); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 87 | } |
| 88 | |
| 89 | static inline __u8 part_hdr__rcpus(enum diag204_format type, void *hdr) |
| 90 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 91 | if (type == DIAG204_INFO_SIMPLE) |
| 92 | return ((struct diag204_part_hdr *)hdr)->cpus; |
| 93 | else /* DIAG204_INFO_EXT */ |
| 94 | return ((struct diag204_x_part_hdr *)hdr)->rcpus; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | static inline void part_hdr__part_name(enum diag204_format type, void *hdr, |
| 98 | char *name) |
| 99 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 100 | if (type == DIAG204_INFO_SIMPLE) |
| 101 | memcpy(name, ((struct diag204_part_hdr *)hdr)->part_name, |
| 102 | DIAG204_LPAR_NAME_LEN); |
| 103 | else /* DIAG204_INFO_EXT */ |
| 104 | memcpy(name, ((struct diag204_x_part_hdr *)hdr)->part_name, |
| 105 | DIAG204_LPAR_NAME_LEN); |
| 106 | EBCASC(name, DIAG204_LPAR_NAME_LEN); |
| 107 | name[DIAG204_LPAR_NAME_LEN] = 0; |
Heiko Carstens | 1d802e2 | 2009-12-18 17:43:27 +0100 | [diff] [blame] | 108 | strim(name); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 109 | } |
| 110 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 111 | /* CPU info block */ |
| 112 | |
| 113 | static inline int cpu_info__size(enum diag204_format type) |
| 114 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 115 | if (type == DIAG204_INFO_SIMPLE) |
| 116 | return sizeof(struct diag204_cpu_info); |
| 117 | else /* DIAG204_INFO_EXT */ |
| 118 | return sizeof(struct diag204_x_cpu_info); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 119 | } |
| 120 | |
| 121 | static inline __u8 cpu_info__ctidx(enum diag204_format type, void *hdr) |
| 122 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 123 | if (type == DIAG204_INFO_SIMPLE) |
| 124 | return ((struct diag204_cpu_info *)hdr)->ctidx; |
| 125 | else /* DIAG204_INFO_EXT */ |
| 126 | return ((struct diag204_x_cpu_info *)hdr)->ctidx; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 127 | } |
| 128 | |
| 129 | static inline __u16 cpu_info__cpu_addr(enum diag204_format type, void *hdr) |
| 130 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 131 | if (type == DIAG204_INFO_SIMPLE) |
| 132 | return ((struct diag204_cpu_info *)hdr)->cpu_addr; |
| 133 | else /* DIAG204_INFO_EXT */ |
| 134 | return ((struct diag204_x_cpu_info *)hdr)->cpu_addr; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 135 | } |
| 136 | |
| 137 | static inline __u64 cpu_info__acc_time(enum diag204_format type, void *hdr) |
| 138 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 139 | if (type == DIAG204_INFO_SIMPLE) |
| 140 | return ((struct diag204_cpu_info *)hdr)->acc_time; |
| 141 | else /* DIAG204_INFO_EXT */ |
| 142 | return ((struct diag204_x_cpu_info *)hdr)->acc_time; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 143 | } |
| 144 | |
| 145 | static inline __u64 cpu_info__lp_time(enum diag204_format type, void *hdr) |
| 146 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 147 | if (type == DIAG204_INFO_SIMPLE) |
| 148 | return ((struct diag204_cpu_info *)hdr)->lp_time; |
| 149 | else /* DIAG204_INFO_EXT */ |
| 150 | return ((struct diag204_x_cpu_info *)hdr)->lp_time; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 151 | } |
| 152 | |
| 153 | static inline __u64 cpu_info__online_time(enum diag204_format type, void *hdr) |
| 154 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 155 | if (type == DIAG204_INFO_SIMPLE) |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 156 | return 0; /* online_time not available in simple info */ |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 157 | else /* DIAG204_INFO_EXT */ |
| 158 | return ((struct diag204_x_cpu_info *)hdr)->online_time; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 159 | } |
| 160 | |
| 161 | /* Physical header */ |
| 162 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 163 | static inline int phys_hdr__size(enum diag204_format type) |
| 164 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 165 | if (type == DIAG204_INFO_SIMPLE) |
| 166 | return sizeof(struct diag204_phys_hdr); |
| 167 | else /* DIAG204_INFO_EXT */ |
| 168 | return sizeof(struct diag204_x_phys_hdr); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 169 | } |
| 170 | |
| 171 | static inline __u8 phys_hdr__cpus(enum diag204_format type, void *hdr) |
| 172 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 173 | if (type == DIAG204_INFO_SIMPLE) |
| 174 | return ((struct diag204_phys_hdr *)hdr)->cpus; |
| 175 | else /* DIAG204_INFO_EXT */ |
| 176 | return ((struct diag204_x_phys_hdr *)hdr)->cpus; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 177 | } |
| 178 | |
| 179 | /* Physical CPU info block */ |
| 180 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 181 | static inline int phys_cpu__size(enum diag204_format type) |
| 182 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 183 | if (type == DIAG204_INFO_SIMPLE) |
| 184 | return sizeof(struct diag204_phys_cpu); |
| 185 | else /* DIAG204_INFO_EXT */ |
| 186 | return sizeof(struct diag204_x_phys_cpu); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 187 | } |
| 188 | |
| 189 | static inline __u16 phys_cpu__cpu_addr(enum diag204_format type, void *hdr) |
| 190 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 191 | if (type == DIAG204_INFO_SIMPLE) |
| 192 | return ((struct diag204_phys_cpu *)hdr)->cpu_addr; |
| 193 | else /* DIAG204_INFO_EXT */ |
| 194 | return ((struct diag204_x_phys_cpu *)hdr)->cpu_addr; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 195 | } |
| 196 | |
| 197 | static inline __u64 phys_cpu__mgm_time(enum diag204_format type, void *hdr) |
| 198 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 199 | if (type == DIAG204_INFO_SIMPLE) |
| 200 | return ((struct diag204_phys_cpu *)hdr)->mgm_time; |
| 201 | else /* DIAG204_INFO_EXT */ |
| 202 | return ((struct diag204_x_phys_cpu *)hdr)->mgm_time; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 203 | } |
| 204 | |
| 205 | static inline __u64 phys_cpu__ctidx(enum diag204_format type, void *hdr) |
| 206 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 207 | if (type == DIAG204_INFO_SIMPLE) |
| 208 | return ((struct diag204_phys_cpu *)hdr)->ctidx; |
| 209 | else /* DIAG204_INFO_EXT */ |
| 210 | return ((struct diag204_x_phys_cpu *)hdr)->ctidx; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 211 | } |
| 212 | |
| 213 | /* Diagnose 204 functions */ |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 214 | /* |
| 215 | * For the old diag subcode 4 with simple data format we have to use real |
| 216 | * memory. If we use subcode 6 or 7 with extended data format, we can (and |
| 217 | * should) use vmalloc, since we need a lot of memory in that case. Currently |
| 218 | * up to 93 pages! |
| 219 | */ |
| 220 | |
| 221 | static void diag204_free_buffer(void) |
| 222 | { |
| 223 | if (!diag204_buf) |
| 224 | return; |
| 225 | if (diag204_buf_vmalloc) { |
| 226 | vfree(diag204_buf_vmalloc); |
| 227 | diag204_buf_vmalloc = NULL; |
| 228 | } else { |
| 229 | free_pages((unsigned long) diag204_buf, 0); |
| 230 | } |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 231 | diag204_buf = NULL; |
| 232 | } |
| 233 | |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 234 | static void *page_align_ptr(void *ptr) |
| 235 | { |
| 236 | return (void *) PAGE_ALIGN((unsigned long) ptr); |
| 237 | } |
| 238 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 239 | static void *diag204_alloc_vbuf(int pages) |
| 240 | { |
| 241 | /* The buffer has to be page aligned! */ |
| 242 | diag204_buf_vmalloc = vmalloc(PAGE_SIZE * (pages + 1)); |
| 243 | if (!diag204_buf_vmalloc) |
| 244 | return ERR_PTR(-ENOMEM); |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 245 | diag204_buf = page_align_ptr(diag204_buf_vmalloc); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 246 | diag204_buf_pages = pages; |
| 247 | return diag204_buf; |
| 248 | } |
| 249 | |
| 250 | static void *diag204_alloc_rbuf(void) |
| 251 | { |
| 252 | diag204_buf = (void*)__get_free_pages(GFP_KERNEL,0); |
Christian Borntraeger | 86b2247 | 2006-12-15 17:18:10 +0100 | [diff] [blame] | 253 | if (!diag204_buf) |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 254 | return ERR_PTR(-ENOMEM); |
| 255 | diag204_buf_pages = 1; |
| 256 | return diag204_buf; |
| 257 | } |
| 258 | |
| 259 | static void *diag204_get_buffer(enum diag204_format fmt, int *pages) |
| 260 | { |
| 261 | if (diag204_buf) { |
| 262 | *pages = diag204_buf_pages; |
| 263 | return diag204_buf; |
| 264 | } |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 265 | if (fmt == DIAG204_INFO_SIMPLE) { |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 266 | *pages = 1; |
| 267 | return diag204_alloc_rbuf(); |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 268 | } else {/* DIAG204_INFO_EXT */ |
| 269 | *pages = diag204((unsigned long)DIAG204_SUBC_RSI | |
| 270 | (unsigned long)DIAG204_INFO_EXT, 0, NULL); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 271 | if (*pages <= 0) |
| 272 | return ERR_PTR(-ENOSYS); |
| 273 | else |
| 274 | return diag204_alloc_vbuf(*pages); |
| 275 | } |
| 276 | } |
| 277 | |
| 278 | /* |
| 279 | * diag204_probe() has to find out, which type of diagnose 204 implementation |
| 280 | * we have on our machine. Currently there are three possible scanarios: |
| 281 | * - subcode 4 + simple data format (only one page) |
| 282 | * - subcode 4-6 + extended data format |
| 283 | * - subcode 4-7 + extended data format |
| 284 | * |
| 285 | * Subcode 5 is used to retrieve the size of the data, provided by subcodes |
| 286 | * 6 and 7. Subcode 7 basically has the same function as subcode 6. In addition |
| 287 | * to subcode 6 it provides also information about secondary cpus. |
| 288 | * In order to get as much information as possible, we first try |
| 289 | * subcode 7, then 6 and if both fail, we use subcode 4. |
| 290 | */ |
| 291 | |
| 292 | static int diag204_probe(void) |
| 293 | { |
| 294 | void *buf; |
| 295 | int pages, rc; |
| 296 | |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 297 | buf = diag204_get_buffer(DIAG204_INFO_EXT, &pages); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 298 | if (!IS_ERR(buf)) { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 299 | if (diag204((unsigned long)DIAG204_SUBC_STIB7 | |
| 300 | (unsigned long)DIAG204_INFO_EXT, pages, buf) >= 0) { |
| 301 | diag204_store_sc = DIAG204_SUBC_STIB7; |
| 302 | diag204_info_type = DIAG204_INFO_EXT; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 303 | goto out; |
| 304 | } |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 305 | if (diag204((unsigned long)DIAG204_SUBC_STIB6 | |
| 306 | (unsigned long)DIAG204_INFO_EXT, pages, buf) >= 0) { |
| 307 | diag204_store_sc = DIAG204_SUBC_STIB6; |
| 308 | diag204_info_type = DIAG204_INFO_EXT; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 309 | goto out; |
| 310 | } |
| 311 | diag204_free_buffer(); |
| 312 | } |
| 313 | |
| 314 | /* subcodes 6 and 7 failed, now try subcode 4 */ |
| 315 | |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 316 | buf = diag204_get_buffer(DIAG204_INFO_SIMPLE, &pages); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 317 | if (IS_ERR(buf)) { |
| 318 | rc = PTR_ERR(buf); |
| 319 | goto fail_alloc; |
| 320 | } |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 321 | if (diag204((unsigned long)DIAG204_SUBC_STIB4 | |
| 322 | (unsigned long)DIAG204_INFO_SIMPLE, pages, buf) >= 0) { |
| 323 | diag204_store_sc = DIAG204_SUBC_STIB4; |
| 324 | diag204_info_type = DIAG204_INFO_SIMPLE; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 325 | goto out; |
| 326 | } else { |
| 327 | rc = -ENOSYS; |
| 328 | goto fail_store; |
| 329 | } |
| 330 | out: |
| 331 | rc = 0; |
| 332 | fail_store: |
| 333 | diag204_free_buffer(); |
| 334 | fail_alloc: |
| 335 | return rc; |
| 336 | } |
| 337 | |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 338 | static int diag204_do_store(void *buf, int pages) |
| 339 | { |
| 340 | int rc; |
| 341 | |
| 342 | rc = diag204((unsigned long) diag204_store_sc | |
| 343 | (unsigned long) diag204_info_type, pages, buf); |
| 344 | return rc < 0 ? -ENOSYS : 0; |
| 345 | } |
| 346 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 347 | static void *diag204_store(void) |
| 348 | { |
| 349 | void *buf; |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 350 | int pages, rc; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 351 | |
| 352 | buf = diag204_get_buffer(diag204_info_type, &pages); |
| 353 | if (IS_ERR(buf)) |
| 354 | goto out; |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 355 | rc = diag204_do_store(buf, pages); |
| 356 | if (rc) |
| 357 | return ERR_PTR(rc); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 358 | out: |
| 359 | return buf; |
| 360 | } |
| 361 | |
| 362 | /* Diagnose 224 functions */ |
| 363 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 364 | static int diag224_get_name_table(void) |
| 365 | { |
| 366 | /* memory must be below 2GB */ |
Michael Holzheu | 237d6e6 | 2016-10-25 16:24:28 +0200 | [diff] [blame] | 367 | diag224_cpu_names = (char *) __get_free_page(GFP_KERNEL | GFP_DMA); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 368 | if (!diag224_cpu_names) |
| 369 | return -ENOMEM; |
Michael Holzheu | c41d4e3 | 2007-05-31 17:38:01 +0200 | [diff] [blame] | 370 | if (diag224(diag224_cpu_names)) { |
Michael Holzheu | 237d6e6 | 2016-10-25 16:24:28 +0200 | [diff] [blame] | 371 | free_page((unsigned long) diag224_cpu_names); |
Heiko Carstens | b8e660b | 2010-02-26 22:37:41 +0100 | [diff] [blame] | 372 | return -EOPNOTSUPP; |
Michael Holzheu | c41d4e3 | 2007-05-31 17:38:01 +0200 | [diff] [blame] | 373 | } |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 374 | EBCASC(diag224_cpu_names + 16, (*diag224_cpu_names + 1) * 16); |
| 375 | return 0; |
| 376 | } |
| 377 | |
| 378 | static void diag224_delete_name_table(void) |
| 379 | { |
Michael Holzheu | 237d6e6 | 2016-10-25 16:24:28 +0200 | [diff] [blame] | 380 | free_page((unsigned long) diag224_cpu_names); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 381 | } |
| 382 | |
| 383 | static int diag224_idx2name(int index, char *name) |
| 384 | { |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 385 | memcpy(name, diag224_cpu_names + ((index + 1) * DIAG204_CPU_NAME_LEN), |
| 386 | DIAG204_CPU_NAME_LEN); |
| 387 | name[DIAG204_CPU_NAME_LEN] = 0; |
Heiko Carstens | 1d802e2 | 2009-12-18 17:43:27 +0100 | [diff] [blame] | 388 | strim(name); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 389 | return 0; |
| 390 | } |
| 391 | |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 392 | struct dbfs_d204_hdr { |
| 393 | u64 len; /* Length of d204 buffer without header */ |
| 394 | u16 version; /* Version of header */ |
| 395 | u8 sc; /* Used subcode */ |
| 396 | char reserved[53]; |
| 397 | } __attribute__ ((packed)); |
| 398 | |
| 399 | struct dbfs_d204 { |
| 400 | struct dbfs_d204_hdr hdr; /* 64 byte header */ |
| 401 | char buf[]; /* d204 buffer */ |
| 402 | } __attribute__ ((packed)); |
| 403 | |
Michael Holzheu | 2fcb368 | 2011-01-05 12:47:43 +0100 | [diff] [blame] | 404 | static int dbfs_d204_create(void **data, void **data_free_ptr, size_t *size) |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 405 | { |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 406 | struct dbfs_d204 *d204; |
| 407 | int rc, buf_size; |
Michael Holzheu | 2fcb368 | 2011-01-05 12:47:43 +0100 | [diff] [blame] | 408 | void *base; |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 409 | |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 410 | buf_size = PAGE_SIZE * (diag204_buf_pages + 1) + sizeof(d204->hdr); |
Joe Perches | dc8a5c9 | 2011-05-28 10:36:21 -0700 | [diff] [blame] | 411 | base = vzalloc(buf_size); |
Michael Holzheu | 2fcb368 | 2011-01-05 12:47:43 +0100 | [diff] [blame] | 412 | if (!base) |
| 413 | return -ENOMEM; |
Michael Holzheu | 2fcb368 | 2011-01-05 12:47:43 +0100 | [diff] [blame] | 414 | d204 = page_align_ptr(base + sizeof(d204->hdr)) - sizeof(d204->hdr); |
| 415 | rc = diag204_do_store(d204->buf, diag204_buf_pages); |
| 416 | if (rc) { |
| 417 | vfree(base); |
| 418 | return rc; |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 419 | } |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 420 | d204->hdr.version = DBFS_D204_HDR_VERSION; |
| 421 | d204->hdr.len = PAGE_SIZE * diag204_buf_pages; |
| 422 | d204->hdr.sc = diag204_store_sc; |
Michael Holzheu | 2fcb368 | 2011-01-05 12:47:43 +0100 | [diff] [blame] | 423 | *data = d204; |
| 424 | *data_free_ptr = base; |
| 425 | *size = d204->hdr.len + sizeof(struct dbfs_d204_hdr); |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 426 | return 0; |
| 427 | } |
| 428 | |
Michael Holzheu | 2fcb368 | 2011-01-05 12:47:43 +0100 | [diff] [blame] | 429 | static struct hypfs_dbfs_file dbfs_file_d204 = { |
| 430 | .name = "diag_204", |
| 431 | .data_create = dbfs_d204_create, |
| 432 | .data_free = vfree, |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 433 | }; |
| 434 | |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 435 | __init int hypfs_diag_init(void) |
| 436 | { |
| 437 | int rc; |
| 438 | |
| 439 | if (diag204_probe()) { |
Michael Holzheu | f55495b | 2008-12-25 13:39:39 +0100 | [diff] [blame] | 440 | pr_err("The hardware system does not support hypfs\n"); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 441 | return -ENODATA; |
| 442 | } |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 443 | if (diag204_info_type == DIAG204_INFO_EXT) { |
Michael Holzheu | 2fcb368 | 2011-01-05 12:47:43 +0100 | [diff] [blame] | 444 | rc = hypfs_dbfs_create_file(&dbfs_file_d204); |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 445 | if (rc) |
Michael Holzheu | 3c8ebca | 2010-10-29 16:50:39 +0200 | [diff] [blame] | 446 | return rc; |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 447 | } |
Michael Holzheu | 3c8ebca | 2010-10-29 16:50:39 +0200 | [diff] [blame] | 448 | if (MACHINE_IS_LPAR) { |
| 449 | rc = diag224_get_name_table(); |
| 450 | if (rc) { |
| 451 | pr_err("The hardware system does not provide all " |
| 452 | "functions required by hypfs\n"); |
| 453 | debugfs_remove(dbfs_d204_file); |
| 454 | return rc; |
| 455 | } |
| 456 | } |
| 457 | return 0; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 458 | } |
| 459 | |
Heiko Carstens | 1375fc1 | 2006-09-20 15:59:12 +0200 | [diff] [blame] | 460 | void hypfs_diag_exit(void) |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 461 | { |
Michael Holzheu | 57b28f6 | 2010-05-17 10:00:20 +0200 | [diff] [blame] | 462 | debugfs_remove(dbfs_d204_file); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 463 | diag224_delete_name_table(); |
| 464 | diag204_free_buffer(); |
Michael Holzheu | 2fcb368 | 2011-01-05 12:47:43 +0100 | [diff] [blame] | 465 | hypfs_dbfs_remove_file(&dbfs_file_d204); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 466 | } |
| 467 | |
| 468 | /* |
| 469 | * Functions to create the directory structure |
| 470 | * ******************************************* |
| 471 | */ |
| 472 | |
Al Viro | e334cf4 | 2013-07-19 17:10:21 +0400 | [diff] [blame] | 473 | static int hypfs_create_cpu_files(struct dentry *cpus_dir, void *cpu_info) |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 474 | { |
| 475 | struct dentry *cpu_dir; |
| 476 | char buffer[TMP_SIZE]; |
| 477 | void *rc; |
| 478 | |
| 479 | snprintf(buffer, TMP_SIZE, "%d", cpu_info__cpu_addr(diag204_info_type, |
| 480 | cpu_info)); |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 481 | cpu_dir = hypfs_mkdir(cpus_dir, buffer); |
| 482 | rc = hypfs_create_u64(cpu_dir, "mgmtime", |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 483 | cpu_info__acc_time(diag204_info_type, cpu_info) - |
| 484 | cpu_info__lp_time(diag204_info_type, cpu_info)); |
| 485 | if (IS_ERR(rc)) |
| 486 | return PTR_ERR(rc); |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 487 | rc = hypfs_create_u64(cpu_dir, "cputime", |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 488 | cpu_info__lp_time(diag204_info_type, cpu_info)); |
| 489 | if (IS_ERR(rc)) |
| 490 | return PTR_ERR(rc); |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 491 | if (diag204_info_type == DIAG204_INFO_EXT) { |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 492 | rc = hypfs_create_u64(cpu_dir, "onlinetime", |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 493 | cpu_info__online_time(diag204_info_type, |
| 494 | cpu_info)); |
| 495 | if (IS_ERR(rc)) |
| 496 | return PTR_ERR(rc); |
| 497 | } |
| 498 | diag224_idx2name(cpu_info__ctidx(diag204_info_type, cpu_info), buffer); |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 499 | rc = hypfs_create_str(cpu_dir, "type", buffer); |
Thomas Meyer | 5eba9bb | 2013-06-01 11:59:51 +0200 | [diff] [blame] | 500 | return PTR_RET(rc); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 501 | } |
| 502 | |
Al Viro | e334cf4 | 2013-07-19 17:10:21 +0400 | [diff] [blame] | 503 | static void *hypfs_create_lpar_files(struct dentry *systems_dir, void *part_hdr) |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 504 | { |
| 505 | struct dentry *cpus_dir; |
| 506 | struct dentry *lpar_dir; |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 507 | char lpar_name[DIAG204_LPAR_NAME_LEN + 1]; |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 508 | void *cpu_info; |
| 509 | int i; |
| 510 | |
| 511 | part_hdr__part_name(diag204_info_type, part_hdr, lpar_name); |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 512 | lpar_name[DIAG204_LPAR_NAME_LEN] = 0; |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 513 | lpar_dir = hypfs_mkdir(systems_dir, lpar_name); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 514 | if (IS_ERR(lpar_dir)) |
| 515 | return lpar_dir; |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 516 | cpus_dir = hypfs_mkdir(lpar_dir, "cpus"); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 517 | if (IS_ERR(cpus_dir)) |
| 518 | return cpus_dir; |
| 519 | cpu_info = part_hdr + part_hdr__size(diag204_info_type); |
| 520 | for (i = 0; i < part_hdr__rcpus(diag204_info_type, part_hdr); i++) { |
| 521 | int rc; |
Al Viro | e334cf4 | 2013-07-19 17:10:21 +0400 | [diff] [blame] | 522 | rc = hypfs_create_cpu_files(cpus_dir, cpu_info); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 523 | if (rc) |
| 524 | return ERR_PTR(rc); |
| 525 | cpu_info += cpu_info__size(diag204_info_type); |
| 526 | } |
| 527 | return cpu_info; |
| 528 | } |
| 529 | |
Al Viro | e334cf4 | 2013-07-19 17:10:21 +0400 | [diff] [blame] | 530 | static int hypfs_create_phys_cpu_files(struct dentry *cpus_dir, void *cpu_info) |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 531 | { |
| 532 | struct dentry *cpu_dir; |
| 533 | char buffer[TMP_SIZE]; |
| 534 | void *rc; |
| 535 | |
| 536 | snprintf(buffer, TMP_SIZE, "%i", phys_cpu__cpu_addr(diag204_info_type, |
| 537 | cpu_info)); |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 538 | cpu_dir = hypfs_mkdir(cpus_dir, buffer); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 539 | if (IS_ERR(cpu_dir)) |
| 540 | return PTR_ERR(cpu_dir); |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 541 | rc = hypfs_create_u64(cpu_dir, "mgmtime", |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 542 | phys_cpu__mgm_time(diag204_info_type, cpu_info)); |
| 543 | if (IS_ERR(rc)) |
| 544 | return PTR_ERR(rc); |
| 545 | diag224_idx2name(phys_cpu__ctidx(diag204_info_type, cpu_info), buffer); |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 546 | rc = hypfs_create_str(cpu_dir, "type", buffer); |
Thomas Meyer | 5eba9bb | 2013-06-01 11:59:51 +0200 | [diff] [blame] | 547 | return PTR_RET(rc); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 548 | } |
| 549 | |
Al Viro | e334cf4 | 2013-07-19 17:10:21 +0400 | [diff] [blame] | 550 | static void *hypfs_create_phys_files(struct dentry *parent_dir, void *phys_hdr) |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 551 | { |
| 552 | int i; |
| 553 | void *cpu_info; |
| 554 | struct dentry *cpus_dir; |
| 555 | |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 556 | cpus_dir = hypfs_mkdir(parent_dir, "cpus"); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 557 | if (IS_ERR(cpus_dir)) |
| 558 | return cpus_dir; |
| 559 | cpu_info = phys_hdr + phys_hdr__size(diag204_info_type); |
| 560 | for (i = 0; i < phys_hdr__cpus(diag204_info_type, phys_hdr); i++) { |
| 561 | int rc; |
Al Viro | e334cf4 | 2013-07-19 17:10:21 +0400 | [diff] [blame] | 562 | rc = hypfs_create_phys_cpu_files(cpus_dir, cpu_info); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 563 | if (rc) |
| 564 | return ERR_PTR(rc); |
| 565 | cpu_info += phys_cpu__size(diag204_info_type); |
| 566 | } |
| 567 | return cpu_info; |
| 568 | } |
| 569 | |
Al Viro | e334cf4 | 2013-07-19 17:10:21 +0400 | [diff] [blame] | 570 | int hypfs_diag_create_files(struct dentry *root) |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 571 | { |
| 572 | struct dentry *systems_dir, *hyp_dir; |
| 573 | void *time_hdr, *part_hdr; |
| 574 | int i, rc; |
| 575 | void *buffer, *ptr; |
| 576 | |
| 577 | buffer = diag204_store(); |
| 578 | if (IS_ERR(buffer)) |
| 579 | return PTR_ERR(buffer); |
| 580 | |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 581 | systems_dir = hypfs_mkdir(root, "systems"); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 582 | if (IS_ERR(systems_dir)) { |
| 583 | rc = PTR_ERR(systems_dir); |
| 584 | goto err_out; |
| 585 | } |
| 586 | time_hdr = (struct x_info_blk_hdr *)buffer; |
| 587 | part_hdr = time_hdr + info_blk_hdr__size(diag204_info_type); |
| 588 | for (i = 0; i < info_blk_hdr__npar(diag204_info_type, time_hdr); i++) { |
Al Viro | e334cf4 | 2013-07-19 17:10:21 +0400 | [diff] [blame] | 589 | part_hdr = hypfs_create_lpar_files(systems_dir, part_hdr); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 590 | if (IS_ERR(part_hdr)) { |
| 591 | rc = PTR_ERR(part_hdr); |
| 592 | goto err_out; |
| 593 | } |
| 594 | } |
Janosch Frank | e65f30e | 2016-02-04 10:24:52 +0100 | [diff] [blame] | 595 | if (info_blk_hdr__flags(diag204_info_type, time_hdr) & |
| 596 | DIAG204_LPAR_PHYS_FLG) { |
Al Viro | e334cf4 | 2013-07-19 17:10:21 +0400 | [diff] [blame] | 597 | ptr = hypfs_create_phys_files(root, part_hdr); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 598 | if (IS_ERR(ptr)) { |
| 599 | rc = PTR_ERR(ptr); |
| 600 | goto err_out; |
| 601 | } |
| 602 | } |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 603 | hyp_dir = hypfs_mkdir(root, "hyp"); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 604 | if (IS_ERR(hyp_dir)) { |
| 605 | rc = PTR_ERR(hyp_dir); |
| 606 | goto err_out; |
| 607 | } |
Al Viro | a118cfd | 2013-07-19 18:05:21 +0400 | [diff] [blame] | 608 | ptr = hypfs_create_str(hyp_dir, "type", "LPAR Hypervisor"); |
Michael Holzheu | 24bbb1f | 2006-06-23 02:05:06 -0700 | [diff] [blame] | 609 | if (IS_ERR(ptr)) { |
| 610 | rc = PTR_ERR(ptr); |
| 611 | goto err_out; |
| 612 | } |
| 613 | rc = 0; |
| 614 | |
| 615 | err_out: |
| 616 | return rc; |
| 617 | } |