From nobody Sun Apr 13 10:00:57 2025 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4Zb5XV2ptNz5t3PD; Sun, 13 Apr 2025 10:00:58 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (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 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4Zb5XT6ZYJz46Tt; Sun, 13 Apr 2025 10:00:57 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744538458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T/Sh0ZgR6VaFZZHJBPG767cKyuE50AObwtPnBEnHcVw=; b=xK3Nk8lYQyMtIWqStNNmvsx3iCAcxs+h1ztvtDHpFRm7vvFS1W6sD5f+QgP04f2VKI1dxD YDtDwGM5hVWXvVYyKv1ELr/0btjuE9nCiSi9ldU+erDfet0OptnF/e77p3AX4FodFMdf1y CQcWcAJG4upivuEriSFbStb/7rDUu1NYThPHbzsQYup8N1nBw6sTY2kqNhW9J6zxkInaYQ lwHo5BsO78Hnb69IJsgAJcCpAxp29DGQMg+jo+7+4NTUsYE7tZeSD2D0gUlpo1NHB+GulO rHWCPPdxE+dTkGJEc83rKCYCkoivNnIp2v+F6UdITyfgiMEGT7tvYIo0cVkO4A== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1744538458; a=rsa-sha256; cv=none; b=EbS+XM+o3hthhea/B/34IIZ3+sxu86tRMFSXCcRImuQxDzDgRvjC4drc5bgxU+DGSnnHTm YNBj/Z+VlKMvkmLgwk6/Lu7tupLRfegYAAlkRSgVczHTrURrhn8h2CgH84ir3BTa3zsq6x jm7F9ynolqzyzC7aXBPJLjjmtUF3c23QZ79D0BZG7nM4OJ/Z5t7mvS/5FgMXQy5oSGfN7c qVefY+2q3zc7ekLEIebh7SJXlo4adG6oUBltU56zoB8S1JKgV6DApFDR2lqow0X3xhsVJf Q9Pt8JMZxR+i+n308EIYCDah89MPSC7yUA+um86VdLPyew/9HabVKNsGcB/oJg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1744538458; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=T/Sh0ZgR6VaFZZHJBPG767cKyuE50AObwtPnBEnHcVw=; b=eH6Kyzf5UPezTT4Go1UdJBWvFBnsLa0m09kQqqCLMLT5AIc2wEguDuFNLBhVmEwMrgEgiR GQOGGbsXZKZ3cXnrGEKRXRBgpjZwPILEOmadKb0RnFQ6TTaoRT9pNMhERM9RLaA0w+3gDj q7t1YBdoOLMshNVr27gf3dOsn0NOFe5g1+hxzV59VioECmyUlDpiHUpbkgN20dMsoSB7+2 ZamheaYHqqKany0VErAydS+5vKcmt6tBWhi9VZ3kw8uVkyeFJPuvF3eG3y01gTEFgj3Cbg GWVCIDT5xHCYItVlN3Sri8pLjT93ahkhwxf2V1E1e+ZcesrY2uziHOTeeH6Iqg== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (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) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4Zb5XT69VtzyHJ; Sun, 13 Apr 2025 10:00:57 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 53DA0vn7083999; Sun, 13 Apr 2025 10:00:57 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 53DA0vEZ083996; Sun, 13 Apr 2025 10:00:57 GMT (envelope-from git) Date: Sun, 13 Apr 2025 10:00:57 GMT Message-Id: <202504131000.53DA0vEZ083996@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: =?utf-8?Q?Jean-S=C3=A9bastien?= =?utf-8?Q?P=C3=A9dron?= Subject: git: 21b556557e46 - main - linuxkpi: Fix `pci_upstream_bridge()` with DRM devices List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-all@freebsd.org Sender: owner-dev-commits-src-all@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: dumbbell X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 21b556557e464701960c4a8b4dcc062cb3954ddc Auto-Submitted: auto-generated The branch main has been updated by dumbbell: URL: https://cgit.FreeBSD.org/src/commit/?id=21b556557e464701960c4a8b4dcc062cb3954ddc commit 21b556557e464701960c4a8b4dcc062cb3954ddc Author: Jean-Sébastien Pédron AuthorDate: 2025-03-03 23:48:20 +0000 Commit: Jean-Sébastien Pédron CommitDate: 2025-04-13 09:51:13 +0000 linuxkpi: Fix `pci_upstream_bridge()` with DRM devices In the case of DRM drivers, the passed device is a child of `vgapci`. We want to start the lookup from `vgapci`, so the parent of the passed `drmn`. We use the `isdrm` flag to determine if we are in this situation. This fixes an infinite loop with the amdgpu DRM driver that started to use this function in Linux 6.8: `pci_upstream_bridge()` was returning itself and the code in amdgpu was calling it again, hoping to get a device with a vendor that is not "ATI". Reviewed by: bz Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49388 --- sys/compat/linuxkpi/common/include/linux/pci.h | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) diff --git a/sys/compat/linuxkpi/common/include/linux/pci.h b/sys/compat/linuxkpi/common/include/linux/pci.h index afd6c827b3b4..e4e8e5c0abd1 100644 --- a/sys/compat/linuxkpi/common/include/linux/pci.h +++ b/sys/compat/linuxkpi/common/include/linux/pci.h @@ -523,7 +523,20 @@ pci_upstream_bridge(struct pci_dev *pdev) if (pdev == pdev->bus->self) { device_t bridge; - bridge = device_get_parent(pdev->dev.bsddev); + /* + * In the case of DRM drivers, the passed device is a child of + * `vgapci`. We want to start the lookup from `vgapci`, so the + * parent of the passed `drmn`. + * + * We can use the `isdrm` flag to determine this. + */ + bridge = pdev->dev.bsddev; + if (pdev->pdrv != NULL && pdev->pdrv->isdrm) + bridge = device_get_parent(bridge); + if (bridge == NULL) + goto done; + + bridge = device_get_parent(bridge); if (bridge == NULL) goto done; bridge = device_get_parent(bridge);