From patchwork Tue Dec 5 19:14:45 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13480651 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 bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (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 BCF14C4167B for ; Tue, 5 Dec 2023 19:15:27 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:References:In-Reply-To: Message-ID:Date:Subject:Cc:To:From:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=vQjm68jsQ5XBE/dJDT8im8QwUoCV4rG/fKQyIEd+riE=; b=cce2DOn9p7QZQf yRa/0ggm9R3qR4pX6k4l5lp50m2SW0Yc+kzxhvMNmm64MXa/ERj9aREXH+Q49lWZqh9i/p8n1WfXp qqs2tghG+YFe4y3tr2rlah7bWtTPJhsoIcdp31OkRsowYiyd7N04AEpxgdedOQuskLIhLDi3s80xl L2vTDodP5rgQ3bPzMfpmm3oy10R1aSku9u5QJq5imRBV3cS+k5uh7pyr7Fn2biWb3ER0iDtiJooDi wk2tHCfHgf3BvsmZoy7ExbZsQRCTNWCtG4dQk+T5oDLCp5f5HEhfbkJkDmjQxmQ2aytyGqwjxl53D DE9THT5TsyMc9pCQRUpg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rAasm-008Exk-0f; Tue, 05 Dec 2023 19:15:00 +0000 Received: from mail-mw2nam12on2061f.outbound.protection.outlook.com ([2a01:111:f400:fe5a::61f] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rAask-008Ewd-0c for linux-arm-kernel@lists.infradead.org; Tue, 05 Dec 2023 19:14:59 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=LKTPodJiNxZW4QBep7YSM3R4Mu9jzm8C2lLIMiCB+KWr5fJOAr7WXWXmwyy9zM8Ir/WNcdk46Xa/ZY9pRTAugTT/wabUlq4ravK55wt5ngj5CYV/unrIP1edWgqS70DNBa0oUhfqXUN/VDHK/iPQAQMQ+raxZAdX2r6kBSIlyOKR6lLNroHyqoXdnWSZudM+lPtiWHadpCTgsQGcz2bDvZBSa/Y6lxGkFPHpze2f5llRuBVbROw1SVvjmquhOm80vqM3oF5g/KekmU1Km/hA+bX3q78Q5gf26xYSww1k+rHiR2c8Q62Y26iOwHUW3acaiZ2ed/3Yzz5JztcLOlfwbw== 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=jw2/0/oSwj2jIslRLSqpZCEey9o1yv2M+zuYQoPGK9A=; b=IJfcVJnvrlnsnOOYzDgt+DjNvtZJB3OUmgRaka3T8wvvBoNMDYkoIr33/0LLY82UzqAoipjoHWgZ+eX316nn2ZiBEJUwHR2Yk6Q4hdCKhHsXgUkbNh3iW8iXneqJPhCjo/ebPZUWGzQ9rR1IPgpDrBc9KcRbjeG2eJooOVrJ3rbo2BmxzMB7cRiP9BgAUAcMvafLTsqtNFFktNP3PEzgd0Ikl0g8TTjy80rySYJxmize8V8jLkAirfHyJuegmAjuLLhRA0J+3vK1s6C43gyLMuRbO6NuUjEs9zeNYIO8SOn0sAytFFT6nZrb9F+OIx03KmVFGVN8/ZZGSf6W50TNMw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=jw2/0/oSwj2jIslRLSqpZCEey9o1yv2M+zuYQoPGK9A=; b=GnPn5KfPgB46eq/jK5YR8/RRIMp3KATZ7M3WP+QM0yP7NRspv/tJAuoRg+R7PlojqUgJpUdj81uipq4aKYwMk90693BsNJ1BNg89MoKpipfW1nzm/HKZWQ3eFEHNOVDwyu0YyU1H26dcXYNHfjf0JbqCdkteUG+YJyKpvws0/SIMV2wqTCL7e72cAJmyJOSIDC1RWbTj28kVSDMUqWekX9o2dtFK1qhQRoH8CPPR97msTE7vWsUA9rL7OZBjE62APwYkn8ZHMK+hkr3RC1yydegCFSWC2Q+ZD9BNeNbKP5ynMPZ5bfvNoMCMPSELXue+aYCW/CbhEAxbHTw1mCEMmQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) by PH7PR12MB6588.namprd12.prod.outlook.com (2603:10b6:510:210::10) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.7046.34; Tue, 5 Dec 2023 19:14:52 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::60d4:c1e3:e1aa:8f93%4]) with mapi id 15.20.7046.034; Tue, 5 Dec 2023 19:14:52 +0000 From: Jason Gunthorpe To: iommu@lists.linux.dev, Joerg Roedel , linux-arm-kernel@lists.infradead.org, Robin Murphy , Will Deacon Cc: Eric Auger , Moritz Fischer , Michael Shavit , Nicolin Chen , patches@lists.linux.dev, Shameer Kolothum Subject: [PATCH v3 13/19] iommu/arm-smmu-v3: Pass smmu_domain to arm_enable/disable_ats() Date: Tue, 5 Dec 2023 15:14:45 -0400 Message-ID: <13-v3-d794f8d934da+411a-smmuv3_newapi_p1_jgg@nvidia.com> In-Reply-To: <0-v3-d794f8d934da+411a-smmuv3_newapi_p1_jgg@nvidia.com> References: X-ClientProxiedBy: BL6PEPF00013E06.NAMP222.PROD.OUTLOOK.COM (2603:10b6:22e:400:0:1001:0:7) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|PH7PR12MB6588:EE_ X-MS-Office365-Filtering-Correlation-Id: 643d38ee-03e9-4f7c-5304-08dbf5c674e3 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: VpQlaq6I9Rh9uzHT10xk40gsxyRP1JvRVjiiPVEmpfkwTIyxCVLyXIuwWJULaUvlY4aXR+5lsceXSHLN8BxyeeF6EQz5EzkD8JimAqijN4XVLTV5GByG4s5iv8+xcWPzqRXCy3RcEy68vlFmmb3mJUG+DKkhpHFrWwYIwMgtYiukLpa5Il8EIMf3NVW1FKAyMXQGvDPizqnYoZXgxHhAoH+ZMPEoMuoYk9GjcB8nIr+VKx2Kg0DIyBmu/Jlp5Ji/PeFFhzjHeHSmRO4DplzYtJJtWe4r+85ak1CsgM0k47u35QoamQ0unQjhtbxK6OaHDHmzcl6JnhxVHl9s2jqTmDqRKtaC6MPIOLGHBGrvGk3YkZjMCbeNIK9y+Bhahx/5XRLHBLXjOBukPRjlRTZSRbo9KH6OUVc/mrOeUlGO7zs2B03WfXALvAxZNAGTTPINvde9yXY6jZlzChEEWmtr1RvfEEZQJJEjuwA5QIuyvq+oHtg+B4UPHSPveu5i9LbL++GjxOFsoza9gB2D3qudDbzKdJm2QYGIkTfrNzlV1EYVuYFIL2L+wcoTIivXFpMu X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:LV2PR12MB5869.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230031)(39860400002)(366004)(136003)(396003)(346002)(376002)(230922051799003)(1800799012)(451199024)(64100799003)(186009)(478600001)(6512007)(6506007)(8936002)(6486002)(2616005)(26005)(6666004)(54906003)(66476007)(110136005)(66556008)(8676002)(66946007)(4326008)(316002)(83380400001)(38100700002)(7416002)(36756003)(5660300002)(2906002)(86362001)(41300700001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: h49r7rkI2wOPyl7/wDMU3eOLygQMrcSOUkrTkfNwb5zOqr++Vh8ClCxg6tD67gXq4a+fj2fl7ofyVYfxiZzvk/5ifq9THjyuIP767ieUNlVl5/AfaPk4oETNcGFTvyzUy9lLaP5UogZ9ef2zfXtT+YOjS7ImLMmQgFbAXeGxdR1S7k4go/Buv3vagornOI4765fU22WZAUIGhrDB9zsHkf9Mmc4P5PlpJgXYQrNTigHRo6DPt42J4sxjlVHfQ2wHSEVxP9FKlwLI2Dd+YuUDgoJnb1fb1MytLsmEefxifuyJQ6p3G65X4VU6uLXyy9lrhpLLeUvdjFpnnPB8QXwTghPcUdlp2QcJfluyFo7dp4dsk5XtsIDtNaWBA7ufpd4ggvIH0mrD7lt61K09KrJZ9EOqlB/fS2seLoUDAUVnEOhXuedKsuHdWutWt7BVPo+Ujp+kRewOQwUSsBAPaI2+bt5flskLIChQnZdY6OL+UeZ5IheclkgEapx4zdWFps5t2mdrnFgWu0UW3kqrpb8bjRAmHrHA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ossTenant-Network-Message-Id: 643d38ee-03e9-4f7c-5304-08dbf5c674e3 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 05 Dec 2023 19:14:51.7920 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: wkw5zWrAP1ByfVKEU0vgbkjHBjVX9o9xrUMnGFrosbvLtTLUA+RTNGhkelAoOSRG X-MS-Exchange-Transport-CrossTenantHeadersStamped: PH7PR12MB6588 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20231205_111458_238849_9CB6AD1E X-CRM114-Status: UNSURE ( 9.62 ) X-CRM114-Notice: Please train this message. X-BeenThere: linux-arm-kernel@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "linux-arm-kernel" Errors-To: linux-arm-kernel-bounces+linux-arm-kernel=archiver.kernel.org@lists.infradead.org The caller already has the domain, just pass it in. A following patch will remove master->domain. Tested-by: Shameer Kolothum Tested-by: Nicolin Chen Reviewed-by: Nicolin Chen Signed-off-by: Jason Gunthorpe --- drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c index 212d0ad7e5f911..e1de2799310961 100644 --- a/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c +++ b/drivers/iommu/arm/arm-smmu-v3/arm-smmu-v3.c @@ -2394,12 +2394,12 @@ static bool arm_smmu_ats_supported(struct arm_smmu_master *master) return dev_is_pci(dev) && pci_ats_supported(to_pci_dev(dev)); } -static void arm_smmu_enable_ats(struct arm_smmu_master *master) +static void arm_smmu_enable_ats(struct arm_smmu_master *master, + struct arm_smmu_domain *smmu_domain) { size_t stu; struct pci_dev *pdev; struct arm_smmu_device *smmu = master->smmu; - struct arm_smmu_domain *smmu_domain = master->domain; /* Don't enable ATS at the endpoint if it's not enabled in the STE */ if (!master->ats_enabled) @@ -2415,10 +2415,9 @@ static void arm_smmu_enable_ats(struct arm_smmu_master *master) dev_err(master->dev, "Failed to enable ATS (STU %zu)\n", stu); } -static void arm_smmu_disable_ats(struct arm_smmu_master *master) +static void arm_smmu_disable_ats(struct arm_smmu_master *master, + struct arm_smmu_domain *smmu_domain) { - struct arm_smmu_domain *smmu_domain = master->domain; - if (!master->ats_enabled) return; @@ -2487,7 +2486,7 @@ static void arm_smmu_detach_dev(struct arm_smmu_master *master) if (!smmu_domain) return; - arm_smmu_disable_ats(master); + arm_smmu_disable_ats(master, smmu_domain); spin_lock_irqsave(&smmu_domain->devices_lock, flags); list_del(&master->domain_head); @@ -2609,7 +2608,7 @@ static int arm_smmu_attach_dev(struct iommu_domain *domain, struct device *dev) break; } - arm_smmu_enable_ats(master); + arm_smmu_enable_ats(master, smmu_domain); goto out_unlock; out_list_del: