Skip to content

Commit 30e037a

Browse files
Benjamin-BlockAlexander Gordeev
authored andcommitted
s390/qdio: Move memory alloc/pointer arithmetic for slib and sl into one place
Instead of distributing the memory allocation and pointer arithmetic to place slib and sl on the page that is allocated for them over multiple functions and comments, move both into the same context directly next to each other, so that the knowledge of how this is done is immediately visible. The actual layout in memory doesn't change with this, just the structure of the code to achieve it. Signed-off-by: Benjamin Block <[email protected]> Reviewed-by: Steffen Maier <[email protected]> Reviewed-by: Alexandra Winter <[email protected]> Signed-off-by: Alexander Gordeev <[email protected]>
1 parent efd34db commit 30e037a

File tree

2 files changed

+16
-10
lines changed

2 files changed

+16
-10
lines changed

drivers/s390/cio/qdio.h

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -210,11 +210,10 @@ struct qdio_q {
210210
qdio_handler_t (*handler);
211211

212212
struct qdio_irq *irq_ptr;
213+
214+
/* memory page (PAGE_SIZE) used to place slib and sl on */
215+
void *sl_page;
213216
struct sl *sl;
214-
/*
215-
* A page is allocated under this pointer and used for slib and sl.
216-
* slib is 2048 bytes big and sl points to offset PAGE_SIZE / 2.
217-
*/
218217
struct slib *slib;
219218
} __attribute__ ((aligned(256)));
220219

drivers/s390/cio/qdio_setup.c

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void __qdio_free_queues(struct qdio_q **queues, unsigned int count)
8383

8484
for (i = 0; i < count; i++) {
8585
q = queues[i];
86-
free_page((unsigned long) q->slib);
86+
free_page((unsigned long)q->sl_page);
8787
kmem_cache_free(qdio_q_cache, q);
8888
}
8989
}
@@ -109,12 +109,16 @@ static int __qdio_allocate_qs(struct qdio_q **irq_ptr_qs, int nr_queues)
109109
return -ENOMEM;
110110
}
111111

112-
q->slib = (struct slib *) __get_free_page(GFP_KERNEL);
113-
if (!q->slib) {
112+
q->sl_page = (void *)__get_free_page(GFP_KERNEL);
113+
if (!q->sl_page) {
114114
kmem_cache_free(qdio_q_cache, q);
115115
__qdio_free_queues(irq_ptr_qs, i);
116116
return -ENOMEM;
117117
}
118+
q->slib = q->sl_page;
119+
/* As per architecture: SLIB is 2K bytes long, and SL 1K. */
120+
q->sl = (struct sl *)(q->slib + 1);
121+
118122
irq_ptr_qs[i] = q;
119123
}
120124
return 0;
@@ -142,11 +146,15 @@ int qdio_allocate_qs(struct qdio_irq *irq_ptr, int nr_input_qs, int nr_output_qs
142146
static void setup_queues_misc(struct qdio_q *q, struct qdio_irq *irq_ptr,
143147
qdio_handler_t *handler, int i)
144148
{
145-
struct slib *slib = q->slib;
149+
struct slib *const slib = q->slib;
150+
void *const sl_page = q->sl_page;
151+
struct sl *const sl = q->sl;
146152

147153
/* queue must be cleared for qdio_establish */
148154
memset(q, 0, sizeof(*q));
149-
memset(slib, 0, PAGE_SIZE);
155+
memset(sl_page, 0, PAGE_SIZE);
156+
q->sl_page = sl_page;
157+
q->sl = sl;
150158
q->slib = slib;
151159
q->irq_ptr = irq_ptr;
152160
q->mask = 1 << (31 - i);
@@ -161,7 +169,6 @@ static void setup_storage_lists(struct qdio_q *q, struct qdio_irq *irq_ptr,
161169
int j;
162170

163171
DBF_HEX(&q, sizeof(void *));
164-
q->sl = (struct sl *)((char *)q->slib + PAGE_SIZE / 2);
165172

166173
/* fill in sbal */
167174
for (j = 0; j < QDIO_MAX_BUFFERS_PER_Q; j++)

0 commit comments

Comments
 (0)