* 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;
}
* 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;
}
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
*/
u8 device_id;
/* Host device buffer constraints */
- size_t buffer_headroom;
size_t buffer_size_max;
/* Private data for the host driver */
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;
* 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
*/
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",
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;