Received: by 2002:a05:6a10:1a4d:0:0:0:0 with SMTP id nk13csp5937139pxb; Mon, 14 Feb 2022 11:08:46 -0800 (PST) X-Google-Smtp-Source: ABdhPJxWXwy1cKrY1U+SoqSb8eV5OGE701o22xOiiu5yQEvGvJn8OCA4U7dVrf/eQAxe4AzadYEk X-Received: by 2002:a63:690a:: with SMTP id e10mr356525pgc.599.1644865726183; Mon, 14 Feb 2022 11:08:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1644865726; cv=none; d=google.com; s=arc-20160816; b=sQdm8EBrtVOdcxu1p3CtsyVSo9aM+IM5WNgJpcqAeDac2Okruh2aIQgfRdxm5obVH9 3U0DJ0/M54zMmjhkNHCfwA+4OrqmBSwSTQqShmKNd/phpr2jbs34MgNEn6gCgeuD0MYX CjAURxXQso35axE4Io0Xzbe6HJQWXqpjS+pXc8fpz1+ixfUQpJ2thEh11FeSeJcP6kfJ I5ZmnnwKXIkkTgffwVOWVr2Y3562iW5aaHWZCvTe7dt8x7oPgtT1Jat6xO/DwLd4ipt8 9V3RubRPlmyjv3cR96iq2pdm57ZeYxFql72wxPu7XXWN4BNWnhnKSqY7w+3E81+LSE+f syCg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date; bh=epESPY/V/1qvNePHuMgzJGit9uJvqle7vTCJrapkWII=; b=wnOogU9BukTDsmMret4i09Q4RZFfjGctzlPKlIB4VcKU/5iMZuIxeXqDrBDQntHRiZ QwkecGA15Y4X8Wd0pqSFtymcXFWs2p39s4nvDV4F3OtaikWqBIXdwVhVZvcpq4d6J5wn +PQ2vmujlOTjHDN/idjGQU31ozrPku2pB5Bnb/I7XrpPyWhFHo4qU/0a+bQ73h4d9KCP 97vwEeDENPrD48tA8vqWce6PLiSMdMaAPzekaIOepLFn7e2+NpzZSXHYPDdgbccUSHtQ 17ImN1gZuOrMY1YEVa9JZklZyDcZ/YOr7SaZpC0U3Nu+kW+5ncvHgiUdBQdEBAtGPOQO sSWA== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id h12si31154575pfh.345.2022.02.14.11.08.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 14 Feb 2022 11:08:46 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=8bytes.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id F276A9285D; Mon, 14 Feb 2022 11:04:46 -0800 (PST) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1354512AbiBNNlK (ORCPT + 99 others); Mon, 14 Feb 2022 08:41:10 -0500 Received: from mxb-00190b01.gslb.pphosted.com ([23.128.96.19]:54580 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S243108AbiBNNlI (ORCPT ); Mon, 14 Feb 2022 08:41:08 -0500 Received: from theia.8bytes.org (8bytes.org [IPv6:2a01:238:4383:600:38bc:a715:4b6d:a889]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 502F9575F4; Mon, 14 Feb 2022 05:41:00 -0800 (PST) Received: by theia.8bytes.org (Postfix, from userid 1000) id 029F02FB; Mon, 14 Feb 2022 14:40:57 +0100 (CET) Date: Mon, 14 Feb 2022 14:40:56 +0100 From: Joerg Roedel To: Jason Gunthorpe Cc: Lu Baolu , Alex Williamson , Robin Murphy , Christoph Hellwig , Kevin Tian , Ashok Raj , Greg Kroah-Hartman , Bjorn Helgaas , Will Deacon , Dan Williams , rafael@kernel.org, Diana Craciun , Cornelia Huck , Eric Auger , Liu Yi L , Jacob jun Pan , Chaitanya Kulkarni , Stuart Yoder , Laurentiu Tudor , Thierry Reding , David Airlie , Daniel Vetter , Jonathan Hunter , Li Yang , Dmitry Osipenko , iommu@lists.linux-foundation.org, linux-pci@vger.kernel.org, kvm@vger.kernel.org, linux-kernel@vger.kernel.org Subject: Re: [PATCH v1 5/8] iommu/amd: Use iommu_attach/detach_device() Message-ID: References: <20220106022053.2406748-1-baolu.lu@linux.intel.com> <20220106022053.2406748-6-baolu.lu@linux.intel.com> <20220106143345.GC2328285@nvidia.com> <20220214131544.GX4160@nvidia.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220214131544.GX4160@nvidia.com> X-Spam-Status: No, score=-1.9 required=5.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE,T_SCC_BODY_TEXT_LINE autolearn=no autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Mon, Feb 14, 2022 at 09:15:44AM -0400, Jason Gunthorpe wrote: > But how does the sound device know that this has been done to it? > > eg how do we know the sound device hasn't been bound to VFIO or > something at this point? The iommu_attach_group() call will fail when the group (which includes GPU and sound device) it not in its default-domain. So if VFIO attached the group to its own domain, there is a failure in this init function. Note that this function is intended to be called by the driver currently controling this device, so there should also be no race with VFIO trying to grab the device in parallel. Regards, Joerg