Skip to content

Commit a9e869e

Browse files
author
Mete Durlu
committed
s390/cio: rework channel-utilization-block handling
JIRA: https://issues.redhat.com/browse/RHEL-50790 commit a817d98 Author: Peter Oberparleiter <oberpar@linux.ibm.com> Date: Tue Mar 26 17:03:20 2024 +0100 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> Signed-off-by: Mete Durlu <mdurlu@redhat.com>
1 parent 6c0c626 commit a9e869e

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
@@ -860,19 +860,16 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable)
860860
u32 : 30;
861861
u32 key : 4;
862862
u32 : 28;
863-
u32 zeroes1;
864-
dma32_t cub_addr1;
865-
u32 zeroes2;
866-
dma32_t cub_addr2;
863+
dma64_t cub[CSS_NUM_CUB_PAGES];
867864
u32 reserved[13];
868865
struct chsc_header response;
869866
u32 status : 8;
870867
u32 : 4;
871868
u32 fmt : 4;
872869
u32 : 16;
873-
} *secm_area;
870+
} __packed *secm_area;
874871
unsigned long flags;
875-
int ret, ccode;
872+
int ret, ccode, i;
876873

877874
spin_lock_irqsave(&chsc_page_lock, flags);
878875
memset(chsc_page, 0, PAGE_SIZE);
@@ -881,8 +878,9 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable)
881878
secm_area->request.code = 0x0016;
882879

883880
secm_area->key = PAGE_DEFAULT_KEY >> 4;
884-
secm_area->cub_addr1 = virt_to_dma32(css->cub_addr1);
885-
secm_area->cub_addr2 = virt_to_dma32(css->cub_addr2);
881+
882+
for (i = 0; i < CSS_NUM_CUB_PAGES; i++)
883+
secm_area->cub[i] = (__force dma64_t)virt_to_dma32(css->cub[i]);
886884

887885
secm_area->operation_code = enable ? 0 : 1;
888886

@@ -908,19 +906,38 @@ int __chsc_do_secm(struct channel_subsystem *css, int enable)
908906
return ret;
909907
}
910908

909+
static int cub_alloc(struct channel_subsystem *css)
910+
{
911+
int i;
912+
913+
for (i = 0; i < CSS_NUM_CUB_PAGES; i++) {
914+
css->cub[i] = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
915+
if (!css->cub[i])
916+
return -ENOMEM;
917+
}
918+
919+
return 0;
920+
}
921+
922+
static void cub_free(struct channel_subsystem *css)
923+
{
924+
int i;
925+
926+
for (i = 0; i < CSS_NUM_CUB_PAGES; i++) {
927+
free_page((unsigned long)css->cub[i]);
928+
css->cub[i] = NULL;
929+
}
930+
}
931+
911932
int
912933
chsc_secm(struct channel_subsystem *css, int enable)
913934
{
914935
int ret;
915936

916937
if (enable && !css->cm_enabled) {
917-
css->cub_addr1 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
918-
css->cub_addr2 = (void *)get_zeroed_page(GFP_KERNEL | GFP_DMA);
919-
if (!css->cub_addr1 || !css->cub_addr2) {
920-
free_page((unsigned long)css->cub_addr1);
921-
free_page((unsigned long)css->cub_addr2);
922-
return -ENOMEM;
923-
}
938+
ret = cub_alloc(css);
939+
if (ret)
940+
goto out;
924941
}
925942
ret = __chsc_do_secm(css, enable);
926943
if (!ret) {
@@ -934,10 +951,11 @@ chsc_secm(struct channel_subsystem *css, int enable)
934951
} else
935952
chsc_remove_cmg_attr(css);
936953
}
937-
if (!css->cm_enabled) {
938-
free_page((unsigned long)css->cub_addr1);
939-
free_page((unsigned long)css->cub_addr2);
940-
}
954+
955+
out:
956+
if (!css->cm_enabled)
957+
cub_free(css);
958+
941959
return ret;
942960
}
943961

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)