From patchwork Thu Feb 6 10:49:27 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Teddy Astie X-Patchwork-Id: 13962805 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 ABA72C02194 for ; Thu, 6 Feb 2025 10:49:55 +0000 (UTC) Received: from list by lists.xenproject.org with outflank-mailman.882713.1292809 (Exim 4.92) (envelope-from ) id 1tfzRt-00021B-N4; Thu, 06 Feb 2025 10:49:33 +0000 X-Outflank-Mailman: Message body and most headers restored to incoming version Received: by outflank-mailman (output) from mailman id 882713.1292809; Thu, 06 Feb 2025 10:49:33 +0000 Received: from localhost ([127.0.0.1] helo=lists.xenproject.org) by lists.xenproject.org with esmtp (Exim 4.92) (envelope-from ) id 1tfzRt-000214-K0; Thu, 06 Feb 2025 10:49:33 +0000 Received: by outflank-mailman (input) for mailman id 882713; Thu, 06 Feb 2025 10:49:32 +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 1tfzRs-00020y-Dg for xen-devel@lists.xenproject.org; Thu, 06 Feb 2025 10:49:32 +0000 Received: from mail145-20.atl61.mandrillapp.com (mail145-20.atl61.mandrillapp.com [198.2.145.20]) by se1-gles-flk1.inumbo.com (Halon) with ESMTPS id 09cfcd29-e478-11ef-b3ef-695165c68f79; Thu, 06 Feb 2025 11:49:29 +0100 (CET) Received: from pmta06.mandrill.prod.atl01.rsglab.com (localhost [127.0.0.1]) by mail145-20.atl61.mandrillapp.com (Mailchimp) with ESMTP id 4YpYkv4Y13zCf9KCn for ; Thu, 6 Feb 2025 10:49:27 +0000 (GMT) Received: from [37.26.189.201] by mandrillapp.com id c7b5e5191f3f44ddaecfd120a10a4d98; Thu, 06 Feb 2025 10:49:27 +0000 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: 09cfcd29-e478-11ef-b3ef-695165c68f79 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=mandrillapp.com; s=mte1; t=1738838967; x=1739108967; bh=L4o2ZZgMga0nK/q0vLs6VvOXTbOpIP3PAVzgoEdo7vE=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=YYAUZTOwsSYtRYYxAQqiBU8Hk3QzDLt4LkH6/u9P6feoaj31B8hm2mbs68PZUt1We gWyxPGBH9GJCoubPSFuTIrJA4sTu86CqDEe/wHfPE5fFmTdnnkO55Gjq1nvJeJgZTY HOQKxbf70ts6Q6C8+9tbf88bSvUt6zkKwY2dPjoR8YrGHDBXm/PMZqByrrLuu/wFol zl21aYLobYMglFZXxAoyFAnA2VJR9NIAFcLA5v40+lPL0PSrSGpIj7TfjEjYxYLgwD Yvlf6myEKYp8C9+XkzEexRDlI5bvz+Lo6yRi68Z62TuEbdaTLibDyVOft2wFlVBHhH 1CoQIGi2GVRvA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=vates.tech; s=mte1; t=1738838967; x=1739099467; i=teddy.astie@vates.tech; bh=L4o2ZZgMga0nK/q0vLs6VvOXTbOpIP3PAVzgoEdo7vE=; h=From:Subject:To:Cc:Message-Id:Feedback-ID:Date:MIME-Version: Content-Type:Content-Transfer-Encoding:CC:Date:Subject:From; b=Bui21VqQgjYCybM4iMw/deRmIsSiFZY8LAIiqW3ICeBwdoYiki2xQYmnqfQvukHVB g7xpYTYejkJCuw51Ax/3eHx79tkNpLT5uoCPcNX8gJ1xdnnzPqxpIqjU55weasBoOJ z5oAIh60LeCFtMkFwvSVP4QrPITOA17+EHtqbDQDgeKHijKItF4gz+HYHbPLVQSwhY h1XmThbq4g+1GkEl3nNVhrhQ15xi2WmJpLew6bsosWRfwODAErM8zBk5IYDMTd/FKR QhACFl1ddePM5vCO6Vz50tCmF9eyBb9aiOGlX0retxv8tS/ixxKYb5RNHXzIGQhjv/ WY4ahO5OsN4fA== From: "Teddy Astie" Subject: =?utf-8?q?=5BXEN_PATCH=5D_iommu/amd=3A_Remove_redundant_values_rede?= =?utf-8?q?finitions?= X-Mailer: git-send-email 2.47.2 X-Bm-Disclaimer: Yes X-Bm-Milter-Handled: 4ffbd6c1-ee69-4e1b-aabd-f977039bd3e2 X-Bm-Transport-Timestamp: 1738838966668 To: xen-devel@lists.xenproject.org Cc: "Teddy Astie" , "Jan Beulich" , "Andrew Cooper" , " =?utf-8?q?Roger_Pau_Monn?= =?utf-8?q?=C3=A9?= " Message-Id: X-Native-Encoded: 1 X-Report-Abuse: =?utf-8?q?Please_forward_a_copy_of_this_message=2C_including?= =?utf-8?q?_all_headers=2C_to_abuse=40mandrill=2Ecom=2E_You_can_also_report_?= =?utf-8?q?abuse_here=3A_https=3A//mandrillapp=2Ecom/contact/abuse=3Fid=3D30?= =?utf-8?q?504962=2Ec7b5e5191f3f44ddaecfd120a10a4d98?= X-Mandrill-User: md_30504962 Feedback-ID: 30504962:30504962.20250206:md Date: Thu, 06 Feb 2025 10:49:27 +0000 MIME-Version: 1.0 In amd_iommu_setup_domain_device, we redefine req_id and ivrs_dev without using it the first time we read it. This is effectively dead logic that we can refactor. Signed-off-by: Teddy Astie --- xen/drivers/passthrough/amd/pci_amd_iommu.c | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/xen/drivers/passthrough/amd/pci_amd_iommu.c b/xen/drivers/passthrough/amd/pci_amd_iommu.c index f96f59440b..1511a2a099 100644 --- a/xen/drivers/passthrough/amd/pci_amd_iommu.c +++ b/xen/drivers/passthrough/amd/pci_amd_iommu.c @@ -147,17 +147,14 @@ static int __must_check amd_iommu_setup_domain_device( if ( rc ) return rc; - req_id = get_dma_requestor_id(iommu->seg, pdev->sbdf.bdf); - ivrs_dev = &get_ivrs_mappings(iommu->seg)[req_id]; - sr_flags = (iommu_hwdom_passthrough && is_hardware_domain(domain) - ? 0 : SET_ROOT_VALID) - | (ivrs_dev->unity_map ? SET_ROOT_WITH_UNITY_MAP : 0); - - /* get device-table entry */ req_id = get_dma_requestor_id(iommu->seg, PCI_BDF(bus, devfn)); table = iommu->dev_table.buffer; + /* get device-table entry */ dte = &table[req_id]; ivrs_dev = &get_ivrs_mappings(iommu->seg)[req_id]; + sr_flags = (iommu_hwdom_passthrough && is_hardware_domain(domain) + ? 0 : SET_ROOT_VALID) + | (ivrs_dev->unity_map ? SET_ROOT_WITH_UNITY_MAP : 0); if ( domain != dom_io ) {