Skip to content

Commit a3a5e94

Browse files
arunabalaegl
authored andcommitted
powerpc/pseries: Remove (de)compression in nvram with pstore enabled
(De)compression support is provided in pstore in subsequent patches which needs an additional argument 'compressed' to determine if the data is compressed or not. This patch will take care of removing (de)compression in nvram with pstore which was making use of 'hsize' argument in pstore write as 'hsize' will be removed in the subsequent patch. Signed-off-by: Aruna Balakrishnaiah <[email protected]> Reviewed-by: Kees Cook <[email protected]> Signed-off-by: Tony Luck <[email protected]>
1 parent c39524e commit a3a5e94

File tree

1 file changed

+12
-90
lines changed
  • arch/powerpc/platforms/pseries

1 file changed

+12
-90
lines changed

arch/powerpc/platforms/pseries/nvram.c

Lines changed: 12 additions & 90 deletions
Original file line numberDiff line numberDiff line change
@@ -539,36 +539,6 @@ static int zip_oops(size_t text_len)
539539
}
540540

541541
#ifdef CONFIG_PSTORE
542-
/* Derived from logfs_uncompress */
543-
int nvram_decompress(void *in, void *out, size_t inlen, size_t outlen)
544-
{
545-
int err, ret;
546-
547-
ret = -EIO;
548-
err = zlib_inflateInit(&stream);
549-
if (err != Z_OK)
550-
goto error;
551-
552-
stream.next_in = in;
553-
stream.avail_in = inlen;
554-
stream.total_in = 0;
555-
stream.next_out = out;
556-
stream.avail_out = outlen;
557-
stream.total_out = 0;
558-
559-
err = zlib_inflate(&stream, Z_FINISH);
560-
if (err != Z_STREAM_END)
561-
goto error;
562-
563-
err = zlib_inflateEnd(&stream);
564-
if (err != Z_OK)
565-
goto error;
566-
567-
ret = stream.total_out;
568-
error:
569-
return ret;
570-
}
571-
572542
static int nvram_pstore_open(struct pstore_info *psi)
573543
{
574544
/* Reset the iterator to start reading partitions again */
@@ -611,30 +581,8 @@ static int nvram_pstore_write(enum pstore_type_id type,
611581
oops_hdr->report_length = (u16) size;
612582
oops_hdr->timestamp = get_seconds();
613583

614-
if (big_oops_buf) {
615-
rc = zip_oops(size);
616-
/*
617-
* If compression fails copy recent log messages from
618-
* big_oops_buf to oops_data.
619-
*/
620-
if (rc != 0) {
621-
size_t diff = size - oops_data_sz + hsize;
622-
623-
if (size > oops_data_sz) {
624-
memcpy(oops_data, big_oops_buf, hsize);
625-
memcpy(oops_data + hsize, big_oops_buf + diff,
626-
oops_data_sz - hsize);
627-
628-
oops_hdr->report_length = (u16) oops_data_sz;
629-
} else
630-
memcpy(oops_data, big_oops_buf, size);
631-
} else
632-
err_type = ERR_TYPE_KERNEL_PANIC_GZ;
633-
}
634-
635584
rc = nvram_write_os_partition(&oops_log_partition, oops_buf,
636-
(int) (sizeof(*oops_hdr) + oops_hdr->report_length), err_type,
637-
count);
585+
(int) (sizeof(*oops_hdr) + size), err_type, count);
638586

639587
if (rc != 0)
640588
return rc;
@@ -655,7 +603,7 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
655603
struct oops_log_info *oops_hdr;
656604
unsigned int err_type, id_no, size = 0;
657605
struct nvram_os_partition *part = NULL;
658-
char *buff = NULL, *big_buff = NULL;
606+
char *buff = NULL;
659607
int sig = 0;
660608
loff_t p;
661609

@@ -719,8 +667,7 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
719667
*id = id_no;
720668

721669
if (nvram_type_ids[read_type] == PSTORE_TYPE_DMESG) {
722-
int length, unzipped_len;
723-
size_t hdr_size;
670+
size_t length, hdr_size;
724671

725672
oops_hdr = (struct oops_log_info *)buff;
726673
if (oops_hdr->version < OOPS_HDR_VERSION) {
@@ -740,24 +687,6 @@ static ssize_t nvram_pstore_read(u64 *id, enum pstore_type_id *type,
740687
return -ENOMEM;
741688
memcpy(*buf, buff + hdr_size, length);
742689
kfree(buff);
743-
744-
if (err_type == ERR_TYPE_KERNEL_PANIC_GZ) {
745-
big_buff = kmalloc(big_oops_buf_sz, GFP_KERNEL);
746-
if (!big_buff)
747-
return -ENOMEM;
748-
749-
unzipped_len = nvram_decompress(*buf, big_buff,
750-
length, big_oops_buf_sz);
751-
752-
if (unzipped_len < 0) {
753-
pr_err("nvram: decompression failed, returned "
754-
"rc %d\n", unzipped_len);
755-
kfree(big_buff);
756-
} else {
757-
*buf = big_buff;
758-
length = unzipped_len;
759-
}
760-
}
761690
return length;
762691
}
763692

@@ -777,13 +706,8 @@ static int nvram_pstore_init(void)
777706
{
778707
int rc = 0;
779708

780-
if (big_oops_buf) {
781-
nvram_pstore_info.buf = big_oops_buf;
782-
nvram_pstore_info.bufsize = big_oops_buf_sz;
783-
} else {
784-
nvram_pstore_info.buf = oops_data;
785-
nvram_pstore_info.bufsize = oops_data_sz;
786-
}
709+
nvram_pstore_info.buf = oops_data;
710+
nvram_pstore_info.bufsize = oops_data_sz;
787711

788712
rc = pstore_register(&nvram_pstore_info);
789713
if (rc != 0)
@@ -802,7 +726,6 @@ static int nvram_pstore_init(void)
802726
static void __init nvram_init_oops_partition(int rtas_partition_exists)
803727
{
804728
int rc;
805-
size_t size;
806729

807730
rc = pseries_nvram_init_os_partition(&oops_log_partition);
808731
if (rc != 0) {
@@ -823,6 +746,11 @@ static void __init nvram_init_oops_partition(int rtas_partition_exists)
823746
oops_data = oops_buf + sizeof(struct oops_log_info);
824747
oops_data_sz = oops_log_partition.size - sizeof(struct oops_log_info);
825748

749+
rc = nvram_pstore_init();
750+
751+
if (!rc)
752+
return;
753+
826754
/*
827755
* Figure compression (preceded by elimination of each line's <n>
828756
* severity prefix) will reduce the oops/panic report to at most
@@ -831,9 +759,8 @@ static void __init nvram_init_oops_partition(int rtas_partition_exists)
831759
big_oops_buf_sz = (oops_data_sz * 100) / 45;
832760
big_oops_buf = kmalloc(big_oops_buf_sz, GFP_KERNEL);
833761
if (big_oops_buf) {
834-
size = max(zlib_deflate_workspacesize(WINDOW_BITS, MEM_LEVEL),
835-
zlib_inflate_workspacesize());
836-
stream.workspace = kmalloc(size, GFP_KERNEL);
762+
stream.workspace = kmalloc(zlib_deflate_workspacesize(
763+
WINDOW_BITS, MEM_LEVEL), GFP_KERNEL);
837764
if (!stream.workspace) {
838765
pr_err("nvram: No memory for compression workspace; "
839766
"skipping compression of %s partition data\n",
@@ -847,11 +774,6 @@ static void __init nvram_init_oops_partition(int rtas_partition_exists)
847774
stream.workspace = NULL;
848775
}
849776

850-
rc = nvram_pstore_init();
851-
852-
if (!rc)
853-
return;
854-
855777
rc = kmsg_dump_register(&nvram_kmsg_dumper);
856778
if (rc != 0) {
857779
pr_err("nvram: kmsg_dump_register() failed; returned %d\n", rc);

0 commit comments

Comments
 (0)