From patchwork Fri Dec 13 12:55:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tero Kristo X-Patchwork-Id: 181548 Delivered-To: patch@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp597527ile; Fri, 13 Dec 2019 04:56:32 -0800 (PST) X-Google-Smtp-Source: APXvYqyyKqKj0PAvz0W8UzPDYklYwZZT/JibLAfUdEcR5+7l6m+vBflhIbiiNS9DhvJRRF0svVJ1 X-Received: by 2002:a9d:2904:: with SMTP id d4mr13920671otb.214.1576241792356; Fri, 13 Dec 2019 04:56:32 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1576241792; cv=none; d=google.com; s=arc-20160816; b=f2RvzyNMcRibeiuh7Yw4s58WYsV2iBml0WN5qsS+mxVP909Ud3s+C1PBKq0ZO1lFhj SWvIvoVwiidVVwgMR3nRoaTeGiwgBhwv44SB/PSZQ6UdCwW0Z+Oiml/eDKaPaiRZilxI aamMrzoYo1xs43wKxp3n9CG1bG75vwoW5sctZEYSKISzj9Np5zdd0ASKAAZRgEQZFPNY Gyhm/Bx0F5eVnStKtjXEVZ8kDg/220hH9GtoMWPNjCTJKVt2BK6xjFU5/L9zai9/d2hj lcEaKEaVclC6faB7DpF7gIBtjuDbjcDBWDXTfNpkGGzO9sFotOh5EfwiXDZzCFbBZZPI Algw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:dkim-signature; bh=iNbjq4C34pR6QNWDK9+NrPFMsPQVY+YacZkcNLYf6FE=; b=Z40T1v/ltnQQgf/XyG+x4BH1KHaZk333cy3X4qg5KVmLiNrJRoTcYDYa/DqCD2fNIt KsQlIb2YDEmQZk38LIRCQUm+0buGUQusQsHks6/BigKkEo7LnS8T0qMB+ewLky/y9C8Y jDPYM/iAQsIBGsR6mtLvPovSxuSm7soYBQnwmd5QvQoIh+k0PcTHxHlPtaRUuA1NHy6/ WpD/wRMCYWQsmw4oV+vaA8jbDiJqNYZOjmds9jmE2xF8e+B91R3FUKs7B4JpbkgzYz8f 0BmE1HNQdlcQcvQqZZJCi/5Jngj9G4eviGKS0aTcrn37gBUV/PevsFtSzfK4PztYeLfG mSdw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ti.com header.s=ti-com-17Q1 header.b=ys1e1lHs; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h22si5078430otn.279.2019.12.13.04.56.32; Fri, 13 Dec 2019 04:56:32 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-omap-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=@ti.com header.s=ti-com-17Q1 header.b=ys1e1lHs; spf=pass (google.com: best guess record for domain of linux-omap-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-omap-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=NONE dis=NONE) header.from=ti.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727483AbfLMM4b (ORCPT + 4 others); Fri, 13 Dec 2019 07:56:31 -0500 Received: from lelv0143.ext.ti.com ([198.47.23.248]:41724 "EHLO lelv0143.ext.ti.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727443AbfLMM4X (ORCPT ); Fri, 13 Dec 2019 07:56:23 -0500 Received: from fllv0035.itg.ti.com ([10.64.41.0]) by lelv0143.ext.ti.com (8.15.2/8.15.2) with ESMTP id xBDCuMCp018534; Fri, 13 Dec 2019 06:56:22 -0600 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ti.com; s=ti-com-17Q1; t=1576241782; bh=iNbjq4C34pR6QNWDK9+NrPFMsPQVY+YacZkcNLYf6FE=; h=From:To:CC:Subject:Date:In-Reply-To:References; b=ys1e1lHsWA+eHLVC79t34J7h8IfYtipG+cgrMr0dldi79xcjTnHPZYm+m76ixgzBs DgsxQUyxNssk/n9gqy6dWFbE/O3/hF22UqOFMFjlpP5mVwkOIRLP7p769FjlfZY09D lNgHu6NG+3A1yVY9RvD8A4ciP2AX0vhFZV06BImU= Received: from DLEE100.ent.ti.com (dlee100.ent.ti.com [157.170.170.30]) by fllv0035.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBDCuMNK009092; Fri, 13 Dec 2019 06:56:22 -0600 Received: from DLEE107.ent.ti.com (157.170.170.37) by DLEE100.ent.ti.com (157.170.170.30) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3; Fri, 13 Dec 2019 06:56:22 -0600 Received: from fllv0040.itg.ti.com (10.64.41.20) by DLEE107.ent.ti.com (157.170.170.37) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1847.3 via Frontend Transport; Fri, 13 Dec 2019 06:56:22 -0600 Received: from sokoban.ti.com (ileax41-snat.itg.ti.com [10.172.224.153]) by fllv0040.itg.ti.com (8.15.2/8.15.2) with ESMTP id xBDCtwVP127295; Fri, 13 Dec 2019 06:56:20 -0600 From: Tero Kristo To: , , CC: , , , Suman Anna , Tero Kristo Subject: [PATCHv3 10/15] remoteproc/omap: Check for undefined mailbox messages Date: Fri, 13 Dec 2019 14:55:32 +0200 Message-ID: <20191213125537.11509-11-t-kristo@ti.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20191213125537.11509-1-t-kristo@ti.com> References: <20191213125537.11509-1-t-kristo@ti.com> MIME-Version: 1.0 X-EXCLAIMER-MD-CONFIG: e1e8a2fd-e40a-4ac6-ac9b-f7e9cc9ee180 Sender: linux-omap-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-omap@vger.kernel.org From: Suman Anna Add some checks in the mailbox callback function to limit any processing in the mailbox callback function to only certain currently valid messages, and drop all the remaining messages. A debug message is added to print any such invalid messages when the appropriate trace control is enabled. Co-developed-by: Subramaniam Chanderashekarapuram Signed-off-by: Subramaniam Chanderashekarapuram Signed-off-by: Suman Anna Signed-off-by: Tero Kristo Reviewed-by: Bjorn Andersson --- drivers/remoteproc/omap_remoteproc.c | 6 ++++++ drivers/remoteproc/omap_remoteproc.h | 7 +++++++ 2 files changed, 13 insertions(+) -- 2.17.1 -- Texas Instruments Finland Oy, Porkkalankatu 22, 00180 Helsinki. Y-tunnus/Business ID: 0615521-4. Kotipaikka/Domicile: Helsinki diff --git a/drivers/remoteproc/omap_remoteproc.c b/drivers/remoteproc/omap_remoteproc.c index 6cf7f0a9ba9a..841981c50d8d 100644 --- a/drivers/remoteproc/omap_remoteproc.c +++ b/drivers/remoteproc/omap_remoteproc.c @@ -126,6 +126,12 @@ static void omap_rproc_mbox_callback(struct mbox_client *client, void *data) dev_info(dev, "received echo reply from %s\n", name); break; default: + if (msg >= RP_MBOX_READY && msg < RP_MBOX_END_MSG) + return; + if (msg > oproc->rproc->max_notifyid) { + dev_dbg(dev, "dropping unknown message 0x%x", msg); + return; + } /* msg contains the index of the triggered vring */ if (rproc_vq_interrupt(oproc->rproc, msg) == IRQ_NONE) dev_dbg(dev, "no message was found in vqid %d\n", msg); diff --git a/drivers/remoteproc/omap_remoteproc.h b/drivers/remoteproc/omap_remoteproc.h index f6d2036d383d..72f656c93caa 100644 --- a/drivers/remoteproc/omap_remoteproc.h +++ b/drivers/remoteproc/omap_remoteproc.h @@ -56,6 +56,12 @@ * * @RP_MBOX_ABORT_REQUEST: a "please crash" request, used for testing the * recovery mechanism (to some extent). + * + * Introduce new message definitions if any here. + * + * @RP_MBOX_END_MSG: Indicates end of known/defined messages from remote core + * This should be the last definition. + * */ enum omap_rp_mbox_messages { RP_MBOX_READY = 0xFFFFFF00, @@ -64,6 +70,7 @@ enum omap_rp_mbox_messages { RP_MBOX_ECHO_REQUEST = 0xFFFFFF03, RP_MBOX_ECHO_REPLY = 0xFFFFFF04, RP_MBOX_ABORT_REQUEST = 0xFFFFFF05, + RP_MBOX_END_MSG = 0xFFFFFF06, }; #endif /* _OMAP_RPMSG_H */