Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp753141ybb; Fri, 10 Apr 2020 09:24:16 -0700 (PDT) X-Google-Smtp-Source: APiQypL6vZ9dx0XgKu8PVrgEooGivBgp+TzxzXU8vUMbN/SSSowXKvv2310B86ltNJiLBxuk9Kjn X-Received: by 2002:ac8:7185:: with SMTP id w5mr4967735qto.356.1586535855991; Fri, 10 Apr 2020 09:24:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586535855; cv=none; d=google.com; s=arc-20160816; b=VUA1wF/HianAEJ0bNdsQo0GIS2AXMsM6X8WN5MJxJTOLrekqGRqELfPEfoJ6+IwIZx NhA3Ud7cqDNWTcfMRxTBL6S2HBJCHP2No/oX98n3WuneoHyyo2op4Z+C86bkkO2V9KKJ 7myAkbJWrbMo2ZcNwaUpnp7rWsE1+LJwhux1wt1qQkYreJohmF0JCpQLFtrNT7YSgF/q fYL8pjdGNgJBZtLPb84K6cOZ2VJEndmzfedSNp3E6T+PIfAvq8Km1uuWsppDVIogO6DR WwTUSIpyRUyoHYvNhjVbvJzStQPX0KJFUTIx29K1VxR154bKcqQNDtgIW5VIHjDKRuy5 50qw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=/lfx3tjaOBOzaW9h0e1NHY7R45MyYzBd77LVWDJwb7c=; b=IOcGtQBxw8GoQTsvPF+QAr65YAmutMQRixycXKtiGamdVK9ryMsHL7Ow2fVqOKVGh2 +jD2beIs3G7ComaenD3fYPBjMWSEY7FHa8YB+PVG2bEAj9CW1y7k5wgTf6cc4sDWUzXe Wx6nFVWhSsGCR9a4FZWwRvxAuSPgFY+nmN2l/hm3oVmkCts1BTrkN8pGvmPsU+WjH9E3 MPK4sqYaCgSlW7Pc3hDL8EXCquk27+Fs+imVaezCtTocInlhJ4Jdfq8ndwmr6yi3pzF0 JIacC7gw4w9DUfyfF0P1zwLvHQTwnwX2Tgv9pjyXfkiy5H3d3lUN86iDsXbRaZPdBnjR 5sVA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jrKTM89N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id q4si1557523qkb.342.2020.04.10.09.24.00; Fri, 10 Apr 2020 09:24:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=jrKTM89N; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726681AbgDJQXX (ORCPT + 99 others); Fri, 10 Apr 2020 12:23:23 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:42385 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726598AbgDJQXX (ORCPT ); Fri, 10 Apr 2020 12:23:23 -0400 Received: by mail-pl1-f193.google.com with SMTP id v2so802729plp.9 for ; Fri, 10 Apr 2020 09:23:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=/lfx3tjaOBOzaW9h0e1NHY7R45MyYzBd77LVWDJwb7c=; b=jrKTM89NWarNDGkzWQeV2RHja8BiVq0r76KzJHL55eZ4Xykhu9ygG4m7HbaqDQZlTJ 33frEQMVpj2Ci6tX5EXpGIXDlDXUJKoZWjLZHmBEAOmj0EVZf0O4SIqvlZiTxX4Vdned kQYXcLhWADTpRgIRMMyqUO9dezuwUawGjYyRA= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=/lfx3tjaOBOzaW9h0e1NHY7R45MyYzBd77LVWDJwb7c=; b=ATjvjQlMBCpClgh6+NQgzNzWruRk408KGFgA/1TtwhZQPTx8JawIfx+m9R5P4v7YGx uL/QxjW+PAEeSRYfY3OrDF2y1QHGWlLLjlfAUGIx9CCRt1lbnwEAPuivwOjDVgbV05gv zSrIVHwBHf2ls4JMYmTrN6IPbDosdhRzwZhIDEo82R9M1za7yjCdsh9hjFXxj6rUdzvz X8SP5ZcHG/ofmjzPaQjZwo1Reh5f0eyy7oxhMBBMGTMmN1YM8dYwU4n+2j42EKYscPSV 8B85iDX4P1Iu9UZpImqQXb/AF12h+Wq8j+te3r/0GMFhPo/KWn8gVQ8iWZYJXr85aBR6 92Aw== X-Gm-Message-State: AGi0PuYoZ7D4WPiG4UtsdqY/nuRn3n2u9c30HBhcib/QWtBnc82jqq7L krtsmm18m8NwPQ/mHEcBUJNrs8pGbMGZLg== X-Received: by 2002:a17:902:988e:: with SMTP id s14mr5261529plp.179.1586535802158; Fri, 10 Apr 2020 09:23:22 -0700 (PDT) Received: from mathewk1.lan ([161.97.192.125]) by smtp.gmail.com with ESMTPSA id c4sm1977138pgg.17.2020.04.10.09.23.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 10 Apr 2020 09:23:21 -0700 (PDT) From: Mathew King To: linux-kernel@vger.kernel.org Cc: Jett Rink , Benson Leung , Enric Balletbo i Serra , Guenter Roeck , Rushikesh S Kadam , Mathew King Subject: [PATCH v2 2/2] platform/chrome: cros_ec_ishtp: free ishtp buffer before sending event Date: Fri, 10 Apr 2020 10:23:05 -0600 Message-Id: <20200410162305.76638-2-mathewk@chromium.org> X-Mailer: git-send-email 2.26.0.110.g2183baf09c-goog In-Reply-To: <20200410162305.76638-1-mathewk@chromium.org> References: <20200410162305.76638-1-mathewk@chromium.org> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Jett Rink 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 Signed-off-by: Mathew King --- v2: Reword the commit message --- drivers/platform/chrome/cros_ec_ishtp.c | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/drivers/platform/chrome/cros_ec_ishtp.c b/drivers/platform/chrome/cros_ec_ishtp.c index e673a7f738fc..ed794a7ddba9 100644 --- a/drivers/platform/chrome/cros_ec_ishtp.c +++ b/drivers/platform/chrome/cros_ec_ishtp.c @@ -303,6 +303,10 @@ static void process_recv(struct ishtp_cl *cros_ish_cl, rb_in_proc->buffer.data, data_len); error_wake_up: + /* Free the buffer since we copied data or didn't need it */ + ishtp_cl_io_rb_recycle(rb_in_proc); + rb_in_proc = NULL; + /* Set flag before waking up the caller */ client_data->response.received = true; @@ -312,12 +316,14 @@ static void process_recv(struct ishtp_cl *cros_ish_cl, break; case CROS_MKBP_EVENT: + /* Free the buffer. This is just an event without data */ + ishtp_cl_io_rb_recycle(rb_in_proc); + rb_in_proc = NULL; /* * Set timestamp from beginning of function since we actually * got an incoming MKBP event */ client_data->ec_dev->last_event_time = timestamp; - /* The event system doesn't send any data in buffer */ schedule_work(&client_data->work_ec_evt); break; @@ -327,8 +333,9 @@ static void process_recv(struct ishtp_cl *cros_ish_cl, } end_error: - /* Free the buffer */ - ishtp_cl_io_rb_recycle(rb_in_proc); + /* Free the buffer if we already haven't */ + if (rb_in_proc) + ishtp_cl_io_rb_recycle(rb_in_proc); up_read(&init_lock); } -- 2.26.0.110.g2183baf09c-goog