prz 115 fs/pstore/ram.c struct persistent_ram_zone *prz; prz 121 fs/pstore/ram.c prz = przs[id]; prz 122 fs/pstore/ram.c if (!prz) prz 126 fs/pstore/ram.c if (prz->type == PSTORE_TYPE_DMESG) prz 127 fs/pstore/ram.c persistent_ram_save_old(prz); prz 129 fs/pstore/ram.c if (!persistent_ram_old_size(prz)) prz 132 fs/pstore/ram.c record->type = prz->type; prz 135 fs/pstore/ram.c return prz; prz 165 fs/pstore/ram.c static bool prz_ok(struct persistent_ram_zone *prz) prz 167 fs/pstore/ram.c return !!prz && !!(persistent_ram_old_size(prz) + prz 168 fs/pstore/ram.c persistent_ram_ecc_string(prz, NULL, 0)); prz 227 fs/pstore/ram.c struct persistent_ram_zone *prz = NULL; prz 241 fs/pstore/ram.c while (cxt->dump_read_cnt < cxt->max_dump_cnt && !prz) { prz 242 fs/pstore/ram.c prz = ramoops_get_next_prz(cxt->dprzs, cxt->dump_read_cnt++, prz 244 fs/pstore/ram.c if (!prz_ok(prz)) prz 246 fs/pstore/ram.c header_length = ramoops_read_kmsg_hdr(persistent_ram_old(prz), prz 251 fs/pstore/ram.c persistent_ram_free_old(prz); prz 252 fs/pstore/ram.c persistent_ram_zap(prz); prz 253 fs/pstore/ram.c prz = NULL; prz 257 fs/pstore/ram.c if (!prz_ok(prz) && !cxt->console_read_cnt++) prz 258 fs/pstore/ram.c prz = ramoops_get_next_prz(&cxt->cprz, 0 /* single */, record); prz 260 fs/pstore/ram.c if (!prz_ok(prz) && !cxt->pmsg_read_cnt++) prz 261 fs/pstore/ram.c prz = ramoops_get_next_prz(&cxt->mprz, 0 /* single */, record); prz 264 fs/pstore/ram.c if (!prz_ok(prz)) { prz 267 fs/pstore/ram.c prz = ramoops_get_next_prz(cxt->fprzs, 0 /* single */, prz 280 fs/pstore/ram.c prz = tmp_prz; prz 302 fs/pstore/ram.c if (!prz_ok(prz)) { prz 307 fs/pstore/ram.c size = persistent_ram_old_size(prz) - header_length; prz 310 fs/pstore/ram.c record->ecc_notice_size = persistent_ram_ecc_string(prz, NULL, 0); prz 318 fs/pstore/ram.c memcpy(record->buf, (char *)persistent_ram_old(prz) + header_length, prz 321 fs/pstore/ram.c persistent_ram_ecc_string(prz, record->buf + size, prz 326 fs/pstore/ram.c kfree(prz->old_log); prz 327 fs/pstore/ram.c kfree(prz); prz 333 fs/pstore/ram.c static size_t ramoops_write_kmsg_hdr(struct persistent_ram_zone *prz, prz 344 fs/pstore/ram.c persistent_ram_write(prz, hdr, len); prz 352 fs/pstore/ram.c struct persistent_ram_zone *prz; prz 408 fs/pstore/ram.c prz = cxt->dprzs[cxt->dump_write_cnt]; prz 419 fs/pstore/ram.c persistent_ram_zap(prz); prz 422 fs/pstore/ram.c hlen = ramoops_write_kmsg_hdr(prz, record); prz 427 fs/pstore/ram.c if (size + hlen > prz->buffer_size) prz 428 fs/pstore/ram.c size = prz->buffer_size - hlen; prz 429 fs/pstore/ram.c persistent_ram_write(prz, record->buf, size); prz 453 fs/pstore/ram.c struct persistent_ram_zone *prz; prz 459 fs/pstore/ram.c prz = cxt->dprzs[record->id]; prz 462 fs/pstore/ram.c prz = cxt->cprz; prz 467 fs/pstore/ram.c prz = cxt->fprzs[record->id]; prz 470 fs/pstore/ram.c prz = cxt->mprz; prz 476 fs/pstore/ram.c persistent_ram_free_old(prz); prz 477 fs/pstore/ram.c persistent_ram_zap(prz); prz 614 fs/pstore/ram.c struct persistent_ram_zone **prz, prz 630 fs/pstore/ram.c *prz = persistent_ram_new(*paddr, sz, sig, &cxt->ecc_info, prz 633 fs/pstore/ram.c if (IS_ERR(*prz)) { prz 634 fs/pstore/ram.c int err = PTR_ERR(*prz); prz 642 fs/pstore/ram.c (*prz)->type = pstore_name_to_type(name); prz 42 fs/pstore/ram_core.c static inline size_t buffer_size(struct persistent_ram_zone *prz) prz 44 fs/pstore/ram_core.c return atomic_read(&prz->buffer->size); prz 47 fs/pstore/ram_core.c static inline size_t buffer_start(struct persistent_ram_zone *prz) prz 49 fs/pstore/ram_core.c return atomic_read(&prz->buffer->start); prz 53 fs/pstore/ram_core.c static size_t buffer_start_add(struct persistent_ram_zone *prz, size_t a) prz 59 fs/pstore/ram_core.c if (!(prz->flags & PRZ_FLAG_NO_LOCK)) prz 60 fs/pstore/ram_core.c raw_spin_lock_irqsave(&prz->buffer_lock, flags); prz 62 fs/pstore/ram_core.c old = atomic_read(&prz->buffer->start); prz 64 fs/pstore/ram_core.c while (unlikely(new >= prz->buffer_size)) prz 65 fs/pstore/ram_core.c new -= prz->buffer_size; prz 66 fs/pstore/ram_core.c atomic_set(&prz->buffer->start, new); prz 68 fs/pstore/ram_core.c if (!(prz->flags & PRZ_FLAG_NO_LOCK)) prz 69 fs/pstore/ram_core.c raw_spin_unlock_irqrestore(&prz->buffer_lock, flags); prz 75 fs/pstore/ram_core.c static void buffer_size_add(struct persistent_ram_zone *prz, size_t a) prz 81 fs/pstore/ram_core.c if (!(prz->flags & PRZ_FLAG_NO_LOCK)) prz 82 fs/pstore/ram_core.c raw_spin_lock_irqsave(&prz->buffer_lock, flags); prz 84 fs/pstore/ram_core.c old = atomic_read(&prz->buffer->size); prz 85 fs/pstore/ram_core.c if (old == prz->buffer_size) prz 89 fs/pstore/ram_core.c if (new > prz->buffer_size) prz 90 fs/pstore/ram_core.c new = prz->buffer_size; prz 91 fs/pstore/ram_core.c atomic_set(&prz->buffer->size, new); prz 94 fs/pstore/ram_core.c if (!(prz->flags & PRZ_FLAG_NO_LOCK)) prz 95 fs/pstore/ram_core.c raw_spin_unlock_irqrestore(&prz->buffer_lock, flags); prz 98 fs/pstore/ram_core.c static void notrace persistent_ram_encode_rs8(struct persistent_ram_zone *prz, prz 104 fs/pstore/ram_core.c memset(prz->ecc_info.par, 0, prz 105 fs/pstore/ram_core.c prz->ecc_info.ecc_size * sizeof(prz->ecc_info.par[0])); prz 106 fs/pstore/ram_core.c encode_rs8(prz->rs_decoder, data, len, prz->ecc_info.par, 0); prz 107 fs/pstore/ram_core.c for (i = 0; i < prz->ecc_info.ecc_size; i++) prz 108 fs/pstore/ram_core.c ecc[i] = prz->ecc_info.par[i]; prz 111 fs/pstore/ram_core.c static int persistent_ram_decode_rs8(struct persistent_ram_zone *prz, prz 116 fs/pstore/ram_core.c for (i = 0; i < prz->ecc_info.ecc_size; i++) prz 117 fs/pstore/ram_core.c prz->ecc_info.par[i] = ecc[i]; prz 118 fs/pstore/ram_core.c return decode_rs8(prz->rs_decoder, data, prz->ecc_info.par, len, prz 122 fs/pstore/ram_core.c static void notrace persistent_ram_update_ecc(struct persistent_ram_zone *prz, prz 125 fs/pstore/ram_core.c struct persistent_ram_buffer *buffer = prz->buffer; prz 126 fs/pstore/ram_core.c uint8_t *buffer_end = buffer->data + prz->buffer_size; prz 129 fs/pstore/ram_core.c int ecc_block_size = prz->ecc_info.block_size; prz 130 fs/pstore/ram_core.c int ecc_size = prz->ecc_info.ecc_size; prz 137 fs/pstore/ram_core.c par = prz->par_buffer + (start / ecc_block_size) * ecc_size; prz 142 fs/pstore/ram_core.c persistent_ram_encode_rs8(prz, block, size, par); prz 148 fs/pstore/ram_core.c static void persistent_ram_update_header_ecc(struct persistent_ram_zone *prz) prz 150 fs/pstore/ram_core.c struct persistent_ram_buffer *buffer = prz->buffer; prz 152 fs/pstore/ram_core.c if (!prz->ecc_info.ecc_size) prz 155 fs/pstore/ram_core.c persistent_ram_encode_rs8(prz, (uint8_t *)buffer, sizeof(*buffer), prz 156 fs/pstore/ram_core.c prz->par_header); prz 159 fs/pstore/ram_core.c static void persistent_ram_ecc_old(struct persistent_ram_zone *prz) prz 161 fs/pstore/ram_core.c struct persistent_ram_buffer *buffer = prz->buffer; prz 165 fs/pstore/ram_core.c if (!prz->ecc_info.ecc_size) prz 169 fs/pstore/ram_core.c par = prz->par_buffer; prz 170 fs/pstore/ram_core.c while (block < buffer->data + buffer_size(prz)) { prz 172 fs/pstore/ram_core.c int size = prz->ecc_info.block_size; prz 173 fs/pstore/ram_core.c if (block + size > buffer->data + prz->buffer_size) prz 174 fs/pstore/ram_core.c size = buffer->data + prz->buffer_size - block; prz 175 fs/pstore/ram_core.c numerr = persistent_ram_decode_rs8(prz, block, size, par); prz 178 fs/pstore/ram_core.c prz->corrected_bytes += numerr; prz 181 fs/pstore/ram_core.c prz->bad_blocks++; prz 183 fs/pstore/ram_core.c block += prz->ecc_info.block_size; prz 184 fs/pstore/ram_core.c par += prz->ecc_info.ecc_size; prz 188 fs/pstore/ram_core.c static int persistent_ram_init_ecc(struct persistent_ram_zone *prz, prz 192 fs/pstore/ram_core.c struct persistent_ram_buffer *buffer = prz->buffer; prz 199 fs/pstore/ram_core.c prz->ecc_info.block_size = ecc_info->block_size ?: 128; prz 200 fs/pstore/ram_core.c prz->ecc_info.ecc_size = ecc_info->ecc_size ?: 16; prz 201 fs/pstore/ram_core.c prz->ecc_info.symsize = ecc_info->symsize ?: 8; prz 202 fs/pstore/ram_core.c prz->ecc_info.poly = ecc_info->poly ?: 0x11d; prz 204 fs/pstore/ram_core.c ecc_blocks = DIV_ROUND_UP(prz->buffer_size - prz->ecc_info.ecc_size, prz 205 fs/pstore/ram_core.c prz->ecc_info.block_size + prz 206 fs/pstore/ram_core.c prz->ecc_info.ecc_size); prz 207 fs/pstore/ram_core.c ecc_total = (ecc_blocks + 1) * prz->ecc_info.ecc_size; prz 208 fs/pstore/ram_core.c if (ecc_total >= prz->buffer_size) { prz 210 fs/pstore/ram_core.c __func__, prz->ecc_info.ecc_size, prz 211 fs/pstore/ram_core.c ecc_total, prz->buffer_size); prz 215 fs/pstore/ram_core.c prz->buffer_size -= ecc_total; prz 216 fs/pstore/ram_core.c prz->par_buffer = buffer->data + prz->buffer_size; prz 217 fs/pstore/ram_core.c prz->par_header = prz->par_buffer + prz 218 fs/pstore/ram_core.c ecc_blocks * prz->ecc_info.ecc_size; prz 224 fs/pstore/ram_core.c prz->rs_decoder = init_rs(prz->ecc_info.symsize, prz->ecc_info.poly, prz 225 fs/pstore/ram_core.c 0, 1, prz->ecc_info.ecc_size); prz 226 fs/pstore/ram_core.c if (prz->rs_decoder == NULL) { prz 232 fs/pstore/ram_core.c prz->ecc_info.par = kmalloc_array(prz->ecc_info.ecc_size, prz 233 fs/pstore/ram_core.c sizeof(*prz->ecc_info.par), prz 235 fs/pstore/ram_core.c if (!prz->ecc_info.par) { prz 240 fs/pstore/ram_core.c prz->corrected_bytes = 0; prz 241 fs/pstore/ram_core.c prz->bad_blocks = 0; prz 243 fs/pstore/ram_core.c numerr = persistent_ram_decode_rs8(prz, buffer, sizeof(*buffer), prz 244 fs/pstore/ram_core.c prz->par_header); prz 247 fs/pstore/ram_core.c prz->corrected_bytes += numerr; prz 250 fs/pstore/ram_core.c prz->bad_blocks++; prz 256 fs/pstore/ram_core.c ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz, prz 261 fs/pstore/ram_core.c if (!prz->ecc_info.ecc_size) prz 264 fs/pstore/ram_core.c if (prz->corrected_bytes || prz->bad_blocks) prz 267 fs/pstore/ram_core.c prz->corrected_bytes, prz->bad_blocks); prz 274 fs/pstore/ram_core.c static void notrace persistent_ram_update(struct persistent_ram_zone *prz, prz 277 fs/pstore/ram_core.c struct persistent_ram_buffer *buffer = prz->buffer; prz 279 fs/pstore/ram_core.c persistent_ram_update_ecc(prz, start, count); prz 282 fs/pstore/ram_core.c static int notrace persistent_ram_update_user(struct persistent_ram_zone *prz, prz 285 fs/pstore/ram_core.c struct persistent_ram_buffer *buffer = prz->buffer; prz 288 fs/pstore/ram_core.c persistent_ram_update_ecc(prz, start, count); prz 292 fs/pstore/ram_core.c void persistent_ram_save_old(struct persistent_ram_zone *prz) prz 294 fs/pstore/ram_core.c struct persistent_ram_buffer *buffer = prz->buffer; prz 295 fs/pstore/ram_core.c size_t size = buffer_size(prz); prz 296 fs/pstore/ram_core.c size_t start = buffer_start(prz); prz 301 fs/pstore/ram_core.c if (!prz->old_log) { prz 302 fs/pstore/ram_core.c persistent_ram_ecc_old(prz); prz 303 fs/pstore/ram_core.c prz->old_log = kmalloc(size, GFP_KERNEL); prz 305 fs/pstore/ram_core.c if (!prz->old_log) { prz 310 fs/pstore/ram_core.c prz->old_log_size = size; prz 311 fs/pstore/ram_core.c memcpy_fromio(prz->old_log, &buffer->data[start], size - start); prz 312 fs/pstore/ram_core.c memcpy_fromio(prz->old_log + size - start, &buffer->data[0], start); prz 315 fs/pstore/ram_core.c int notrace persistent_ram_write(struct persistent_ram_zone *prz, prz 322 fs/pstore/ram_core.c if (unlikely(c > prz->buffer_size)) { prz 323 fs/pstore/ram_core.c s += c - prz->buffer_size; prz 324 fs/pstore/ram_core.c c = prz->buffer_size; prz 327 fs/pstore/ram_core.c buffer_size_add(prz, c); prz 329 fs/pstore/ram_core.c start = buffer_start_add(prz, c); prz 331 fs/pstore/ram_core.c rem = prz->buffer_size - start; prz 333 fs/pstore/ram_core.c persistent_ram_update(prz, s, start, rem); prz 338 fs/pstore/ram_core.c persistent_ram_update(prz, s, start, c); prz 340 fs/pstore/ram_core.c persistent_ram_update_header_ecc(prz); prz 345 fs/pstore/ram_core.c int notrace persistent_ram_write_user(struct persistent_ram_zone *prz, prz 353 fs/pstore/ram_core.c if (unlikely(c > prz->buffer_size)) { prz 354 fs/pstore/ram_core.c s += c - prz->buffer_size; prz 355 fs/pstore/ram_core.c c = prz->buffer_size; prz 358 fs/pstore/ram_core.c buffer_size_add(prz, c); prz 360 fs/pstore/ram_core.c start = buffer_start_add(prz, c); prz 362 fs/pstore/ram_core.c rem = prz->buffer_size - start; prz 364 fs/pstore/ram_core.c ret = persistent_ram_update_user(prz, s, start, rem); prz 370 fs/pstore/ram_core.c ret = persistent_ram_update_user(prz, s, start, c); prz 372 fs/pstore/ram_core.c persistent_ram_update_header_ecc(prz); prz 377 fs/pstore/ram_core.c size_t persistent_ram_old_size(struct persistent_ram_zone *prz) prz 379 fs/pstore/ram_core.c return prz->old_log_size; prz 382 fs/pstore/ram_core.c void *persistent_ram_old(struct persistent_ram_zone *prz) prz 384 fs/pstore/ram_core.c return prz->old_log; prz 387 fs/pstore/ram_core.c void persistent_ram_free_old(struct persistent_ram_zone *prz) prz 389 fs/pstore/ram_core.c kfree(prz->old_log); prz 390 fs/pstore/ram_core.c prz->old_log = NULL; prz 391 fs/pstore/ram_core.c prz->old_log_size = 0; prz 394 fs/pstore/ram_core.c void persistent_ram_zap(struct persistent_ram_zone *prz) prz 396 fs/pstore/ram_core.c atomic_set(&prz->buffer->start, 0); prz 397 fs/pstore/ram_core.c atomic_set(&prz->buffer->size, 0); prz 398 fs/pstore/ram_core.c persistent_ram_update_header_ecc(prz); prz 467 fs/pstore/ram_core.c struct persistent_ram_zone *prz, int memtype) prz 469 fs/pstore/ram_core.c prz->paddr = start; prz 470 fs/pstore/ram_core.c prz->size = size; prz 473 fs/pstore/ram_core.c prz->vaddr = persistent_ram_vmap(start, size, memtype); prz 475 fs/pstore/ram_core.c prz->vaddr = persistent_ram_iomap(start, size, memtype, prz 476 fs/pstore/ram_core.c prz->label); prz 478 fs/pstore/ram_core.c if (!prz->vaddr) { prz 484 fs/pstore/ram_core.c prz->buffer = prz->vaddr; prz 485 fs/pstore/ram_core.c prz->buffer_size = size - sizeof(struct persistent_ram_buffer); prz 490 fs/pstore/ram_core.c static int persistent_ram_post_init(struct persistent_ram_zone *prz, u32 sig, prz 494 fs/pstore/ram_core.c bool zap = !!(prz->flags & PRZ_FLAG_ZAP_OLD); prz 496 fs/pstore/ram_core.c ret = persistent_ram_init_ecc(prz, ecc_info); prz 498 fs/pstore/ram_core.c pr_warn("ECC failed %s\n", prz->label); prz 504 fs/pstore/ram_core.c if (prz->buffer->sig == sig) { prz 505 fs/pstore/ram_core.c if (buffer_size(prz) == 0) { prz 510 fs/pstore/ram_core.c if (buffer_size(prz) > prz->buffer_size || prz 511 fs/pstore/ram_core.c buffer_start(prz) > buffer_size(prz)) { prz 513 fs/pstore/ram_core.c buffer_size(prz), buffer_start(prz)); prz 517 fs/pstore/ram_core.c buffer_size(prz), buffer_start(prz)); prz 518 fs/pstore/ram_core.c persistent_ram_save_old(prz); prz 522 fs/pstore/ram_core.c prz->buffer->sig); prz 523 fs/pstore/ram_core.c prz->buffer->sig = sig; prz 529 fs/pstore/ram_core.c persistent_ram_zap(prz); prz 534 fs/pstore/ram_core.c void persistent_ram_free(struct persistent_ram_zone *prz) prz 536 fs/pstore/ram_core.c if (!prz) prz 539 fs/pstore/ram_core.c if (prz->vaddr) { prz 540 fs/pstore/ram_core.c if (pfn_valid(prz->paddr >> PAGE_SHIFT)) { prz 542 fs/pstore/ram_core.c vunmap(prz->vaddr - offset_in_page(prz->paddr)); prz 544 fs/pstore/ram_core.c iounmap(prz->vaddr); prz 545 fs/pstore/ram_core.c release_mem_region(prz->paddr, prz->size); prz 547 fs/pstore/ram_core.c prz->vaddr = NULL; prz 549 fs/pstore/ram_core.c if (prz->rs_decoder) { prz 550 fs/pstore/ram_core.c free_rs(prz->rs_decoder); prz 551 fs/pstore/ram_core.c prz->rs_decoder = NULL; prz 553 fs/pstore/ram_core.c kfree(prz->ecc_info.par); prz 554 fs/pstore/ram_core.c prz->ecc_info.par = NULL; prz 556 fs/pstore/ram_core.c persistent_ram_free_old(prz); prz 557 fs/pstore/ram_core.c kfree(prz->label); prz 558 fs/pstore/ram_core.c kfree(prz); prz 565 fs/pstore/ram_core.c struct persistent_ram_zone *prz; prz 568 fs/pstore/ram_core.c prz = kzalloc(sizeof(struct persistent_ram_zone), GFP_KERNEL); prz 569 fs/pstore/ram_core.c if (!prz) { prz 575 fs/pstore/ram_core.c raw_spin_lock_init(&prz->buffer_lock); prz 576 fs/pstore/ram_core.c prz->flags = flags; prz 577 fs/pstore/ram_core.c prz->label = kstrdup(label, GFP_KERNEL); prz 579 fs/pstore/ram_core.c ret = persistent_ram_buffer_map(start, size, prz, memtype); prz 583 fs/pstore/ram_core.c ret = persistent_ram_post_init(prz, sig, ecc_info); prz 588 fs/pstore/ram_core.c prz->label, prz->size, (unsigned long long)prz->paddr, prz 589 fs/pstore/ram_core.c sizeof(*prz->buffer), prz->buffer_size, prz 590 fs/pstore/ram_core.c prz->size - sizeof(*prz->buffer) - prz->buffer_size, prz 591 fs/pstore/ram_core.c prz->ecc_info.ecc_size, prz->ecc_info.block_size); prz 593 fs/pstore/ram_core.c return prz; prz 595 fs/pstore/ram_core.c persistent_ram_free(prz); prz 105 include/linux/pstore_ram.h void persistent_ram_free(struct persistent_ram_zone *prz); prz 106 include/linux/pstore_ram.h void persistent_ram_zap(struct persistent_ram_zone *prz); prz 108 include/linux/pstore_ram.h int persistent_ram_write(struct persistent_ram_zone *prz, const void *s, prz 110 include/linux/pstore_ram.h int persistent_ram_write_user(struct persistent_ram_zone *prz, prz 113 include/linux/pstore_ram.h void persistent_ram_save_old(struct persistent_ram_zone *prz); prz 114 include/linux/pstore_ram.h size_t persistent_ram_old_size(struct persistent_ram_zone *prz); prz 115 include/linux/pstore_ram.h void *persistent_ram_old(struct persistent_ram_zone *prz); prz 116 include/linux/pstore_ram.h void persistent_ram_free_old(struct persistent_ram_zone *prz); prz 117 include/linux/pstore_ram.h ssize_t persistent_ram_ecc_string(struct persistent_ram_zone *prz,