Skip to content

Commit 91a970d

Browse files
hbruecknerMartin Schwidefsky
authored andcommitted
[S390] hvc_iucv: allocate memory buffers for IUCV in zone DMA
The device driver must allocate memory for IUCV buffers with GFP_DMA, because IUCV cannot address memory above 2GB (31bit addresses only). Because the IUCV ignores the higher bits of the address, sending and receiving IUCV data with this driver might cause memory corruptions. Signed-off-by: Hendrik Brueckner <brueckner@linux.vnet.ibm.com> Signed-off-by: Martin Schwidefsky <schwidefsky@de.ibm.com>
1 parent 596a95c commit 91a970d

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

drivers/char/hvc_iucv.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,6 +139,8 @@ struct hvc_iucv_private *hvc_iucv_get_private(uint32_t num)
139139
*
140140
* This function allocates a new struct iucv_tty_buffer element and, optionally,
141141
* allocates an internal data buffer with the specified size @size.
142+
* The internal data buffer is always allocated with GFP_DMA which is
143+
* required for receiving and sending data with IUCV.
142144
* Note: The total message size arises from the internal buffer size and the
143145
* members of the iucv_tty_msg structure.
144146
* The function returns NULL if memory allocation has failed.
@@ -154,7 +156,7 @@ static struct iucv_tty_buffer *alloc_tty_buffer(size_t size, gfp_t flags)
154156

155157
if (size > 0) {
156158
bufp->msg.length = MSG_SIZE(size);
157-
bufp->mbuf = kmalloc(bufp->msg.length, flags);
159+
bufp->mbuf = kmalloc(bufp->msg.length, flags | GFP_DMA);
158160
if (!bufp->mbuf) {
159161
mempool_free(bufp, hvc_iucv_mempool);
160162
return NULL;
@@ -237,7 +239,7 @@ static int hvc_iucv_write(struct hvc_iucv_private *priv,
237239
if (!rb->mbuf) { /* message not yet received ... */
238240
/* allocate mem to store msg data; if no memory is available
239241
* then leave the buffer on the list and re-try later */
240-
rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC);
242+
rb->mbuf = kmalloc(rb->msg.length, GFP_ATOMIC | GFP_DMA);
241243
if (!rb->mbuf)
242244
return -ENOMEM;
243245

0 commit comments

Comments
 (0)