Commit 24ef4853 authored by Johan Hovold's avatar Johan Hovold Committed by Greg Kroah-Hartman

greybus: drop host-driver buffer headroom

Drop the host-driver buffer headroom that was used to transfer the cport
id on ES1 and ES2.

Rather than transferring additional bytes on the wire and having to deal
with buffer-alignment issues (e.g. requiring the headroom to be a
multiple of 8 bytes) simply drop the headroom functionality.

Host drivers are expected set up their transfer descriptors separately
from the data buffers and any intermediate drivers (e.g. for Greybus
over USB) can (ab)use the operation message pad bytes for now.
Signed-off-by: default avatarJohan Hovold <johan@hovoldconsulting.com>
Reviewed-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@google.com>
parent 491e60d6
...@@ -106,29 +106,11 @@ static void usb_log_disable(struct es1_ap_dev *es1); ...@@ -106,29 +106,11 @@ static void usb_log_disable(struct es1_ap_dev *es1);
* which defines a region of memory used by the host driver for * which defines a region of memory used by the host driver for
* transferring the data. When Greybus allocates a buffer, it must * transferring the data. When Greybus allocates a buffer, it must
* do so subject to the constraints associated with the host driver. * do so subject to the constraints associated with the host driver.
* These constraints are specified by two parameters: the
* headroom; and the maximum buffer size.
* *
* +------------------+ * size_max: The maximum size of a buffer
* | Host driver | \
* | reserved area | }- headroom
* | . . . | /
* buffer pointer ---> +------------------+
* | Buffer space for | \
* | transferred data | }- buffer size
* | . . . | / (limited to size_max)
* +------------------+
*
* headroom: Every buffer must have at least this much space
* *before* the buffer pointer, reserved for use by the
* host driver. I.e., ((char *)buffer - headroom) must
* point to valid memory, usable only by the host driver.
* size_max: The maximum size of a buffer (not including the
* headroom) must not exceed this.
*/ */
static void hd_buffer_constraints(struct greybus_host_device *hd) static void hd_buffer_constraints(struct greybus_host_device *hd)
{ {
hd->buffer_headroom = 0;
hd->buffer_size_max = ES1_GBUF_MSG_SIZE_MAX; hd->buffer_size_max = ES1_GBUF_MSG_SIZE_MAX;
} }
......
...@@ -106,29 +106,11 @@ static void usb_log_disable(struct es1_ap_dev *es1); ...@@ -106,29 +106,11 @@ static void usb_log_disable(struct es1_ap_dev *es1);
* which defines a region of memory used by the host driver for * which defines a region of memory used by the host driver for
* transferring the data. When Greybus allocates a buffer, it must * transferring the data. When Greybus allocates a buffer, it must
* do so subject to the constraints associated with the host driver. * do so subject to the constraints associated with the host driver.
* These constraints are specified by two parameters: the
* headroom; and the maximum buffer size.
* *
* +------------------+ * size_max: The maximum size of a buffer
* | Host driver | \
* | reserved area | }- headroom
* | . . . | /
* buffer pointer ---> +------------------+
* | Buffer space for | \
* | transferred data | }- buffer size
* | . . . | / (limited to size_max)
* +------------------+
*
* headroom: Every buffer must have at least this much space
* *before* the buffer pointer, reserved for use by the
* host driver. I.e., ((char *)buffer - headroom) must
* point to valid memory, usable only by the host driver.
* size_max: The maximum size of a buffer (not including the
* headroom) must not exceed this.
*/ */
static void hd_buffer_constraints(struct greybus_host_device *hd) static void hd_buffer_constraints(struct greybus_host_device *hd)
{ {
hd->buffer_headroom = 0;
hd->buffer_size_max = ES1_GBUF_MSG_SIZE_MAX; hd->buffer_size_max = ES1_GBUF_MSG_SIZE_MAX;
} }
......
...@@ -71,14 +71,6 @@ ...@@ -71,14 +71,6 @@
struct greybus_host_device; struct greybus_host_device;
struct svc_msg; struct svc_msg;
/*
* When the Greybus code allocates a buffer it sets aside bytes
* prior to the beginning of the payload area for the host device's
* exclusive use. The size is specified by hd->buffer_headroom, and
* which can't be greater than GB_BUFFER_HEADROOM_MAX.
*/
#define GB_BUFFER_HEADROOM_MAX sizeof(u64)
/* Greybus "Host driver" structure, needed by a host controller driver to be /* Greybus "Host driver" structure, needed by a host controller driver to be
* able to handle both SVC control as well as "real" greybus messages * able to handle both SVC control as well as "real" greybus messages
*/ */
...@@ -103,7 +95,6 @@ struct greybus_host_device { ...@@ -103,7 +95,6 @@ struct greybus_host_device {
u8 device_id; u8 device_id;
/* Host device buffer constraints */ /* Host device buffer constraints */
size_t buffer_headroom;
size_t buffer_size_max; size_t buffer_size_max;
/* Private data for the host driver */ /* Private data for the host driver */
......
...@@ -230,7 +230,7 @@ static void gb_operation_message_init(struct greybus_host_device *hd, ...@@ -230,7 +230,7 @@ static void gb_operation_message_init(struct greybus_host_device *hd,
u8 *buffer; u8 *buffer;
buffer = message->buffer; buffer = message->buffer;
header = (struct gb_operation_msg_hdr *)(buffer + hd->buffer_headroom); header = message->buffer;
message->header = header; message->header = header;
message->payload = payload_size ? header + 1 : NULL; message->payload = payload_size ? header + 1 : NULL;
...@@ -271,7 +271,6 @@ static void gb_operation_message_init(struct greybus_host_device *hd, ...@@ -271,7 +271,6 @@ static void gb_operation_message_init(struct greybus_host_device *hd,
* they'll be filled in by arriving data. * they'll be filled in by arriving data.
* *
* Our message buffers have the following layout: * Our message buffers have the following layout:
* headroom
* message header \_ these combined are * message header \_ these combined are
* message payload / the message size * message payload / the message size
*/ */
...@@ -282,7 +281,6 @@ gb_operation_message_alloc(struct greybus_host_device *hd, u8 type, ...@@ -282,7 +281,6 @@ gb_operation_message_alloc(struct greybus_host_device *hd, u8 type,
struct gb_message *message; struct gb_message *message;
struct gb_operation_msg_hdr *header; struct gb_operation_msg_hdr *header;
size_t message_size = payload_size + sizeof(*header); size_t message_size = payload_size + sizeof(*header);
size_t size;
if (hd->buffer_size_max > GB_OPERATION_MESSAGE_SIZE_MAX) { if (hd->buffer_size_max > GB_OPERATION_MESSAGE_SIZE_MAX) {
pr_warn("limiting buffer size to %u\n", pr_warn("limiting buffer size to %u\n",
...@@ -301,8 +299,7 @@ gb_operation_message_alloc(struct greybus_host_device *hd, u8 type, ...@@ -301,8 +299,7 @@ gb_operation_message_alloc(struct greybus_host_device *hd, u8 type,
if (!message) if (!message)
return NULL; return NULL;
size = hd->buffer_headroom + message_size; message->buffer = kzalloc(message_size, gfp_flags);
message->buffer = kzalloc(size, gfp_flags);
if (!message->buffer) if (!message->buffer)
goto err_free_message; goto err_free_message;
......
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