From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5FEC821ABA2 for ; Fri, 18 Jul 2025 21:41:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752874920; cv=none; b=ZLLW5c8vhoyxFRvMi6GvzfJtSlknHPah8v3lAQIoYjA7TQyg/nzKSlF6jfVizlYD/V04O92LMhT0Dz7bTzFZX0vjxOTAtXAtGDbzINKjIFyOy3fcePBVEbUQCR0ozjL4fKYGBWxlO5nd5pktAlETTMQxDC9DI+pqHEuUId1MJJw= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1752874920; c=relaxed/simple; bh=uxXpdkcHdOrQaJc+eu4/GeOXinhx7hO5tirp5wkNhw8=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=l/YCNEKww0qkCUqW9BGO8DjhPxTh25cT22xbG30tmO2i0mHOaY7BUv9zHqYo2M+OKwbA6fGmr7IhopHWnhCkW4Dhnf20VyYQYU3tSAPTOK53CipvRY37XrkaQCvRLdfuFnb6Qb92/NJCNG+gZxRx0kj6aZ7C0j3AWYC5fYY9gek= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=fFQmP15Y; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="fFQmP15Y" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1752874917; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=Pl8HYJY2kuf3xc5dYY1A2bTJiaSaxCFVikVVLsHu9SQ=; b=fFQmP15YyTrp1cdeW0nLiL00F+p3DdbGFiCHVD3AbSFPhfco1jCO3sNPlHo07/yd9bDgF8 /tCTYzlEscDwzewuHAbC/j/YB8u/h96gc+LhKHQ0bozc/ZGVBakT1MtdYcAntzyKQHnATT YIheDeCctZ5eOni7Dnhnnbn2R0gxMCQ= Received: from mail-pl1-f200.google.com (mail-pl1-f200.google.com [209.85.214.200]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-182-k-iTEOiMNSSrj5hMww0Z-g-1; Fri, 18 Jul 2025 17:41:55 -0400 X-MC-Unique: k-iTEOiMNSSrj5hMww0Z-g-1 X-Mimecast-MFC-AGG-ID: k-iTEOiMNSSrj5hMww0Z-g_1752874914 Received: by mail-pl1-f200.google.com with SMTP id d9443c01a7336-2355651d204so22363645ad.2 for ; Fri, 18 Jul 2025 14:41:55 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1752874914; x=1753479714; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=Pl8HYJY2kuf3xc5dYY1A2bTJiaSaxCFVikVVLsHu9SQ=; b=LtMEmm6TE3YHUCu93pnvwzeInq6TqgJo7Hd8XMb6MXCujdyjI/ba18WK2tpxOkdLKf VqOO0J9LW33v4bgbcRbyjnzAkfA9dKwUqD5RnfKKL7ogg2hfIRSeBzpVcICleHWDY0H9 WbwrbEkBiG2zfDfL0fXE7A6mY5WwIQPxoJuXIlMNk90M6AqNYHBAHDJ33b7x30hni5Af 5GoYYWYwEbDplFeswS/IWDdwEm6JFiM66WYsyAcNLFgOMp2MgwG9wksAfc9dm9mCrfSi 7CNw2ZAuqY1aFj7Wu6JVwuue7Rg5EYPX035MSiLsN6fakf6m67P++AMAh2y06imxId6+ CFsA== X-Forwarded-Encrypted: i=1; AJvYcCUUiqsWu98isx5Sqw/kq2RpllnupeSI6JVXXSj6C/yhBbYuMuLn9Epd3gbmETQWbEQvEfo4/Q==@lists.linux.dev X-Gm-Message-State: AOJu0YwVcGVwPa6QgdJEGI7N9FWgVBG2JDzsLIX+CHJ1eB1lTxan/rcw 0M4V62w7x0RAeFGEKCH0qO4CqdJoWWbaMrI+GP1pmEeYeTLs/jNzZrb7SoKjTWKbFwSxGUyudtq J+hDs3ZHOVenekjb2v3uSPRCIuQkcZpytdlq4sS5vcirr4ebcMe+xfrgl X-Gm-Gg: ASbGnctvWdYE5xbaW8LNM90vq5X/DwPKrddAIjSaFVLHxUa6lq9tLWXf7ihODWaeWpR LREsno9176D69MUcMHhGjiXHn179TeFi79iL+HwlN0plZlT3BzCUjjhcPoDHgO2Gz3SlLkin8VV dSO0E206HX2hKMf6dZcNTWwPh4r6UNGZIobhQJC9yUUXLFlqTqyDfwVQibquq7DH3GzS2Oi2sHB u4QjpvyPZoUL4tLfC+lD8RuGZRjfFzSPMxDTKEIuuMJN1WephYkm76+4MBM69t4DViHiRFmysqF 5NMUpgQ9R0/EDUyJ5YbAeGerZhiKt6t/UIhrvws2 X-Received: by 2002:a17:902:ef02:b0:234:9656:7db9 with SMTP id d9443c01a7336-23e24f4ae0emr193121265ad.32.1752874914364; Fri, 18 Jul 2025 14:41:54 -0700 (PDT) X-Google-Smtp-Source: AGHT+IElJIwNy/gAl1oOb5k7nEBq38Uon8tJbJo/3EEmGz51w51P0ZBbNDEpVhWKCJJ33lSWOle8bg== X-Received: by 2002:a17:902:ef02:b0:234:9656:7db9 with SMTP id d9443c01a7336-23e24f4ae0emr193120855ad.32.1752874913939; Fri, 18 Jul 2025 14:41:53 -0700 (PDT) Received: from [192.168.40.164] ([70.105.235.240]) by smtp.gmail.com with ESMTPSA id d9443c01a7336-23e3b6b4b20sm18055975ad.121.2025.07.18.14.41.48 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Fri, 18 Jul 2025 14:41:53 -0700 (PDT) Message-ID: <1cda6f16-fb56-450e-8d33-b775f57ae949@redhat.com> Date: Fri, 18 Jul 2025 17:41:47 -0400 Precedence: bulk X-Mailing-List: iommu@lists.linux.dev List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 User-Agent: Mozilla Thunderbird Subject: Re: [PATCH v2 03/16] iommu: Compute iommu_groups properly for PCIe switches To: Jason Gunthorpe Cc: Bjorn Helgaas , iommu@lists.linux.dev, Joerg Roedel , linux-pci@vger.kernel.org, Robin Murphy , Will Deacon , Alex Williamson , Lu Baolu , galshalom@nvidia.com, Joerg Roedel , Kevin Tian , kvm@vger.kernel.org, maorg@nvidia.com, patches@lists.linux.dev, tdave@nvidia.com, Tony Zhu References: <3-v2-4a9b9c983431+10e2-pcie_switch_groups_jgg@nvidia.com> <5b1f12e0-9113-41c4-accb-d8ab755cc7d7@redhat.com> <20250718180947.GB2394663@nvidia.com> <1b47ede0-bd64-46b4-a24f-4b01bbdd9710@redhat.com> <20250718201953.GI2250220@nvidia.com> From: Donald Dutile In-Reply-To: <20250718201953.GI2250220@nvidia.com> X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: isMwEQfCA1-M_u-nJe7sT6QckGBO42pAvDpfzwmYOGA_1752874914 X-Mimecast-Originator: redhat.com Content-Language: en-US Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit On 7/18/25 4:19 PM, Jason Gunthorpe wrote: > On Fri, Jul 18, 2025 at 03:00:28PM -0400, Donald Dutile wrote: >>>>> + /* >>>>> + * !self is only for SRIOV virtual busses which should have been >>>>> + * excluded above. >>>> by pci_is_root_bus() ?? -- that checks if bus->parent exists... >>>> not sure how that excludes the case of !bus->self ... >>> >>> Should be this: >>> >>> /* >>> * !self is only for SRIOV virtual busses which should have been >>> * excluded by pci_physfn() >>> */ >>> if (WARN_ON(!bus->self)) >>> >> my Linux tree says its this: >> static inline bool pci_is_root_bus(struct pci_bus *pbus) >> { >> return !(pbus->parent); >> } >> >> is there a change to pci_is_root_bus() in a -next branch? > > Not that, at the start of the function there is a pci_physfn(), the > entire function never works on a VF, so bus is never a VF's bus. > Well, i guess it depends on what you call 'a VF's bus' -- it returns the VF's->PF(pdev)->bus if virt-fn, which I would call the VF's bus. thanks for pointing further up... now I get your added edit above (which I didn't read carefully, /my bad). >>>>> + */ >>>>> + if (WARN_ON(!bus->self)) >>>>> + return ERR_PTR(-EINVAL); >>>>> + >>>>> + group = iommu_group_get(&bus->self->dev); >>>>> + if (!group) { >>>>> + /* >>>>> + * If the upstream bridge needs the same group as pdev then >>>>> + * there is no way for it's pci_device_group() to discover it. >>>>> + */ >>>>> + dev_err(&pdev->dev, >>>>> + "PCI device is probing out of order, upstream bridge device of %s is not probed yet\n", >>>>> + pci_name(bus->self)); >>>>> + return ERR_PTR(-EPROBE_DEFER); >>>>> + } >>>>> + if (group->bus_data & BUS_DATA_PCI_NON_ISOLATED) >>>>> + return group; >>>>> + iommu_group_put(group); >>>>> + return NULL; >>>> ... and w/o the function description, I don't follow: >>>> -- rtn an iommu-group if it has NON_ISOLATED property ... but rtn null if all devices below it are isolated? >>> >>> Yes. For all these internal functions non null means we found a group >>> to join, NULL means to keep checking isolation rules. >>> >> ah, so !group == keep looking for for non-isolated conditions.. got it. >> Could that lead to two iommu-groups being created that could/should be one larger one? > > The insistence on doing things in order should prevent that from > happening. So long as the larger group is present in the upstream > direction, or within the current bus, then it can be joined up. > > This doesn't work if it randomly applies to PCI devices, it is why the > above has added the "PCI device is probing out of order" detection. > ok, will keep that concept in mind when reviewing. > Jason >