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: Johan Hovold <johan@hovoldconsulting.com> Reviewed-by: Alex Elder <elder@linaro.org> Signed-off-by: Greg Kroah-Hartman <gregkh@google.com>
This commit is contained in:
parent
491e60d63f
commit
24ef485398
@ -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
|
||||
* transferring the data. When Greybus allocates a buffer, it must
|
||||
* 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.
|
||||
*
|
||||
* +------------------+
|
||||
* | 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.
|
||||
* size_max: The maximum size of a buffer
|
||||
*/
|
||||
static void hd_buffer_constraints(struct greybus_host_device *hd)
|
||||
{
|
||||
hd->buffer_headroom = 0;
|
||||
hd->buffer_size_max = ES1_GBUF_MSG_SIZE_MAX;
|
||||
}
|
||||
|
||||
|
@ -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
|
||||
* transferring the data. When Greybus allocates a buffer, it must
|
||||
* 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.
|
||||
*
|
||||
* +------------------+
|
||||
* | 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.
|
||||
* size_max: The maximum size of a buffer
|
||||
*/
|
||||
static void hd_buffer_constraints(struct greybus_host_device *hd)
|
||||
{
|
||||
hd->buffer_headroom = 0;
|
||||
hd->buffer_size_max = ES1_GBUF_MSG_SIZE_MAX;
|
||||
}
|
||||
|
||||
|
@ -71,14 +71,6 @@
|
||||
struct greybus_host_device;
|
||||
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
|
||||
* able to handle both SVC control as well as "real" greybus messages
|
||||
*/
|
||||
@ -103,7 +95,6 @@ struct greybus_host_device {
|
||||
u8 device_id;
|
||||
|
||||
/* Host device buffer constraints */
|
||||
size_t buffer_headroom;
|
||||
size_t buffer_size_max;
|
||||
|
||||
/* Private data for the host driver */
|
||||
|
@ -230,7 +230,7 @@ static void gb_operation_message_init(struct greybus_host_device *hd,
|
||||
u8 *buffer;
|
||||
|
||||
buffer = message->buffer;
|
||||
header = (struct gb_operation_msg_hdr *)(buffer + hd->buffer_headroom);
|
||||
header = message->buffer;
|
||||
|
||||
message->header = header;
|
||||
message->payload = payload_size ? header + 1 : NULL;
|
||||
@ -271,7 +271,6 @@ static void gb_operation_message_init(struct greybus_host_device *hd,
|
||||
* they'll be filled in by arriving data.
|
||||
*
|
||||
* Our message buffers have the following layout:
|
||||
* headroom
|
||||
* message header \_ these combined are
|
||||
* message payload / the message size
|
||||
*/
|
||||
@ -282,7 +281,6 @@ gb_operation_message_alloc(struct greybus_host_device *hd, u8 type,
|
||||
struct gb_message *message;
|
||||
struct gb_operation_msg_hdr *header;
|
||||
size_t message_size = payload_size + sizeof(*header);
|
||||
size_t size;
|
||||
|
||||
if (hd->buffer_size_max > GB_OPERATION_MESSAGE_SIZE_MAX) {
|
||||
pr_warn("limiting buffer size to %u\n",
|
||||
@ -301,8 +299,7 @@ gb_operation_message_alloc(struct greybus_host_device *hd, u8 type,
|
||||
if (!message)
|
||||
return NULL;
|
||||
|
||||
size = hd->buffer_headroom + message_size;
|
||||
message->buffer = kzalloc(size, gfp_flags);
|
||||
message->buffer = kzalloc(message_size, gfp_flags);
|
||||
if (!message->buffer)
|
||||
goto err_free_message;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user