Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp5137553pxj; Wed, 9 Jun 2021 09:59:50 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwwCbaKGriYtr3L5YplT0viAEMPVoMwLL9mkT921dnq4INs0FXMN+01jJcjV4sx4Fi0w5sg X-Received: by 2002:a17:906:8a55:: with SMTP id gx21mr803727ejc.179.1623257990102; Wed, 09 Jun 2021 09:59:50 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1623257990; cv=none; d=google.com; s=arc-20160816; b=ShUOF1mmixEqATRSorU8h1Q4RDT9xvB2/yzEs4grjNH3JccGG4sxd1DepiwujRu2uD FVa+bVDEGeRfg+ab5MBR6iXRR/3OFIKUjrD1y/Rrpm6xz501VxgQaJl3s5fn/rmlETwa brcLCghXX4G/md58EV8Mj0phyAgORgDL3YSpjjk9bTzitpshVE7LSmu4oXfng2fhSPyf Ml0t2lGHq0dHS5+SYaz01GW/0dgJwistMob8DzX4sJaQqZM1x5jZCzI+QCjumuKyvqao k/iAqOdM8jCevsyQFAG+sPfKhwiWgZ4RIDAHEguqZanksUsZGO26Gh+/DhI+gb+tXVf8 r5kw== 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=vHXNCzPH6vP65w3gRv4QZZVovB1oVYvISDjQp48lif0=; b=PFMCFzbdyLBVV/hec3d2L0fEFXhZ78yiKeqeANv+r1VPm1OB94aNnfqfzqbPeR9ECN QIlxbhnpnKc9Rp3eKw9ruwb0PugvlyWbKGvVxEL0HuoRpt3yncEdDIX4Wlmn4K+Tdo9P GaZT1bDr4+m58NbYdXEm3p187Zh/FoMIWnQBbjlkKx0+j18bA88/GL2DdO54zMXFBIKb uqWuH5Q+nohm9aN3O+TfqtAYlf+OxyS8VHcHWu9y9fdktqVKw8dFbIYW2SIqFG2wZ/zF kDlVB0j2J4gz22Yc/KLO+U8Tav03w+PjoVizx8mdigX0j7JwZNmHDgn6IhwAggDeztiQ VLtw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=YppJut9n; 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 d26si195141edr.567.2021.06.09.09.59.26; Wed, 09 Jun 2021 09:59:50 -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=YppJut9n; 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 S234224AbhFIA1n (ORCPT + 99 others); Tue, 8 Jun 2021 20:27:43 -0400 Received: from linux.microsoft.com ([13.77.154.182]:55094 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232302AbhFIA1l (ORCPT ); Tue, 8 Jun 2021 20:27:41 -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 1EAF620B83C2; Tue, 8 Jun 2021 17:25:47 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1EAF620B83C2 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1623198348; bh=vHXNCzPH6vP65w3gRv4QZZVovB1oVYvISDjQp48lif0=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=YppJut9nsSSQgdw+KEfSv+ryv8MWrJeg/pL/A62zsMeT3Iiq1kgUnB3T5A2s05lEF i1IoRR4Nbxa+F3HBMbmITMBVLdhzbqeCBr7B6WjM+wteDkxBxBufxO938LpeZ5lJq+ 6Mp1VP34mNZO4gDW+jO8p8kqC5nq1UA24GHOTKVE= 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 v3 3/7] optee: fix tee out of memory failure seen during kexec reboot Date: Tue, 8 Jun 2021 19:23:22 -0500 Message-Id: <20210609002326.210024-4-tyhicks@linux.microsoft.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210609002326.210024-1-tyhicks@linux.microsoft.com> References: <20210609002326.210024-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 Signed-off-by: Allen Pais Reviewed-by: Tyler Hicks --- 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