Skip to content

Commit fd167f7

Browse files
Jett RinkEnric Balletbo i Serra
authored andcommitted
platform/chrome: cros_ec_ishtp: free ishtp buffer before sending event
Recycle the ISH buffer before notifying of a response or an event. Often a new message is sent in response to an event and in high traffic scenarios this can lead to exhausting all available buffers. We can ensure we are using the fewest buffers possible by freeing buffers as soon as they are used. Signed-off-by: Jett Rink <[email protected]> Signed-off-by: Mathew King <[email protected]> Signed-off-by: Enric Balletbo i Serra <[email protected]>
1 parent 0f706b4 commit fd167f7

File tree

1 file changed

+10
-3
lines changed

1 file changed

+10
-3
lines changed

drivers/platform/chrome/cros_ec_ishtp.c

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,10 @@ static void process_recv(struct ishtp_cl *cros_ish_cl,
303303
rb_in_proc->buffer.data, data_len);
304304

305305
error_wake_up:
306+
/* Free the buffer since we copied data or didn't need it */
307+
ishtp_cl_io_rb_recycle(rb_in_proc);
308+
rb_in_proc = NULL;
309+
306310
/* Set flag before waking up the caller */
307311
client_data->response.received = true;
308312

@@ -312,12 +316,14 @@ static void process_recv(struct ishtp_cl *cros_ish_cl,
312316
break;
313317

314318
case CROS_MKBP_EVENT:
319+
/* Free the buffer. This is just an event without data */
320+
ishtp_cl_io_rb_recycle(rb_in_proc);
321+
rb_in_proc = NULL;
315322
/*
316323
* Set timestamp from beginning of function since we actually
317324
* got an incoming MKBP event
318325
*/
319326
client_data->ec_dev->last_event_time = timestamp;
320-
/* The event system doesn't send any data in buffer */
321327
schedule_work(&client_data->work_ec_evt);
322328

323329
break;
@@ -327,8 +333,9 @@ static void process_recv(struct ishtp_cl *cros_ish_cl,
327333
}
328334

329335
end_error:
330-
/* Free the buffer */
331-
ishtp_cl_io_rb_recycle(rb_in_proc);
336+
/* Free the buffer if we already haven't */
337+
if (rb_in_proc)
338+
ishtp_cl_io_rb_recycle(rb_in_proc);
332339

333340
up_read(&init_lock);
334341
}

0 commit comments

Comments
 (0)