From patchwork Fri Nov 13 07:02:06 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tzung-Bi Shih X-Patchwork-Id: 11902641 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.7 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_ADSP_CUSTOM_MED,DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, INCLUDES_PATCH,MAILING_LIST_MULTI,SIGNED_OFF_BY,SPF_HELO_NONE,SPF_PASS, URIBL_BLOCKED,USER_AGENT_GIT autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 30A1FC388F7 for ; Fri, 13 Nov 2020 07:02:59 +0000 (UTC) Received: from merlin.infradead.org (merlin.infradead.org [205.233.59.134]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPS id CD01320B80 for ; Fri, 13 Nov 2020 07:02:58 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=lists.infradead.org header.i=@lists.infradead.org header.b="l7YNQ4GD"; dkim=fail reason="signature verification failed" (2048-bit key) header.d=google.com header.i=@google.com header.b="vVZ4pBXY" DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org CD01320B80 Authentication-Results: mail.kernel.org; dmarc=fail (p=reject dis=none) header.from=google.com Authentication-Results: mail.kernel.org; spf=none smtp.mailfrom=linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=merlin.20170209; h=Sender:Content-Transfer-Encoding: Content-Type:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:To:From:Subject:References:Mime-Version:Message-Id: In-Reply-To:Date:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=CLHYHooke9nNiMegWvL6SUxcyPFMppIngEsd7y8DvRk=; b=l7YNQ4GD2osBqzZUgtKsdochq 9JQb2Dqndl1aLwaq18PCnjUvdh3xtCFJJ1BlkvieKnK5k9b06mA2NEMxSApblABPZUCEk3uHkB0A2 f0n/TpeALRPgIa25x51z1UaLsFhQDT7bdHy+TDz17x+cznLutqLzjjvO/GW1TyiP8ydIUVb1uIPxT vXtctodlN6/oZWlwyFaNqMVxjq3tzTEi12jAkW5Ypr5woEdooGR8sEhg3pbZs3B7NmB9yNhKTL13s EzAQ6PSRfiPzGWuVC33SdrjPSwvLlahVdtJPrbcA54JOm7ovo3b4dZv66x2/6vqknMHdH1u8DcHnD MvI+gYLGQ==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdT6S-000243-LE; Fri, 13 Nov 2020 07:02:36 +0000 Received: from mail-pl1-x64a.google.com ([2607:f8b0:4864:20::64a]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1kdT6K-00020r-1B for linux-arm-kernel@lists.infradead.org; Fri, 13 Nov 2020 07:02:29 +0000 Received: by mail-pl1-x64a.google.com with SMTP id x19so5401865plm.19 for ; Thu, 12 Nov 2020 23:02:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20161025; h=sender:date:in-reply-to:message-id:mime-version:references:subject :from:to:cc; bh=od5RzXQQDUYNdgHqpNLuL0ghCcmfAozESYAcDCe7NAo=; b=vVZ4pBXYbM3nzNUI1cLnpzMC29BCXXpYtA5AMN+l263aJDpnRb2tDK+Ts1e7ULWBvH L0NPUQTsoBc01RAQPpDr7iqR+uWyyn4oNauHZU55d1UHPgMzxVPDFe7JjBUCvWz+/yVI 935k29j8WUY2NO/EY38KYEFBIWOiBBEiVQ1JOglwOy7oNuI+dz6472ixF/ShVRqnchlu mM8/dfep+ArTnx1ih6xHVBBBizLe7na/YmTjvZ2FkhNKOhqU0DctIDs84mZwOgbzXHVS xWy3Qqh2YbAMwCAd1aVjjfATU6mqQ3tNcQ0FEsnJ3cPgfhQZnve17bfRDJE/x8FXpetc ZrsA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:date:in-reply-to:message-id:mime-version :references:subject:from:to:cc; bh=od5RzXQQDUYNdgHqpNLuL0ghCcmfAozESYAcDCe7NAo=; b=fw886Sv6/7cpsY0t6IDO9CRunT+JaBqnXNvhOuw4IGT71ehdOlo/MDpZPfkCLVP1Wo Z9huCYVOFUzPLedvgjJbrQ022t/2tDUf17R/f/MIgGH1r4URI+ogbnJ0w1X83kbUlXN0 FZbiXOuoBVarzlxOtA54Bfg3oa6hL2xQ8k0DNR7TuuiTqGi1CSeEI8xBy49zlewlPG7l ygH1Si/h65dn4faegEJE/TKWEl1sFwGJII7KJ8lZUFKxEPh/TRe6cgVSQMaZ1XYUrRQq JbkJNBq+CydahMRufjc6mIy0CC5BG13Af9IAYhsv20O3d2Y4KB4p3vtmK3MP/gleD1NP 6hMw== X-Gm-Message-State: AOAM531PL2oDIsorNPHA3HIKKJc1uDwlJgr3YW1nb++BMphed2+Sdju4 AmuPkk19yw7W7/sw12hezuQW26YA2QEc X-Google-Smtp-Source: ABdhPJwTrEoI2V870amcgehFqHWitjg4WqLqzPkOKYCxwyxo0RZHFnPV/ysQuGnhBWchSZF6+jQjlqEeiqca X-Received: from tzungbi-z840.tpe.corp.google.com ([2401:fa00:1:b:725a:fff:fe41:c6a5]) (user=tzungbi job=sendgmr) by 2002:aa7:9e4e:0:b029:18b:7623:7cdb with SMTP id z14-20020aa79e4e0000b029018b76237cdbmr790147pfq.45.1605250944835; Thu, 12 Nov 2020 23:02:24 -0800 (PST) Date: Fri, 13 Nov 2020 15:02:06 +0800 In-Reply-To: <20201113070207.836613-1-tzungbi@google.com> Message-Id: <20201113070207.836613-3-tzungbi@google.com> Mime-Version: 1.0 References: <20201113070207.836613-1-tzungbi@google.com> X-Mailer: git-send-email 2.29.2.299.gdc1121823c-goog Subject: [PATCH 2/3] remoteproc/mediatek: skip if filesz is 0 From: Tzung-Bi Shih To: ohad@wizery.com, bjorn.andersson@linaro.org X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20201113_020228_151537_542F30D1 X-CRM114-Status: GOOD ( 14.70 ) X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: linux-remoteproc@vger.kernel.org, tzungbi@google.com, linux-mediatek@lists.infradead.org, pihsun@chromium.org, matthias.bgg@gmail.com, linux-arm-kernel@lists.infradead.org Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The main purpose of the loop is to load the memory to the SCP SRAM. If filesz is 0, can go to next program header directly. We don't need to try to validate the FW binary for those filesz==0 segments. Signed-off-by: Tzung-Bi Shih --- drivers/remoteproc/mtk_scp.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/drivers/remoteproc/mtk_scp.c b/drivers/remoteproc/mtk_scp.c index 7ba00305009a..60ba4cece074 100644 --- a/drivers/remoteproc/mtk_scp.c +++ b/drivers/remoteproc/mtk_scp.c @@ -234,12 +234,14 @@ static int scp_elf_load_segments(struct rproc *rproc, const struct firmware *fw) u32 offset = phdr->p_offset; void __iomem *ptr; - if (phdr->p_type != PT_LOAD) - continue; - dev_dbg(dev, "phdr: type %d da 0x%x memsz 0x%x filesz 0x%x\n", phdr->p_type, da, memsz, filesz); + if (phdr->p_type != PT_LOAD) + continue; + if (!filesz) + continue; + if (filesz > memsz) { dev_err(dev, "bad phdr filesz 0x%x memsz 0x%x\n", filesz, memsz); @@ -263,9 +265,7 @@ static int scp_elf_load_segments(struct rproc *rproc, const struct firmware *fw) } /* put the segment where the remote processor expects it */ - if (phdr->p_filesz) - scp_memcpy_aligned(ptr, elf_data + phdr->p_offset, - filesz); + scp_memcpy_aligned(ptr, elf_data + phdr->p_offset, filesz); } return ret;