Received: by 2002:a25:23cc:0:0:0:0:0 with SMTP id j195csp177512ybj; Fri, 8 May 2020 09:08:35 -0700 (PDT) X-Google-Smtp-Source: APiQypJpx0FRZvDYDawBBvkkrr98bJJ0olBjuNlFawra34bYjwv6xQR3wY1zDINyYUjSDA+uL6D/ X-Received: by 2002:a17:906:81d7:: with SMTP id e23mr2271203ejx.309.1588954115730; Fri, 08 May 2020 09:08:35 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1588954115; cv=none; d=google.com; s=arc-20160816; b=cb5R3CcldzrKmE5XorOq/nTcIwjYOIZCJTl5cC/86FrDnWCVaqvyObl5e3VHj3ro7h 4NazurDMVXr1f3YfLsKs1N6xmSXSefVrNuWsnFFUoZ6Js+qg/3rwChQXf6e3ydYKIqIw 9kAoPbPK3LI/2QmoXI0lZ42Rq9+s/NEqmG+rgJfk4afmR7RHj9k2aU9j5RNtwUt6TRbS xUJa9QlKtR2OC72xMFS48qpcbqHu9cp0oMbXEu/tRceBOb3d0tzAuirNewMyTNVoN1Mr d7JBZiT31tLTNhOMLzyIJxyfFuWH1Yt2qBimRzWNgBV7Bj2TI+IL5vNsCGjghRYVyZpt oyBQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:content-disposition :mime-version:message-id:subject:cc:to:from:date:dkim-signature; bh=q4ZTy+6tWRlfg+IoUGvDTDXQ3Cuppl9aW6VHfSn11jg=; b=PYW++PZ1POfjkDLgw9ySM0vLhXwKxJQKnOKT5wbKIGHwV7UhgRUB/CtBXcRWdwKhCE lMwjUevj8qbg+Fvi/4WMe/x+8UxLWN2GaLN9zXNqjo7zxy4aHhkLUZ5J3qjGEpjYN2Hr d8Eodfg7GFU0R9Rf4Q81/Q2YsNRa93bGS9h14yLdvAKjMyr1OeKFmKPae6y4P0Ym2ROB uH9uIqtjrBR66B5Jc5hc2QAHHPPPvcD6ziMTMLQJ+3GS/xjmtIGKGG+f5qgk+NhhvN9i uhVtVzIFLzSy9kBppeKhu2cWya1bARFEZ3cp797m0qIZqnhVwzSo2bx/cL+0HrsUQZmY AOMQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vfa8MaGs; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id q7si1149971ejz.377.2020.05.08.09.07.53; Fri, 08 May 2020 09:08:35 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@kernel.org header.s=default header.b=Vfa8MaGs; spf=pass (google.com: domain of linux-wireless-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-wireless-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726891AbgEHQHP (ORCPT + 99 others); Fri, 8 May 2020 12:07:15 -0400 Received: from mail.kernel.org ([198.145.29.99]:34220 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726736AbgEHQHO (ORCPT ); Fri, 8 May 2020 12:07:14 -0400 Received: from localhost (mobile-166-175-190-200.mycingular.net [166.175.190.200]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by mail.kernel.org (Postfix) with ESMTPSA id 1B65320725; Fri, 8 May 2020 16:07:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=default; t=1588954034; bh=uLbNyI7Z14KTi1E6slPZdT0e6uxwRWlOOk93NDOTbTw=; h=Date:From:To:Cc:Subject:In-Reply-To:From; b=Vfa8MaGsNoJhb0kFwm2qNcSKwyhZThyTfoj8OtYgR5/qX5J6CxRIiqYMRCRBVWsml l6ivXOBTIIOpt8oYE0DgNaIp8Ng16ySnyuA5sw1RH290pvqmH7B6JcYrCqGZTgANTw EENa4s8urGyc9CgQR0pyspVhBFyx/tjagHOr1xSo= Date: Fri, 8 May 2020 11:07:12 -0500 From: Bjorn Helgaas To: Yicong Yang Cc: linux-pci@vger.kernel.org, kvalo@codeaurora.org, andreas.noever@gmail.com, rjw@rjwysocki.net, linux-wireless@vger.kernel.org, linux-usb@vger.kernel.org, mika.westerberg@linux.intel.com, linuxarm@huawei.com Subject: Re: [PATCH v2] PCI: Use pci_pcie_find_root_port() to get root port Message-ID: <20200508160712.GA75354@bjorn-Precision-5520> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3a5ccd55-5aac-ef16-6402-75dfaeaee6bf@hisilicon.com> Sender: linux-wireless-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-wireless@vger.kernel.org On Fri, May 08, 2020 at 08:40:49PM +0800, Yicong Yang wrote: > On 2020/5/7 3:48, Bjorn Helgaas wrote: > > On Wed, May 06, 2020 at 08:42:56PM +0800, Yicong Yang wrote: > >> { > >> - while (1) { > >> - if (!pci_is_pcie(dev)) > >> - break; > >> + dev = pci_physfn(dev); > >> + while (dev) { > >> if (pci_pcie_type(dev) == PCI_EXP_TYPE_ROOT_PORT) > >> return dev; > >> - if (!dev->bus->self) > >> - break; > >> dev = dev->bus->self; > > Why not use pci_upstream_bridge() here? > > We'll judge whether the device is virtual or not every time we call > pci_upstream_bridge(). I think it's unnecessary and we only need to get > the physical function at the beginning of the traverse. It's okay to > use pci_upstream_bridge() here if you suggest so. I think we should use pci_upstream_bridge() consistently. Using two different patterns is confusing and error-prone. Bjorn