Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit c74c9318 authored by Sudeep Dutt's avatar Sudeep Dutt Committed by Greg Kroah-Hartman
Browse files

misc: mic: MIC host and card driver changes to enable VOP



This patch modifies the MIC host and card drivers to start using the
VOP driver. The MIC host and card drivers now implement the VOP bus
operations and register a VOP device on the VOP bus. MIC driver stack
documentation is also updated to include the new VOP driver.

Reviewed-by: default avatarAshutosh Dixit <ashutosh.dixit@intel.com>
Signed-off-by: default avatarSudeep Dutt <sudeep.dutt@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 8810df37
Loading
Loading
Loading
Loading
+30 −24
Original line number Diff line number Diff line
@@ -12,10 +12,19 @@ for the X100 devices.

Since it is a PCIe card, it does not have the ability to host hardware
devices for networking, storage and console. We provide these devices
on X100 coprocessors thus enabling a self-bootable equivalent environment
for applications. A key benefit of our solution is that it leverages
the standard virtio framework for network, disk and console devices,
though in our case the virtio framework is used across a PCIe bus.
on X100 coprocessors thus enabling a self-bootable equivalent
environment for applications. A key benefit of our solution is that it
leverages the standard virtio framework for network, disk and console
devices, though in our case the virtio framework is used across a PCIe
bus. A Virtio Over PCIe (VOP) driver allows creating user space
backends or devices on the host which are used to probe virtio drivers
for these devices on the MIC card. The existing VRINGH infrastructure
in the kernel is used to access virtio rings from the host. The card
VOP driver allows card virtio drivers to communicate with their user
space backends on the host via a device page. Ring 3 apps on the host
can add, remove and configure virtio devices. A thin MIC specific
virtio_config_ops is implemented which is borrowed heavily from
previous similar implementations in lguest and s390.

MIC PCIe card has a dma controller with 8 channels. These channels are
shared between the host s/w and the card s/w. 0 to 3 are used by host
@@ -38,7 +47,6 @@ single threaded performance for the host compared to MIC, the ability of
the host to initiate DMA's to/from the card using the MIC DMA engine and
the fact that the virtio block storage backend can only be on the host.

                                      |
               +----------+           |             +----------+
               | Card OS  |           |             | Host OS  |
               +----------+           |             +----------+
@@ -47,27 +55,25 @@ the fact that the virtio block storage backend can only be on the host.
        | Virtio| |Virtio  | |Virtio| | |Virtio   |  |Virtio  | |Virtio  |
        | Net   | |Console | |Block | | |Net      |  |Console | |Block   |
        | Driver| |Driver  | |Driver| | |backend  |  |backend | |backend |
        +-------+ +--------+ +------+ | +---------+  +--------+ +--------+
        +---+---+ +---+----+ +--+---+ | +---------+  +----+---+ +--------+
            |         |         |     |      |            |         |
            |         |         |     |User  |            |         |
            |         |         |     |------|------------|---------|-------
            +-------------------+     |Kernel +--------------------------+
                      |               |       | Virtio over PCIe IOCTLs  |
                      |               |       +--------------------------+
+-----------+         |               |                   |  +-----------+
| MIC DMA   |         |      +------+ | +------+ +------+ |  | MIC DMA   |
| Driver    |         |      | SCIF | | | SCIF | | COSM | |  | Driver    |
+-----------+         |      +------+ | +------+ +--+---+ |  +-----------+
      |               |         |     |    |        |     |        |
+---------------+     |      +------+ | +--+---+ +--+---+ | +----------------+
|MIC virtual Bus|     |      |SCIF  | | |SCIF  | | COSM | | |MIC virtual Bus |
+---------------+     |      |HW Bus| | |HW Bus| | Bus  | | +----------------+
      |               |      +------+ | +--+---+ +------+ |              |
      |               |         |     |       |     |     |              |
      |   +-----------+---+     |     |       |    +---------------+     |
            |         |         |     |------|------------|--+------|-------
            +---------+---------+     |Kernel                |
                      |               |                      |
  +---------+     +---+----+ +------+ | +------+ +------+ +--+---+  +-------+
  |MIC DMA  |     |  VOP   | | SCIF | | | SCIF | | COSM | | VOP  |  |MIC DMA|
  +---+-----+     +---+----+ +--+---+ | +--+---+ +--+---+ +------+  +----+--+
      |               |         |     |    |        |                    |
  +---+-----+     +---+----+ +--+---+ | +--+---+ +--+---+ +------+  +----+--+
  |MIC      |     |  VOP   | |SCIF  | | |SCIF  | | COSM | | VOP  |  | MIC   |
  |HW Bus   |     |  HW Bus| |HW Bus| | |HW Bus| | Bus  | |HW Bus|  |HW Bus |
  +---------+     +--------+ +--+---+ | +--+---+ +------+ +------+  +-------+
      |               |         |     |       |     |                    |
      |   +-----------+--+      |     |       |    +---------------+     |
      |   |Intel MIC     |      |     |       |    |Intel MIC      |     |
      +---|Card Driver    |     |     |       |    |Host Driver    |     |
          +------------+--------+     |       +----+---------------+-----+
      |   |Card Driver   |      |     |       |    |Host Driver    |     |
      +---+--------------+------+     |       +----+---------------+-----+
                 |                    |                   |
             +-------------------------------------------------------------+
             |                                                             |
+1 −1
Original line number Diff line number Diff line
@@ -35,7 +35,7 @@

exec=/usr/sbin/mpssd
sysfs="/sys/class/mic"
mic_modules="mic_host mic_x100_dma scif"
mic_modules="mic_host mic_x100_dma scif vop"

start()
{
+1 −1
Original line number Diff line number Diff line
@@ -926,7 +926,7 @@ add_virtio_device(struct mic_info *mic, struct mic_device_desc *dd)
	char path[PATH_MAX];
	int fd, err;

	snprintf(path, PATH_MAX, "/dev/mic%d", mic->id);
	snprintf(path, PATH_MAX, "/dev/vop_virtio%d", mic->id);
	fd = open(path, O_RDWR);
	if (fd < 0) {
		mpsslog("Could not open %s %s\n", path, strerror(errno));
+4 −3
Original line number Diff line number Diff line
@@ -53,8 +53,8 @@ comment "Intel MIC Host Driver"

config INTEL_MIC_HOST
	tristate "Intel MIC Host Driver"
	depends on 64BIT && PCI && X86 && INTEL_MIC_BUS && SCIF_BUS && MIC_COSM
	select VHOST_RING
	depends on 64BIT && PCI && X86
	depends on INTEL_MIC_BUS && SCIF_BUS && MIC_COSM && VOP_BUS
	help
	  This enables Host Driver support for the Intel Many Integrated
	  Core (MIC) family of PCIe form factor coprocessor devices that
@@ -73,7 +73,8 @@ comment "Intel MIC Card Driver"

config INTEL_MIC_CARD
	tristate "Intel MIC Card Driver"
	depends on 64BIT && X86 && INTEL_MIC_BUS && SCIF_BUS && MIC_COSM
	depends on 64BIT && X86
	depends on INTEL_MIC_BUS && SCIF_BUS && MIC_COSM && VOP_BUS
	select VIRTIO
	help
	  This enables card driver support for the Intel Many Integrated
+82 −2
Original line number Diff line number Diff line
@@ -249,12 +249,82 @@ static struct scif_hw_ops scif_hw_ops = {
	.iounmap = ___mic_iounmap,
};

static inline struct mic_driver *vpdev_to_mdrv(struct vop_device *vpdev)
{
	return dev_get_drvdata(vpdev->dev.parent);
}

static struct mic_irq *
__mic_request_irq(struct vop_device *vpdev,
		  irqreturn_t (*func)(int irq, void *data),
		   const char *name, void *data, int intr_src)
{
	return mic_request_card_irq(func, NULL, name, data, intr_src);
}

static void __mic_free_irq(struct vop_device *vpdev,
			   struct mic_irq *cookie, void *data)
{
	return mic_free_card_irq(cookie, data);
}

static void __mic_ack_interrupt(struct vop_device *vpdev, int num)
{
	struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);

	mic_ack_interrupt(&mdrv->mdev);
}

static int __mic_next_db(struct vop_device *vpdev)
{
	return mic_next_card_db();
}

static void __iomem *__mic_get_remote_dp(struct vop_device *vpdev)
{
	struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);

	return mdrv->dp;
}

static void __mic_send_intr(struct vop_device *vpdev, int db)
{
	struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);

	mic_send_intr(&mdrv->mdev, db);
}

static void __iomem *__mic_ioremap(struct vop_device *vpdev,
				   dma_addr_t pa, size_t len)
{
	struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);

	return mic_card_map(&mdrv->mdev, pa, len);
}

static void __mic_iounmap(struct vop_device *vpdev, void __iomem *va)
{
	struct mic_driver *mdrv = vpdev_to_mdrv(vpdev);

	mic_card_unmap(&mdrv->mdev, va);
}

static struct vop_hw_ops vop_hw_ops = {
	.request_irq = __mic_request_irq,
	.free_irq = __mic_free_irq,
	.ack_interrupt = __mic_ack_interrupt,
	.next_db = __mic_next_db,
	.get_remote_dp = __mic_get_remote_dp,
	.send_intr = __mic_send_intr,
	.ioremap = __mic_ioremap,
	.iounmap = __mic_iounmap,
};

static int mic_request_dma_chans(struct mic_driver *mdrv)
{
	dma_cap_mask_t mask;
	struct dma_chan *chan;

	request_module("mic_x100_dma");
	dma_cap_zero(mask);
	dma_cap_set(DMA_MEMCPY, mask);

@@ -308,6 +378,13 @@ int __init mic_driver_init(struct mic_driver *mdrv)
		rc = -ENODEV;
		goto irq_uninit;
	}
	mdrv->vpdev = vop_register_device(mdrv->dev, VOP_DEV_TRNSP,
					  NULL, &vop_hw_ops, 0,
					  NULL, mdrv->dma_ch[0]);
	if (IS_ERR(mdrv->vpdev)) {
		rc = PTR_ERR(mdrv->vpdev);
		goto dma_free;
	}
	bootparam = mdrv->dp;
	node_id = ioread8(&bootparam->node_id);
	mdrv->scdev = scif_register_device(mdrv->dev, MIC_SCIF_DEV,
@@ -317,11 +394,13 @@ int __init mic_driver_init(struct mic_driver *mdrv)
					   mdrv->num_dma_ch, true);
	if (IS_ERR(mdrv->scdev)) {
		rc = PTR_ERR(mdrv->scdev);
		goto dma_free;
		goto vop_remove;
	}
	mic_create_card_debug_dir(mdrv);
done:
	return rc;
vop_remove:
	vop_unregister_device(mdrv->vpdev);
dma_free:
	mic_free_dma_chans(mdrv);
irq_uninit:
@@ -342,6 +421,7 @@ void mic_driver_uninit(struct mic_driver *mdrv)
{
	mic_delete_card_debug_dir(mdrv);
	scif_unregister_device(mdrv->scdev);
	vop_unregister_device(mdrv->vpdev);
	mic_free_dma_chans(mdrv);
	mic_uninit_irq();
	mic_dp_uninit();
Loading