Received: by 2002:ac0:a5b6:0:0:0:0:0 with SMTP id m51-v6csp155756imm; Wed, 30 May 2018 20:21:16 -0700 (PDT) X-Google-Smtp-Source: ADUXVKJgDc2+3FdRwIi5MHa1CkrIU6ZY8FdA4+wbYvJUgg6cZVZNRZlF3RyQn1Pi3LWERiPJ6Erx X-Received: by 2002:a17:902:6a89:: with SMTP id n9-v6mr5297958plk.41.1527736876280; Wed, 30 May 2018 20:21:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1527736876; cv=none; d=google.com; s=arc-20160816; b=IUBGGbHipTqtSk7p+U4r3y+xRpV7OEQvG9M0hoNt1u0HHx45HWcpTbW1Xznewo3GJL rq68zfWnuwWIGytX3ygSDWee7CO22xnCKw3vLnGgpOyXloEwuaSV+8PNS5fyBPsaM7Io 4ssBMv1B9FfN5/d6ta94nAktTsZc2/mJj4+8j02KLhQLRzQAADJjEr80vNSwzN3YBv33 ByVB8rXWcba7t4TKGbwc8hMDbwAk5/rVFouhsQqxBbEtQfqE1XP9ZZHG4RY4FeaG/QLz IoeEe0nRe/5SeDgDqvo1D4pOKLwCjTwQBm6S1m46YGSHtCkv5pE/m8IZpWMYUcI9seQc K1pw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date:arc-authentication-results; bh=3El0tJOWVQSJpy81zuvqVFIk1v4lEOSV/HgcKeQnH38=; b=iZpBg+gAwBYAzikNiJmsd186yj/40l7K74llBu+wwMHMWLwF8seTfPGbAP779Pkx9L hoipA+eexltr5Eleh0jukO+qiQQHSNpz7dE16vbGU62JriWXBZJkhKT1ekgY7qtCZ+oY WQplVrDxdCa4eRla1zTMKmkBQlad3JwDC5LiJvI/Ut7ZSdTWGsO/w1nBp/WCLpHg2bcw n3F/B6gtHrraBj1bUh644qzzJgxhAWS3Bak4DDl/T/HWjNZDdKYEv0y99iIhg7+CWdkd pU0eZSu7dAWj/c/eQ7NupyXrtnSh18g+6YgI18kL/jfTlQY8HV3zG1I18TCwNxhNZBlP Q77w== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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. [209.132.180.67]) by mx.google.com with ESMTP id 5-v6si10208535pgb.430.2018.05.30.20.21.02; Wed, 30 May 2018 20:21:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 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 S932696AbeEaDUg (ORCPT + 99 others); Wed, 30 May 2018 23:20:36 -0400 Received: from mga14.intel.com ([192.55.52.115]:31205 "EHLO mga14.intel.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S932637AbeEaDUf (ORCPT ); Wed, 30 May 2018 23:20:35 -0400 X-Amp-Result: UNKNOWN X-Amp-Original-Verdict: FILE UNKNOWN X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga103.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 May 2018 20:20:34 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.49,462,1520924400"; d="scan'208";a="45580590" Received: from debian.sh.intel.com (HELO debian) ([10.67.104.203]) by orsmga008.jf.intel.com with ESMTP; 30 May 2018 20:20:32 -0700 Date: Thu, 31 May 2018 11:20:49 +0800 From: Tiwei Bie To: "Duyck, Alexander H" , "Rustad, Mark D" Cc: "mst@redhat.com" , "linux-kernel@vger.kernel.org" , "virtualization@lists.linux-foundation.org" , "virtio-dev@lists.oasis-open.org" , "Daly, Dan" , "linux-pci@vger.kernel.org" , "bhelgaas@google.com" , "Liang, Cunming" , "Wang, Zhihong" Subject: Re: [PATCH] virtio_pci: support enabling VFs Message-ID: <20180531032049.GB15516@debian> References: <20180530085521.26583-1-tiwei.bie@intel.com> <20180530192010-mutt-send-email-mst@kernel.org> <414C18B1-30FA-4AC0-B47D-F0FBF9832737@intel.com> <1527699273.29907.2.camel@intel.com> <5063D90B-7955-4F1E-85A2-D8AFD661ACB7@intel.com> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline In-Reply-To: <5063D90B-7955-4F1E-85A2-D8AFD661ACB7@intel.com> User-Agent: Mutt/1.9.5 (2018-04-13) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Thu, May 31, 2018 at 01:11:37AM +0800, Rustad, Mark D wrote: > On May 30, 2018, at 9:54 AM, Duyck, Alexander H > wrote: > > > On Wed, 2018-05-30 at 09:44 -0700, Rustad, Mark D wrote: > > > On May 30, 2018, at 9:22 AM, Michael S. Tsirkin wrote: > > > > > > > > +static int virtio_pci_sriov_configure(struct pci_dev *pci_dev, int > > > > > num_vfs) > > > > > +{ > > > > > + struct virtio_pci_device *vp_dev = pci_get_drvdata(pci_dev); > > > > > + struct virtio_device *vdev = &vp_dev->vdev; > > > > > + int (*sriov_configure)(struct pci_dev *pci_dev, int num_vfs); > > > > > + > > > > > + if (!(vdev->config->get_status(vdev) & VIRTIO_CONFIG_S_DRIVER_OK)) > > > > > + return -EBUSY; > > > > > + > > > > > + if (!__virtio_test_bit(vdev, VIRTIO_F_SR_IOV)) > > > > > + return -EINVAL; > > > > > + > > > > > + sriov_configure = pci_sriov_configure_simple; > > > > > + if (sriov_configure == NULL) > > > > > + return -ENOENT; > > > > > > > > BTW what is all this trickery in aid of? > > > > > > When SR-IOV support is not compiled into the kernel, > > > pci_sriov_configure_simple is #defined as NULL. This allows it to compile > > > in that case, even though there is utterly no way for it to be called in > > > that case. It is an alternative to #ifs in the code. > > > > Why even have the call though? I would wrap all of this in an #ifdef > > and strip it out since you couldn't support SR-IOV if it isn't present > > in the kernel anyway. > > I am inclined to agree. In this case, the presence of #ifdefs I think would > be clearer. As written, someone will want to get rid of the pointer only to > create a build problem when SR-IOV is not configured. In my opinion, maybe it would be better to make pci_sriov_configure_simple() always available just like other sriov functions. Based on the comments in the original patch: https://patchwork.kernel.org/patch/10353197/ """ +/* this is expected to be used as a function pointer, just define as NULL */ +#define pci_sriov_configure_simple NULL """ This function could be defined as NULL just because it was expected to be used as a function pointer. But actually it could be called directly as a function, just like this case. So I prefer to make this function always available just like other sriov functions. Best regards, Tiwei Bie