Commit 4f83b8d3 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: fix an allocation flag bug

We allocate message buffers with GFP_KERNEL allocation flags if
possible.  However when an incoming request message is received we
can be in interrupt context, so we must use GFP_ATOMIC in that case.

The computation of gfp_flags in gb_operation_message_init() is
wrong.  It is needlessly using GFP_ATOMIC when allocating outbound
response buffers.  Fix the flawed logic.

Change the name of "data_out" to be "outbound" to be consistent with
usage elsewhere.  (Data/messages are "inbound" or "outbound";
requests are "incoming" or "outgoing".)
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent 374e6a26
...@@ -213,14 +213,14 @@ static void operation_timeout(struct work_struct *work) ...@@ -213,14 +213,14 @@ static void operation_timeout(struct work_struct *work)
*/ */
static int gb_operation_message_init(struct gb_operation *operation, static int gb_operation_message_init(struct gb_operation *operation,
u8 type, size_t size, u8 type, size_t size,
bool request, bool data_out) bool request, bool outbound)
{ {
struct gb_connection *connection = operation->connection; struct gb_connection *connection = operation->connection;
struct greybus_host_device *hd = connection->hd; struct greybus_host_device *hd = connection->hd;
struct gb_message *message; struct gb_message *message;
struct gb_operation_msg_hdr *header; struct gb_operation_msg_hdr *header;
struct gbuf *gbuf; struct gbuf *gbuf;
gfp_t gfp_flags = data_out ? GFP_KERNEL : GFP_ATOMIC; gfp_t gfp_flags = request && !outbound ? GFP_ATOMIC : GFP_KERNEL;
u16 dest_cport_id; u16 dest_cport_id;
int ret; int ret;
...@@ -236,7 +236,7 @@ static int gb_operation_message_init(struct gb_operation *operation, ...@@ -236,7 +236,7 @@ static int gb_operation_message_init(struct gb_operation *operation,
} }
gbuf = &message->gbuf; gbuf = &message->gbuf;
if (data_out) if (outbound)
dest_cport_id = connection->interface_cport_id; dest_cport_id = connection->interface_cport_id;
else else
dest_cport_id = CPORT_ID_BAD; dest_cport_id = CPORT_ID_BAD;
......
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