Message ID | 20230302194235.1724-8-mario.limonciello@amd.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a5d:5915:0:0:0:0:0 with SMTP id v21csp41653wrd; Thu, 2 Mar 2023 11:58:44 -0800 (PST) X-Google-Smtp-Source: AK7set9SnjiclkLy1mzNQFV9RoAGJRGCzqVQqjw/wbhyeFRXd3fJtINqNZ499xM9CDbPalNimGh3 X-Received: by 2002:a17:902:e54c:b0:19d:121a:6795 with SMTP id n12-20020a170902e54c00b0019d121a6795mr14181834plf.55.1677787123690; Thu, 02 Mar 2023 11:58:43 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1677787123; cv=pass; d=google.com; s=arc-20160816; b=V8KW3Xx2WAnCooCkK39/J3IF4+qy33rhiSpPzsKsAWh5HR6LZRHo80gDb6G6b61XLw gHDa0Ka+Quua7jgUXnVEi9nCITKLjTsA0vo8TZNOAPiIMlum0h6Xu0jczcGRfo8V/atP WE+xReVWSdAnnHvY5a6+nk1U3mEYZPqntRTZzJ/sfAuUBRBaiXkDI3xiSQ1m8pa0nR1q ahH940WPZkUGtdyZBIcMzgUK9WuyJeycZZT6OUFYlnBdbPAlq4/mFPyYdZx6iU4yix5K hmhk1Jg585d3BhAOMQgtYRbLGgtatFjLnCaTNSrNB7r5q2pQaIalwzBUDNyVSi0JX4D8 F0YA== ARC-Message-Signature: i=2; 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=s37fTeFDkcK8QJ01FeyF0CA9erfiM7clF+ueBoMu37s=; b=GD3DZA4Gnrz+F0nCKzFZSoQ7mFsatuE1E7hIwRz/euZuCptW41joYem0qC8DlOQNuu A8Bw/5qlcArLcL90unKBWVo978ClGsWPkfpq3ir0UaZKWRxew2klu+4j95EDmhglpR+5 Kb8V4jCmAP4GTQksxUMegKVAiXfEctZ7PJmO85ZNfOQuLr+D1iJmVqAjZ0ufzavWxGdf b+mC/il9NPugEGx7DvVJUjJZ33l7Bx0N6Vx/+1U31Vrq7w7/4gKNTo3x5YOWO7m2fk7x qnoFCdByBILdHVGK4OxdlF9PpYHHid8a70JGT9Q00dCF6lAZ8gEBtDHjcbo8qr6Flquj p4yw== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=N6v5VXtx; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id i5-20020a17090332c500b0019ac23c3800si263433plr.111.2023.03.02.11.58.31; Thu, 02 Mar 2023 11:58:43 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@amd.com header.s=selector1 header.b=N6v5VXtx; arc=pass (i=1 spf=pass spfdomain=amd.com dmarc=pass fromdomain=amd.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=QUARANTINE sp=QUARANTINE dis=NONE) header.from=amd.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230096AbjCBToX (ORCPT <rfc822;davidbtadokoro@gmail.com> + 99 others); Thu, 2 Mar 2023 14:44:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42048 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S230006AbjCBToC (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Thu, 2 Mar 2023 14:44:02 -0500 Received: from NAM11-BN8-obe.outbound.protection.outlook.com (mail-bn8nam11on20601.outbound.protection.outlook.com [IPv6:2a01:111:f400:7eae::601]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 957B258B4B; Thu, 2 Mar 2023 11:43:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=GhwUG7YbF8gl+rDrCE6RXYfKVnueiIaxdOo0KyU0OsbQm6Cg/N7XxUNy3DHNSH5sgNbN4svI3cvDG46v2umF0JH7sheAKwRcSnS7G2Rgvu7UToxcMwnOvvCuAkROkyn4r6kFg6TBePCAoIBWOZ76gO7NexzwLaWQeg5M0a4FJv3r+PMmyGTffF5IeKCiS6xWyc1oweK6MeyUK9/svdOFAQi4ebP8aQDDkKDYoNv3HDQRFUyZx2rRHtVtqrBQTK8PiZbNQAvCSGiyFa6x4KkMmV/1NC8tirsR6BAVL6XpX4mNKoqXUQP89w2GZkJQVa0GGAuQMhkeIYXM+F9e/LUPcQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=s37fTeFDkcK8QJ01FeyF0CA9erfiM7clF+ueBoMu37s=; b=BhEAJEJJ0g4Fx5O0OyfM4OxirAmL4n4ZEL2oX6fuplUs5ZBizuMEcKx2oT3YzxNoTdXPsx+/ikHN+tzokr6Yo7l/3Xk19NRncBbBO/csG2ubupb9hY/FptV+deqAmJmPFTbGZcsq9vT2MagC1KRXScgZl4nLGaGuwxg0F9iMFQCV4in5/wVsEpX3X+MF9wn0xt9t5zNn3ZmxGEG0gxizD1J9Ex1M1XsHBDLvpHpGNLK8Rzy3IUjKzHTzKW1bbTK36eWadZY4myYiUjGADXyhCPwvFxzKykju48bjcr6uPRXwO9c7Y9M6M2dpxsb49CR7HGAHv5PD56e1wJpa2+PZSg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=semihalf.com smtp.mailfrom=amd.com; dmarc=pass (p=quarantine sp=quarantine pct=100) action=none header.from=amd.com; dkim=none (message not signed); arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=amd.com; s=selector1; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=s37fTeFDkcK8QJ01FeyF0CA9erfiM7clF+ueBoMu37s=; b=N6v5VXtx6HRi7I/EuF2UlnImSAZIquD5Ga65DIk8LtIxcRe3x+OXR596bCdrEe1iyHWrM55PtBCYz6/6PqqAzP2rzdkKBK/Ia5U2PN8Nc8ETeliU6qBWxymCdGnxYRRMUaU7hYMrHRNXoDpezTtPoZ6BLSHTz4MM9y0EDXcKrDQ= Received: from BN9PR03CA0928.namprd03.prod.outlook.com (2603:10b6:408:107::33) by BL3PR12MB6475.namprd12.prod.outlook.com (2603:10b6:208:3bb::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6134.25; Thu, 2 Mar 2023 19:43:22 +0000 Received: from BN8NAM11FT026.eop-nam11.prod.protection.outlook.com (2603:10b6:408:107:cafe::a3) by BN9PR03CA0928.outlook.office365.com (2603:10b6:408:107::33) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6156.19 via Frontend Transport; Thu, 2 Mar 2023 19:43:22 +0000 X-MS-Exchange-Authentication-Results: spf=pass (sender IP is 165.204.84.17) smtp.mailfrom=amd.com; dkim=none (message not signed) header.d=none;dmarc=pass action=none header.from=amd.com; Received-SPF: Pass (protection.outlook.com: domain of amd.com designates 165.204.84.17 as permitted sender) receiver=protection.outlook.com; client-ip=165.204.84.17; helo=SATLEXMB04.amd.com; pr=C Received: from SATLEXMB04.amd.com (165.204.84.17) by BN8NAM11FT026.mail.protection.outlook.com (10.13.177.51) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6156.20 via Frontend Transport; Thu, 2 Mar 2023 19:43:22 +0000 Received: from AUS-LX-MLIMONCI.amd.com (10.180.168.240) by SATLEXMB04.amd.com (10.181.40.145) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Thu, 2 Mar 2023 13:43:21 -0600 From: Mario Limonciello <mario.limonciello@amd.com> To: =?utf-8?b?SmFuIETEhWJyb8Wb?= <jsd@semihalf.com>, Grzegorz Bernacki <gjb@semihalf.com>, <Rijo-john.Thomas@amd.com>, <Thomas.Lendacky@amd.com>, <herbert@gondor.apana.org.au>, Tom Lendacky <thomas.lendacky@amd.com>, "John Allen" <john.allen@amd.com> CC: Mario Limonciello <mario.limonciello@amd.com>, "David S. Miller" <davem@davemloft.net>, <linux-crypto@vger.kernel.org>, <linux-kernel@vger.kernel.org> Subject: [PATCH v2 7/9] crypto: ccp: Add support for ringing a platform doorbell Date: Thu, 2 Mar 2023 13:42:30 -0600 Message-ID: <20230302194235.1724-8-mario.limonciello@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230302194235.1724-1-mario.limonciello@amd.com> References: <20230302194235.1724-1-mario.limonciello@amd.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Content-Type: text/plain X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB04.amd.com (10.181.40.145) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: BN8NAM11FT026:EE_|BL3PR12MB6475:EE_ X-MS-Office365-Filtering-Correlation-Id: 1096de2f-4834-4269-c8e0-08db1b56620c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0AMaahyjxiCWh8xvSkiK5WjWjRVvgirBKQBidhyE78FhvEYqVqY2gA/Kr2KXyrb6i5Ay3utnmBSrnTD+hMUt71Sd1b+M9JrKuqXKGuP/YrchGcm6nC3CDzqmeIMAlRdV6BYXU48AYJPJbjLD/+D7aJIP1P3mTpGtVja3yMcn6qP2bknzP/JO38uptdMP4nTPh2hUCzsIkcOPHY2RqqMeD2sDXCA24Wh/VBnkFjdoGvkCxbmON0qSyDsT/tbekQr6LrvYkU7CYAi8hkkwus0QzPbFjzkEjYDnecGdypkmvUZNEA05CBNRInGFRwlg6OOAD8K8ar1CO4hiUmGyoYFDu0r5GB7U8hu6Q6qSmcjk82LrmzXN6m6S7nI1dKqNX+PBkmzHCIbY5Urrmefy0nH3NhbyMEEtJBCxUZUeTmFLHpXSwP5Ts/l9syCAwbcTqKcx9FiQ6ht7vJoDmEYAbGz23q6VSSi1g2EE1Gs9rO1aTI9ZJajq8pZRjnUJs2YYjlh5YVItuvUPN0j8V3QFkPTrDpp0C6JfwuRx1UWh9L5A9/6yC3IPs9J3kxRoPFVztU/VO9J2WQmnig34ejzDmqdRUEVeYMwM6g5ZYc0LsMumAceYI7XpIVWaPHr9c50Oh9/j1oWPwJBvolah9XgpJA2Ya+x0QmI8AcorpcV9wZCIk0ne9/wpfv5Zi0FeUR9xX4P2XaZqmO/0qWBzZGlNcpfW6IoLiqFVi+djZDTBwIVaFg2S2v4p3vAm5RlN2y7yp3RR X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB04.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230025)(4636009)(136003)(396003)(346002)(376002)(39860400002)(451199018)(40470700004)(36840700001)(46966006)(478600001)(110136005)(83380400001)(6636002)(316002)(54906003)(426003)(86362001)(7696005)(2616005)(82310400005)(36860700001)(336012)(81166007)(47076005)(26005)(36756003)(966005)(186003)(82740400003)(16526019)(356005)(1076003)(40460700003)(6666004)(40480700001)(2906002)(70206006)(8936002)(44832011)(5660300002)(41300700001)(4326008)(70586007)(8676002)(36900700001)(134885004);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 02 Mar 2023 19:43:22.8887 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 1096de2f-4834-4269-c8e0-08db1b56620c X-MS-Exchange-CrossTenant-Id: 3dd8961f-e488-4e60-8e11-a82d994e183d X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=3dd8961f-e488-4e60-8e11-a82d994e183d;Ip=[165.204.84.17];Helo=[SATLEXMB04.amd.com] X-MS-Exchange-CrossTenant-AuthSource: BN8NAM11FT026.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: BL3PR12MB6475 X-Spam-Status: No, score=-1.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,FORGED_SPF_HELO,SPF_HELO_PASS, SPF_NONE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1759287310882036395?= X-GMAIL-MSGID: =?utf-8?q?1759287310882036395?= |
Series |
Export platform features from ccp driver
|
|
Commit Message
Mario Limonciello
March 2, 2023, 7:42 p.m. UTC
Some platforms support using a doorbell to communicate. Export
this feature for other drivers to utilize as well.
Link: https://lore.kernel.org/linux-i2c/20220916131854.687371-3-jsd@semihalf.com/
Suggested-by: Jan Dabros <jsd@semihalf.com>
Signed-off-by: Mario Limonciello <mario.limonciello@amd.com>
---
v1->v2:
* New patch
---
drivers/crypto/ccp/platform-access.c | 47 ++++++++++++++++++++++++++++
drivers/crypto/ccp/sp-dev.h | 1 +
include/linux/psp-platform-access.h | 15 +++++++++
include/linux/psp.h | 3 ++
4 files changed, 66 insertions(+)
Comments
On 3/2/23 13:42, Mario Limonciello wrote: > Some platforms support using a doorbell to communicate. Export > this feature for other drivers to utilize as well. > > Link: https://lore.kernel.org/linux-i2c/20220916131854.687371-3-jsd@semihalf.com/ > Suggested-by: Jan Dabros <jsd@semihalf.com> > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> > --- > v1->v2: > * New patch > --- > drivers/crypto/ccp/platform-access.c | 47 ++++++++++++++++++++++++++++ > drivers/crypto/ccp/sp-dev.h | 1 + > include/linux/psp-platform-access.h | 15 +++++++++ > include/linux/psp.h | 3 ++ > 4 files changed, 66 insertions(+) > > diff --git a/drivers/crypto/ccp/platform-access.c b/drivers/crypto/ccp/platform-access.c > index af3a1e97abfe..0763389a2814 100644 > --- a/drivers/crypto/ccp/platform-access.c > +++ b/drivers/crypto/ccp/platform-access.c > @@ -135,6 +135,53 @@ int psp_send_platform_access_msg(enum psp_platform_access_msg msg, > } > EXPORT_SYMBOL_GPL(psp_send_platform_access_msg); > > +int psp_ring_platform_doorbell(enum psp_platform_access_msg msg) > +{ > + struct psp_device *psp = psp_get_master_device(); > + struct psp_platform_access_device *pa_dev; > + u32 __iomem *drbl; > + u32 drbl_reg; Lets spell out doorbell for these two variable names. > + int ret; > + > + if (!psp || !psp->platform_access_data) > + return -ENODEV; > + > + pa_dev = psp->platform_access_data; > + drbl = psp->io_regs + pa_dev->vdata->doorbell_reg; > + > + if (!drbl) > + return -ENODEV; This will be non-zero because psp->io_regs will always be non-zero. Maybe you meant to check the actual pa_dev->vdata->doorbell_reg value? I think you should squash this and patch #9 together so that patch #8 just works right away. > + > + mutex_lock(&pa_dev->mutex); Does the doorbell register operate independently from the other registers (C2PMSG_28 - C2PMSG_30)? If it does, you could probably just introduce a doorbell mutex. > + > + if (check_recovery(drbl)) { > + dev_dbg(psp->dev, "in recovery\n"); Maybe a bit more info as to what is "in recovery" (that goes for patch #4, too) or just prefix it with "doorbell" (and "platform" in #4) since you now have duplicated messages. > + ret = -EBUSY; > + goto unlock; > + } > + > + if (wait_cmd(drbl)) { > + dev_dbg(psp->dev, "not done processing command\n"); Ditto. Thanks, Tom > + ret = -EBUSY; > + goto unlock; > + } > + > + drbl_reg = FIELD_PREP(PSP_DRBL_MSG, msg) | PSP_DRBL_RING; > + iowrite32(drbl_reg, drbl); > + > + if (wait_cmd(drbl)) { > + ret = -ETIMEDOUT; > + goto unlock; > + } > + > + ret = 0; > +unlock: > + mutex_unlock(&pa_dev->mutex); > + > + return ret; > +} > +EXPORT_SYMBOL_GPL(psp_ring_platform_doorbell); > + > void platform_access_dev_destroy(struct psp_device *psp) > { > struct psp_platform_access_device *pa_dev = psp->platform_access_data; > diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h > index 5ec6c219a731..87c0b9350bc2 100644 > --- a/drivers/crypto/ccp/sp-dev.h > +++ b/drivers/crypto/ccp/sp-dev.h > @@ -54,6 +54,7 @@ struct tee_vdata { > }; > > struct platform_access_vdata { > + const unsigned int doorbell_reg; > const unsigned int cmdresp_reg; > const unsigned int cmdbuff_addr_lo_reg; > const unsigned int cmdbuff_addr_hi_reg; > diff --git a/include/linux/psp-platform-access.h b/include/linux/psp-platform-access.h > index f5a03cd11f10..1e1d0e077cec 100644 > --- a/include/linux/psp-platform-access.h > +++ b/include/linux/psp-platform-access.h > @@ -35,6 +35,21 @@ struct psp_request { > */ > int psp_send_platform_access_msg(enum psp_platform_access_msg, struct psp_request *req); > > +/** > + * psp_ring_platform_doorbell() - Ring platform doorbell > + * > + * This function is intended to be used by drivers outside of ccp to ring the > + * platform doorbell with a message. > + * > + * Returns: > + * 0: success > + * -%EBUSY: mailbox in recovery or in use > + * -%ENODEV: driver not bound with PSP device > + * -%ETIMEDOUT: request timed out > + * -%EIO: unknown error (see kernel log) > + */ > +int psp_ring_platform_doorbell(enum psp_platform_access_msg); > + > /** > * psp_check_platform_access_status() - Checks whether platform features is ready > * > diff --git a/include/linux/psp.h b/include/linux/psp.h > index d3424790a70e..92e60aeef21e 100644 > --- a/include/linux/psp.h > +++ b/include/linux/psp.h > @@ -23,4 +23,7 @@ > #define PSP_CMDRESP_RECOVERY BIT(30) > #define PSP_CMDRESP_RESP BIT(31) > > +#define PSP_DRBL_MSG PSP_CMDRESP_CMD > +#define PSP_DRBL_RING BIT(0) > + > #endif /* __PSP_H */
[Public] > -----Original Message----- > From: Lendacky, Thomas <Thomas.Lendacky@amd.com> > Sent: Thursday, March 2, 2023 15:52 > To: Limonciello, Mario <Mario.Limonciello@amd.com>; Jan Dąbroś > <jsd@semihalf.com>; Grzegorz Bernacki <gjb@semihalf.com>; Thomas, Rijo- > john <Rijo-john.Thomas@amd.com>; herbert@gondor.apana.org.au; Allen, > John <John.Allen@amd.com> > Cc: David S. Miller <davem@davemloft.net>; linux-crypto@vger.kernel.org; > linux-kernel@vger.kernel.org > Subject: Re: [PATCH v2 7/9] crypto: ccp: Add support for ringing a platform > doorbell > > On 3/2/23 13:42, Mario Limonciello wrote: > > Some platforms support using a doorbell to communicate. Export > > this feature for other drivers to utilize as well. > > > > Link: https://lore.kernel.org/linux-i2c/20220916131854.687371-3- > jsd@semihalf.com/ > > Suggested-by: Jan Dabros <jsd@semihalf.com> > > Signed-off-by: Mario Limonciello <mario.limonciello@amd.com> > > --- > > v1->v2: > > * New patch > > --- > > drivers/crypto/ccp/platform-access.c | 47 > ++++++++++++++++++++++++++++ > > drivers/crypto/ccp/sp-dev.h | 1 + > > include/linux/psp-platform-access.h | 15 +++++++++ > > include/linux/psp.h | 3 ++ > > 4 files changed, 66 insertions(+) > > > > diff --git a/drivers/crypto/ccp/platform-access.c > b/drivers/crypto/ccp/platform-access.c > > index af3a1e97abfe..0763389a2814 100644 > > --- a/drivers/crypto/ccp/platform-access.c > > +++ b/drivers/crypto/ccp/platform-access.c > > @@ -135,6 +135,53 @@ int psp_send_platform_access_msg(enum > psp_platform_access_msg msg, > > } > > EXPORT_SYMBOL_GPL(psp_send_platform_access_msg); > > > > +int psp_ring_platform_doorbell(enum psp_platform_access_msg msg) > > +{ > > + struct psp_device *psp = psp_get_master_device(); > > + struct psp_platform_access_device *pa_dev; > > + u32 __iomem *drbl; > > + u32 drbl_reg; > > Lets spell out doorbell for these two variable names. Ack. Given drbl_reg is only used one place, I might just drop it too. > > > + int ret; > > + > > + if (!psp || !psp->platform_access_data) > > + return -ENODEV; > > + > > + pa_dev = psp->platform_access_data; > > + drbl = psp->io_regs + pa_dev->vdata->doorbell_reg; > > + > > + if (!drbl) > > + return -ENODEV; > > This will be non-zero because psp->io_regs will always be non-zero. Maybe > you meant to check the actual pa_dev->vdata->doorbell_reg value? > > I think you should squash this and patch #9 together so that patch #8 just > works right away. Ack, I'll squash them together. > > > + > > + mutex_lock(&pa_dev->mutex); > > Does the doorbell register operate independently from the other registers > (C2PMSG_28 - C2PMSG_30)? If it does, you could probably just introduce a > doorbell mutex. It does work independently. I'll add a second mutex. > > > + > > + if (check_recovery(drbl)) { > > + dev_dbg(psp->dev, "in recovery\n"); > > Maybe a bit more info as to what is "in recovery" (that goes for patch #4, > too) or just prefix it with "doorbell" (and "platform" in #4) since you > now have duplicated messages. Will add prefixes to make unique messages. > > > + ret = -EBUSY; > > + goto unlock; > > + } > > + > > + if (wait_cmd(drbl)) { > > + dev_dbg(psp->dev, "not done processing command\n"); > > Ditto. > > Thanks, > Tom Thanks for the new comments. I'll wait on Jan and Grzegorz to confirm whether the new doorbell stuff works on Skyrim or not to spin a v3. > > > + ret = -EBUSY; > > + goto unlock; > > + } > > + > > + drbl_reg = FIELD_PREP(PSP_DRBL_MSG, msg) | PSP_DRBL_RING; > > + iowrite32(drbl_reg, drbl); > > + > > + if (wait_cmd(drbl)) { > > + ret = -ETIMEDOUT; > > + goto unlock; > > + } > > + > > + ret = 0; > > +unlock: > > + mutex_unlock(&pa_dev->mutex); > > + > > + return ret; > > +} > > +EXPORT_SYMBOL_GPL(psp_ring_platform_doorbell); > > + > > void platform_access_dev_destroy(struct psp_device *psp) > > { > > struct psp_platform_access_device *pa_dev = psp- > >platform_access_data; > > diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h > > index 5ec6c219a731..87c0b9350bc2 100644 > > --- a/drivers/crypto/ccp/sp-dev.h > > +++ b/drivers/crypto/ccp/sp-dev.h > > @@ -54,6 +54,7 @@ struct tee_vdata { > > }; > > > > struct platform_access_vdata { > > + const unsigned int doorbell_reg; > > const unsigned int cmdresp_reg; > > const unsigned int cmdbuff_addr_lo_reg; > > const unsigned int cmdbuff_addr_hi_reg; > > diff --git a/include/linux/psp-platform-access.h b/include/linux/psp- > platform-access.h > > index f5a03cd11f10..1e1d0e077cec 100644 > > --- a/include/linux/psp-platform-access.h > > +++ b/include/linux/psp-platform-access.h > > @@ -35,6 +35,21 @@ struct psp_request { > > */ > > int psp_send_platform_access_msg(enum psp_platform_access_msg, > struct psp_request *req); > > > > +/** > > + * psp_ring_platform_doorbell() - Ring platform doorbell > > + * > > + * This function is intended to be used by drivers outside of ccp to ring the > > + * platform doorbell with a message. > > + * > > + * Returns: > > + * 0: success > > + * -%EBUSY: mailbox in recovery or in use > > + * -%ENODEV: driver not bound with PSP device > > + * -%ETIMEDOUT: request timed out > > + * -%EIO: unknown error (see kernel log) > > + */ > > +int psp_ring_platform_doorbell(enum psp_platform_access_msg); > > + > > /** > > * psp_check_platform_access_status() - Checks whether platform > features is ready > > * > > diff --git a/include/linux/psp.h b/include/linux/psp.h > > index d3424790a70e..92e60aeef21e 100644 > > --- a/include/linux/psp.h > > +++ b/include/linux/psp.h > > @@ -23,4 +23,7 @@ > > #define PSP_CMDRESP_RECOVERY BIT(30) > > #define PSP_CMDRESP_RESP BIT(31) > > > > +#define PSP_DRBL_MSG PSP_CMDRESP_CMD > > +#define PSP_DRBL_RING BIT(0) > > + > > #endif /* __PSP_H */
diff --git a/drivers/crypto/ccp/platform-access.c b/drivers/crypto/ccp/platform-access.c index af3a1e97abfe..0763389a2814 100644 --- a/drivers/crypto/ccp/platform-access.c +++ b/drivers/crypto/ccp/platform-access.c @@ -135,6 +135,53 @@ int psp_send_platform_access_msg(enum psp_platform_access_msg msg, } EXPORT_SYMBOL_GPL(psp_send_platform_access_msg); +int psp_ring_platform_doorbell(enum psp_platform_access_msg msg) +{ + struct psp_device *psp = psp_get_master_device(); + struct psp_platform_access_device *pa_dev; + u32 __iomem *drbl; + u32 drbl_reg; + int ret; + + if (!psp || !psp->platform_access_data) + return -ENODEV; + + pa_dev = psp->platform_access_data; + drbl = psp->io_regs + pa_dev->vdata->doorbell_reg; + + if (!drbl) + return -ENODEV; + + mutex_lock(&pa_dev->mutex); + + if (check_recovery(drbl)) { + dev_dbg(psp->dev, "in recovery\n"); + ret = -EBUSY; + goto unlock; + } + + if (wait_cmd(drbl)) { + dev_dbg(psp->dev, "not done processing command\n"); + ret = -EBUSY; + goto unlock; + } + + drbl_reg = FIELD_PREP(PSP_DRBL_MSG, msg) | PSP_DRBL_RING; + iowrite32(drbl_reg, drbl); + + if (wait_cmd(drbl)) { + ret = -ETIMEDOUT; + goto unlock; + } + + ret = 0; +unlock: + mutex_unlock(&pa_dev->mutex); + + return ret; +} +EXPORT_SYMBOL_GPL(psp_ring_platform_doorbell); + void platform_access_dev_destroy(struct psp_device *psp) { struct psp_platform_access_device *pa_dev = psp->platform_access_data; diff --git a/drivers/crypto/ccp/sp-dev.h b/drivers/crypto/ccp/sp-dev.h index 5ec6c219a731..87c0b9350bc2 100644 --- a/drivers/crypto/ccp/sp-dev.h +++ b/drivers/crypto/ccp/sp-dev.h @@ -54,6 +54,7 @@ struct tee_vdata { }; struct platform_access_vdata { + const unsigned int doorbell_reg; const unsigned int cmdresp_reg; const unsigned int cmdbuff_addr_lo_reg; const unsigned int cmdbuff_addr_hi_reg; diff --git a/include/linux/psp-platform-access.h b/include/linux/psp-platform-access.h index f5a03cd11f10..1e1d0e077cec 100644 --- a/include/linux/psp-platform-access.h +++ b/include/linux/psp-platform-access.h @@ -35,6 +35,21 @@ struct psp_request { */ int psp_send_platform_access_msg(enum psp_platform_access_msg, struct psp_request *req); +/** + * psp_ring_platform_doorbell() - Ring platform doorbell + * + * This function is intended to be used by drivers outside of ccp to ring the + * platform doorbell with a message. + * + * Returns: + * 0: success + * -%EBUSY: mailbox in recovery or in use + * -%ENODEV: driver not bound with PSP device + * -%ETIMEDOUT: request timed out + * -%EIO: unknown error (see kernel log) + */ +int psp_ring_platform_doorbell(enum psp_platform_access_msg); + /** * psp_check_platform_access_status() - Checks whether platform features is ready * diff --git a/include/linux/psp.h b/include/linux/psp.h index d3424790a70e..92e60aeef21e 100644 --- a/include/linux/psp.h +++ b/include/linux/psp.h @@ -23,4 +23,7 @@ #define PSP_CMDRESP_RECOVERY BIT(30) #define PSP_CMDRESP_RESP BIT(31) +#define PSP_DRBL_MSG PSP_CMDRESP_CMD +#define PSP_DRBL_RING BIT(0) + #endif /* __PSP_H */