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.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER, INCLUDES_PATCH,MAILING_LIST_MULTI,MENTIONS_GIT_HOSTING,SPF_HELO_NONE,SPF_PASS 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 87FAEC433DB for ; Mon, 1 Mar 2021 14:36:53 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 4E8CA6146D for ; Mon, 1 Mar 2021 14:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236461AbhCAOgh (ORCPT ); Mon, 1 Mar 2021 09:36:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40790 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236451AbhCAOga (ORCPT ); Mon, 1 Mar 2021 09:36:30 -0500 Received: from mail-ot1-x32a.google.com (mail-ot1-x32a.google.com [IPv6:2607:f8b0:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA2E8C061788 for ; Mon, 1 Mar 2021 06:35:50 -0800 (PST) Received: by mail-ot1-x32a.google.com with SMTP id k13so16602678otn.13 for ; Mon, 01 Mar 2021 06:35:50 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xrKyDD+nXhsE7yBfgO1RnI90ZWxZNc5CQ2d/LEfCEVs=; b=EvKeF2BSaUOR94etd2XM5SP+27aPZLUGZzs1KGL5ozp3QqIlhP9l7Uev0R/xnRUFLA QCqoaDUwAxx2fiB/e3BeaGUpmzf2B2CH64Zogi5aPKi/HCOBOKN7NHV80dJ9+QZvYkBo hiS7KCaxm0Ibdy1C5YhQONar+r2gQU4xiBQTDCYf1xQOsRx11a1uZU0h6LahmJfdyvDm 8tkVOiyNJK3KzZrGiJ/6yZg/6YtkPDmxJ3U/ECBkd5WSuCNBSOiCjweK3b6xoUK9kAWx G+dFbejWGnWKFc54JG2G+Y/BQEbPBRoR50nwpCs+Si6MGiFNppqOTX7S0Y6ZQQKExgFv RD9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xrKyDD+nXhsE7yBfgO1RnI90ZWxZNc5CQ2d/LEfCEVs=; b=kibgezsXIfIkxLCYE/EFd6OtztUCAiOpDtVy2eJ1AWXEX64cxVxHPvkMceb3ruaCDF DqdiWJvFVPfeYugnCE0uw02su79XVBLmk6jp5DnVVvlmY3DATAgy73wnY+sUIFOX+wTa xinlQ90fkScFCPyIXlJ9lddTljBiiCX7H7wvRYOwq5F7mrjKQGL4XtOYkIPAVAPyPnw1 AXDDUBd1GQu5rcvLSY6325r9AXmeutJRDsgx/9jwOwBfEc5rckPq/2ZIORJjwr95q7Xv Eu4SFakl9i9G56iDvHSS1m4c+JhYuVQqtJFYYXUmwQYIchYuxI2PhvIbh+u9gezces6F mZZg== X-Gm-Message-State: AOAM531pfIxY4iJM3k61+p+NdcSpSzGCpnIYNdvC7X3u2HE0VhB2joMv JQBEWXYWX/9mlkM63YFxivu2kPpAPBxV80HFlD6AZZB6fYM= X-Google-Smtp-Source: ABdhPJxTUWL8+rtDcjvKoi9N7CkFS4lsnhyMXNledGGmivopGZ1Ru6PuusyIpBfINyoQbWRK2lL6xZGgZPlgMLpFOIc= X-Received: by 2002:a05:6830:1352:: with SMTP id r18mr14233961otq.283.1614609350048; Mon, 01 Mar 2021 06:35:50 -0800 (PST) MIME-Version: 1.0 References: <20210225090610.242623-1-allen.lkml@gmail.com> <20210225090610.242623-2-allen.lkml@gmail.com> In-Reply-To: <20210225090610.242623-2-allen.lkml@gmail.com> From: Jens Wiklander Date: Mon, 1 Mar 2021 15:35:36 +0100 Message-ID: Subject: Re: [PATCH v2 1/2] optee: fix tee out of memory failure seen during kexec reboot To: Allen Pais Cc: zajec5@gmail.com, bcm-kernel-feedback-list@broadcom.com, Linux ARM , Linux Kernel Mailing List , op-tee@lists.trustedfirmware.org, Allen Pais Content-Type: text/plain; charset="UTF-8" Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, Feb 25, 2021 at 10:06 AM Allen Pais wrote: > > 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? 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 > 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=-18.8 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,SPF_HELO_NONE,SPF_PASS autolearn=unavailable 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 B9484C433DB for ; Mon, 1 Mar 2021 14:37:16 +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 7251D6146D for ; Mon, 1 Mar 2021 14:37:16 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 mail.kernel.org 7251D6146D Authentication-Results: mail.kernel.org; dmarc=fail (p=none dis=none) header.from=linaro.org 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:Subject:Message-ID:Date:From:In-Reply-To: References:MIME-Version:Reply-To:Content-ID:Content-Description:Resent-Date: Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=tXP1zcS3rsVqFMEiS+9oflDKFXyQGrAYDduOLX0Mr+I=; b=J/1QvgS5VY9dyrWwYZ48yE9of 3n9wbS8K/IXtFcvfje8wNDncauUvfxe9LmjsLspJVbUqKPVfaKLMs/9CqbeRg8yag32TYOPoLn02/ aQgD9+SauNDn3PYaHSXRIfE7uZJONUq/sOf4bbdgzAgPbOAi8OFUnGr6kPY8Al5rFR3KxxALrtxaI N8Cz9kfnojcZTAqFZd2Od5pBvTmvwGttsXcm1h8vVpuuejzBCwI6lqrTlSO+QyzxkvDLhqm6B6DWz Xqg/pEiU6cvJx83oqzBdvEmt6U/4XH9SPoMrHhu0LUyubUR5Fkl0J2ljjTm7jr44be3QMSl4qpuyj /XTTsX6Zw==; Received: from localhost ([::1] helo=merlin.infradead.org) by merlin.infradead.org with esmtp (Exim 4.92.3 #3 (Red Hat Linux)) id 1lGjeQ-0002JJ-Qd; Mon, 01 Mar 2021 14:35:58 +0000 Received: from mail-ot1-x335.google.com ([2607:f8b0:4864:20::335]) by merlin.infradead.org with esmtps (Exim 4.92.3 #3 (Red Hat Linux)) id 1lGjeM-0002Hm-DP for linux-arm-kernel@lists.infradead.org; Mon, 01 Mar 2021 14:35:55 +0000 Received: by mail-ot1-x335.google.com with SMTP id v12so15513030ott.10 for ; Mon, 01 Mar 2021 06:35:51 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=xrKyDD+nXhsE7yBfgO1RnI90ZWxZNc5CQ2d/LEfCEVs=; b=EvKeF2BSaUOR94etd2XM5SP+27aPZLUGZzs1KGL5ozp3QqIlhP9l7Uev0R/xnRUFLA QCqoaDUwAxx2fiB/e3BeaGUpmzf2B2CH64Zogi5aPKi/HCOBOKN7NHV80dJ9+QZvYkBo hiS7KCaxm0Ibdy1C5YhQONar+r2gQU4xiBQTDCYf1xQOsRx11a1uZU0h6LahmJfdyvDm 8tkVOiyNJK3KzZrGiJ/6yZg/6YtkPDmxJ3U/ECBkd5WSuCNBSOiCjweK3b6xoUK9kAWx G+dFbejWGnWKFc54JG2G+Y/BQEbPBRoR50nwpCs+Si6MGiFNppqOTX7S0Y6ZQQKExgFv RD9A== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=xrKyDD+nXhsE7yBfgO1RnI90ZWxZNc5CQ2d/LEfCEVs=; b=BuWQHmqlyksUprlL6GvX+y3WTdkOXa9YFNIeKJF+vd2W/c0ofSZeSiypdeZaQGph3+ Y1J7OF+bkoEEhet0GELNEjCAKvHrHyL4Bg8BMHveFEqi+Qv17L7WsWzwiQEtBW/+5nGq 3wIwDgltuE5215W8qcHaYFHeu1BqeRXgSbsdDyElQpW+dSUA6eIbC+SfVV1ZLJS3nkcw 7rQ563HsDWqpHHxBFPyu58fp/2kz3BMRBsoJYc6ovVoVkGLRv8qlrKrzr3D0Q7ZQad6p SYuCA8lFadhxt2kow+dIrgx3kd+ozbJeX4YtuSA6vD9DsbbsVbgawx8Nj5jngmHc8Gvc UZfg== X-Gm-Message-State: AOAM530jZKALjPO1ePfXyMmZe3CUql1HmG3m7vaO9FguJRzk4hIuYRmR rvOOP6tkFqmmXMeSWE4lp7bpJUVcHY5sqK3EkHvEzw== X-Google-Smtp-Source: ABdhPJxTUWL8+rtDcjvKoi9N7CkFS4lsnhyMXNledGGmivopGZ1Ru6PuusyIpBfINyoQbWRK2lL6xZGgZPlgMLpFOIc= X-Received: by 2002:a05:6830:1352:: with SMTP id r18mr14233961otq.283.1614609350048; Mon, 01 Mar 2021 06:35:50 -0800 (PST) MIME-Version: 1.0 References: <20210225090610.242623-1-allen.lkml@gmail.com> <20210225090610.242623-2-allen.lkml@gmail.com> In-Reply-To: <20210225090610.242623-2-allen.lkml@gmail.com> From: Jens Wiklander Date: Mon, 1 Mar 2021 15:35:36 +0100 Message-ID: Subject: Re: [PATCH v2 1/2] optee: fix tee out of memory failure seen during kexec reboot To: Allen Pais X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20210301_093554_604790_03F74B61 X-CRM114-Status: GOOD ( 26.01 ) 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: zajec5@gmail.com, Linux Kernel Mailing List , op-tee@lists.trustedfirmware.org, bcm-kernel-feedback-list@broadcom.com, Allen Pais , Linux ARM Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org On Thu, Feb 25, 2021 at 10:06 AM Allen Pais wrote: > > 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? 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