From patchwork Fri Jun 9 19:55:52 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jason Gunthorpe X-Patchwork-Id: 13274359 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 15146C7EE37 for ; Fri, 9 Jun 2023 19:59:01 +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=34Ri4OeJ2xctrtMBUos/1j9tTey7CeRaCP4AHFtnykk=; b=Jx9Vzz3OQ7kgU7 Czl4/BB/yQDePLT4bF4w/r4XqPZkIPiQCrEUi+uRmXYfn5ezMK5Iyx2boGGhNay3lS1H4y6Chhc2W QnCkJJ6y7Tbc6l5Yw8M1/N/if48hNE3ezN0M+0Z4XJ8PBTDYWdupW2EwBZRb3PtO+iWgv9EDKSQur VkZ5BT08hjOfAZ+2VNa2xd4As6NvVkA/7B3SIaWXYI9+3LXLFRsvBXMbgjgPCz1PrRawUL4u7o00H QpGxFz7Ig0Yd51NIAGpIuqJG60uSS5XXjVcJZFVV9tNudfPXfEz58ybHfB+4kg4qXQPezXCvuys8E jzH8jJ1UqHew9DsvucPA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1q7iG4-00E6wd-1G; Fri, 09 Jun 2023 19:58:52 +0000 Received: from mail-mw2nam12on2061c.outbound.protection.outlook.com ([2a01:111:f400:fe5a::61c] helo=NAM12-MW2-obe.outbound.protection.outlook.com) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1q7iDu-00E4R9-1v; Fri, 09 Jun 2023 19:56:42 +0000 ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=UnhJ+ww3gfnAYhPXWYaYPcNkSTkbqsq9+FjUzMEncSgGLOqszyv8TwE4WGzwhbTgd9gay/IvLOKyX1sNgPDNftq1wm+7LSjstAe6FXL9KzuivSrQCEEuiDzBBicl0Je+5pUIuTOvdUmbHOtIWAyN9zOJwAZQ0zXyHM33iNejPRen07sEKsJEIuJzrxwBzMClMcInP7aYOaTu9PeCAEjerCf4cF7Uc73aqqIZ563X0oWeX1O5rhEVOH4RObhdz7CAodWSqUAtmgHNDtFStfLPxtPS0tVxucLxQtoKqR1bFB+h++Vx8et686L9b/LCyUxV5tk7hLx3YXDBBv+PGh/J7A== 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=KWXa5iPUsdOK6aga88CkdY8DnvSE5VOlKfKrBPcpAvo=; b=QKCTZPhf/3RuogQ5ynIeAHSWsxs5RcgCalxuIzf83kwTW/v+Shz878MawDSNOI+eytFUyvdc9bNETtio7eq4bDmeM7lMgAAB7s1vJM+BgGRs14Tg+P07WGhcSHCtfj5GvMvLhCW/kxKMf7TEAQEuLPes98jr548wY2Pr4px2MZ0UlzUuDfkgc6AT9J/Gd8JG/5HlDEkIX8mpci58W17OprsR8fsE3XYSk4TGXWJIgQs0hXRbZ6PdrkEdoBtXNFG5RfRJuFxY+HahDw2yJMoSOjdv6HyRefXLRCSajpH9CHVsjOu/y+TfgZ//LwD83/Cs+aRfXyx5I71qJatg1dbCBg== 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=KWXa5iPUsdOK6aga88CkdY8DnvSE5VOlKfKrBPcpAvo=; b=OmmG09seABBlZ3CAvMtZ+S/5CY+xrWFEHqTNlLhsW9m6A5sbVH2bdCAqwR1EvtvY9yVrEh8m4HR2nqcGJsSx6m6ppBKjwsWI0yZd8wN+467bbmCTdxPmrGtLBQ9+xIqkRrNmfBxYTmj1GKlryr32Eb20pnBCxZBVShPNc+S48Th2yC23eYtCZneq9/E2xHwWieSjCm1o0BUBo+9rqlz6r5nYM+chfQANkkOOXBsjncO5FzfOIjeh0SrscJdleco8t+Mwm2fVqxa0YEvuVYdUygtRISXWvZl1fFi3wEEdZpF8kjT2+ElKtSrctgNJASgAfhuP8fxJngqhknFTgI1LnQ== 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 DM4PR12MB5264.namprd12.prod.outlook.com (2603:10b6:5:39c::17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6455.33; Fri, 9 Jun 2023 19:56:22 +0000 Received: from LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab]) by LV2PR12MB5869.namprd12.prod.outlook.com ([fe80::f7a7:a561:87e9:5fab%6]) with mapi id 15.20.6455.030; Fri, 9 Jun 2023 19:56:22 +0000 From: Jason Gunthorpe To: Andy Gross , Alim Akhtar , Bjorn Andersson , AngeloGioacchino Del Regno , Baolin Wang , Christophe Leroy , Gerald Schaefer , Heiko Stuebner , iommu@lists.linux.dev, Jernej Skrabec , Jonathan Hunter , Joerg Roedel , Kevin Tian , Konrad Dybcio , Krzysztof Kozlowski , linux-arm-kernel@lists.infradead.org, linux-arm-msm@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-rockchip@lists.infradead.org, linux-s390@vger.kernel.org, linux-samsung-soc@vger.kernel.org, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, Russell King , linuxppc-dev@lists.ozlabs.org, Matthias Brugger , Matthew Rosato , Michael Ellerman , Nicholas Piggin , Orson Zhai , Rob Clark , Robin Murphy , Samuel Holland , Thierry Reding , Krishna Reddy , Chen-Yu Tsai , Will Deacon , Yong Wu , Chunyan Zhang Cc: Lu Baolu , Dmitry Osipenko , Marek Szyprowski , Nicolin Chen , Niklas Schnelle , Steven Price , Thierry Reding Subject: [PATCH v3 04/25] iommu: Add IOMMU_DOMAIN_PLATFORM for S390 Date: Fri, 9 Jun 2023 16:55:52 -0300 Message-Id: <4-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com> In-Reply-To: <0-v3-89830a6c7841+43d-iommu_all_defdom_jgg@nvidia.com> References: X-ClientProxiedBy: SJ0PR03CA0365.namprd03.prod.outlook.com (2603:10b6:a03:3a1::10) To LV2PR12MB5869.namprd12.prod.outlook.com (2603:10b6:408:176::16) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: LV2PR12MB5869:EE_|DM4PR12MB5264:EE_ X-MS-Office365-Filtering-Correlation-Id: 8c88ff9f-9d05-4f32-8017-08db69239808 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: yqSmH0lkCQnRDiwjA+WKYvosNvm1u0aBlaGEZ09NIIiAm+oap5zbQRpVDSJhaRhP97ft2TEhlJs/siioXPTG3qTMemgv2jO9forf9urLdxBwqe5WW1gWpEZa50tCCEOGVRHnlrdNhwTxJNhznOVkYfv+C0+LRnTIBstMDA0ftg2sKpbcq0tUvhctJ3Zlw029gvG4NbHcmJPBapAgTydM7fTUf7HjfYjY52YHSB8TUx97q+Vgv8NWpz8n/cpED1Hm6hGIQdq/HqNWkVCCOlANHstFkW58cz/+AkSG47If8WEwCe9F+T8DbomrfolFoJHg46J1IasWwNlnndyytrtV8e0LFJUreAZY40iYU6NAL/YSmdtu+S2BqrQiCv26Anp2ov+xU0Zk7Ct23XG3UglptOmSyrHStMQlFsH21MFhx4TVDAWpXlfzcOmt7K00M7no7Jw52ic7pztUZANX8K7bML4Vo1mkxJI8JtRek4oYR7661LXxwRivmjpqagI+z/zzbWB7mPtt1zAa9tn71evOGhh9lcUoG95eOPM4WsWen6QlWA95pTOmLvtHyxyi/1+CPWGxPf5115joWSRtpzfWG+vIUsEIjP4eq+9hdPU+6DTbQn6NTAQeC48NTjDiVux5 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:(13230028)(4636009)(346002)(39860400002)(366004)(136003)(376002)(396003)(451199021)(2906002)(83380400001)(36756003)(26005)(6512007)(6506007)(478600001)(54906003)(110136005)(107886003)(6486002)(6666004)(8936002)(7416002)(7406005)(5660300002)(2616005)(41300700001)(66946007)(66556008)(4326008)(66476007)(8676002)(186003)(316002)(38100700002)(921005)(86362001)(4216001);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Fm5guM/jQCYXfnb4Ib6epEV52+co2E+brZeKoCkU+Kju7c32GffilVlcWx6h9GtmONjGdDLB3/vKW1tn4/0p6Kd9LS9P65lDVqfmKtrYonGbmAWPh7il+98bxa9sUDI5/xYVozKaWTyYObiSK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it6y6ICAZzekoS9QI4fgMSUIIwhGyD/1R41CU2ttcUo7mbztLYLPYWqqtz/Wqh2tilpIkWZLbNA2qu6tcQWx7+qmEWeQ78s6hxxaql42+XI9+PpdS340LYn4qsRmJ5MLF0iZDGJFcsMq8y/9JN0SrHMnPrEzCBexA9sSJk3BeX/ahObNWcae2XkhdPkLHOvIk1PYAgMHFg9qUN7yZvnjuV4fYFIvafjfiAxmAX3YZO/CcJT3e5X8sllYRNyrFrEKeEVBIaF2p68IOQSfA6IV9su7VcSvyQHzFqCMSrnxAOgGjkGag3i9WZGX4ZNUPM7VgjDDzbfI44rw+Zwh/u9gkSSfVDrz6gnxSB1EfzXxId3Le46eGw+DF9oVYVz X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8c88ff9f-9d05-4f32-8017-08db69239808 X-MS-Exchange-CrossTenant-AuthSource: LV2PR12MB5869.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 09 Jun 2023 19:56:20.1257 (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: JwPPtq3DYZl0SFNSqWiUrp7gprT6EUjAh7aikFMAQCYhvy6uPH1bweqRjLlnQCMz X-MS-Exchange-Transport-CrossTenantHeadersStamped: DM4PR12MB5264 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20230609_125638_685013_29BC8BA2 X-CRM114-Status: GOOD ( 14.35 ) X-BeenThere: linux-rockchip@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Upstream kernel work for Rockchip platforms List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Linux-rockchip" Errors-To: linux-rockchip-bounces+linux-rockchip=archiver.kernel.org@lists.infradead.org The PLATFORM domain will be set as the default domain and attached as normal during probe. The driver will ignore the initial attach from a NULL domain to the PLATFORM domain. After this, the PLATFORM domain's attach_dev will be called whenever we detach from an UNMANAGED domain (eg for VFIO). This is the same time the original design would have called op->detach_dev(). This is temporary until the S390 dma-iommu.c conversion is merged. Tested-by: Heiko Stuebner Tested-by: Niklas Schnelle Signed-off-by: Jason Gunthorpe --- drivers/iommu/s390-iommu.c | 21 +++++++++++++++++++-- 1 file changed, 19 insertions(+), 2 deletions(-) diff --git a/drivers/iommu/s390-iommu.c b/drivers/iommu/s390-iommu.c index fbf59a8db29b11..f0c867c57a5b9b 100644 --- a/drivers/iommu/s390-iommu.c +++ b/drivers/iommu/s390-iommu.c @@ -142,14 +142,31 @@ static int s390_iommu_attach_device(struct iommu_domain *domain, return 0; } -static void s390_iommu_set_platform_dma(struct device *dev) +/* + * Switch control over the IOMMU to S390's internal dma_api ops + */ +static int s390_iommu_platform_attach(struct iommu_domain *platform_domain, + struct device *dev) { struct zpci_dev *zdev = to_zpci_dev(dev); + if (!zdev->s390_domain) + return 0; + __s390_iommu_detach_device(zdev); zpci_dma_init_device(zdev); + return 0; } +static struct iommu_domain_ops s390_iommu_platform_ops = { + .attach_dev = s390_iommu_platform_attach, +}; + +static struct iommu_domain s390_iommu_platform_domain = { + .type = IOMMU_DOMAIN_PLATFORM, + .ops = &s390_iommu_platform_ops, +}; + static void s390_iommu_get_resv_regions(struct device *dev, struct list_head *list) { @@ -428,12 +445,12 @@ void zpci_destroy_iommu(struct zpci_dev *zdev) } static const struct iommu_ops s390_iommu_ops = { + .default_domain = &s390_iommu_platform_domain, .capable = s390_iommu_capable, .domain_alloc = s390_domain_alloc, .probe_device = s390_iommu_probe_device, .release_device = s390_iommu_release_device, .device_group = generic_device_group, - .set_platform_dma_ops = s390_iommu_set_platform_dma, .pgsize_bitmap = SZ_4K, .get_resv_regions = s390_iommu_get_resv_regions, .default_domain_ops = &(const struct iommu_domain_ops) {