From patchwork Mon Jul 8 06:25:54 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: "Chen, Jiqian" X-Patchwork-Id: 13726209 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 E3DF1C3271E for ; Mon, 8 Jul 2024 06:26:54 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.755006.1163256 (Exim 4.92) (envelope-from ) id 1sQhpO-0007Kw-MU; Mon, 08 Jul 2024 06:26:22 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 755006.1163256; Mon, 08 Jul 2024 06:26:22 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1sQhpO-0007Kp-Jz; Mon, 08 Jul 2024 06:26:22 +0000 Received: by outflank-mailman (input) for mailman id 755006; Mon, 08 Jul 2024 06:26:20 +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 1sQhpM-0007Kj-KF for xen-devel@lists.xenproject.org; Mon, 08 Jul 2024 06:26:20 +0000 Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on20620.outbound.protection.outlook.com [2a01:111:f400:7ea9::620]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id fa9c45d6-3cf2-11ef-8776-851b0ebba9a2; Mon, 08 Jul 2024 08:26:16 +0200 (CEST) Received: from SA0PR11CA0144.namprd11.prod.outlook.com (2603:10b6:806:131::29) by MW4PR12MB8610.namprd12.prod.outlook.com (2603:10b6:303:1ef::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.34; Mon, 8 Jul 2024 06:26:12 +0000 Received: from SN1PEPF00026367.namprd02.prod.outlook.com (2603:10b6:806:131:cafe::5c) by SA0PR11CA0144.outlook.office365.com (2603:10b6:806:131::29) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7741.35 via Frontend Transport; Mon, 8 Jul 2024 06:26:12 +0000 Received: from SATLEXMB04.amd.com (165.204.84.17) by SN1PEPF00026367.mail.protection.outlook.com (10.167.241.132) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.20.7762.17 via Frontend Transport; Mon, 8 Jul 2024 06:26:11 +0000 Received: from cjq-desktop.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.2507.39; Mon, 8 Jul 2024 01:26:09 -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: fa9c45d6-3cf2-11ef-8776-851b0ebba9a2 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=dsfo8dPeKnFft4b0tFK/ZgN1P6Q8tDAQKwakGgK+z5Zb1RR50fjL4qYNCIAnWz2SQC2tOsxeQsSZEfh8q83ttA+UloQo4YV/silIEBzP0hhjNLpx8YupA1dUnufiOtktyG1Ut65NBJNsHe9T1neGUoeStYqkOb1aHU1cNcgMKDP3fDChpPSOEAMGjW6F/VbKcxhV+TpbQnKXTiFmOobnCN2OZlCTizhcaz76/7PONU6rRIB/dpNvgTaNA2yv1kCFI5E0TnjXdQK1an/IlpvE05iorHNVxtD4g14dUV+BQRlLsFrBP2K7XLp5g82Jx9XJyMRiMP4/mRdx2L6KcJCcqw== 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=/tohzRVqTI0hSAsmX0f+iY/yn1JVZZtLAdvD2aQ6XSg=; b=So6GeBiX6wmDg+KTQZ17PpWOVmOQDxOFsIRgSqfYsoVZd99OUeDdoUme3m0ZmrB8tPK2bX0cKtP2V6hgbYvHoCjvyuNiO06xK+Va4Gl+v+WdZD0Uk+75U8T8XKD83HyDYvF+lQ+zfsn+Njwgi21JaEn4UgAXnP0YRM4CKBcmg0NDLjfSQS6wL2ktvipaxAOcxyHVC5Cwqa1ts3SldlE/+9Brni0EAgAxqqrX9arTesZRa8AWgEl4WmDWS8wRO+4zFq1fAdZBH5Hiid0HjzNeJydd4BHri+QCAHJja1dz4qqVk4SIVeheIcMfU5u9piUAUfmW2gsjcuVB79Sed5Wn6w== 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 (0) 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=/tohzRVqTI0hSAsmX0f+iY/yn1JVZZtLAdvD2aQ6XSg=; b=GPyyScZwIUFv4tj0FztLsUCYp1fmb4hnzNa0maz1IXLo1VdA/qUcdegHNqT86f9TFcI/FWKoJxp+ZkUk4Diw92fmY5L/EHbJEXSNLvu4uAPj+UyTYTEbJTgQkZCs97g+iuTKu12dZnC6jzF4AtKKSH2Jk1PJ31MjMF4fbDjzXIU= 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: Jiqian Chen To: CC: Jan Beulich , Andrew Cooper , =?utf-8?q?Roger_Pau_Monn=C3=A9?= , Oleksii Kurochko , "Huang Rui" , Jiqian Chen , Huang Rui Subject: [PATCH for-4.19] x86/physdev: Return pirq that irq was already mapped to Date: Mon, 8 Jul 2024 14:25:54 +0800 Message-ID: <20240708062554.399784-1-Jiqian.Chen@amd.com> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 X-Originating-IP: [10.180.168.240] X-ClientProxiedBy: SATLEXMB03.amd.com (10.181.40.144) To SATLEXMB04.amd.com (10.181.40.145) X-EOPAttributedMessage: 0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: SN1PEPF00026367:EE_|MW4PR12MB8610:EE_ X-MS-Office365-Filtering-Correlation-Id: 7bdd9a74-8340-4c28-cb24-08dc9f16dcae X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0;ARA:13230040|36860700013|82310400026|376014|1800799024; X-Microsoft-Antispam-Message-Info: 9OQ3HLlDa8gGWh5c/+ieer2X4oXHq9Vd8K0w33DqArjQe2Ym5OhJbi/JkyB0M5pZKNpa8F4+IUus9kLIsiK9aMWIxjinGG/RzWOh7PzKcgJm9ndvVRwCu787mKDplgl1yxvvi58mvvIDiZ1axMxvNKMRzZDIrS2nTI8Twr2pDx0hBsLGp9hAP37bdNTsgJjOXopT1GV3/6+eLt1jDU0vY6+W92xiZk3QmwJKOUi6PFQv6bWaghNveQ/xZJ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LD3lquKXDCjnht1hSWUvNIPdcko0lsvJGKOMEoYpx9GV6OGWu3tHXzkjkEjZ+GQR2XHJuEnKCsBtaB8WcVLmkeOJvPIEWN1qYJsWlGF/whsXN010qKiygymMrmOa9g0A3+e/w9jItczGqVMXWDXehuG 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:(13230040)(36860700013)(82310400026)(376014)(1800799024);DIR:OUT;SFP:1101; X-OriginatorOrg: amd.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Jul 2024 06:26:11.9525 (UTC) X-MS-Exchange-CrossTenant-Network-Message-Id: 7bdd9a74-8340-4c28-cb24-08dc9f16dcae 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: SN1PEPF00026367.namprd02.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Anonymous X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW4PR12MB8610 Fix bug imported by 0762e2502f1f ("x86/physdev: factor out the code to allocate and map a pirq"). After that re-factoring, when pirq<0 and current_pirq>0, it means caller want to allocate a free pirq for irq but irq already has a mapped pirq, then it returns the negative pirq, so it fails. However, the logic before that re-factoring is different, it should return the current_pirq that irq was already mapped to and make the call success. Fixes: 0762e2502f1f ("x86/physdev: factor out the code to allocate and map a pirq") Signed-off-by: Jiqian Chen Signed-off-by: Huang Rui Signed-off-by: Jiqian Chen Reviewed-by: Jan Beulich --- xen/arch/x86/irq.c | 1 + 1 file changed, 1 insertion(+) diff --git a/xen/arch/x86/irq.c b/xen/arch/x86/irq.c index 9a611c79e024..1a827ccc8498 100644 --- a/xen/arch/x86/irq.c +++ b/xen/arch/x86/irq.c @@ -2897,6 +2897,7 @@ static int allocate_pirq(struct domain *d, int index, int pirq, int irq, d->domain_id, index, pirq, current_pirq); if ( current_pirq < 0 ) return -EBUSY; + pirq = current_pirq; } else if ( type == MAP_PIRQ_TYPE_MULTI_MSI ) {