Commit 1c7658cf authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: operation: fix atomic response allocation

Response allocation also needs a GFP-flags argument as a response is
allocated as part of an outgoing operation.

Fixes: 9aa174d202e5 ("operation: allow atomic operation allocations")
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 93047af2
...@@ -75,7 +75,8 @@ static int gb_control_request_recv(u8 type, struct gb_operation *op) ...@@ -75,7 +75,8 @@ static int gb_control_request_recv(u8 type, struct gb_operation *op)
// an AP. // an AP.
break; break;
case GB_CONTROL_TYPE_PROTOCOL_VERSION: case GB_CONTROL_TYPE_PROTOCOL_VERSION:
if (!gb_operation_response_alloc(op, sizeof(*version))) { if (!gb_operation_response_alloc(op, sizeof(*version),
GFP_KERNEL)) {
dev_err(&connection->dev, dev_err(&connection->dev,
"%s: error allocating response\n", __func__); "%s: error allocating response\n", __func__);
return -ENOMEM; return -ENOMEM;
......
...@@ -283,7 +283,8 @@ static int gb_loopback_request_recv(u8 type, struct gb_operation *operation) ...@@ -283,7 +283,8 @@ static int gb_loopback_request_recv(u8 type, struct gb_operation *operation)
} }
if (len) { if (len) {
if (!gb_operation_response_alloc(operation, len)) { if (!gb_operation_response_alloc(operation, len,
GFP_KERNEL)) {
dev_err(&connection->dev, dev_err(&connection->dev,
"error allocating response\n"); "error allocating response\n");
return -ENOMEM; return -ENOMEM;
......
...@@ -426,7 +426,7 @@ static u8 gb_operation_errno_map(int errno) ...@@ -426,7 +426,7 @@ static u8 gb_operation_errno_map(int errno)
} }
bool gb_operation_response_alloc(struct gb_operation *operation, bool gb_operation_response_alloc(struct gb_operation *operation,
size_t response_size) size_t response_size, gfp_t gfp)
{ {
struct greybus_host_device *hd = operation->connection->hd; struct greybus_host_device *hd = operation->connection->hd;
struct gb_operation_msg_hdr *request_header; struct gb_operation_msg_hdr *request_header;
...@@ -434,8 +434,7 @@ bool gb_operation_response_alloc(struct gb_operation *operation, ...@@ -434,8 +434,7 @@ bool gb_operation_response_alloc(struct gb_operation *operation,
u8 type; u8 type;
type = operation->type | GB_MESSAGE_TYPE_RESPONSE; type = operation->type | GB_MESSAGE_TYPE_RESPONSE;
response = gb_operation_message_alloc(hd, type, response_size, response = gb_operation_message_alloc(hd, type, response_size, gfp);
GFP_KERNEL);
if (!response) if (!response)
return false; return false;
response->operation = operation; response->operation = operation;
...@@ -497,8 +496,10 @@ gb_operation_create_common(struct gb_connection *connection, u8 type, ...@@ -497,8 +496,10 @@ gb_operation_create_common(struct gb_connection *connection, u8 type,
/* Allocate the response buffer for outgoing operations */ /* Allocate the response buffer for outgoing operations */
if (!(op_flags & GB_OPERATION_FLAG_INCOMING)) { if (!(op_flags & GB_OPERATION_FLAG_INCOMING)) {
if (!gb_operation_response_alloc(operation, response_size)) if (!gb_operation_response_alloc(operation, response_size,
gfp_flags)) {
goto err_request; goto err_request;
}
} }
operation->flags = op_flags; operation->flags = op_flags;
...@@ -734,7 +735,7 @@ static int gb_operation_response_send(struct gb_operation *operation, ...@@ -734,7 +735,7 @@ static int gb_operation_response_send(struct gb_operation *operation,
if (!operation->response && if (!operation->response &&
!gb_operation_is_unidirectional(operation)) { !gb_operation_is_unidirectional(operation)) {
if (!gb_operation_response_alloc(operation, 0)) if (!gb_operation_response_alloc(operation, 0, GFP_KERNEL))
return -ENOMEM; return -ENOMEM;
} }
......
...@@ -166,7 +166,7 @@ static inline void gb_operation_destroy(struct gb_operation *operation) ...@@ -166,7 +166,7 @@ static inline void gb_operation_destroy(struct gb_operation *operation)
} }
bool gb_operation_response_alloc(struct gb_operation *operation, bool gb_operation_response_alloc(struct gb_operation *operation,
size_t response_size); size_t response_size, gfp_t gfp);
int gb_operation_request_send(struct gb_operation *operation, int gb_operation_request_send(struct gb_operation *operation,
gb_operation_callback callback, gb_operation_callback callback,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment