From mboxrd@z Thu Jan 1 00:00:00 1970 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=-20.3 required=3.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,NICE_REPLY_A, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED,USER_AGENT_SANE_1 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 A8A91C433DB for ; Tue, 2 Mar 2021 05:53:36 +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 58ED36146B for ; Tue, 2 Mar 2021 05:53:36 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 58ED36146B Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linux.microsoft.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-Type: Content-Transfer-Encoding:Cc:List-Subscribe:List-Help:List-Post:List-Archive: List-Unsubscribe:List-Id:In-Reply-To:MIME-Version:Date:Message-ID:From: References:To:Subject:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=Fkw4Mgy1uP1PRhwARjiBgDsjnlP79VAXZX+3LEI+fy8=; b=DJoCb5pUgSD2doPJ7WpvQeK7G hq7URFksNjoQ2DXKWp3H7rV12lFeE9eVJ3h2qn3cbqyVef23nC0ALxBOU8+i4/QAkdYlDZ0QpW3ct dp8XcyIuov6rB2bKbsjRmpPYkOOdNfNbl3lehOg2+peSBT+IvPcRQm3XE1YegCg42rVPsunK1Qa93 Rv1NeEmKPGpCeDC6cXihjAkwWRdOTyk4ylIpUoFMOaDhMcQpKStwtA9U10+d5b5iVqK0/qzL3RMku ZPkKX6fUE2bJ9G8sHc+CvUy73RFu/NjX2K7pmYWFcwFwO3gW54wxkb87/isZiClqSUdcRr5wnYpDM prO7Z/UQA==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lGxwd-0008Ef-4n; Tue, 02 Mar 2021 05:51:43 +0000 Received: from linux.microsoft.com ([13.77.154.182]) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lGxwb-0008E6-24 for linux-arm-kernel@lists.infradead.org; Tue, 02 Mar 2021 05:51:42 +0000 Received: from [192.168.0.114] (unknown [49.207.214.138]) by linux.microsoft.com (Postfix) with ESMTPSA id 42D7A20B83EA; Mon, 1 Mar 2021 21:51:35 -0800 (PST) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 42D7A20B83EA DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1614664298; bh=/ckm4hpJQMLPLRduFqR8+KLJLPJLAdSa7Z0HzY+zdP8=; h=Subject:To:Cc:References:From:Date:In-Reply-To:From; b=mSUt4IVEUFIAk7XeNpoz8MZq31IkhU/TZCmi4B2x26uwNwU5uPxNRgobTzfCslL+c Hulo+Eoog+6dGA+jBsG8BQfTwJTXGcLr0cAR/gEleZo6Z/5oCfdoPEb2yXSRte+IIq GNYs1rpUUy0S1zZw5EEwCLp+9iYpiBDjqRfM9Ydk= Subject: Re: [PATCH v2 1/2] optee: fix tee out of memory failure seen during kexec reboot To: Jens Wiklander , Allen Pais References: <20210225090610.242623-1-allen.lkml@gmail.com> <20210225090610.242623-2-allen.lkml@gmail.com> From: Allen Pais Message-ID: <6f1c6529-7c89-21c9-0ce6-28545c251a9f@linux.microsoft.com> Date: Tue, 2 Mar 2021 11:21:33 +0530 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.10.0 MIME-Version: 1.0 In-Reply-To: Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210302_005141_282939_F77B86E1 X-CRM114-Status: GOOD ( 22.68 ) 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: op-tee@lists.trustedfirmware.org, zajec5@gmail.com, bcm-kernel-feedback-list@broadcom.com, Linux Kernel Mailing List , Linux ARM Content-Transfer-Encoding: 7bit Content-Type: text/plain; charset="us-ascii"; Format="flowed" Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org >> >> From: Allen Pais >> >> The following out of memory errors are seen on kexec reboot >> from the optee core. >> >> [ 0.368428] tee_bnxt_fw optee-clnt0: tee_shm_alloc failed >> [ 0.368461] tee_bnxt_fw: probe of optee-clnt0 failed with error -22 >> >> tee_shm_release() is not invoked on dma shm buffer. >> >> Implement .shutdown() method to handle the release of the buffers >> correctly. >> >> More info: >> https://github.com/OP-TEE/optee_os/issues/3637 >> >> Signed-off-by: Allen Pais >> --- >> drivers/tee/optee/core.c | 20 ++++++++++++++++++++ >> 1 file changed, 20 insertions(+) > > This looks good to me. Do you have a practical way of testing this on > QEMU for instance? I have not tried this on QEMU. I will give it a go today. Thanks. > > Thanks, > Jens > >> >> diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c >> index cf4718c6d35d..80e2774b5e2a 100644 >> --- a/drivers/tee/optee/core.c >> +++ b/drivers/tee/optee/core.c >> @@ -582,6 +582,13 @@ static optee_invoke_fn *get_invoke_func(struct device *dev) >> return ERR_PTR(-EINVAL); >> } >> >> +/* optee_remove - Device Removal Routine >> + * @pdev: platform device information struct >> + * >> + * optee_remove is called by platform subsystem to alter the driver >> + * that it should release the device >> + */ >> + >> static int optee_remove(struct platform_device *pdev) >> { >> struct optee *optee = platform_get_drvdata(pdev); >> @@ -612,6 +619,18 @@ static int optee_remove(struct platform_device *pdev) >> return 0; >> } >> >> +/* optee_shutdown - Device Removal Routine >> + * @pdev: platform device information struct >> + * >> + * platform_shutdown is called by the platform subsystem to alter >> + * the driver that a shutdown/reboot(or kexec) is happening and >> + * device must be disabled. >> + */ >> +static void optee_shutdown(struct platform_device *pdev) >> +{ >> + optee_disable_shm_cache(platform_get_drvdata(pdev)); >> +} >> + >> static int optee_probe(struct platform_device *pdev) >> { >> optee_invoke_fn *invoke_fn; >> @@ -738,6 +757,7 @@ MODULE_DEVICE_TABLE(of, optee_dt_match); >> static struct platform_driver optee_driver = { >> .probe = optee_probe, >> .remove = optee_remove, >> + .shutdown = optee_shutdown, >> .driver = { >> .name = "optee", >> .of_match_table = optee_dt_match, >> -- >> 2.25.1 >> _______________________________________________ linux-arm-kernel mailing list linux-arm-kernel@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-arm-kernel