Received: by 2002:a05:7412:a9a2:b0:e2:908c:2ebd with SMTP id o34csp944056rdh; Thu, 26 Oct 2023 23:15:56 -0700 (PDT) X-Google-Smtp-Source: AGHT+IG/HetEZblsgS4NHF2Q2nil7EAJ3f2M7XCrYV9r6uqFoQ67gJxZOZ10M8wKCfFMu9Hwe7It X-Received: by 2002:a05:6808:1451:b0:3a7:2d4c:5d4e with SMTP id x17-20020a056808145100b003a72d4c5d4emr1882748oiv.7.1698387355907; Thu, 26 Oct 2023 23:15:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698387355; cv=none; d=google.com; s=arc-20160816; b=r2bPOyifEFW7InU3Yjjx7cGlIquI6a0cF/pqFXdx4bo7HKxkY3KXJlCRwfSklf87C5 kiJBTD9qYEvq6mLH6PUnIG6YlAOlglfMJhBGz/dinJ4gsUirT4qzCpVMb2QFiOQRjQ/u RUMMLOLzww2E5dVZ2v+/6g7/OfroqoEVC2jFDX7pE2O2J22Gy9dd53MD77E8eazn9i8g l0oKJeZSfPDMICjvj4dbxGBfahsuJVCEWMDOcXdpi+BGhcoqutY5nhr0TDE25b5AcCV8 QLCmkgN7cM3aAvLsts1kShtrrtSIyBHFe9pA8EaUPW1UDPSUW9FXn3lamVOeVXziuAEE TRSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:references:in-reply-to:message-id :subject:cc:to:from:date:dkim-signature; bh=dZAEgQquByxTyOWNG5sJpM+ib6iTynmtMRqYF46g4FY=; fh=zBCc/qqWAUryCnSof31iC/NE3oM9BcsYgXg/ZHh1pEc=; b=ePWR1BKamQmtx4KHlC5qR4B1PyqrGkQwoqAHhNcbPFW5N7WmFkXnH3qIb1SqVyCldt RCgn17qMUtLgVFqcSnyElTP1BYsvREIf/lesx7dcF/OU5s/u6gTCVft2h+wmM6mTirui hcE6SnvTWASdCNeiMknjzL7CpZItA6/p0ixZT420msjySAlXDEw0v9tNz7U8M0eNsYgu OwQC352fe04WwsNv9Bcd2OAAyvpRgox7AdovcVoJzUpgawLEMH/kvPbxLAhlPxxziCFK t8Ym1Kuu9Pl0TEmvT18XhzAdHOO1fgTdCAlVvTeY4q4NZuxx1qzPK58Vk4gX7oxeIsWS Tkfg== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@canb.auug.org.au header.s=201702 header.b=YOt7DT+8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canb.auug.org.au Return-Path: Received: from agentk.vger.email (agentk.vger.email. [2620:137:e000::3:2]) by mx.google.com with ESMTPS id 83-20020a251856000000b00da04292553fsi1466982yby.78.2023.10.26.23.15.51 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 26 Oct 2023 23:15:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) client-ip=2620:137:e000::3:2; Authentication-Results: mx.google.com; dkim=pass header.i=@canb.auug.org.au header.s=201702 header.b=YOt7DT+8; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::3:2 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canb.auug.org.au Received: from out1.vger.email (depot.vger.email [IPv6:2620:137:e000::3:0]) by agentk.vger.email (Postfix) with ESMTP id AB8A681E5E78; Thu, 26 Oct 2023 23:15:41 -0700 (PDT) X-Virus-Status: Clean X-Virus-Scanned: clamav-milter 0.103.10 at agentk.vger.email Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1345144AbjJ0GPb (ORCPT + 99 others); Fri, 27 Oct 2023 02:15:31 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:56854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229590AbjJ0GPa (ORCPT ); Fri, 27 Oct 2023 02:15:30 -0400 Received: from gandalf.ozlabs.org (gandalf.ozlabs.org [150.107.74.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5778C1BF; Thu, 26 Oct 2023 23:15:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canb.auug.org.au; s=201702; t=1698387325; bh=dZAEgQquByxTyOWNG5sJpM+ib6iTynmtMRqYF46g4FY=; h=Date:From:To:Cc:Subject:In-Reply-To:References:From; b=YOt7DT+8snrICRHOztXrDyLyZ2C1zHZbsig+BqJ5sbmjCuFpVHUkO34fqIiTLIQgN 39HZpxUjcjcsdE9IjmEuRj1IEKmmNmTF52qX0J4brD5L9zlmn5Jx1d28+na0iiDwiR /CCwhPOIZxxLS5T4TerVugYoFtT5Riu1FCQwDiKVdvdUhsKQF8i6fyK6EQDxQN8m0P +hsfgLIbnnb/HAI0jyHniQKpZIpI6YNYcEGmPJbPgxwEeJ01+PuMNAn1UXZMExr5VL ip2/rcGN6BV2UwRx+3TJv5olosl4xQn7RjF3cf/CSXyWjfT4vBEOQXcT9nwHESt8SJ xXFzLOtc109BQ== Received: from authenticated.ozlabs.org (localhost [127.0.0.1]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by mail.ozlabs.org (Postfix) with ESMTPSA id 4SGspg5Qqwz4xF1; Fri, 27 Oct 2023 17:15:23 +1100 (AEDT) Date: Fri, 27 Oct 2023 17:15:22 +1100 From: Stephen Rothwell To: Jason Gunthorpe , Joerg Roedel Cc: Jason Gunthorpe , Joao Martins , Joerg Roedel , Linux Kernel Mailing List , Linux Next Mailing List , Nicolin Chen , Yi Liu Subject: Re: linux-next: manual merge of the iommufd tree with the iommu tree Message-ID: <20231027171522.692a58ec@canb.auug.org.au> In-Reply-To: <20231027155522.6b2863a4@canb.auug.org.au> References: <20231027155522.6b2863a4@canb.auug.org.au> MIME-Version: 1.0 Content-Type: multipart/signed; boundary="Sig_/xmJMZm=NjYI=7llw3LNgUlE"; protocol="application/pgp-signature"; micalg=pgp-sha256 X-Spam-Status: No, score=-0.8 required=5.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU,HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS autolearn=unavailable autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on agentk.vger.email Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-Greylist: Sender passed SPF test, not delayed by milter-greylist-4.6.4 (agentk.vger.email [0.0.0.0]); Thu, 26 Oct 2023 23:15:41 -0700 (PDT) --Sig_/xmJMZm=NjYI=7llw3LNgUlE Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: quoted-printable Hi all, On Fri, 27 Oct 2023 15:55:22 +1100 Stephen Rothwell = wrote: > > Today's linux-next merge of the iommufd tree got a conflict in: >=20 > drivers/iommu/iommufd/selftest.c >=20 > between commits: >=20 > 1c68cbc64fe6 ("iommu: Add IOMMU_DOMAIN_PLATFORM") > 13fbceb1b8e9 ("iommufd: Convert to alloc_domain_paging()") >=20 > from the iommu tree and commits: >=20 > 408663619fcf ("iommufd/selftest: Add domain_alloc_user() support in iom= mu mock") > 266ce58989ba ("iommufd/selftest: Test IOMMU_HWPT_ALLOC_DIRTY_TRACKING") > 7adf267d66d1 ("iommufd/selftest: Test IOMMU_HWPT_SET_DIRTY_TRACKING") > a9af47e382a4 ("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP") > 0795b305da89 ("iommufd/selftest: Test IOMMU_HWPT_GET_DIRTY_BITMAP_NO_CL= EAR flag") > 65fe32f7a447 ("iommufd/selftest: Add nested domain allocation for mock = domain") >=20 > from the iommufd tree. >=20 > I fixed it up (see below) and can carry the fix as necessary. This > is now fixed as far as linux-next is concerned, but any non trivial > conflicts should be mentioned to your upstream maintainer when your tree > is submitted for merging. You may also want to consider cooperating > with the maintainer of the conflicting tree to minimise any particularly > complex conflicts. The resolution should have been as below (I think). --=20 Cheers, Stephen Rothwell diff --cc drivers/iommu/iommufd/selftest.c index ee6079847091,6684ab4cdc7a..7d28ff9a278e --- a/drivers/iommu/iommufd/selftest.c +++ b/drivers/iommu/iommufd/selftest.c @@@ -155,6 -244,80 +239,76 @@@ __mock_domain_alloc_paging(unsigned in return &mock->domain; } =20 + static struct iommu_domain * + __mock_domain_alloc_nested(struct mock_iommu_domain *mock_parent, + const struct iommu_hwpt_selftest *user_cfg) + { + struct mock_iommu_domain_nested *mock_nested; + int i; +=20 + mock_nested =3D kzalloc(sizeof(*mock_nested), GFP_KERNEL); + if (!mock_nested) + return ERR_PTR(-ENOMEM); + mock_nested->parent =3D mock_parent; + mock_nested->domain.ops =3D &domain_nested_ops; + mock_nested->domain.type =3D IOMMU_DOMAIN_NESTED; + for (i =3D 0; i < MOCK_NESTED_DOMAIN_IOTLB_NUM; i++) + mock_nested->iotlb[i] =3D user_cfg->iotlb; + return &mock_nested->domain; + } +=20 -static struct iommu_domain *mock_domain_alloc(unsigned int iommu_domain_t= ype) ++static struct iommu_domain *mock_domain_alloc_paging(struct device *dev) + { + struct iommu_domain *domain; +=20 - if (iommu_domain_type =3D=3D IOMMU_DOMAIN_BLOCKED) - return &mock_blocking_domain; - if (iommu_domain_type !=3D IOMMU_DOMAIN_UNMANAGED) - return NULL; - domain =3D __mock_domain_alloc_paging(iommu_domain_type, false); ++ domain =3D __mock_domain_alloc_paging(IOMMU_DOMAIN_UNMANAGED, false); + if (IS_ERR(domain)) + domain =3D NULL; + return domain; + } +=20 + static struct iommu_domain * + mock_domain_alloc_user(struct device *dev, u32 flags, + struct iommu_domain *parent, + const struct iommu_user_data *user_data) + { + struct mock_iommu_domain *mock_parent; + struct iommu_hwpt_selftest user_cfg; + int rc; +=20 + /* must be mock_domain */ + if (!parent) { + struct mock_dev *mdev =3D container_of(dev, struct mock_dev, dev); + bool has_dirty_flag =3D flags & IOMMU_HWPT_ALLOC_DIRTY_TRACKING; + bool no_dirty_ops =3D mdev->flags & MOCK_FLAGS_DEVICE_NO_DIRTY; +=20 + if (flags & (~(IOMMU_HWPT_ALLOC_NEST_PARENT | + IOMMU_HWPT_ALLOC_DIRTY_TRACKING))) + return ERR_PTR(-EOPNOTSUPP); + if (user_data || (has_dirty_flag && no_dirty_ops)) + return ERR_PTR(-EOPNOTSUPP); + return __mock_domain_alloc_paging(IOMMU_DOMAIN_UNMANAGED, + has_dirty_flag); + } +=20 + /* must be mock_domain_nested */ + if (user_data->type !=3D IOMMU_HWPT_DATA_SELFTEST || flags) + return ERR_PTR(-EOPNOTSUPP); + if (!parent || parent->ops !=3D mock_ops.default_domain_ops) + return ERR_PTR(-EINVAL); +=20 + mock_parent =3D container_of(parent, struct mock_iommu_domain, domain); + if (!mock_parent) + return ERR_PTR(-EINVAL); +=20 + rc =3D iommu_copy_struct_from_user(&user_cfg, user_data, + IOMMU_HWPT_DATA_SELFTEST, iotlb); + if (rc) + return ERR_PTR(rc); +=20 + return __mock_domain_alloc_nested(mock_parent, &user_cfg); + } +=20 static void mock_domain_free(struct iommu_domain *domain) { struct mock_iommu_domain *mock =3D @@@ -272,9 -435,28 +426,20 @@@ static phys_addr_t mock_domain_iova_to_ =20 static bool mock_domain_capable(struct device *dev, enum iommu_cap cap) { - return cap =3D=3D IOMMU_CAP_CACHE_COHERENCY; + struct mock_dev *mdev =3D container_of(dev, struct mock_dev, dev); +=20 + switch (cap) { + case IOMMU_CAP_CACHE_COHERENCY: + return true; + case IOMMU_CAP_DIRTY_TRACKING: + return !(mdev->flags & MOCK_FLAGS_DEVICE_NO_DIRTY); + default: + break; + } +=20 + return false; } =20 -static void mock_domain_set_plaform_dma_ops(struct device *dev) -{ - /* - * mock doesn't setup default domains because we can't hook into the - * normal probe path - */ -} - static struct iommu_device mock_iommu_device =3D { }; =20 @@@ -293,8 -469,10 +458,9 @@@ static const struct iommu_ops mock_ops=20 .owner =3D THIS_MODULE, .pgsize_bitmap =3D MOCK_IO_PAGE_SIZE, .hw_info =3D mock_domain_hw_info, - .domain_alloc =3D mock_domain_alloc, + .domain_alloc_paging =3D mock_domain_alloc_paging, + .domain_alloc_user =3D mock_domain_alloc_user, .capable =3D mock_domain_capable, - .set_platform_dma_ops =3D mock_domain_set_plaform_dma_ops, .device_group =3D generic_device_group, .probe_device =3D mock_probe_device, .default_domain_ops =3D --Sig_/xmJMZm=NjYI=7llw3LNgUlE Content-Type: application/pgp-signature Content-Description: OpenPGP digital signature -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEENIC96giZ81tWdLgKAVBC80lX0GwFAmU7VXoACgkQAVBC80lX 0GwOugf/ffvG/EFF57tZ4seguiZ2JKWC0e9HYiQI21tn0dxx4Ikj9Hg1r/jLSLIz 0weOrycXXb3I9VTsjdUmHTMtWhOzcgg4iWDv9S/cUzbMMdCcf/dta+8dtbRG+zVA CEakmQWI8j7tyrpL7tsSbTB33StaTaodiLLTGYS0SatqkoDB1g3nKp6eoFXeNCgP opVc6TKsqJezGhBbiCZplBthBCxGCLqo3oysli8wCY9+7rvLXnKO4z5H/QbfDvQl vW01uflRAqTIwV1L/cfE/fJ2XcMti3HWn0QDhoSIKVu8SQET51UfQ8n0aQBDfoRB Q9pXFsjskq/Z2+rmS8EfE6YtbNcoDg== =/xQM -----END PGP SIGNATURE----- --Sig_/xmJMZm=NjYI=7llw3LNgUlE--