Received: by 2002:a05:6a10:c604:0:0:0:0 with SMTP id y4csp3765630pxt; Tue, 10 Aug 2021 10:48:27 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwuqz36OU7m+j5pquLBzZ9VLTuvafs0CCAreM9b/hVmhpQTZQnTFOJZsxU2Brao52caJ6WQ X-Received: by 2002:a92:c503:: with SMTP id r3mr144611ilg.148.1628617707557; Tue, 10 Aug 2021 10:48:27 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1628617707; cv=none; d=google.com; s=arc-20160816; b=wDS4YkxaLXKnDO4B/GPjWQTMnPsUAHCFxJM2fAT9ZF4GTDhVwWoqHK2HtGc8NnfpPY 88qPxv6Xe8eMvpXWkA/ffG30GvGS5jEyLHIjkT1yn0tDsdftfzQ3cuE+MaztIyMFjzGL lq+MOd+lqVYXsTce3XWt+uDzFmXg/Wjg4ZWWqT+1EVMFycuf/Tx/P7q0IHQs4oxRbeEg wSzO0yxMIAt5uCy/Pthm8T5dUiJ+NF0LjYOXNE/QmGAuirugo9sQShhc68ZBGSXQxmIL CNaKlGZNZIXCtMSuWJqsY7/onzUWJCGGMGhC1xNv65DJ8swVdVokxfY1nWTTkcBgZKgk HY/A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=Hl4aKWY8xWT5IkomdSow1laihR5aXsFPBadvlyCLn5s=; b=fe7527OnYi0pyT36pNwMtxO5YIB4mhgwwT+ztVv8ScLCKHK74NzWdP2rWHCARac2+z 3BNYGhuol7R6y9g8tHEvTzUG9RqATggobFNZOIbOVWf2oPxIyKwFPQ22ngCZbiIkFdcY QNqFB8ZlzeOIMtrQEV2rIsD74nvh+Sh7/A+ptwgcfIhW0H47z7K0YOdm6eVcnPww3Wfp Dhnn2CI0qEg1Oz/oGL6UvPrs4IRT3Mcc1P0gUYhlh/SfTs2GnEp+sFSym6Te/+gmaoFG r2XL8ZYbb2sPItiK2DyPdgEU02JJJmb4nP2lu9clGthwTIa2zFfiIpkBPWOQrXpgtON3 l9iw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XU8ZA5Jb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id d131si32788481iog.11.2021.08.10.10.48.14; Tue, 10 Aug 2021 10:48:27 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=XU8ZA5Jb; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235201AbhHJRrx (ORCPT + 99 others); Tue, 10 Aug 2021 13:47:53 -0400 Received: from mail.kernel.org ([198.145.29.99]:40452 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236401AbhHJRor (ORCPT ); Tue, 10 Aug 2021 13:44:47 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id EA12C6113E; Tue, 10 Aug 2021 17:39:48 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1628617189; bh=UDYn/sXNwcrelw60R5bbVD9NsgnclwSRbxT8mOj/JcU=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=XU8ZA5JbYmnrwzOdhCub9FS89rVDi/zknDQXP0FJcdP7STvf0CKjC2MoR8WxGnlhF IhfYgpfbqhHqoVZkeUNL44+5RBBmC6QpJjeqc73jcaUZLUzq4XMVbzWnisZzdNI22e d8kGZN/wP11iHECdQduQSBBaUlhRPdo6skkX3IpM= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Allen Pais , Tyler Hicks , Jens Wiklander , Sumit Garg Subject: [PATCH 5.10 085/135] optee: fix tee out of memory failure seen during kexec reboot Date: Tue, 10 Aug 2021 19:30:19 +0200 Message-Id: <20210810172958.638635445@linuxfoundation.org> X-Mailer: git-send-email 2.32.0 In-Reply-To: <20210810172955.660225700@linuxfoundation.org> References: <20210810172955.660225700@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Allen Pais commit f25889f93184db8b07a543cc2bbbb9a8fcaf4333 upstream. 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 Cc: stable@vger.kernel.org Signed-off-by: Allen Pais Reviewed-by: Tyler Hicks Reviewed-by: Jens Wiklander Reviewed-by: Sumit Garg Signed-off-by: Jens Wiklander Signed-off-by: Greg Kroah-Hartman --- drivers/tee/optee/core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -573,6 +573,13 @@ static optee_invoke_fn *get_invoke_func( return ERR_PTR(-EINVAL); } +/* optee_remove - Device Removal Routine + * @pdev: platform device information struct + * + * optee_remove is called by platform subsystem to alert the driver + * that it should release the device + */ + static int optee_remove(struct platform_device *pdev) { struct optee *optee = platform_get_drvdata(pdev); @@ -603,6 +610,18 @@ static int optee_remove(struct platform_ return 0; } +/* optee_shutdown - Device Removal Routine + * @pdev: platform device information struct + * + * platform_shutdown is called by the platform subsystem to alert + * 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; @@ -748,6 +767,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,