mirror of
https://github.com/torvalds/linux.git
synced 2026-04-18 14:53:58 -04:00
s390/ap/zcrypt: Rework AP message buffer allocation
Slight rework on the way how AP message buffers are allocated. Instead of having multiple places with kmalloc() calls all the AP message buffers are now allocated and freed on exactly one place: ap_init_apmsg() allocates the current AP bus max limit of ap_max_msg_size (defaults to 12KB). The AP message buffer is then freed in ap_release_apmsg(). Signed-off-by: Harald Freudenberger <freude@linux.ibm.com> Reviewed-by: Holger Dengler <dengler@linux.ibm.com> Link: https://lore.kernel.org/r/20250424133619.16495-3-freude@linux.ibm.com Signed-off-by: Heiko Carstens <hca@linux.ibm.com>
This commit is contained in:
committed by
Heiko Carstens
parent
43435495a0
commit
57db62a130
@@ -547,6 +547,32 @@ static void ap_poll_thread_stop(void)
|
||||
#define is_card_dev(x) ((x)->parent == ap_root_device)
|
||||
#define is_queue_dev(x) ((x)->parent != ap_root_device)
|
||||
|
||||
/*
|
||||
* ap_init_apmsg() - Initialize ap_message.
|
||||
*/
|
||||
int ap_init_apmsg(struct ap_message *ap_msg)
|
||||
{
|
||||
unsigned int maxmsgsize = atomic_read(&ap_max_msg_size);
|
||||
|
||||
memset(ap_msg, 0, sizeof(*ap_msg));
|
||||
ap_msg->msg = kmalloc(maxmsgsize, GFP_KERNEL);
|
||||
if (!ap_msg->msg)
|
||||
return -ENOMEM;
|
||||
ap_msg->bufsize = maxmsgsize;
|
||||
|
||||
return 0;
|
||||
}
|
||||
EXPORT_SYMBOL(ap_init_apmsg);
|
||||
|
||||
/*
|
||||
* ap_release_apmsg() - Release ap_message.
|
||||
*/
|
||||
void ap_release_apmsg(struct ap_message *ap_msg)
|
||||
{
|
||||
kfree_sensitive(ap_msg->msg);
|
||||
}
|
||||
EXPORT_SYMBOL(ap_release_apmsg);
|
||||
|
||||
/**
|
||||
* ap_bus_match()
|
||||
* @dev: Pointer to device
|
||||
|
||||
Reference in New Issue
Block a user