Skip to content

Commit

Permalink
s390/boot: add dfltcc= kernel command line parameter
Browse files Browse the repository at this point in the history
Add the new kernel command line parameter 'dfltcc=' to configure s390
zlib hardware support.

Format: { on | off | def_only | inf_only | always }
 on:       s390 zlib hardware support for compression on
           level 1 and decompression (default)
 off:      No s390 zlib hardware support
 def_only: s390 zlib hardware support for deflate
           only (compression on level 1)
 inf_only: s390 zlib hardware support for inflate
           only (decompression)
 always:   Same as 'on' but ignores the selected compression
           level always using hardware support (used for debugging)

Link: http:https://lkml.kernel.org/r/[email protected]
Signed-off-by: Mikhail Zaslonko <[email protected]>
Cc: Chris Mason <[email protected]>
Cc: Christian Borntraeger <[email protected]>
Cc: David Sterba <[email protected]>
Cc: Eduard Shishkin <[email protected]>
Cc: Heiko Carstens <[email protected]>
Cc: Ilya Leoshkevich <[email protected]>
Cc: Josef Bacik <[email protected]>
Cc: Richard Purdie <[email protected]>
Cc: Vasily Gorbik <[email protected]>
Signed-off-by: Andrew Morton <[email protected]>
Signed-off-by: Linus Torvalds <[email protected]>
  • Loading branch information
mzaslonk authored and torvalds committed Jan 31, 2020
1 parent 1261961 commit c65e681
Show file tree
Hide file tree
Showing 9 changed files with 55 additions and 2 deletions.
12 changes: 12 additions & 0 deletions Documentation/admin-guide/kernel-parameters.txt
Original file line number Diff line number Diff line change
Expand Up @@ -834,6 +834,18 @@
dump out devices still on the deferred probe list after
retrying.

dfltcc= [HW,S390]
Format: { on | off | def_only | inf_only | always }
on: s390 zlib hardware support for compression on
level 1 and decompression (default)
off: No s390 zlib hardware support
def_only: s390 zlib hardware support for deflate
only (compression on level 1)
inf_only: s390 zlib hardware support for inflate
only (decompression)
always: Same as 'on' but ignores the selected compression
level always using hardware support (used for debugging)

dhash_entries= [KNL]
Set number of hash buckets for dentry cache.

Expand Down
14 changes: 14 additions & 0 deletions arch/s390/boot/ipl_parm.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
char __bootdata(early_command_line)[COMMAND_LINE_SIZE];
struct ipl_parameter_block __bootdata_preserved(ipl_block);
int __bootdata_preserved(ipl_block_valid);
unsigned int __bootdata_preserved(zlib_dfltcc_support) = ZLIB_DFLTCC_FULL;

unsigned long __bootdata(vmalloc_size) = VMALLOC_DEFAULT_SIZE;
unsigned long __bootdata(memory_end);
Expand Down Expand Up @@ -229,6 +230,19 @@ void parse_boot_command_line(void)
if (!strcmp(param, "vmalloc") && val)
vmalloc_size = round_up(memparse(val, NULL), PAGE_SIZE);

if (!strcmp(param, "dfltcc")) {
if (!strcmp(val, "off"))
zlib_dfltcc_support = ZLIB_DFLTCC_DISABLED;
else if (!strcmp(val, "on"))
zlib_dfltcc_support = ZLIB_DFLTCC_FULL;
else if (!strcmp(val, "def_only"))
zlib_dfltcc_support = ZLIB_DFLTCC_DEFLATE_ONLY;
else if (!strcmp(val, "inf_only"))
zlib_dfltcc_support = ZLIB_DFLTCC_INFLATE_ONLY;
else if (!strcmp(val, "always"))
zlib_dfltcc_support = ZLIB_DFLTCC_FULL_DEBUG;
}

if (!strcmp(param, "noexec")) {
rc = kstrtobool(val, &enabled);
if (!rc && !enabled)
Expand Down
7 changes: 7 additions & 0 deletions arch/s390/include/asm/setup.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,13 @@ struct parmarea {
char command_line[ARCH_COMMAND_LINE_SIZE]; /* 0x10480 */
};

extern unsigned int zlib_dfltcc_support;
#define ZLIB_DFLTCC_DISABLED 0
#define ZLIB_DFLTCC_FULL 1
#define ZLIB_DFLTCC_DEFLATE_ONLY 2
#define ZLIB_DFLTCC_INFLATE_ONLY 3
#define ZLIB_DFLTCC_FULL_DEBUG 4

extern int noexec_disabled;
extern int memory_end_set;
extern unsigned long memory_end;
Expand Down
2 changes: 2 additions & 0 deletions arch/s390/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,8 @@ unsigned long __bootdata_preserved(__etext_dma);
unsigned long __bootdata_preserved(__sdma);
unsigned long __bootdata_preserved(__edma);
unsigned long __bootdata_preserved(__kaslr_offset);
unsigned int __bootdata_preserved(zlib_dfltcc_support);
EXPORT_SYMBOL(zlib_dfltcc_support);

unsigned long VMALLOC_START;
EXPORT_SYMBOL(VMALLOC_START);
Expand Down
5 changes: 4 additions & 1 deletion lib/zlib_dfltcc/dfltcc.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,10 @@ void dfltcc_reset(
dfltcc_state->param.nt = 1;

/* Initialize tuning parameters */
dfltcc_state->level_mask = DFLTCC_LEVEL_MASK;
if (zlib_dfltcc_support == ZLIB_DFLTCC_FULL_DEBUG)
dfltcc_state->level_mask = DFLTCC_LEVEL_MASK_DEBUG;
else
dfltcc_state->level_mask = DFLTCC_LEVEL_MASK;
dfltcc_state->block_size = DFLTCC_BLOCK_SIZE;
dfltcc_state->block_threshold = DFLTCC_FIRST_FHT_BLOCK_SIZE;
dfltcc_state->dht_threshold = DFLTCC_DHT_MIN_SAMPLE_SIZE;
Expand Down
1 change: 1 addition & 0 deletions lib/zlib_dfltcc/dfltcc.h
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
* Tuning parameters.
*/
#define DFLTCC_LEVEL_MASK 0x2 /* DFLTCC compression for level 1 only */
#define DFLTCC_LEVEL_MASK_DEBUG 0x3fe /* DFLTCC compression for all levels */
#define DFLTCC_BLOCK_SIZE 1048576
#define DFLTCC_FIRST_FHT_BLOCK_SIZE 4096
#define DFLTCC_DHT_MIN_SAMPLE_SIZE 4096
Expand Down
6 changes: 6 additions & 0 deletions lib/zlib_dfltcc/dfltcc_deflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../zlib_deflate/defutil.h"
#include "dfltcc_util.h"
#include "dfltcc.h"
#include <asm/setup.h>
#include <linux/zutil.h>

/*
Expand All @@ -15,6 +16,11 @@ int dfltcc_can_deflate(
deflate_state *state = (deflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);

/* Check for kernel dfltcc command line parameter */
if (zlib_dfltcc_support == ZLIB_DFLTCC_DISABLED ||
zlib_dfltcc_support == ZLIB_DFLTCC_INFLATE_ONLY)
return 0;

/* Unsupported compression settings */
if (!dfltcc_are_params_ok(state->level, state->w_bits, state->strategy,
dfltcc_state->level_mask))
Expand Down
6 changes: 6 additions & 0 deletions lib/zlib_dfltcc/dfltcc_inflate.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "../zlib_inflate/inflate.h"
#include "dfltcc_util.h"
#include "dfltcc.h"
#include <asm/setup.h>
#include <linux/zutil.h>

/*
Expand All @@ -15,6 +16,11 @@ int dfltcc_can_inflate(
struct inflate_state *state = (struct inflate_state *)strm->state;
struct dfltcc_state *dfltcc_state = GET_DFLTCC_STATE(state);

/* Check for kernel dfltcc command line parameter */
if (zlib_dfltcc_support == ZLIB_DFLTCC_DISABLED ||
zlib_dfltcc_support == ZLIB_DFLTCC_DEFLATE_ONLY)
return 0;

/* Unsupported compression settings */
if (state->wbits != HB_BITS)
return 0;
Expand Down
4 changes: 3 additions & 1 deletion lib/zlib_dfltcc/dfltcc_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <linux/zutil.h>
#include <asm/facility.h>
#include <asm/setup.h>

/*
* C wrapper for the DEFLATE CONVERSION CALL instruction.
Expand Down Expand Up @@ -102,7 +103,8 @@ static inline int dfltcc_are_params_ok(

static inline int is_dfltcc_enabled(void)
{
return test_facility(DFLTCC_FACILITY);
return (zlib_dfltcc_support != ZLIB_DFLTCC_DISABLED &&
test_facility(DFLTCC_FACILITY));
}

char *oesc_msg(char *buf, int oesc);
Expand Down

0 comments on commit c65e681

Please sign in to comment.