Commit 161284b2 authored by Rafael J. Wysocki's avatar Rafael J. Wysocki
Browse files

Merge branch 'pm-sleep'

Merge fixes for issues related to the handling of compressed hibernation
images that were introduced during the 6.9 development cycle.

* pm-sleep:
  PM: hibernate: Fix style issues in save_compressed_image()
  PM: hibernate: Use atomic64_t for compressed_size variable
  PM: hibernate: Emit an error when image writing fails
parents 4b747cc6 0b6c10cb
Loading
Loading
Loading
Loading
+13 −9
Original line number Diff line number Diff line
@@ -635,7 +635,7 @@ struct cmp_data {
};

/* Indicates the image size after compression */
static atomic_t compressed_size = ATOMIC_INIT(0);
static atomic64_t compressed_size = ATOMIC_INIT(0);

/*
 * Compression function that runs in its own thread.
@@ -664,7 +664,7 @@ static int compress_threadfn(void *data)
		d->ret = crypto_acomp_compress(d->cr);
		d->cmp_len = d->cr->dlen;

		atomic_set(&compressed_size, atomic_read(&compressed_size) + d->cmp_len);
		atomic64_add(d->cmp_len, &compressed_size);
		atomic_set_release(&d->stop, 1);
		wake_up(&d->done);
	}
@@ -689,14 +689,14 @@ static int save_compressed_image(struct swap_map_handle *handle,
	ktime_t start;
	ktime_t stop;
	size_t off;
	unsigned thr, run_threads, nr_threads;
	unsigned int thr, run_threads, nr_threads;
	unsigned char *page = NULL;
	struct cmp_data *data = NULL;
	struct crc_data *crc = NULL;

	hib_init_batch(&hb);

	atomic_set(&compressed_size, 0);
	atomic64_set(&compressed_size, 0);

	/*
	 * We'll limit the number of threads for compression to limit memory
@@ -877,11 +877,14 @@ static int save_compressed_image(struct swap_map_handle *handle,
	stop = ktime_get();
	if (!ret)
		ret = err2;
	if (!ret)
		pr_info("Image saving done\n");
	if (!ret) {
		swsusp_show_speed(start, stop, nr_to_write, "Wrote");
	pr_info("Image size after compression: %d kbytes\n",
		(atomic_read(&compressed_size) / 1024));
		pr_info("Image size after compression: %lld kbytes\n",
			(atomic64_read(&compressed_size) / 1024));
		pr_info("Image saving done\n");
	} else {
		pr_err("Image saving failed: %d\n", ret);
	}

out_clean:
	hib_finish_batch(&hb);
@@ -899,7 +902,8 @@ static int save_compressed_image(struct swap_map_handle *handle,
		}
		vfree(data);
	}
	if (page) free_page((unsigned long)page);
	if (page)
		free_page((unsigned long)page);

	return ret;
}