Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp3137853pxj; Mon, 14 Jun 2021 15:35:44 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzSt97scbi6V9q+UkISbGwNoKYBMkVvxuh1iU+cYGGCA0iMLn6rt5GB3ie8tSVysuDiigAJ X-Received: by 2002:a17:906:d150:: with SMTP id br16mr17536404ejb.190.1623710143825; Mon, 14 Jun 2021 15:35:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623710143; cv=none; d=google.com; s=arc-20160816; b=YxPwhZnm1hMdptGEOilNvVNBDYvSMC9PK2+Wlv380Oc0SWChNYAeJjpPrTSOqaFts0 EzM0lDRbOnq9zCyfYrbxfh87AQMpI3i+Fw3Qo8NSRukOXojELBWfoBO6TZIrfD3kA1dh bPAwCNqxUJc5/NaciHFw44jn0tgUfZWfGS72D9Po4gi8Cr8K25+WeUlEJk6g+bguXCXt sLCBMtMj0k615WUuyDpLxxE5n9G6IY+iRqVenNWh4sgRhXTx6VLSk4gJOxB8hZ8tGxt9 9Bm39WEV6nDUBBQjnRndcaY+wCGOekJmM8yo1YmvFl31t6uCme/tyacqs0Q4ePpVaik6 DMXg== 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 :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=f+eL8pK9p2IL+p45rhOk41ve8PrQYT9LbO9wgCJTmOc=; b=l1Uub0lMgi67TBdpIKhjFthzu5cYf2xrjLh9ShrSlfpndZo3EQPVZDnRvitRYpuehh X5DNeGDqJ5OBqnt/zql9mZyfTiP4S7Ai0R+22SZgI7AEbFPxdNFeyOuLyLHdImL3jY7W 0NE0AU83orOohtBocccpEk8vMPuxsDBWNWsDytODHZBwTR7h+l/poSb9x/gQYSFmyiw/ zztvKUHznPWLEqy0wHqmPsrIFoPaSO4oLgK8+bV21TWxAoeMgsqXNcf4GHqqtcFJFal/ MOjFk1h50Qic1/j69R9YDcS7mLj84GMovnpeMSGRdzPa7/k37q2xlCCY7cDvjl/A7Qjf twew== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=SNSe4ezI; 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=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id n18si13658642eja.465.2021.06.14.15.35.21; Mon, 14 Jun 2021 15:35:43 -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=@linux.microsoft.com header.s=default header.b=SNSe4ezI; 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=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231723AbhFNWfq (ORCPT + 99 others); Mon, 14 Jun 2021 18:35:46 -0400 Received: from linux.microsoft.com ([13.77.154.182]:56098 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231664AbhFNWfj (ORCPT ); Mon, 14 Jun 2021 18:35:39 -0400 Received: from sequoia.work.tihix.com (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id 8A65820B83C2; Mon, 14 Jun 2021 15:33:35 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 8A65820B83C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1623710016; bh=f+eL8pK9p2IL+p45rhOk41ve8PrQYT9LbO9wgCJTmOc=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=SNSe4ezIfk0AYcN2wHCS4Pfet2a3Au6ekROvMM7aKHYGOLXvkaylSikcDoZxCrHkC yCLwBIgvG6jSlEvWNkvAsAnExkFpbg8MNvEhQn58oTXXDBhCZblX+4KypncgvI/GHi 2ZpW5am9fz4gQ+ut9fartJ+rPCKtWEJ2qXREfSxc= From: Tyler Hicks To: Jens Wiklander , Allen Pais , Sumit Garg , Peter Huewe , Jarkko Sakkinen , Jason Gunthorpe , Vikas Gupta Cc: Thirupathaiah Annapureddy , Pavel Tatashin , =?UTF-8?q?Rafa=C5=82=20Mi=C5=82ecki?= , op-tee@lists.trustedfirmware.org, linux-integrity@vger.kernel.org, bcm-kernel-feedback-list@broadcom.com, linux-mips@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v5 3/8] optee: fix tee out of memory failure seen during kexec reboot Date: Mon, 14 Jun 2021 17:33:12 -0500 Message-Id: <20210614223317.999867-4-tyhicks@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210614223317.999867-1-tyhicks@linux.microsoft.com> References: <20210614223317.999867-1-tyhicks@linux.microsoft.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.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 Cc: stable@vger.kernel.org Signed-off-by: Allen Pais Reviewed-by: Tyler Hicks Reviewed-by: Jens Wiklander --- drivers/tee/optee/core.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/drivers/tee/optee/core.c b/drivers/tee/optee/core.c index 5288cd767d82..0987074d7ed0 100644 --- a/drivers/tee/optee/core.c +++ b/drivers/tee/optee/core.c @@ -573,6 +573,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 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_device *pdev) 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; @@ -739,6 +758,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