Received: by 2002:a05:6a10:8395:0:0:0:0 with SMTP id n21csp7732pxh; Tue, 9 Nov 2021 19:56:05 -0800 (PST) X-Google-Smtp-Source: ABdhPJxR20Fgh4KmFLh6Du8KTBlRItmwaR2xw0zI+zFvBZUATmLcMABRXHhkjuEVFtKARbOJtaBx X-Received: by 2002:a05:6602:1645:: with SMTP id y5mr8556242iow.35.1636516565485; Tue, 09 Nov 2021 19:56:05 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1636516565; cv=none; d=google.com; s=arc-20160816; b=UO4sizQBjQLslJpvkGf9ZEiBT/1KgL90ZgdurdSxxhulK0dvipZHD1rpaYo8Aog2Tx 45r1Bwe+EwE+ggtTCEEFdFXsud++MGlCVIMOQwlFw3yumWb+Bx9D+7PUN7DwezpjyRrr aLQjFAGeDMhitBych3zNlcQNx0XNptUl0aiGHirX1YrL9GQdcajQ5GkOYCPDpV6MHy8w g24KKqVi9DNymSfd/eW4WY6JPiPzqsJGrDbboB6ZBvlosx80L1vVgh1K1lQotxMigMN+ 5niDltDQSRjBUP/6xZQVW3s5lRdYNm58eTmpb02H+6KQ94Qy4oEUq6nJlHwKUhAVltms lx3A== 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=eWgNXMfo5J+SEKJw6Pi/goq96ix3H4B/TLiesB8zgbY=; b=IqAf3/VZxPg5ALzfucpYAjvjg9bAT3RP3WNiUQYnxZyUlmiSw+uu7gleWdyjKwSFZ+ vJF5Ly06W0hpZrgvmzCfeSCpenPbHi+3yu5DJnK1zJTtmGmVLd+yTgcU4qFD6+R5NV7n 7VCGhpRVZBQKynHi0oVWnNzmgaqmoaKKuJBfgJ3iaq4a0sFrafUJ/7vA2F1CGRz0RP8t HTyYBCB0JE0J+e8T1gnpyNh1NxF29hU2xVlP303Cr0VN2dznFli9vpeyj+EeEwPbr/Cw MhuQPW6DxfL8Yjy3je8iBlV6FssQ3uMPoODf0dgBiJjP08G85W7hxtH8Nv4QCsXZmH5O 4dbA== 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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id l14si44517294ilv.14.2021.11.09.19.55.51; Tue, 09 Nov 2021 19:56:05 -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; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=intel.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S230222AbhKJDyk (ORCPT + 99 others); Tue, 9 Nov 2021 22:54:40 -0500 Received: from mga04.intel.com ([192.55.52.120]:42692 "EHLO mga04.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229963AbhKJDyj (ORCPT ); Tue, 9 Nov 2021 22:54:39 -0500 X-IronPort-AV: E=McAfee;i="6200,9189,10163"; a="231319822" X-IronPort-AV: E=Sophos;i="5.87,222,1631602800"; d="scan'208";a="231319822" Received: from orsmga004.jf.intel.com ([10.7.209.38]) by fmsmga104.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 09 Nov 2021 19:51:52 -0800 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.87,222,1631602800"; d="scan'208";a="602061612" Received: from yilunxu-optiplex-7050.sh.intel.com (HELO localhost) ([10.239.159.68]) by orsmga004.jf.intel.com with ESMTP; 09 Nov 2021 19:51:49 -0800 Date: Wed, 10 Nov 2021 11:44:57 +0800 From: Xu Yilun To: matthew.gerlach@linux.intel.com Cc: Tom Rix , Andy Shevchenko , Moritz Fischer , linux-fpga@vger.kernel.org, linux-kernel@vger.kernel.org, Wu Hao Subject: Re: [PATCH v1 1/1] fpga: dfl: pci: Use pci_find_vsec_capability() when looking for DFL Message-ID: <20211110034457.GA286728@yilunxu-OptiPlex-7050> References: <20211109154127.18455-1-andriy.shevchenko@linux.intel.com> <8ccc133a-fb47-4548-fee3-d57775a5166d@redhat.com> <39ac1f40-66ab-6c7e-0042-8fcdc062ed00@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Nov 09, 2021 at 10:51:33AM -0800, matthew.gerlach@linux.intel.com wrote: > > > On Tue, 9 Nov 2021, Tom Rix wrote: > > > > > On 11/9/21 10:05 AM, Andy Shevchenko wrote: > > > On Tue, Nov 09, 2021 at 07:55:43AM -0800, Tom Rix wrote: > > > > On 11/9/21 7:41 AM, Andy Shevchenko wrote: > > > > > Currently the find_dfls_by_vsec() opens code pci_find_vsec_capability(). > > > > > Refactor the former to use the latter. No functional change intended. > > > Thanks for review, my answers below. > > > > > > ... > > > > > > > > + u16 voff; > > > > The later use of voff in pci_read_config_dword is of type 'int', it may be > > > > better to keep voff as an int. > > > I don't think so. The rule of thumb that the types should match the > > > value they > > > got in the first place. In this case it's u16. Compiler will > > > implicitly cast it > > > to whatever is needed as long as the type is good for integer promotion. > > > > > I think u16 is more precise than int, but I think it'll get promoted to an > int anywhen when used with calls to pci_read_config_dword(). Was this I agree u16 is OK. A minor concern, is it better we also change the dfl_res_off to u16? dfl_res_off & voff are the same type of variables needed on positioning the DFL, so I'd like them listed together. > change tested on real or emulated HW? > > > > ... > > > > > > > > + voff = pci_find_vsec_capability(dev, PCI_VENDOR_ID_INTEL, > > > > > PCI_VSEC_ID_INTEL_DFLS); > > > > This may be a weakness in the origin code, but intel isn't the exclusive > > > > user of DFL. > > > This does not change the original code. If you think so, this can be > > > extended > > > later on. > > > > I would rather see this fixed now or explained why this isn't a problem. > > I agree that a single Vendor/VSEC id being supported is a problem, but I > think fixing it should be a separate patch. Do we need to change this a I agree. The vendor_id should be checked before VSEC ID is meaningful, and now this Vendor/VSEC pair is the only supported one, so this piece of code is good to me. > table lookup of Vendor/VSEC id's, or do we need to reserve a more generic > Vendor/VSEC pair? A generic Vendor/VSEC pair means all vendors must use the unified vendor_id if they want to use DFL. I'm not sure if this is proper. Thanks, Yilun > > > > > Tom > > > > > > > > > > if (!voff) { > > > > > dev_dbg(&pcidev->dev, "%s no DFL VSEC found\n", __func__); > > > > > return -ENODEV; > > > >