mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/stable/linux.git
synced 2024-12-29 17:25:38 +00:00
b8f03cb703
Immutable params never change once comp has been allocated and setup, so we don't need to store multiple copies of them in each per-CPU backend context. Move those to per-comp zcomp_params and pass it to backends callbacks for requests execution. Basically, this means parameters sharing between different contexts. Also introduce two new backends callbacks: setup_params() and release_params(). First, we need to validate params in a driver-specific way; second, driver may want to allocate its specific representation of the params which is needed to execute requests. Link: https://lkml.kernel.org/r/20240902105656.1383858-20-senozhatsky@chromium.org Signed-off-by: Sergey Senozhatsky <senozhatsky@chromium.org> Cc: Minchan Kim <minchan@kernel.org> Cc: Nick Terrell <terrelln@fb.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
62 lines
1.3 KiB
C
62 lines
1.3 KiB
C
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
#include <linux/kernel.h>
|
|
#include <linux/slab.h>
|
|
#include <linux/sw842.h>
|
|
#include <linux/vmalloc.h>
|
|
|
|
#include "backend_842.h"
|
|
|
|
static void release_params_842(struct zcomp_params *params)
|
|
{
|
|
}
|
|
|
|
static int setup_params_842(struct zcomp_params *params)
|
|
{
|
|
return 0;
|
|
}
|
|
|
|
static void destroy_842(struct zcomp_ctx *ctx)
|
|
{
|
|
kfree(ctx->context);
|
|
}
|
|
|
|
static int create_842(struct zcomp_params *params, struct zcomp_ctx *ctx)
|
|
{
|
|
ctx->context = kmalloc(SW842_MEM_COMPRESS, GFP_KERNEL);
|
|
if (!ctx->context)
|
|
return -ENOMEM;
|
|
return 0;
|
|
}
|
|
|
|
static int compress_842(struct zcomp_params *params, struct zcomp_ctx *ctx,
|
|
struct zcomp_req *req)
|
|
{
|
|
unsigned int dlen = req->dst_len;
|
|
int ret;
|
|
|
|
ret = sw842_compress(req->src, req->src_len, req->dst, &dlen,
|
|
ctx->context);
|
|
if (ret == 0)
|
|
req->dst_len = dlen;
|
|
return ret;
|
|
}
|
|
|
|
static int decompress_842(struct zcomp_params *params, struct zcomp_ctx *ctx,
|
|
struct zcomp_req *req)
|
|
{
|
|
unsigned int dlen = req->dst_len;
|
|
|
|
return sw842_decompress(req->src, req->src_len, req->dst, &dlen);
|
|
}
|
|
|
|
const struct zcomp_ops backend_842 = {
|
|
.compress = compress_842,
|
|
.decompress = decompress_842,
|
|
.create_ctx = create_842,
|
|
.destroy_ctx = destroy_842,
|
|
.setup_params = setup_params_842,
|
|
.release_params = release_params_842,
|
|
.name = "842",
|
|
};
|