Lines Matching +full:no +full:- +full:dump +full:- +full:oops
1 // SPDX-License-Identifier: GPL-2.0-or-later
51 .name = "ibm,rtas-log",
54 .index = -1,
60 .name = "lnx,oops-log",
63 .index = -1,
69 "ibm,rtas-log",
71 "lnx,oops-log",
79 .dump = oops_to_nvram
83 * For capturing and compressing an oops or panic report...
87 * oops_buf[] holds the compressed text, preceded by a oops header.
88 * oops header has u16 holding the version of oops header (to differentiate
95 * +- oops_buf
96 * | +- oops_data
98 * +-----------+-----------+-----------+------------------------+
101 * +-----------+-----------+-----------+------------------------+
103 * +- oops_log_info
105 * We preallocate these buffers during init to avoid kmalloc during oops/panic.
122 .index = -1,
129 .name = "of-config",
130 .index = -1,
137 .index = -1,
144 -1,
145 -1,
146 -1
155 * is no way to guarantee that the OS or the machine is in a state to
158 * IO address, there is no way of guaranteeing that the device driver
165 * +-----------+----------+--------+------------+------------------+
167 * |0 |1 |2 3|4 15|16 length-1|
168 * +-----------+----------+--------+------------+------------------+
171 * +--------------+------------+-----------------------------------+
173 * |0 3|4 7|8 error_log_size-1|
174 * +--------------+------------+-----------------------------------+
189 if (part->index == -1) in nvram_write_os_partition()
190 return -ESPIPE; in nvram_write_os_partition()
192 if (length > part->size) in nvram_write_os_partition()
193 length = part->size; in nvram_write_os_partition()
198 tmp_index = part->index; in nvram_write_os_partition()
227 if (part->index == -1) in nvram_read_partition()
228 return -1; in nvram_read_partition()
230 if (length > part->size) in nvram_read_partition()
231 length = part->size; in nvram_read_partition()
233 tmp_index = part->index; in nvram_read_partition()
235 if (part->os_partition) { in nvram_read_partition()
249 if (part->os_partition) { in nvram_read_partition()
263 * - If it's large enough, use it.
264 * - Otherwise, recycle it and keep going.
272 * Returns 0 on success, else -1.
280 p = nvram_find_partition(part->name, NVRAM_SIG_OS, &size); in nvram_init_os_partition()
283 if (p && size < part->min_size) { in nvram_init_os_partition()
285 " removing it...\n", part->name); in nvram_init_os_partition()
286 nvram_remove_partition(part->name, NVRAM_SIG_OS, NULL); in nvram_init_os_partition()
292 p = nvram_create_partition(part->name, NVRAM_SIG_OS, in nvram_init_os_partition()
293 part->req_size, part->min_size); in nvram_init_os_partition()
294 if (p == -ENOSPC) { in nvram_init_os_partition()
295 pr_info("nvram: No room to create %s partition, " in nvram_init_os_partition()
297 part->name); in nvram_init_os_partition()
300 p = nvram_create_partition(part->name, NVRAM_SIG_OS, in nvram_init_os_partition()
301 part->req_size, part->min_size); in nvram_init_os_partition()
307 " partition, err %d\n", part->name, (int)p); in nvram_init_os_partition()
308 return -1; in nvram_init_os_partition()
311 part->index = p; in nvram_init_os_partition()
312 part->size = nvram_get_partition_size(p) - sizeof(struct err_log_info); in nvram_init_os_partition()
323 ret = -EIO; in nvram_compress()
360 pr_err("nvram: logging uncompressed oops/panic report\n"); in zip_oops()
361 return -1; in zip_oops()
363 oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); in zip_oops()
364 oops_hdr->report_length = cpu_to_be16(zipped_len); in zip_oops()
365 oops_hdr->timestamp = cpu_to_be64(ktime_get_real_seconds()); in zip_oops()
373 read_type = -1; in nvram_pstore_open()
378 * nvram_pstore_write - pstore write callback for nvram
381 * Called by pstore_dump() when an oops or panic report is logged in the
392 if (record->part > 1 || (record->type != PSTORE_TYPE_DMESG)) in nvram_pstore_write()
393 return -1; in nvram_pstore_write()
396 return -1; in nvram_pstore_write()
398 oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); in nvram_pstore_write()
399 oops_hdr->report_length = cpu_to_be16(record->size); in nvram_pstore_write()
400 oops_hdr->timestamp = cpu_to_be64(ktime_get_real_seconds()); in nvram_pstore_write()
402 if (record->compressed) in nvram_pstore_write()
406 (int) (sizeof(*oops_hdr) + record->size), err_type, in nvram_pstore_write()
407 record->count); in nvram_pstore_write()
412 record->id = record->part; in nvram_pstore_write()
417 * Reads the oops/panic report, rtas, of-config and common partition.
435 record->type = PSTORE_TYPE_DMESG; in nvram_pstore_read()
440 record->type = PSTORE_TYPE_PPC_COMMON; in nvram_pstore_read()
441 record->id = PSTORE_TYPE_PPC_COMMON; in nvram_pstore_read()
442 record->time.tv_sec = 0; in nvram_pstore_read()
443 record->time.tv_nsec = 0; in nvram_pstore_read()
448 record->type = PSTORE_TYPE_PPC_RTAS; in nvram_pstore_read()
449 record->time.tv_sec = last_rtas_event; in nvram_pstore_read()
450 record->time.tv_nsec = 0; in nvram_pstore_read()
455 record->type = PSTORE_TYPE_PPC_OF; in nvram_pstore_read()
456 record->id = PSTORE_TYPE_PPC_OF; in nvram_pstore_read()
457 record->time.tv_sec = 0; in nvram_pstore_read()
458 record->time.tv_nsec = 0; in nvram_pstore_read()
465 record->type = PSTORE_TYPE_PPC_OPAL; in nvram_pstore_read()
466 record->id = PSTORE_TYPE_PPC_OPAL; in nvram_pstore_read()
467 record->time.tv_sec = 0; in nvram_pstore_read()
468 record->time.tv_nsec = 0; in nvram_pstore_read()
475 if (!part->os_partition) { in nvram_pstore_read()
476 p = nvram_find_partition(part->name, sig, &size); in nvram_pstore_read()
479 "err %d\n", part->name, (int)p); in nvram_pstore_read()
482 part->index = p; in nvram_pstore_read()
483 part->size = size; in nvram_pstore_read()
486 buff = kmalloc(part->size, GFP_KERNEL); in nvram_pstore_read()
489 return -ENOMEM; in nvram_pstore_read()
491 if (nvram_read_partition(part, buff, part->size, &err_type, &id_no)) { in nvram_pstore_read()
496 record->count = 0; in nvram_pstore_read()
498 if (part->os_partition) in nvram_pstore_read()
499 record->id = id_no; in nvram_pstore_read()
505 if (be16_to_cpu(oops_hdr->version) < OOPS_HDR_VERSION) { in nvram_pstore_read()
506 /* Old format oops header had 2-byte record size */ in nvram_pstore_read()
508 length = be16_to_cpu(oops_hdr->version); in nvram_pstore_read()
509 record->time.tv_sec = 0; in nvram_pstore_read()
510 record->time.tv_nsec = 0; in nvram_pstore_read()
513 length = be16_to_cpu(oops_hdr->report_length); in nvram_pstore_read()
514 record->time.tv_sec = be64_to_cpu(oops_hdr->timestamp); in nvram_pstore_read()
515 record->time.tv_nsec = 0; in nvram_pstore_read()
517 record->buf = kmemdup(buff + hdr_size, length, GFP_KERNEL); in nvram_pstore_read()
519 if (record->buf == NULL) in nvram_pstore_read()
520 return -ENOMEM; in nvram_pstore_read()
522 record->ecc_notice_size = 0; in nvram_pstore_read()
524 record->compressed = true; in nvram_pstore_read()
526 record->compressed = false; in nvram_pstore_read()
530 record->buf = buff; in nvram_pstore_read()
531 return part->size; in nvram_pstore_read()
557 if (rc && (rc != -EPERM)) in nvram_pstore_init()
567 return -1; in nvram_pstore_init()
579 pr_err("nvram: Failed to initialize oops partition!"); in nvram_init_oops_partition()
583 " RTAS errors and oops/panic reports\n", in nvram_init_oops_partition()
588 pr_err("nvram: Failed to initialize oops partition!"); in nvram_init_oops_partition()
594 pr_err("nvram: No memory for %s partition\n", in nvram_init_oops_partition()
599 oops_data_sz = oops_log_partition.size - sizeof(struct oops_log_info); in nvram_init_oops_partition()
608 * severity prefix) will reduce the oops/panic report to at most in nvram_init_oops_partition()
617 pr_err("nvram: No memory for compression workspace; " in nvram_init_oops_partition()
624 pr_err("No memory for uncompressed %s data; " in nvram_init_oops_partition()
639 * This is our kmsg_dump callback, called after an oops or panic report
642 * that we think will compress sufficiently to fit in the lnx,oops-log
656 int rc = -1; in oops_to_nvram()
695 oops_hdr->version = cpu_to_be16(OOPS_HDR_VERSION); in oops_to_nvram()
696 oops_hdr->report_length = cpu_to_be16(text_len); in oops_to_nvram()
697 oops_hdr->timestamp = cpu_to_be64(ktime_get_real_seconds()); in oops_to_nvram()
712 printk(KERN_WARNING "--------%s---------\n", label); in nvram_print_partitions()
716 tmp_part->index, tmp_part->header.signature, in nvram_print_partitions()
717 tmp_part->header.checksum, tmp_part->header.length, in nvram_print_partitions()
718 tmp_part->header.name); in nvram_print_partitions()
730 memcpy(&phead, &part->header, NVRAM_HEADER_LEN); in nvram_write_header()
733 tmp_index = part->index; in nvram_write_header()
743 unsigned short *sp = (unsigned short *)p->name; /* assume 6 shorts */ in nvram_checksum()
744 c_sum = p->signature + p->length + sp[0] + sp[1] + sp[2] + sp[3] + sp[4] + sp[5]; in nvram_checksum()
761 if (part->header.signature != sig) in nvram_can_remove_partition()
764 if (strncmp(name, part->header.name, 12)) in nvram_can_remove_partition()
769 if (!strncmp(*except, part->header.name, 12)) in nvram_can_remove_partition()
777 * nvram_remove_partition - Remove one or more partitions in nvram
796 part->header.signature = NVRAM_SIG_FREE; in nvram_remove_partition()
797 memset(part->header.name, 'w', 12); in nvram_remove_partition()
798 part->header.checksum = nvram_checksum(&part->header); in nvram_remove_partition()
809 if (part->header.signature != NVRAM_SIG_FREE) { in nvram_remove_partition()
814 prev->header.length += part->header.length; in nvram_remove_partition()
815 prev->header.checksum = nvram_checksum(&prev->header); in nvram_remove_partition()
821 list_del(&part->partition); in nvram_remove_partition()
831 * nvram_create_partition - Create a partition in nvram
860 /* If no minimum size specified, make it the same as the in nvram_create_partition()
866 return -EINVAL; in nvram_create_partition()
875 if (part->header.signature != NVRAM_SIG_FREE) in nvram_create_partition()
878 if (part->header.length >= req_size) { in nvram_create_partition()
883 if (part->header.length > size && in nvram_create_partition()
884 part->header.length >= min_size) { in nvram_create_partition()
885 size = part->header.length; in nvram_create_partition()
890 return -ENOSPC; in nvram_create_partition()
896 return -ENOMEM; in nvram_create_partition()
899 new_part->index = free_part->index; in nvram_create_partition()
900 new_part->header.signature = sig; in nvram_create_partition()
901 new_part->header.length = size; in nvram_create_partition()
902 memcpy(new_part->header.name, name, strnlen(name, sizeof(new_part->header.name))); in nvram_create_partition()
903 new_part->header.checksum = nvram_checksum(&new_part->header); in nvram_create_partition()
911 list_add_tail(&new_part->partition, &free_part->partition); in nvram_create_partition()
914 if (free_part->header.length > size) { in nvram_create_partition()
915 free_part->index += size * NVRAM_BLOCK_LEN; in nvram_create_partition()
916 free_part->header.length -= size; in nvram_create_partition()
917 free_part->header.checksum = nvram_checksum(&free_part->header); in nvram_create_partition()
925 list_del(&free_part->partition); in nvram_create_partition()
930 for (tmp_index = new_part->index + NVRAM_HEADER_LEN; in nvram_create_partition()
931 tmp_index < ((size - 1) * NVRAM_BLOCK_LEN); in nvram_create_partition()
941 return new_part->index + NVRAM_HEADER_LEN; in nvram_create_partition()
945 * nvram_get_partition_size - Get the data size of an nvram partition
955 if (part->index + NVRAM_HEADER_LEN == data_index) in nvram_get_partition_size()
956 return (part->header.length - 1) * NVRAM_BLOCK_LEN; in nvram_get_partition_size()
958 return -1; in nvram_get_partition_size()
963 * nvram_find_partition - Find an nvram partition by signature and name
966 * @out_size: if non-NULL, returns the size of the data part of the partition
973 if (p->header.signature == sig && in nvram_find_partition()
974 (!name || !strncmp(p->header.name, name, 12))) { in nvram_find_partition()
976 *out_size = (p->header.length - 1) * in nvram_find_partition()
978 return p->index + NVRAM_HEADER_LEN; in nvram_find_partition()
995 return -ENODEV; in nvram_scan_partitions()
1001 return -ENOMEM; in nvram_scan_partitions()
1013 cur_index -= NVRAM_HEADER_LEN; /* nvram_read will advance us */ in nvram_scan_partitions()
1030 "detected: 0-length partition\n"); in nvram_scan_partitions()
1034 err = -ENOMEM; in nvram_scan_partitions()
1040 memcpy(&tmp_part->header, &phead, NVRAM_HEADER_LEN); in nvram_scan_partitions()
1041 tmp_part->index = cur_index; in nvram_scan_partitions()
1042 list_add_tail(&tmp_part->partition, &nvram_partitions); in nvram_scan_partitions()