Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 343292
b: refs/heads/master
c: f9726bf
h: refs/heads/master
v: v3
  • Loading branch information
Daniel J Blueman authored and Bjorn Helgaas committed Dec 7, 2012
1 parent 9a1ca1f commit 01400c2
Show file tree
Hide file tree
Showing 47 changed files with 480 additions and 1,059 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 27e1c8ee0170e80f6426c35d54f3b5cd9dadb25b
refs/heads/master: f9726bfd4b14401d294207a70c7c0c4be8a8c6cc
34 changes: 0 additions & 34 deletions trunk/Documentation/ABI/testing/sysfs-bus-pci
Original file line number Diff line number Diff line change
Expand Up @@ -222,37 +222,3 @@ Description:
satisfied too. Reading this attribute will show the current
value of d3cold_allowed bit. Writing this attribute will set
the value of d3cold_allowed bit.

What: /sys/bus/pci/devices/.../sriov_totalvfs
Date: November 2012
Contact: Donald Dutile <ddutile@redhat.com>
Description:
This file appears when a physical PCIe device supports SR-IOV.
Userspace applications can read this file to determine the
maximum number of Virtual Functions (VFs) a PCIe physical
function (PF) can support. Typically, this is the value reported
in the PF's SR-IOV extended capability structure's TotalVFs
element. Drivers have the ability at probe time to reduce the
value read from this file via the pci_sriov_set_totalvfs()
function.

What: /sys/bus/pci/devices/.../sriov_numvfs
Date: November 2012
Contact: Donald Dutile <ddutile@redhat.com>
Description:
This file appears when a physical PCIe device supports SR-IOV.
Userspace applications can read and write to this file to
determine and control the enablement or disablement of Virtual
Functions (VFs) on the physical function (PF). A read of this
file will return the number of VFs that are enabled on this PF.
A number written to this file will enable the specified
number of VFs. A userspace application would typically read the
file and check that the value is zero, and then write the number
of VFs that should be enabled on the PF; the value written
should be less than or equal to the value in the sriov_totalvfs
file. A userspace application wanting to disable the VFs would
write a zero to this file. The core ensures that valid values
are written to this file, and returns errors when values are not
valid. For example, writing a 2 to this file when sriov_numvfs
is not 0 and not 2 already will return an error. Writing a 10
when the value of sriov_totalvfs is 8 will return an error.
48 changes: 4 additions & 44 deletions trunk/Documentation/PCI/pci-iov-howto.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
Copyright (C) 2009 Intel Corporation
Yu Zhao <yu.zhao@intel.com>

Update: November 2012
-- sysfs-based SRIOV enable-/disable-ment
Donald Dutile <ddutile@redhat.com>

1. Overview

Expand All @@ -27,21 +24,10 @@ real existing PCI device.

2.1 How can I enable SR-IOV capability

Multiple methods are available for SR-IOV enablement.
In the first method, the device driver (PF driver) will control the
enabling and disabling of the capability via API provided by SR-IOV core.
If the hardware has SR-IOV capability, loading its PF driver would
enable it and all VFs associated with the PF. Some PF drivers require
a module parameter to be set to determine the number of VFs to enable.
In the second method, a write to the sysfs file sriov_numvfs will
enable and disable the VFs associated with a PCIe PF. This method
enables per-PF, VF enable/disable values versus the first method,
which applies to all PFs of the same device. Additionally, the
PCI SRIOV core support ensures that enable/disable operations are
valid to reduce duplication in multiple drivers for the same
checks, e.g., check numvfs == 0 if enabling VFs, ensure
numvfs <= totalvfs.
The second method is the recommended method for new/future VF devices.
The device driver (PF driver) will control the enabling and disabling
of the capability via API provided by SR-IOV core. If the hardware
has SR-IOV capability, loading its PF driver would enable it and all
VFs associated with the PF.

2.2 How can I use the Virtual Functions

Expand All @@ -54,22 +40,13 @@ requires device driver that is same as a normal PCI device's.
3.1 SR-IOV API

To enable SR-IOV capability:
(a) For the first method, in the driver:
int pci_enable_sriov(struct pci_dev *dev, int nr_virtfn);
'nr_virtfn' is number of VFs to be enabled.
(b) For the second method, from sysfs:
echo 'nr_virtfn' > \
/sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs

To disable SR-IOV capability:
(a) For the first method, in the driver:
void pci_disable_sriov(struct pci_dev *dev);
(b) For the second method, from sysfs:
echo 0 > \
/sys/bus/pci/devices/<DOMAIN:BUS:DEVICE.FUNCTION>/sriov_numvfs

To notify SR-IOV core of Virtual Function Migration:
(a) In the driver:
irqreturn_t pci_sriov_migration(struct pci_dev *dev);

3.2 Usage example
Expand Down Expand Up @@ -111,22 +88,6 @@ static void dev_shutdown(struct pci_dev *dev)
...
}

static int dev_sriov_configure(struct pci_dev *dev, int numvfs)
{
if (numvfs > 0) {
...
pci_enable_sriov(dev, numvfs);
...
return numvfs;
}
if (numvfs == 0) {
....
pci_disable_sriov(dev);
...
return 0;
}
}

static struct pci_driver dev_driver = {
.name = "SR-IOV Physical Function driver",
.id_table = dev_id_table,
Expand All @@ -135,5 +96,4 @@ static struct pci_driver dev_driver = {
.suspend = dev_suspend,
.resume = dev_resume,
.shutdown = dev_shutdown,
.sriov_configure = dev_sriov_configure,
};
1 change: 1 addition & 0 deletions trunk/arch/x86/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -374,6 +374,7 @@ config X86_NUMACHIP
depends on NUMA
depends on SMP
depends on X86_X2APIC
depends on PCI_MMCONFIG
---help---
Adds support for Numascale NumaChip large-SMP systems. Needed to
enable more than ~168 cores.
Expand Down
118 changes: 0 additions & 118 deletions trunk/arch/x86/boot/compressed/eboot.c
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
* ----------------------------------------------------------------------- */

#include <linux/efi.h>
#include <linux/pci.h>
#include <asm/efi.h>
#include <asm/setup.h>
#include <asm/desc.h>
Expand Down Expand Up @@ -244,121 +243,6 @@ static void find_bits(unsigned long mask, u8 *pos, u8 *size)
*size = len;
}

static efi_status_t setup_efi_pci(struct boot_params *params)
{
efi_pci_io_protocol *pci;
efi_status_t status;
void **pci_handle;
efi_guid_t pci_proto = EFI_PCI_IO_PROTOCOL_GUID;
unsigned long nr_pci, size = 0;
int i;
struct setup_data *data;

data = (struct setup_data *)params->hdr.setup_data;

while (data && data->next)
data = (struct setup_data *)data->next;

status = efi_call_phys5(sys_table->boottime->locate_handle,
EFI_LOCATE_BY_PROTOCOL, &pci_proto,
NULL, &size, pci_handle);

if (status == EFI_BUFFER_TOO_SMALL) {
status = efi_call_phys3(sys_table->boottime->allocate_pool,
EFI_LOADER_DATA, size, &pci_handle);

if (status != EFI_SUCCESS)
return status;

status = efi_call_phys5(sys_table->boottime->locate_handle,
EFI_LOCATE_BY_PROTOCOL, &pci_proto,
NULL, &size, pci_handle);
}

if (status != EFI_SUCCESS)
goto free_handle;

nr_pci = size / sizeof(void *);
for (i = 0; i < nr_pci; i++) {
void *h = pci_handle[i];
uint64_t attributes;
struct pci_setup_rom *rom;

status = efi_call_phys3(sys_table->boottime->handle_protocol,
h, &pci_proto, &pci);

if (status != EFI_SUCCESS)
continue;

if (!pci)
continue;

status = efi_call_phys4(pci->attributes, pci,
EfiPciIoAttributeOperationGet, 0,
&attributes);

if (status != EFI_SUCCESS)
continue;

if (!attributes & EFI_PCI_IO_ATTRIBUTE_EMBEDDED_ROM)
continue;

if (!pci->romimage || !pci->romsize)
continue;

size = pci->romsize + sizeof(*rom);

status = efi_call_phys3(sys_table->boottime->allocate_pool,
EFI_LOADER_DATA, size, &rom);

if (status != EFI_SUCCESS)
continue;

rom->data.type = SETUP_PCI;
rom->data.len = size - sizeof(struct setup_data);
rom->data.next = 0;
rom->pcilen = pci->romsize;

status = efi_call_phys5(pci->pci.read, pci,
EfiPciIoWidthUint16, PCI_VENDOR_ID,
1, &(rom->vendor));

if (status != EFI_SUCCESS)
goto free_struct;

status = efi_call_phys5(pci->pci.read, pci,
EfiPciIoWidthUint16, PCI_DEVICE_ID,
1, &(rom->devid));

if (status != EFI_SUCCESS)
goto free_struct;

status = efi_call_phys5(pci->get_location, pci,
&(rom->segment), &(rom->bus),
&(rom->device), &(rom->function));

if (status != EFI_SUCCESS)
goto free_struct;

memcpy(rom->romdata, pci->romimage, pci->romsize);

if (data)
data->next = (uint64_t)rom;
else
params->hdr.setup_data = (uint64_t)rom;

data = (struct setup_data *)rom;

continue;
free_struct:
efi_call_phys1(sys_table->boottime->free_pool, rom);
}

free_handle:
efi_call_phys1(sys_table->boottime->free_pool, pci_handle);
return status;
}

/*
* See if we have Graphics Output Protocol
*/
Expand Down Expand Up @@ -1142,8 +1026,6 @@ struct boot_params *efi_main(void *handle, efi_system_table_t *_table,

setup_graphics(boot_params);

setup_efi_pci(boot_params);

status = efi_call_phys3(sys_table->boottime->allocate_pool,
EFI_LOADER_DATA, sizeof(*gdt),
(void **)&gdt);
Expand Down
1 change: 0 additions & 1 deletion trunk/arch/x86/include/asm/bootparam.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
#define SETUP_NONE 0
#define SETUP_E820_EXT 1
#define SETUP_DTB 2
#define SETUP_PCI 3

/* extensible setup data list node */
struct setup_data {
Expand Down
19 changes: 19 additions & 0 deletions trunk/arch/x86/include/asm/numachip/numachip.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* This file is subject to the terms and conditions of the GNU General Public
* License. See the file "COPYING" in the main directory of this archive
* for more details.
*
* Numascale NumaConnect-specific header file
*
* Copyright (C) 2012 Numascale AS. All rights reserved.
*
* Send feedback to <support@numascale.com>
*
*/

#ifndef _ASM_X86_NUMACHIP_NUMACHIP_H
#define _ASM_X86_NUMACHIP_NUMACHIP_H

extern int __init pci_numachip_init(void);

#endif /* _ASM_X86_NUMACHIP_NUMACHIP_H */
12 changes: 0 additions & 12 deletions trunk/arch/x86/include/asm/pci.h
Original file line number Diff line number Diff line change
Expand Up @@ -171,16 +171,4 @@ cpumask_of_pcibus(const struct pci_bus *bus)
}
#endif

struct pci_setup_rom {
struct setup_data data;
uint16_t vendor;
uint16_t devid;
uint64_t pcilen;
unsigned long segment;
unsigned long bus;
unsigned long device;
unsigned long function;
uint8_t romdata[0];
};

#endif /* _ASM_X86_PCI_H */
2 changes: 2 additions & 0 deletions trunk/arch/x86/kernel/apic/apic_numachip.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
#include <linux/hardirq.h>
#include <linux/delay.h>

#include <asm/numachip/numachip.h>
#include <asm/numachip/numachip_csr.h>
#include <asm/smp.h>
#include <asm/apic.h>
Expand Down Expand Up @@ -179,6 +180,7 @@ static int __init numachip_system_init(void)
return 0;

x86_cpuinit.fixup_cpu_id = fixup_cpu_id;
x86_init.pci.arch_init = pci_numachip_init;

map_csrs();

Expand Down
4 changes: 4 additions & 0 deletions trunk/arch/x86/kernel/setup.c
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,11 @@ int default_check_phys_apicid_present(int phys_apicid)
}
#endif

#ifndef CONFIG_DEBUG_BOOT_PARAMS
struct boot_params __initdata boot_params;
#else
struct boot_params boot_params;
#endif

/*
* Machine setup..
Expand Down
1 change: 1 addition & 0 deletions trunk/arch/x86/pci/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ obj-$(CONFIG_STA2X11) += sta2x11-fixup.o
obj-$(CONFIG_X86_VISWS) += visws.o

obj-$(CONFIG_X86_NUMAQ) += numaq_32.o
obj-$(CONFIG_X86_NUMACHIP) += numachip.o

obj-$(CONFIG_X86_INTEL_MID) += mrst.o

Expand Down
Loading

0 comments on commit 01400c2

Please sign in to comment.