Received: by 2002:a05:6a10:16a7:0:0:0:0 with SMTP id gp39csp506489pxb; Wed, 18 Nov 2020 09:52:39 -0800 (PST) X-Google-Smtp-Source: ABdhPJyS1nAK9elVQLYthB3iqLlFUVg0X2GhPSfMyydAdwwLqDlsAeHgsXxUtQUTJULhopyzFiUg X-Received: by 2002:a17:906:5c43:: with SMTP id c3mr26971583ejr.390.1605721959176; Wed, 18 Nov 2020 09:52:39 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1605721959; cv=none; d=google.com; s=arc-20160816; b=LscRIJRAs977+iUdp/ToTnHoGMnKrEOTzxy+NA7q9ErMkXqj2vwTXxGRC4JsPkWnJ6 xYTdmG/JdNfeOSNHh7F+WgDJtIoGxyv3qzI0dAcmZiFmggg2GlKuS+2V35SeJyUQbESK EtN308ioxYfhf51wiWFfY/8AMOOA8aBeACoJF/UkTxVfHgWGx+9XHBFzyliM/Bo1dGMB 84M3y1LisCRJ4yLx/32FN2n54tRBsaWpYe5EH0OUdlm5FPYrfguKu4TlxYjRgCqEvcUU te56tfI59V9XjhUXi8yV0Vo53sOAa7WRXEV+aj/FqwMrrwm4NU5GJC93lSN1gLNKUnFb 6EMw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:user-agent:references:message-id :in-reply-to:subject:cc:to:from:date:ironport-sdr:ironport-sdr; bh=lmXEa/0q6DQT9C+qgiuq4GRcnp7VvoIMfn+hxMH4TfU=; b=EvxnlCVvdLVzsI2iKggV221qZ0c2Lr4PqLZ3nQssOlchiake/rnQFYYpgjiglzbWoa mZLe4rwT9niitbzkrv+G3/yFhqbgRU+SlEFb9mPOv8aiU4PlHx3MfAa/5RLf7abKyeDN g1Bpa5UAd9rBcLQEyWet5TSW98Krex1U4LtZNQVlrVC0CIdAMi9nK/cX2JfdS2iMXeJ2 C6wB1qAXmd9zDpdmXAXroLzvr2SxvlrQ3YbfA/EUY46WKh+A1UE4pN6I7af4qAbzqvQL UNuGx+kj3PiEbNGHJGII+bflFvu4FMPOlDJzjW3+B1gRdfPtM7kxHyUaDrj3GLEr9xLE cyfg== 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 r8si16911523edm.62.2020.11.18.09.52.16; Wed, 18 Nov 2020 09:52:39 -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 S1727754AbgKRRsq (ORCPT + 99 others); Wed, 18 Nov 2020 12:48:46 -0500 Received: from mga14.intel.com ([192.55.52.115]:63212 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726547AbgKRRsp (ORCPT ); Wed, 18 Nov 2020 12:48:45 -0500 IronPort-SDR: Z09j0oN4DuxJZ3uo9MxXQ9e890e15O2tlhyi2TqU+0EnpfGT8DSrz/2oanXmT5lIw7RF+EK8ru x6GnS6sT0kkQ== X-IronPort-AV: E=McAfee;i="6000,8403,9809"; a="170374318" X-IronPort-AV: E=Sophos;i="5.77,488,1596524400"; d="scan'208";a="170374318" X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga005.jf.intel.com ([10.7.209.41]) by fmsmga103.fm.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2020 09:48:44 -0800 IronPort-SDR: 75b4MMWvGFm/tIxeLpMDnHiz3+HVFR2GHiMxm9Izlvywo2dylZuzEwjvMK/LamwEQpFeJ2Kx+c XXO+U7Z/5jiA== X-IronPort-AV: E=Sophos;i="5.77,488,1596524400"; d="scan'208";a="544633974" Received: from rhweight-wrk1.ra.intel.com ([137.102.106.140]) by orsmga005-auth.jf.intel.com with ESMTP/TLS/ECDHE-RSA-AES256-GCM-SHA384; 18 Nov 2020 09:48:43 -0800 Date: Wed, 18 Nov 2020 09:49:55 -0800 (PST) From: matthew.gerlach@linux.intel.com X-X-Sender: mgerlach@rhweight-WRK1 To: "Wu, Hao" cc: "linux-fpga@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "mdf@kernel.org" , "trix@redhat.com" , "linux-doc@vger.kernel.org" , "corbet@lwn.net" Subject: RE: [PATCH 2/2] fpga: dfl: look for vendor specific capability In-Reply-To: Message-ID: References: <20201117012552.262149-1-matthew.gerlach@linux.intel.com> <20201117012552.262149-3-matthew.gerlach@linux.intel.com> User-Agent: Alpine 2.22 (DEB 394 2020-01-19) MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII; format=flowed Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Wed, 18 Nov 2020, Wu, Hao wrote: >> On Tue, 17 Nov 2020, Wu, Hao wrote: > > [...] > >>>> Open discussion >>>> =============== >>>> diff --git a/drivers/fpga/dfl-pci.c b/drivers/fpga/dfl-pci.c >>>> index b1b157b41942..5418e8bf2496 100644 >>>> --- a/drivers/fpga/dfl-pci.c >>>> +++ b/drivers/fpga/dfl-pci.c >>>> @@ -27,6 +27,13 @@ >>>> #define DRV_VERSION "0.8" >>>> #define DRV_NAME "dfl-pci" >>>> >>>> +#define PCI_VNDR_ID_DFLS 0x43 >>> >>> What about PCI_VSEC_ID_INTEL_DFLS? >>> >>> Is it possible a different ID chosen by different vendor? >> >> I think another vendor could choose their own ID. > > If another vendor could choose their own ID, so should we > check vendor id as well? Yes, the vendor id should be checked. I will add it to v2. > > [...] > >>>> + for (i = 0; i < dfl_cnt; i++) { >>>> + dfl_res_off = voff + PCI_VNDR_DFLS_RES_OFFSET + >>>> + (i * sizeof(dfl_res)); >>>> + pci_read_config_dword(pcidev, dfl_res_off, &dfl_res); >>>> + >>>> + dev_dbg(&pcidev->dev, "dfl_res 0x%x\n", dfl_res); >>>> + >>>> + bar = dfl_res & PCI_VND_DFLS_RES_BAR_MASK; >>>> + >>>> + if (bar >= PCI_STD_NUM_BARS) { >>>> + dev_err(&pcidev->dev, "%s bad bar number %d\n", >>>> + __func__, bar); >>>> + return -EINVAL; >>>> + } >>>> + >>>> + len = pci_resource_len(pcidev, bar); >>>> + >>> >>> Remove this blank line. >> OK, v2. >> >>> >>>> + if (len == 0) { >>>> + dev_err(&pcidev->dev, "%s unmapped bar >>>> number %d\n", >>> >>> Why "unmapped bar"? >> >> How about, "zero length bar"? > > I think this checking can be covered by below one, right? > if (offset >= len) > ... I agree. I will make the change in v2. > >> >>> >>>> + __func__, bar); >>>> + return -EINVAL; >>>> + } >>>> + >>>> + offset = dfl_res & ~PCI_VND_DFLS_RES_BAR_MASK; >>>> + >>> >>> Remove this blank line. >> >> OK, v2. >> >>> >>>> + if (offset >= len) { >>>> + dev_err(&pcidev->dev, "%s bad offset %u >= %llu\n", >>>> + __func__, offset, len); >>>> + return -EINVAL; >>>> + } >>>> + > > [....] > >>>> + >>>> + start = pci_resource_start(pcidev, bar) + offset; >>>> + len -= offset; >>>> + >>>> + if (!PAGE_ALIGNED(start)) { >>> >>> Is this a hard requirement? Or offset should be page aligned per VSEC >> definition? >>> Or this is just the requirement from driver point of view. Actually we don't >> like >>> to add rules only in driver, so it's better we have this requirement in VSEC >> definition >>> with proper documentation. >> >> The DFL parsing code ioremaps the memory bounded by start/len. I thought >> this would require the start to be page aligned. > > If consider mmap the region to userspace, it requires page aligned, but do we > need to apply this rule for everyone? I will remove this check in v2. > > Thanks > Hao > >