Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp271399pxb; Thu, 25 Feb 2021 01:58:33 -0800 (PST) X-Google-Smtp-Source: ABdhPJx6MISaC81mc9GOrEF6gF1Sz4R1hJmXxW+rVOEHJB9LVDzTbNKvcGKt6R0wCVNBBUsuvjJI X-Received: by 2002:a17:906:2bc2:: with SMTP id n2mr1825461ejg.381.1614247113417; Thu, 25 Feb 2021 01:58:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614247113; cv=none; d=google.com; s=arc-20160816; b=mBd4f43aZ5DJahpXkrEuyYZ/EwRveWSzi1pV8Z2SnAMnRS1JcU0B4L1wamETo2ENf9 Wt5IK5WoS843zeSMAZaV/uovnRPdYnf/XhUkfYebCJPEvp6zYYqv2wma5gQ4xzial0tu /tSeWQDHsKR9Z/Tsw0BzmwDnaTtXr1c9MatN+XL9xfa2c2gRoG3otpFQo3au6IxSIj8t fhzTbwSAIUHcjRRfypeUbcUCPQFNXcFI53gwgz0m5krLElMlzvL6PQ8pIlF3B4bcEz2q kAxRpXFc4X9W2AZBiE6rH34mHVvdyjWG/5R+ZyVQ3XdJlAgkp9LyFMbcVowAS8cywPVJ v6Qw== 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; bh=7oTUgWWdsDaun/nhLkz8THldhf/BUoF8aFanx1A5q08=; b=matgE0Ir1+nwwyPSfYD3/ttlLxbBtaU2ysXOcl8oQV0/NpXCp9y0fEZ1FFnG6OVNnF LastjqXGbsyV4bTeuJj2bjx3K74SPDp2ycVTdcP32gWz6+XTU9sbjrlOSyMfbHcoXo4N t5a83D2YiMw39AYt5wk2iFCHWWWhKVvxDtr9YX7H7/ClaGX68UtdkPOyQKG+MzTYY5C0 4OT600cMnI0+JfZaSI7uRYK74FN6RQt4P+iubbcuIl+/ziXbOV/m2AZlp7AI85F2KXf4 3C/ZMk4xk66GMUftZuegNQPmLFC7ezgx/m7PiCVmlsjYuUAQfU502AKk2jin5Es93T3n QsxA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b="u0xk/at+"; 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=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id a11si2848853ejt.753.2021.02.25.01.58.10; Thu, 25 Feb 2021 01:58: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=@gmail.com header.s=20161025 header.b="u0xk/at+"; 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=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S235178AbhBYJK0 (ORCPT + 99 others); Thu, 25 Feb 2021 04:10:26 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:40856 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S235200AbhBYJHO (ORCPT ); Thu, 25 Feb 2021 04:07:14 -0500 Received: from mail-pf1-x431.google.com (mail-pf1-x431.google.com [IPv6:2607:f8b0:4864:20::431]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6749C061756 for ; Thu, 25 Feb 2021 01:06:32 -0800 (PST) Received: by mail-pf1-x431.google.com with SMTP id r5so3159410pfh.13 for ; Thu, 25 Feb 2021 01:06:32 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=7oTUgWWdsDaun/nhLkz8THldhf/BUoF8aFanx1A5q08=; b=u0xk/at+ZtV2khvMxKfg/zP8LeL19xpqF0Xd5cWwVG8yoHARHKPEqsTiTnyEo6I1O7 NkC3kQ7dTtzUKk4vecHpwHKT1eszAEOpHA0JG22D5mF/yEs5sBqP/0Z2B3fh1zxzFeZw O6HsRtmOswKjNLckzz3ryGM/o13LgHMDpOs6jbOBDMV+SLSWYJ0/Ukr6NZ1AuW7JeuJt S9cM8HnM5rGAlrQ4JHw11trpx2Y+bjEx1lZqTM+HYQUAYgA9PAlON2sMKjG/tRYNd+X2 g9xP79hWAGy8+Ben5MkmjZe/vZ5WyT/sMzfhLCZ550C+oHmNT3GcVG0Fxl6k26dTh495 zsqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=7oTUgWWdsDaun/nhLkz8THldhf/BUoF8aFanx1A5q08=; b=j433iGF6OpHSiCwm/z8atBOqG+kk2Weie5Dc4VreC2QoZs2vsQ7sGd1XqvYphtS0Ju 2p1PCsDgOZI+8LkNTMocAeiisv18NFy8uiYV4pxoaaZl1EqtYBV/pKuGUBE5WJ/POs0I Eumler7g7N5yoPPRstMKlnIPDuAUGmcXxqEk3QXv8u914hVrA8P/G1MFScJh3HpR0Qsn 3ochpwmpK5J7tlvHcFij1DYQcSDh29hHwehgSRutAzkFhNBm5QDnhZ05bKm3OgaI6CEg ti4IcUYNQ2HpuIdAUNKsOTRzs+sUj1qo87U88GDoQ7eHDyey1Wip6yVtdojGzC8uj6FN aFvw== X-Gm-Message-State: AOAM532PY9F+Fp4Z0jSdv826mQOW3/A47tcH6BRhsQx1r09sBZupLkxR 38iSfmWxuOdo9pBwb4v2AcQ= X-Received: by 2002:a05:6a00:ac8:b029:1ed:f8dc:cb3b with SMTP id c8-20020a056a000ac8b02901edf8dccb3bmr2350632pfl.60.1614243992361; Thu, 25 Feb 2021 01:06:32 -0800 (PST) Received: from localhost.localdomain ([49.207.194.79]) by smtp.gmail.com with ESMTPSA id n11sm5098373pgm.30.2021.02.25.01.06.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 25 Feb 2021 01:06:31 -0800 (PST) From: Allen Pais To: jens.wiklander@linaro.org, zajec5@gmail.com Cc: bcm-kernel-feedback-list@broadcom.com, linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org, op-tee@lists.trustedfirmware.org, Allen Pais Subject: [PATCH v2 1/2] optee: fix tee out of memory failure seen during kexec reboot Date: Thu, 25 Feb 2021 14:36:09 +0530 Message-Id: <20210225090610.242623-2-allen.lkml@gmail.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20210225090610.242623-1-allen.lkml@gmail.com> References: <20210225090610.242623-1-allen.lkml@gmail.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 --- 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 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