Skip to content

Commit a817d98

Browse files
oberparAlexander Gordeev
authored andcommitted
s390/cio: rework channel-utilization-block handling
Convert channel-utilization-block (CUB) address variables from separate named fields to arrays of addresses. Also simplify error handling and introduce named constants. This is done in preparation of introducing additional CUBs. Note: With this change the __packed annotation of secm_area is required to prevent an alignment hole that would otherwise occur due to the switch from u32 to dma64_t. Reviewed-by: Vineeth Vijayan <vneethv@linux.ibm.com> Acked-by: Heiko Carstens <hca@linux.ibm.com> Signed-off-by: Peter Oberparleiter <oberpar@linux.ibm.com> Signed-off-by: Alexander Gordeev <agordeev@linux.ibm.com>
1 parent d35c34b commit a817d98

File tree

3 files changed

+49
-25
lines changed

3 files changed

+49
-25
lines changed

drivers/s390/cio/chp.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,12 @@ static void chp_measurement_copy_block(struct cmg_entry *buf,
161161
struct cmg_entry *entry, reference_buf;
162162
int idx;
163163

164-
if (chpid.id < 128) {
165-
area = css->cub_addr1;
164+
if (chpid.id < CSS_CUES_PER_PAGE) {
165+
area = css->cub[0];
166166
idx = chpid.id;
167167
} else {
168-
area = css->cub_addr2;
169-
idx = chpid.id - 128;
168+
area = css->cub[1];
169+
idx = chpid.id - CSS_CUES_PER_PAGE;
170170
}
171171
entry = area + (idx * sizeof(struct cmg_entry));
172172
do {

drivers/s390/cio/chsc.c

Lines changed: 37 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -874,19 +874,16 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable)
874874
u32 : 30;
875875
u32 key : 4;
876876
u32 : 28;
877-
u32 zeroes1;
878-
dma32_t cub_addr1;
879-
u32 zeroes2;
880-
dma32_t cub_addr2;
877+
dma64_t cub[CSS_NUM_CUB_PAGES];
881878
u32 reserved[13];
882879
struct chsc_header response;
883880
u32 status : 8;
884881
u32 : 4;
885882
u32 fmt : 4;
886883
u32 : 16;
887-
} *secm_area;
884+
} __packed *secm_area;
888885
unsigned long flags;
889-
int ret, ccode;
886+
int ret, ccode, i;
890887

891888
spin_lock_irqsave(&chsc_page_lock, flags);
892889
memset(chsc_page, 0, PAGE_SIZE);
@@ -895,8 +892,9 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable)
895892
secm_area->request.code = 0x0016;
896893

897894
secm_area->key = PAGE_DEFAULT_KEY >> 4;
898-
secm_area->cub_addr1 = virt_to_dma32(css->cub_addr1);
899-
secm_area->cub_addr2 = virt_to_dma32(css->cub_addr2);
895+
896+
for (i = 0; i < CSS_NUM_CUB_PAGES; i++)
897+
secm_area->cub[i] = (__force dma64_t)virt_to_dma32(css->cub[i]);
900898

901899
secm_area->operation_code = enable ? 0 : 1;
902900

@@ -922,19 +920,38 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable)
922920
return ret;
923921
}
924922

923+
static int cub_alloc(struct channel_subsystem *css)
924+
{
925+
int i;
926+
927+
for (i = 0; i < CSS_NUM_CUB_PAGES; i++) {
928+
css->cub[i] = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
929+
if (!css->cub[i])
930+
return -ENOMEM;
931+
}
932+
933+
return 0;
934+
}
935+
936+
static void cub_free(struct channel_subsystem *css)
937+
{
938+
int i;
939+
940+
for (i = 0; i < CSS_NUM_CUB_PAGES; i++) {
941+
free_page((unsigned long)css->cub[i]);
942+
css->cub[i] = NULL;
943+
}
944+
}
945+
925946
int
926947
chsc_secm(struct channel_subsystem *css, int enable)
927948
{
928949
int ret;
929950

930951
if (enable && !css->cm_enabled) {
931-
css->cub_addr1 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
932-
css->cub_addr2 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
933-
if (!css->cub_addr1 || !css->cub_addr2) {
934-
free_page((unsigned long)css->cub_addr1);
935-
free_page((unsigned long)css->cub_addr2);
936-
return -ENOMEM;
937-
}
952+
ret = cub_alloc(css);
953+
if (ret)
954+
goto out;
938955
}
939956
ret = __chsc_do_secm(css, enable);
940957
if (!ret) {
@@ -948,10 +965,11 @@ chsc_secm(struct channel_subsystem *css, int enable)
948965
} else
949966
chsc_remove_cmg_attr(css);
950967
}
951-
if (!css->cm_enabled) {
952-
free_page((unsigned long)css->cub_addr1);
953-
free_page((unsigned long)css->cub_addr2);
954-
}
968+
969+
out:
970+
if (!css->cm_enabled)
971+
cub_free(css);
972+
955973
return ret;
956974
}
957975

drivers/s390/cio/css.h

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,13 @@
3434
#define SNID_STATE3_MULTI_PATH 1
3535
#define SNID_STATE3_SINGLE_PATH 0
3636

37+
/*
38+
* Miscellaneous constants
39+
*/
40+
41+
#define CSS_NUM_CUB_PAGES 2
42+
#define CSS_CUES_PER_PAGE 128
43+
3744
/*
3845
* Conditions used to specify which subchannels need evaluation
3946
*/
@@ -122,8 +129,7 @@ struct channel_subsystem {
122129
struct mutex mutex;
123130
/* channel measurement related */
124131
int cm_enabled;
125-
void *cub_addr1;
126-
void *cub_addr2;
132+
void *cub[CSS_NUM_CUB_PAGES];
127133
/* for orphaned ccw devices */
128134
struct subchannel *pseudo_subchannel;
129135
};

0 commit comments

Comments
 (0)