Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp939467pxb; Wed, 3 Mar 2021 21:50:34 -0800 (PST) X-Google-Smtp-Source: ABdhPJy0UcNqQu70YT8fgLzispo3lXGgpFU13Sb1H0l/XmdVzetN0TyfI/u655dmC0qfyyJqZBhX X-Received: by 2002:aa7:dd55:: with SMTP id o21mr2532178edw.237.1614837033838; Wed, 03 Mar 2021 21:50:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614837033; cv=none; d=google.com; s=arc-20160816; b=CNVWUFq6wAY9rPjEbDhPk4ZbA/ztJfFY383dRZMxP7Pmz1RHbdDypa4WFcpZz79fFA GcIugeGSuJMKYLElEofjG/RCBY4Cfvt31+Q4mqVqjqH88Zc9dNhYtmwdAJKrSH61vRMC KUjFEHoAMIy36V0qA5gCQtUX72lUZgYN8+c068Wz36YIbrv680PI615iReu8vmzlBu3g HRFFvOr1OV4QwT0aGRETJIJnzB1t28jyXrsc7JCgfTkqFxQkVi/Gn5PHbDnBpDjEIpf0 Gu29oqmgSqp4BkNFt/Yenn6aBYIUIIEKxAbdpZCmR9Jwz9yhzi5IyI5xcl4uK0cIwjV6 yNkQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:content-language :in-reply-to:mime-version:user-agent:date:message-id:from:references :cc:to:subject:dkim-signature:dkim-filter; bh=/ckm4hpJQMLPLRduFqR8+KLJLPJLAdSa7Z0HzY+zdP8=; b=r/DiAS7VLIPmY0uv08NnyvSZLTpjG8JmoKPzhxHMwLyBkYL5ynd06OvHA/P5mbYvyH NV/RudSXGaV4W/feBXrBFtA6ZpQBh6hUPZpUzKaIhhORPsMWzo/1Ajul185GSm5vrJdG sw7UcjGg15pma3pP5wy9zHcu07Fu4naMDKgBjgEdP1GJ7T0RShPCF4qcdM82nfzQEkNl TSzKikU0c6ouiVF2dOYJ/rA+ht+nwyq3Keu+1M1Y+2p9g6irN8inLcBNlXl49xYqXxQV si0lP9umk7e9D0yoBojnMScKdOoTgqr0Zgho2cvFLwNLU482kpzlZnNRZ6VTg5HSF5d+ YhRg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=mSUt4IVE; 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 lj27si7961049ejb.513.2021.03.03.21.50.11; Wed, 03 Mar 2021 21:50:33 -0800 (PST) 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=mSUt4IVE; 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 S1836324AbhCBHAm (ORCPT + 99 others); Tue, 2 Mar 2021 02:00:42 -0500 Received: from linux.microsoft.com ([13.77.154.182]:42312 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1347661AbhCBFwY (ORCPT ); Tue, 2 Mar 2021 00:52:24 -0500 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 Cc: zajec5@gmail.com, bcm-kernel-feedback-list@broadcom.com, Linux ARM , Linux Kernel Mailing List , op-tee@lists.trustedfirmware.org 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-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 7bit 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 >> --- >> 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 >>