Commit 63921d88 authored by Alex Elder's avatar Alex Elder Committed by Greg Kroah-Hartman

greybus: record a gbuf's destination CPort id

Rather than indicating whether a gbuf is intended for outbound data,
record its destination CPort id.  That's what's really needed by
the ES1 host driver.  Use CPORT_ID_BAD when the buffer is intended
for inbound data.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <greg@kroah.com>
parent c7d0f258
...@@ -97,7 +97,7 @@ static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size, ...@@ -97,7 +97,7 @@ static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size,
gfp_t gfp_mask) gfp_t gfp_mask)
{ {
struct gb_connection *connection = gbuf->operation->connection; struct gb_connection *connection = gbuf->operation->connection;
u32 cport_reserve = gbuf->outbound ? 1 : 0; u32 cport_reserve = gbuf->dest_cport_id == CPORT_ID_BAD ? 0 : 1;
u8 *buffer; u8 *buffer;
if (size > ES1_GBUF_MSG_SIZE) { if (size > ES1_GBUF_MSG_SIZE) {
...@@ -130,7 +130,7 @@ static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size, ...@@ -130,7 +130,7 @@ static int alloc_gbuf_data(struct gbuf *gbuf, unsigned int size,
} }
/* Insert the cport id for outbound buffers */ /* Insert the cport id for outbound buffers */
if (gbuf->outbound) if (cport_reserve)
*buffer++ = connection->interface_cport_id; *buffer++ = connection->interface_cport_id;
gbuf->transfer_buffer = buffer; gbuf->transfer_buffer = buffer;
gbuf->transfer_buffer_length = size; gbuf->transfer_buffer_length = size;
...@@ -147,7 +147,8 @@ static void free_gbuf_data(struct gbuf *gbuf) ...@@ -147,7 +147,8 @@ static void free_gbuf_data(struct gbuf *gbuf)
if (!transfer_buffer) if (!transfer_buffer)
return; return;
if (gbuf->outbound) /* Account for the cport id in outbound buffers */
if (gbuf->dest_cport_id != CPORT_ID_BAD)
transfer_buffer--; /* Back up to cport id */ transfer_buffer--; /* Back up to cport id */
kfree(transfer_buffer); kfree(transfer_buffer);
} }
......
...@@ -35,8 +35,8 @@ static struct kmem_cache *gbuf_head_cache; ...@@ -35,8 +35,8 @@ static struct kmem_cache *gbuf_head_cache;
* hardware designers for this issue... * hardware designers for this issue...
*/ */
struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation, struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation,
u16 dest_cport_id,
unsigned int size, unsigned int size,
bool outbound,
gfp_t gfp_mask) gfp_t gfp_mask)
{ {
struct greybus_host_device *hd = operation->connection->hd; struct greybus_host_device *hd = operation->connection->hd;
...@@ -49,7 +49,7 @@ struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation, ...@@ -49,7 +49,7 @@ struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation,
kref_init(&gbuf->kref); kref_init(&gbuf->kref);
gbuf->operation = operation; gbuf->operation = operation;
gbuf->outbound = outbound; gbuf->dest_cport_id = dest_cport_id;
gbuf->status = -EBADR; /* Initial value--means "never set" */ gbuf->status = -EBADR; /* Initial value--means "never set" */
/* Host controller specific allocation for the actual buffer */ /* Host controller specific allocation for the actual buffer */
......
...@@ -122,12 +122,12 @@ struct gbuf { ...@@ -122,12 +122,12 @@ struct gbuf {
struct kref kref; struct kref kref;
struct gb_operation *operation; struct gb_operation *operation;
u16 dest_cport_id; /* Destination CPort id */
int status; int status;
void *transfer_buffer; void *transfer_buffer;
u32 transfer_buffer_length; u32 transfer_buffer_length;
bool outbound; /* AP-relative data direction */
void *hcd_data; /* for the HCD to track the gbuf */ void *hcd_data; /* for the HCD to track the gbuf */
}; };
...@@ -182,7 +182,7 @@ void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id, ...@@ -182,7 +182,7 @@ void greybus_cport_in(struct greybus_host_device *hd, u16 cport_id,
u8 *data, size_t length); u8 *data, size_t length);
struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation, struct gbuf *greybus_alloc_gbuf(struct gb_operation *operation,
unsigned int size, bool outbound, u16 dest_cport_id, unsigned int size,
gfp_t gfp_mask); gfp_t gfp_mask);
void greybus_free_gbuf(struct gbuf *gbuf); void greybus_free_gbuf(struct gbuf *gbuf);
struct gbuf *greybus_get_gbuf(struct gbuf *gbuf); struct gbuf *greybus_get_gbuf(struct gbuf *gbuf);
......
...@@ -203,12 +203,17 @@ static struct gbuf *gb_operation_gbuf_create(struct gb_operation *operation, ...@@ -203,12 +203,17 @@ static struct gbuf *gb_operation_gbuf_create(struct gb_operation *operation,
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 = data_out ? GFP_KERNEL : GFP_ATOMIC;
u16 dest_cport_id;
if (size > GB_OPERATION_MESSAGE_SIZE_MAX) if (size > GB_OPERATION_MESSAGE_SIZE_MAX)
return NULL; /* Message too big */ return NULL; /* Message too big */
if (data_out)
dest_cport_id = operation->connection->interface_cport_id;
else
dest_cport_id = CPORT_ID_BAD;
size += sizeof(*header); size += sizeof(*header);
gbuf = greybus_alloc_gbuf(operation, size, data_out, gfp_flags); gbuf = greybus_alloc_gbuf(operation, dest_cport_id, size, gfp_flags);
if (!gbuf) if (!gbuf)
return NULL; return NULL;
......
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