From patchwork Wed Apr 5 11:17:48 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Orzel X-Patchwork-Id: 13201621 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 85529C7619A for ; Wed, 5 Apr 2023 11:18:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.518468.805068 (Exim 4.92) (envelope-from ) id 1pk19p-0003Q1-5M; Wed, 05 Apr 2023 11:18:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 518468.805068; Wed, 05 Apr 2023 11:18:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pk19p-0003Pu-0t; Wed, 05 Apr 2023 11:18:29 +0000 Received: by outflank-mailman (input) for mailman id 518468; Wed, 05 Apr 2023 11:18:26 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pk19m-0003OA-OQ for xen-devel@lists.xenproject.org; Wed, 05 Apr 2023 11:18:26 +0000 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2060b.outbound.protection.outlook.com [2a01:111:f400:fe59::60b]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 91da60b8-d3a3-11ed-b464-930f4c7d94ae; Wed, 05 Apr 2023 13:18:21 +0200 (CEST) Received: from DM6PR06CA0007.namprd06.prod.outlook.com (2603:10b6:5:120::20) by PH0PR12MB7094.namprd12.prod.outlook.com (2603:10b6:510:21d::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.35; Wed, 5 Apr 2023 11:18:17 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::87) by DM6PR06CA0007.outlook.office365.com (2603:10b6:5:120::20) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.22 via Frontend Transport; Wed, 5 Apr 2023 11:18:17 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6277.28 via Frontend Transport; Wed, 5 Apr 2023 11:18:17 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 5 Apr 2023 06:18:16 -0500 Received: from XIR-MICHALO-L1.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 5 Apr 2023 06:18:14 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 91da60b8-d3a3-11ed-b464-930f4c7d94ae ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=m7m5NbTPhzb7l3VwIWfMjPF0agHjhvDRI5bjtLX/cGY/YqGVspD8l/HgOc7rheU0HnfO3CrjzYkiYOrHqpAQODmbHfbaWHiG9ILddNkqjOWCR7X9L8/tQsHHdc9nwrISy7ZSkfOKEvAUebAzFOxukXXZFcsmIKPbitVnCglvdEwpl6mwDE0hQiw15v03PL/DMQq50GQVOZbYgen/UHHtnj2MiY90RKeUsyTf7RW4rGx6N7LbihxnNLRlPFf0UCuRsR0MJjhMu6wmP0A9CPPzqmjZkucJPAZyAbJLgKfHeZcaF4GO6eHT/wFyNZSchFqPhBhmA/qOR5fxHdjbW0heZQ== 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=g9H/C1PpC36IRqyjibUsIvzP3hGQMaqzwi6jG5cD2/k=; b=LcOD00f4Pwrf/Q9l5/hye4fjRCUSuUfode4Ka8gjlQEMhJsc/4E8M7QcfH7NYuaFLU30b76yQO70tCAjWDUpxjwIzJrI6HKwePMJcMNG8fWhKjftN+/D2kslmBZDPdM+04V+x1CbaK9GUXx8jUOieIJ8/omNZiS2hnQFoIOyABZr53mHKKECVJ5+plWGK97XNNxFZTdV9g7YjV2xnQO78PNe3RKCNehmhjpcoMaW4Dq+zqfsZ167hFYjl5k6DHLJBQBfsCCPAMyzKBai84Ehhsh8YZ8ikuQGhgn4ptdSxmUjml/eBxWwzcgRDEjIQM/sHreLtad//HvjsJJeURTkJg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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=g9H/C1PpC36IRqyjibUsIvzP3hGQMaqzwi6jG5cD2/k=; b=S8u0uFlo56x4SJF28DGuVASrEGaufHrfkZD42Js/oteIoLFAIadIi4lxOxGCdROXvRJ8x+nl4k8FHV4FbfAp8pAAavf43f1O+PXGMO80GMs9E4avFLObGREL5g14kukD116YjGP1yCSYLRRS4LnwkYEbx/hLPsVp/GKjWxOzfZU= 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=SATLEXMB03.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 1/3] xen/arm: vpl011: Fix misleading comments Date: Wed, 5 Apr 2023 13:17:48 +0200 Message-ID: <20230405111750.12491-2-michal.orzel@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405111750.12491-1-michal.orzel@amd.com> References: <20230405111750.12491-1-michal.orzel@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT049:EE_|PH0PR12MB7094:EE_ X-MS-Office365-Filtering-Correlation-Id: 042fd97e-6201-403b-d9f8-08db35c7748c X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 0RALEhyx4hTMbmn4HT+qB3sV+Icf8kyI862pPtJsaCk9JidOAgy4PZV3O8LitYNCN9bFdqVZLx4p3ZP+er+6w8xs7MgX+EMhh8iuQxCWxNT1e85I274W0QwUurjN4ulrH8Y218TPtRV0QegQBQ2+eqJ9vaIRZW3zqJWkMaR2E5X4GkKtG4P/JnGajP8Z1cFXQmOBaMqenVPJRd1y1y1+nUDiq2oW91TbCuE7Xq4i1IjFOkJ61mCZ4WnzbYuuixxi01NqfQDPo7gvbQx1RP/mFkoQRrUZyYVPbSImOqDj5eh9v9l0VSoFc6ByXpRaXvuskf5rGhr+f7LYsE+NsKZTinzNURUvSAb86OfijPa5UaZ+BqTL3LrePiJrAG3HvVsRD95VJgQe90+SIDfVk2r+kXt8YIibBiRk0cLX/dMxV6GO4Fq5bATRsFcFxCKlUNbSwM+C5i4dy6khOjGutBvk9FjIe2p7NO8y/cfGyRoF4UnmS+GQWKIdHbI1aJu1NDJfey0rx2necX9nX6o3/jr3zs5evXyueaV1+MYSRhfm1aYx02NwyDQU6wn1d8bThlVtSs9q9HrViDboFcxFzOLLwd3xmXb7bo2sDAkOFZv7duSem4PComl7rXuji47LGPcwCMvjsXbUGkFkezrOy0YXgD8SwxFc2dkMd2c2Bz4WMU+fuSB2oCLx8eTErmxPQvxXe5pGsMtTcfQfCVZyNQ4SjHUSXcSw40fYaejnS7YVpko= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(346002)(39860400002)(136003)(376002)(396003)(451199021)(40470700004)(46966006)(36840700001)(86362001)(2906002)(36756003)(82310400005)(40480700001)(6666004)(2616005)(47076005)(186003)(83380400001)(426003)(336012)(1076003)(26005)(8676002)(4326008)(478600001)(70206006)(36860700001)(41300700001)(40460700003)(70586007)(5660300002)(6916009)(82740400003)(316002)(81166007)(356005)(8936002)(44832011)(54906003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2023 11:18:17.2427 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 042fd97e-6201-403b-d9f8-08db35c7748c 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH0PR12MB7094 In both vpl011_read_data() and vpl011_read_data_xen(), there is a comment stating that the guest is expected to read the DR register only if the TXFE bit of FR register is not set. This is obviously logically wrong and it should be RXFE (i.e. RX FIFO empty bit set -> nothing to read). Signed-off-by: Michal Orzel Reviewed-by: Ayan Kumar Halder Reviewed-by: Stefano Stabellini Reviewed-by: Henry Wang --- xen/arch/arm/vpl011.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 2fa80bc15ac4..0186d8a31834 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -143,8 +143,8 @@ static uint8_t vpl011_read_data_xen(struct domain *d) /* * It is expected that there will be data in the ring buffer when this * function is called since the guest is expected to read the data register - * only if the TXFE flag is not set. - * If the guest still does read when TXFE bit is set then 0 will be returned. + * only if the RXFE flag is not set. + * If the guest still does read when RXFE bit is set then 0 will be returned. */ if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) > 0 ) { @@ -202,8 +202,8 @@ static uint8_t vpl011_read_data(struct domain *d) /* * It is expected that there will be data in the ring buffer when this * function is called since the guest is expected to read the data register - * only if the TXFE flag is not set. - * If the guest still does read when TXFE bit is set then 0 will be returned. + * only if the RXFE flag is not set. + * If the guest still does read when RXFE bit is set then 0 will be returned. */ if ( xencons_queued(in_prod, in_cons, sizeof(intf->in)) > 0 ) { From patchwork Wed Apr 5 11:17:49 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Orzel X-Patchwork-Id: 13201623 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 799C2C77B60 for ; Wed, 5 Apr 2023 11:18:40 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.518467.805053 (Exim 4.92) (envelope-from ) id 1pk19j-0002xS-US; Wed, 05 Apr 2023 11:18:23 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 518467.805053; Wed, 05 Apr 2023 11:18:23 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pk19j-0002x0-Q9; Wed, 05 Apr 2023 11:18:23 +0000 Received: by outflank-mailman (input) for mailman id 518467; Wed, 05 Apr 2023 11:18:22 +0000 Received: from se1-gles-sth1-in.inumbo.com ([159.253.27.254] helo=se1-gles-sth1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pk19i-0002uD-JG for xen-devel@lists.xenproject.org; Wed, 05 Apr 2023 11:18:22 +0000 Received: from NAM11-DM6-obe.outbound.protection.outlook.com (mail-dm6nam11on20627.outbound.protection.outlook.com [2a01:111:f400:7eaa::627]) by se1-gles-sth1.inumbo.com (Halon) with ESMTPS id 92183f78-d3a3-11ed-85db-49a42c6b2330; Wed, 05 Apr 2023 13:18:21 +0200 (CEST) Received: from DM6PR06CA0034.namprd06.prod.outlook.com (2603:10b6:5:120::47) by DM4PR12MB7669.namprd12.prod.outlook.com (2603:10b6:8:106::22) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.33; Wed, 5 Apr 2023 11:18:18 +0000 Received: from DM6NAM11FT049.eop-nam11.prod.protection.outlook.com (2603:10b6:5:120:cafe::5d) by DM6PR06CA0034.outlook.office365.com (2603:10b6:5:120::47) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6178.44 via Frontend Transport; Wed, 5 Apr 2023 11:18:18 +0000 Received: from SATLEXMB03.amd.com (165.204.84.17) by DM6NAM11FT049.mail.protection.outlook.com (10.13.172.188) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6277.28 via Frontend Transport; Wed, 5 Apr 2023 11:18:18 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.2375.34; Wed, 5 Apr 2023 06:18:17 -0500 Received: from XIR-MICHALO-L1.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 5 Apr 2023 06:18:16 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 92183f78-d3a3-11ed-85db-49a42c6b2330 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=kaV+HV0ycyoxTc4dkHTLNG3K/5Lf8Nrp6RWQmY7xY/RCfHl5wjPN6xLzuACwqAB8LXSj4+l4lQu+ZdOJJYzgJBYwTIIqBWlAiTO5set3uLlIWptzeYAYbTcNr9ET4OSqAR/NTYXftoAqHkOxCUfr497FQLyTir1c3cNidabbBUg1MgoQklCzmc9bEVCTl0izAjlUBALj1p6Ri8Q41wegJoVSjVrcF68eIfuQFavsZUx9cMSVrwHLPvtkAhzf0y/2hYX5pA2Io3pskB+in6gnGQQFsrM4ux17AFxeqmr+bX7dItVsciPcSCjzJmvL5AL5zQHeh/yauswQAikgVCAiKw== 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=faFuTvjumdAB2CRmAM9G85/4bLPNgqkuwbkGeX5rngE=; b=kjcKQVGukCECjqOvmwnNyPf0gBTADZsQJvmNCJaJdAlX8+ngV4qh8nmRmOiZ+RrnbRVTaAZn99vRWxz32iEejmTqhncYyTuOVMjFxOobagQ6GYp4LAxlAIuiBWrPLsEVUz3rLkhDQL1dkvxLNAc7jg9jJCfEKGKd2U0QZJaQDR4LhhIlFOmtlSb/SsssxgGPaFGHSDywdTiiSSXpGEXJpzAyiElsoXVg5p0rvQTlfHljVnIgZI1DFINedb4OuUeH73wSC+5GPumTRTOaqK5rze63t0/LDz3leVeapXIgCWZi3cTurBab/D4huHCQa9FsT33fbwhyC7dR7KD96VHH2A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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=faFuTvjumdAB2CRmAM9G85/4bLPNgqkuwbkGeX5rngE=; b=RGWTlBzc/JICUHm5hSlDVNLdIDkoqasILDgwRVjJy8Wy5VyTTNIMvLeCRi90OU3dKuueFx5BfRhTFQMoytkKVLLpx8TeRepO1Ht2sFp9EREclTMnzchUyjPPaVnwJOg6GHyhDqYIsuXawjCJvA645nPaTIT6Qp2aa0cFrGZq+8E= 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=SATLEXMB03.amd.com; pr=C From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 2/3] xen/arm: vpl011: Handle correctly TXFE when backend in Xen Date: Wed, 5 Apr 2023 13:17:49 +0200 Message-ID: <20230405111750.12491-3-michal.orzel@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405111750.12491-1-michal.orzel@amd.com> References: <20230405111750.12491-1-michal.orzel@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT049:EE_|DM4PR12MB7669:EE_ X-MS-Office365-Filtering-Correlation-Id: 00ee4a16-6e8e-45a1-6a0d-08db35c77563 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 673hHt9abvZww3bon2Kv6waImqCn0qsquHbGnmusaOu7iVAKUuPp5cX6+6AoDjbO58/zapfGBe7PKWVcNp1zpMIG8Gjy9Tvdcor/6L/iAf8vgPbI2mOQ2ME8tODBjmNyP51Dho96jUFa3eBTG338ii166a4b+m3/eutD+i6Se6O2tdEscxiXIbn7MnDDPfyV0JsVbwHNfeoaZAvhBZUGnGuDl5qbgmi1ZBKaU6AViSlG6J9t6V888PSVNr8dXYWOG6q7d4qmCkO8IzesWXsbXMJBWST/eaPiJ99LLnsYwMtDr+4X177Q5svIQqIC9mCpLT3FEY7VGJD/BkfkdbMn7F33bFWxPa0uysUp9RSO+/AzOeh5+584GxNZPbVn4vixHuSpPk4mZH5hBF53dhWiW0x1iGw4Oa1+RaegIrA/aQKzte7qrCDx6Gc9pmEAYpzaoc3/ZizLqiOgOl/MZcsKaKK7R7PKPfgTlE8Y8nhi/5kghqkRlPIaPWt0lQlhjVC5n8hiBF3DdIpRe8valZsvV3xE8JlBkbHKst7SJePziBKVNs/eXI8uUgYg7ASq3ttqb5fHOSMfsVWjfV4RcDxFEJjIbRyRD/dDY0OVWgpVVb5WDvfqIkdJ25ruz/HLURA0CFnkHHgM3a706skgYR19XL3we5x/Lhfc8P6E0LvgOiSz4MWwdzSnhq85LI+eOuo9ealmotnfaUpcEPp5qmgvpYa1222kEq3j0Wve0Y4v/tM= X-Forefront-Antispam-Report: CIP:165.204.84.17;CTRY:US;LANG:en;SCL:1;SRV:;IPV:CAL;SFV:NSPM;H:SATLEXMB03.amd.com;PTR:InfoDomainNonexistent;CAT:NONE;SFS:(13230028)(4636009)(396003)(346002)(376002)(39860400002)(136003)(451199021)(40470700004)(36840700001)(46966006)(86362001)(426003)(70206006)(70586007)(41300700001)(4326008)(6666004)(316002)(6916009)(54906003)(8676002)(40480700001)(82310400005)(186003)(44832011)(8936002)(36860700001)(5660300002)(2906002)(356005)(82740400003)(81166007)(478600001)(83380400001)(47076005)(336012)(1076003)(2616005)(26005)(36756003)(40460700003)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2023 11:18:18.6489 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 00ee4a16-6e8e-45a1-6a0d-08db35c77563 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=[SATLEXMB03.amd.com] X-MS-Exchange-CrossTenant-AuthSource: DM6NAM11FT049.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB7669 When backend is in Xen, the handling of data written to DR register is a bit special because we want to tell guest that we are always ready for new data to be written (i.e. no real FIFO, TXFF/BUSY never set and TXI always set). This conflicts with the current handling of TXFE bit, which we always clear and never set on a write path (we happen to set it when we receive char from serial input due to use of vpl011_data_avail() but this might never be called). This can lead to issues if a guest driver makes use of TXFE bit to check for TX transmission completion (such guest could then wait endlessly). Fix it by keeping TXFE always set to match the current emulation logic. Signed-off-by: Michal Orzel Reviewed-by: Stefano Stabellini Reviewed-by: Henry Wang Tested-by: Henry Wang --- We don't have to look far for an example of a PL011/SBSA driver relying on TXFE. If a guest had a driver like we have in Xen, we would end up with no messages being printed. --- xen/arch/arm/vpl011.c | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index 0186d8a31834..ff06deeb645c 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -112,8 +112,14 @@ static void vpl011_write_data_xen(struct domain *d, uint8_t data) } } + /* + * When backend is in Xen, we tell guest we are always ready for new data + * to be written. This is fulfilled by having: + * - TXI/TXFE -> always set, + * - TXFF/BUSY -> never set. + */ vpl011->uartris |= TXI; - vpl011->uartfr &= ~TXFE; + vpl011->uartfr |= TXFE; vpl011_update_interrupt_status(d); VPL011_UNLOCK(d, flags); From patchwork Wed Apr 5 11:17:50 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Michal Orzel X-Patchwork-Id: 13201620 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from lists.xenproject.org (lists.xenproject.org [192.237.175.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 8A7D2C761A6 for ; Wed, 5 Apr 2023 11:18:39 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.518469.805072 (Exim 4.92) (envelope-from ) id 1pk19p-0003Tf-Fq; Wed, 05 Apr 2023 11:18:29 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 518469.805072; Wed, 05 Apr 2023 11:18:29 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pk19p-0003TA-AT; Wed, 05 Apr 2023 11:18:29 +0000 Received: by outflank-mailman (input) for mailman id 518469; Wed, 05 Apr 2023 11:18:27 +0000 Received: from se1-gles-flk1-in.inumbo.com ([94.247.172.50] helo=se1-gles-flk1.inumbo.com) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1pk19n-0003OA-2Z for xen-devel@lists.xenproject.org; Wed, 05 Apr 2023 11:18:27 +0000 Received: from NAM10-DM6-obe.outbound.protection.outlook.com (mail-dm6nam10on20626.outbound.protection.outlook.com [2a01:111:f400:7e88::626]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 93a97213-d3a3-11ed-b464-930f4c7d94ae; Wed, 05 Apr 2023 13:18:24 +0200 (CEST) Received: from DS7P222CA0022.NAMP222.PROD.OUTLOOK.COM (2603:10b6:8:2e::25) by IA1PR12MB7734.namprd12.prod.outlook.com (2603:10b6:208:422::11) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.35; Wed, 5 Apr 2023 11:18:20 +0000 Received: from DM6NAM11FT061.eop-nam11.prod.protection.outlook.com (2603:10b6:8:2e:cafe::2f) by DS7P222CA0022.outlook.office365.com (2603:10b6:8:2e::25) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6254.37 via Frontend Transport; Wed, 5 Apr 2023 11:18:20 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by DM6NAM11FT061.mail.protection.outlook.com (10.13.173.138) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.6277.28 via Frontend Transport; Wed, 5 Apr 2023 11:18:20 +0000 Received: from SATLEXMB03.amd.com (10.181.40.144) 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; Wed, 5 Apr 2023 06:18:19 -0500 Received: from XIR-MICHALO-L1.xilinx.com (10.180.168.240) by SATLEXMB03.amd.com (10.181.40.144) with Microsoft SMTP Server id 15.1.2375.34 via Frontend Transport; Wed, 5 Apr 2023 06:18:18 -0500 X-BeenThere: xen-devel@lists.xenproject.org List-Id: Xen developer discussion List-Unsubscribe: , List-Post: List-Help: List-Subscribe: , Errors-To: xen-devel-bounces@lists.xenproject.org Precedence: list Sender: "Xen-devel" X-Inumbo-ID: 93a97213-d3a3-11ed-b464-930f4c7d94ae ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=HHh3tRuCS0Lg5C3Tq6P6x0xOB0FnbYQVfh4OfOuKxKw3t3a+PTDKaebTimcA2ee2m4MqTeUVlbqQbg5cnhOjC0Bmu5VAzxucmSa841KW+S1wfRDXjvDVtYxUCcjPCcZRTh5SG7jhVI5RUuMjerVOJGqvUVn782ESYZKZ7wuaKmbCSFwjZ4mHfnD4e+hBHgHAVhNIyGAuHO6CmIQwk4cznwLUBNcBDN5cmEQFO+ie73yjrwkFezyx3K4kLkQ2qa5ZB0RYr/uMmhCV/toVY8p95UiyG2DxqSXGcF4dXZ7a1Qjl9x09/2LqJb58YaBrUzWsUuzwRy1cvjW/HbuYE6DMcA== 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=u4oUaq7lN8GdxSqirWE6VLLbTs/fytDNa65dm3uA6/s=; b=mug+DyJJAZSjAG0UIkT8KjUfmhoWC6M965ZyxpF/CHnPOoTSHVuuNcQCzTqrMzXiu31/qbUpqnngH5eSEw4UsPwGJo30bnnytVsoHZ3UlUhkMLuoJ4dMjEEM+4pUUlafB8t8PM1djhU970gHPSMdgsSwdVFk/S7C3jdk9Il3GqlpuXN2sZhwOho/Z5U/G67nmMEG3uPe56R1rE4UIh1leuwauPjcWioHmhFetyGT068OIaXOv78YP5m9FbjB87yQQty/QQrka+VPBT+I0Gmyj2Y/aBuALCcIUojIicGcdGeVge7HBTAq8j5vzy0FYWv1pb2W757Dk6Erh3H4CGE1TQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass (sender ip is 165.204.84.17) smtp.rcpttodomain=lists.xenproject.org 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=u4oUaq7lN8GdxSqirWE6VLLbTs/fytDNa65dm3uA6/s=; b=GGPjY6Sk8EY31upxf3pvXMKjvhmR5OWXEIsSh3IwDq9BwOXDEDLGF86X7BQh3y5CIUBjLlrlqt+TsC1EdMBtXvHkKfq7lHp8yBy2RtKO00CPZAqsiBlIrC+DqWV52YftIpby/bregZ9ExP9/gTPyBto3Tx+XuCFXJvEkMMdEaAc= 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 From: Michal Orzel To: CC: Michal Orzel , Stefano Stabellini , Julien Grall , Bertrand Marquis , Volodymyr Babchuk Subject: [PATCH 3/3] xen/arm: vpl011: Do not try to handle TX FIFO status when backend in Xen Date: Wed, 5 Apr 2023 13:17:50 +0200 Message-ID: <20230405111750.12491-4-michal.orzel@amd.com> X-Mailer: git-send-email 2.25.1 In-Reply-To: <20230405111750.12491-1-michal.orzel@amd.com> References: <20230405111750.12491-1-michal.orzel@amd.com> MIME-Version: 1.0 X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: DM6NAM11FT061:EE_|IA1PR12MB7734:EE_ X-MS-Office365-Filtering-Correlation-Id: 3ddf0363-7b25-4ed1-c010-08db35c7765a X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 7B7zit89wb63fCYp2LFg+8QgEUB4Nx2tYbry3sdtjGK7YV8f0oZfGcKsRh+tuQduXsx3bx4JdJwl+Zy0BgdWsA5sbFH4M3lkEMh24Z1TZ+SoV289UbyghlO5gzxn352weDtNTvaXaAZlN8kH0G/eulweLK4uNuMNNlwDqnkQhkdX5OIwo41rbbSn8Ljt1EsHJmf5RyKH47BzQ3GUrfnyjNmDsF3gf5q4seflzwxPyOi6dQRwGeoPPfW6MCpxMEQkv4/t0CxsQCM6Tj9ECkSvnx3La2Co0+AdGzYNtY10K/dAumfXeLz6qmmhEWAKNVmXLYyEK0UPp5hhUPWC8JY+4N2n+EXJ9X+HMebRy8TYAMFcnUpXE+P5WNYcugAQ+XUSrmzIfcvXwn5QYVu/DWWtq7g+Cm8RyARoARUvIZCAyMsVzdsF9FKnUb0vISBENWhFEzmehgKiyaqBwJokrjMln82CyhQu2HwikmXO9z22bOgNehpMOllzEdXkBn2eMwpkjTkxM9vlxwLD402KFk/sQIwnwHjp6DoRXaA+76W9hYNFqXFZf9SSSNyK28JuTDipwKGVwOFBupeamnwqd75X9I4J+Uyzxolsjhs/kYV+VkkjG0DBtPPRDuH9yS3e8BoXzH8icqDInjU0A0IPHarKY2JMNNVOvvb1AN5jSwkzt8pH1YsvwOCz49RH0Mxvca5NdGy4LIe8satRfLsyf/Y9OUSjr45yQ9izAVICNn6zqyE= 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:(13230028)(4636009)(376002)(136003)(346002)(39860400002)(396003)(451199021)(40470700004)(46966006)(36840700001)(2616005)(8936002)(186003)(44832011)(5660300002)(2906002)(26005)(81166007)(82740400003)(1076003)(356005)(36860700001)(54906003)(4326008)(8676002)(6916009)(41300700001)(86362001)(40460700003)(426003)(70586007)(336012)(70206006)(478600001)(316002)(40480700001)(82310400005)(36756003)(47076005)(83380400001)(6666004)(36900700001);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Apr 2023 11:18:20.2698 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 3ddf0363-7b25-4ed1-c010-08db35c7765a 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: DM6NAM11FT061.eop-nam11.prod.protection.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: IA1PR12MB7734 From vpl011_rx_char_xen(), we call vpl011_data_avail() that handles both RX and TX state. Because we are passing 0 as out_fifo_level and SBSA_UART_FIFO_SIZE as out_size, we end up calling a function vpl011_update_tx_fifo_status() which performs TXI bit handling depending on the FIFO trigger level. This does not make sense when backend is in Xen, as we maintain a single TX state where data can always be written and as such there is no TX FIFO handling. Furthermore, this function assumes that the backend is in domain by making use of struct xencons_interface unconditionally. Fix it by calling this function only when backend is in domain. Also add an assert for sanity. Signed-off-by: Michal Orzel Reviewed-by: Stefano Stabellini Tested-by: Henry Wang --- xen/arch/arm/vpl011.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/xen/arch/arm/vpl011.c b/xen/arch/arm/vpl011.c index ff06deeb645c..7856b4b5f5a3 100644 --- a/xen/arch/arm/vpl011.c +++ b/xen/arch/arm/vpl011.c @@ -261,6 +261,9 @@ static void vpl011_update_tx_fifo_status(struct vpl011 *vpl011, struct xencons_interface *intf = vpl011->backend.dom.ring_buf; unsigned int fifo_threshold = sizeof(intf->out) - SBSA_UART_FIFO_LEVEL; + /* No TX FIFO handling when backend is in Xen */ + ASSERT(vpl011->backend_in_domain); + BUILD_BUG_ON(sizeof(intf->out) < SBSA_UART_FIFO_SIZE); /* @@ -547,7 +550,13 @@ static void vpl011_data_avail(struct domain *d, */ vpl011->uartfr &= ~BUSY; - vpl011_update_tx_fifo_status(vpl011, out_fifo_level); + /* + * When backend is in Xen, we are always ready for new data to be + * written (i.e. no TX FIFO handling), therefore we do not want + * to change the TX FIFO status in such case. + */ + if ( vpl011->backend_in_domain ) + vpl011_update_tx_fifo_status(vpl011, out_fifo_level); } vpl011_update_interrupt_status(d);