Received: by 2002:a05:6a10:8c0a:0:0:0:0 with SMTP id go10csp141837pxb; Wed, 3 Feb 2021 01:40:24 -0800 (PST) X-Google-Smtp-Source: ABdhPJySIuYzO3OJXlLtchye8f0Pt14INctm0D0dGh+v16kein9kxkwdD1BgqHQH2OORGtYUQcCK X-Received: by 2002:a17:906:2407:: with SMTP id z7mr2381705eja.219.1612345223803; Wed, 03 Feb 2021 01:40:23 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1612345223; cv=none; d=google.com; s=arc-20160816; b=QK+bsSPR/ITuGeRY6qJuvcm51Ha+ax/nrXIwNHl352jmBKtqt+FzvnSc3sg0w9tyY7 zDgj/5ItB60QlEGBNwvVEGWjPH/VxKQ5b5vnny+3nFWV3mhxY/JdszkLqHZqB33+vsTE MnKtDFrwAKKnVE8pXvSy1IXIPc91gnwRsk6gE7ibek1ufdrDktGg9cfVToHugaj1biB2 /GuGz+qVJ8TM+487oWSlMG0JqvT3yrUl76HDOX9hv2nxosBmXj0xfXo+Zv1xggSs0Oy1 mmOGCRqm/19xACdP6mxjGU+YMHDh6GtKDSasxdnOD4zwnEbE5388S9DDJIM9EgK4fs7T 2wJA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:user-agent:in-reply-to:content-disposition :mime-version:references:message-id:subject:cc:to:from:date; bh=3ssP/Z04xkmfDLbZIBhmx1v5ThcDZeLWeG7MVCKgITY=; b=TEEiIJGWPsnajp/ldp60+nueONNT5EiAbtO6hG08J8khv1kpdm2WT4+V+MTIs7ww4D x0EYcSCa6KM4iw5tkDAxMb6MC9q7SP8/QFVd+MB213IsixFBRUP4pn3gwlZd5159HnnG 7dHhNs5MEScV0ru9kxO+JtW5JGygKLlaiT/oXn6FZbWUrtLLhmharhxg6Ohvbwj9U0g6 Ewm57qH1XV1mfJdid70RCpjglAo/ZXT663hCxcnt4ph+9w2zp5iKvonQoXLCFXU/s5BN 1Uhe9U6ediq+UKV8Bv4mqCR7Hp1s9/0znr25s8ZqE0Mqo/SrXb2YBnaIM5TRbrCAzxk7 iuBQ== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id cy17si848871edb.193.2021.02.03.01.39.59; Wed, 03 Feb 2021 01:40:23 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233401AbhBCJhi (ORCPT + 99 others); Wed, 3 Feb 2021 04:37:38 -0500 Received: from bmailout3.hostsharing.net ([176.9.242.62]:45251 "EHLO bmailout3.hostsharing.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232992AbhBCJhh (ORCPT ); Wed, 3 Feb 2021 04:37:37 -0500 X-Greylist: delayed 6348 seconds by postgrey-1.27 at vger.kernel.org; Wed, 03 Feb 2021 04:37:35 EST Received: from h08.hostsharing.net (h08.hostsharing.net [IPv6:2a01:37:1000::53df:5f1c:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client CN "*.hostsharing.net", Issuer "RapidSSL TLS DV RSA Mixed SHA256 2020 CA-1" (verified OK)) by bmailout3.hostsharing.net (Postfix) with ESMTPS id A6C75100DECA6; Wed, 3 Feb 2021 10:36:54 +0100 (CET) Received: by h08.hostsharing.net (Postfix, from userid 100393) id 699EC5165; Wed, 3 Feb 2021 10:36:54 +0100 (CET) Date: Wed, 3 Feb 2021 10:36:54 +0100 From: Lukas Wunner To: Gustavo Pimentel Cc: "linux-pci@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "dmaengine@vger.kernel.org" , Bjorn Helgaas Subject: Re: [PATCH v2 04/15] PCI: Add pci_find_vsec_capability() to find a specific VSEC Message-ID: <20210203093654.GA14315@wunner.de> References: <2ecb33dfee5dc05efc05de0731b0cb77bc246f54.1612269537.git.gustavo.pimentel@synopsys.com> <20210202180855.GA3571@wunner.de> <20210203075103.GA18742@wunner.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: User-Agent: Mutt/1.10.1 (2018-07-13) Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, Feb 03, 2021 at 09:11:03AM +0000, Gustavo Pimentel wrote: > On Wed, Feb 3, 2021 at 7:51:3, Lukas Wunner wrote: > > On Wed, Feb 03, 2021 at 01:54:49AM +0000, Gustavo Pimentel wrote: > > > On Tue, Feb 2, 2021 at 18:8:55, Lukas Wunner wrote: > > > > As the name implies, the capability is "vendor-specific", so it is > > > > perfectly possible that two vendors use the same VSEC ID for different > > > > things. > > > > > > > > To make sure you're looking for the right capability, you need to pass > > > > a u16 vendor into this function and bail out if dev->vendor is > > > > different. > > > > > > This function will be called by the driver that will pass the correct > > > device which will be already pointing to the config space associated with > > > the endpoint for instance. Because the driver is already attached to the > > > endpoint through the vendor ID and device ID specified, there is no need > > > to do that validation, it will be redundant. > > > > Okay. Please amend the kernel-doc to make it explicit that it's the > > caller's responsibility to check the vendor ID. > > I don't think that would be necessary, as I said, the 'struct pci_dev *' > already points exclusively for the device' config space, which contains > all the capabilities for that particular device by his turn will be > attached to a specific driver by the Vendor and Device IDs to a specific > driver, that will know, firstly search for the specific device vendor ID, > and then secondly how to decode it, and thirdly to do something with it. The helper you're adding may not only be called from drivers but also from generic PCI code (such as set_pcie_thunderbolt()). In that case the vendor ID is arbitrary. Also, it doesn't *hurt* documenting this requirement, does it? Thanks, Lukas