mirror of
https://github.com/armbian/linux-cix.git
synced 2026-01-06 12:30:45 -08:00
misc: mic: remove the MIC drivers
This patch removes the MIC drivers from the kernel tree since the corresponding devices have been discontinued. Removing the dma and char-misc changes in one patch and merging via the char-misc tree is best to avoid any potential build breakage. Cc: Nikhil Rao <nikhil.rao@intel.com> Reviewed-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Sudeep Dutt <sudeep.dutt@intel.com> Acked-By: Vinod Koul <vkoul@kernel.org> Reviewed-by: Sherry Sun <sherry.sun@nxp.com> Link: https://lore.kernel.org/r/8c1443136563de34699d2c084df478181c205db4.1603854416.git.sudeep.dutt@intel.com Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
committed by
Greg Kroah-Hartman
parent
3650b228f8
commit
80ade22c06
@@ -1,16 +0,0 @@
|
||||
=============================================
|
||||
Intel Many Integrated Core (MIC) architecture
|
||||
=============================================
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
mic_overview
|
||||
scif_overview
|
||||
|
||||
.. only:: subproject and html
|
||||
|
||||
Indices
|
||||
=======
|
||||
|
||||
* :ref:`genindex`
|
||||
@@ -1,85 +0,0 @@
|
||||
======================================================
|
||||
Intel Many Integrated Core (MIC) architecture overview
|
||||
======================================================
|
||||
|
||||
An Intel MIC X100 device is a PCIe form factor add-in coprocessor
|
||||
card based on the Intel Many Integrated Core (MIC) architecture
|
||||
that runs a Linux OS. It is a PCIe endpoint in a platform and therefore
|
||||
implements the three required standard address spaces i.e. configuration,
|
||||
memory and I/O. The host OS loads a device driver as is typical for
|
||||
PCIe devices. The card itself runs a bootstrap after reset that
|
||||
transfers control to the card OS downloaded from the host driver. The
|
||||
host driver supports OSPM suspend and resume operations. It shuts down
|
||||
the card during suspend and reboots the card OS during resume.
|
||||
The card OS as shipped by Intel is a Linux kernel with modifications
|
||||
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. 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
|
||||
and 4 to 7 by card. As the dma device doesn't show up as PCIe device,
|
||||
a virtual bus called mic bus is created and virtual dma devices are
|
||||
created on it by the host/card drivers. On host the channels are private
|
||||
and used only by the host driver to transfer data for the virtio devices.
|
||||
|
||||
The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a
|
||||
low level communications API across PCIe currently implemented for MIC.
|
||||
More details are available at scif_overview.txt.
|
||||
|
||||
The Coprocessor State Management (COSM) driver on the host allows for
|
||||
boot, shutdown and reset of Intel MIC devices. It communicates with a COSM
|
||||
"client" driver on the MIC cards over SCIF to perform these functions.
|
||||
|
||||
Here is a block diagram of the various components described above. The
|
||||
virtio backends are situated on the host rather than the card given better
|
||||
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 |
|
||||
+----------+ | +----------+
|
||||
|
|
||||
+-------+ +--------+ +------+ | +---------+ +--------+ +--------+
|
||||
| Virtio| |Virtio | |Virtio| | |Virtio | |Virtio | |Virtio |
|
||||
| Net | |Console | |Block | | |Net | |Console | |Block |
|
||||
| Driver| |Driver | |Driver| | |backend | |backend | |backend |
|
||||
+---+---+ +---+----+ +--+---+ | +---------+ +----+---+ +--------+
|
||||
| | | | | | |
|
||||
| | | |User | | |
|
||||
| | | |------|------------|--+------|-------
|
||||
+---------+---------+ |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 | |
|
||||
+---+--------------+------+ | +----+---------------+-----+
|
||||
| | |
|
||||
+-------------------------------------------------------------+
|
||||
| |
|
||||
| PCIe Bus |
|
||||
+-------------------------------------------------------------+
|
||||
@@ -1,108 +0,0 @@
|
||||
========================================
|
||||
Symmetric Communication Interface (SCIF)
|
||||
========================================
|
||||
|
||||
The Symmetric Communication Interface (SCIF (pronounced as skiff)) is a low
|
||||
level communications API across PCIe currently implemented for MIC. Currently
|
||||
SCIF provides inter-node communication within a single host platform, where a
|
||||
node is a MIC Coprocessor or Xeon based host. SCIF abstracts the details of
|
||||
communicating over the PCIe bus while providing an API that is symmetric
|
||||
across all the nodes in the PCIe network. An important design objective for SCIF
|
||||
is to deliver the maximum possible performance given the communication
|
||||
abilities of the hardware. SCIF has been used to implement an offload compiler
|
||||
runtime and OFED support for MPI implementations for MIC coprocessors.
|
||||
|
||||
SCIF API Components
|
||||
===================
|
||||
|
||||
The SCIF API has the following parts:
|
||||
|
||||
1. Connection establishment using a client server model
|
||||
2. Byte stream messaging intended for short messages
|
||||
3. Node enumeration to determine online nodes
|
||||
4. Poll semantics for detection of incoming connections and messages
|
||||
5. Memory registration to pin down pages
|
||||
6. Remote memory mapping for low latency CPU accesses via mmap
|
||||
7. Remote DMA (RDMA) for high bandwidth DMA transfers
|
||||
8. Fence APIs for RDMA synchronization
|
||||
|
||||
SCIF exposes the notion of a connection which can be used by peer processes on
|
||||
nodes in a SCIF PCIe "network" to share memory "windows" and to communicate. A
|
||||
process in a SCIF node initiates a SCIF connection to a peer process on a
|
||||
different node via a SCIF "endpoint". SCIF endpoints support messaging APIs
|
||||
which are similar to connection oriented socket APIs. Connected SCIF endpoints
|
||||
can also register local memory which is followed by data transfer using either
|
||||
DMA, CPU copies or remote memory mapping via mmap. SCIF supports both user and
|
||||
kernel mode clients which are functionally equivalent.
|
||||
|
||||
SCIF Performance for MIC
|
||||
========================
|
||||
|
||||
DMA bandwidth comparison between the TCP (over ethernet over PCIe) stack versus
|
||||
SCIF shows the performance advantages of SCIF for HPC applications and
|
||||
runtimes::
|
||||
|
||||
Comparison of TCP and SCIF based BW
|
||||
|
||||
Throughput (GB/sec)
|
||||
8 + PCIe Bandwidth ******
|
||||
+ TCP ######
|
||||
7 + ************************************** SCIF %%%%%%
|
||||
| %%%%%%%%%%%%%%%%%%%
|
||||
6 + %%%%
|
||||
| %%
|
||||
| %%%
|
||||
5 + %%
|
||||
| %%
|
||||
4 + %%
|
||||
| %%
|
||||
3 + %%
|
||||
| %
|
||||
2 + %%
|
||||
| %%
|
||||
| %
|
||||
1 +
|
||||
+ ######################################
|
||||
0 +++---+++--+--+-+--+--+-++-+--+-++-+--+-++-+-
|
||||
1 10 100 1000 10000 100000
|
||||
Transfer Size (KBytes)
|
||||
|
||||
SCIF allows memory sharing via mmap(..) between processes on different PCIe
|
||||
nodes and thus provides bare-metal PCIe latency. The round trip SCIF mmap
|
||||
latency from the host to an x100 MIC for an 8 byte message is 0.44 usecs.
|
||||
|
||||
SCIF has a user space library which is a thin IOCTL wrapper providing a user
|
||||
space API similar to the kernel API in scif.h. The SCIF user space library
|
||||
is distributed @ https://software.intel.com/en-us/mic-developer
|
||||
|
||||
Here is some pseudo code for an example of how two applications on two PCIe
|
||||
nodes would typically use the SCIF API::
|
||||
|
||||
Process A (on node A) Process B (on node B)
|
||||
|
||||
/* get online node information */
|
||||
scif_get_node_ids(..) scif_get_node_ids(..)
|
||||
scif_open(..) scif_open(..)
|
||||
scif_bind(..) scif_bind(..)
|
||||
scif_listen(..)
|
||||
scif_accept(..) scif_connect(..)
|
||||
/* SCIF connection established */
|
||||
|
||||
/* Send and receive short messages */
|
||||
scif_send(..)/scif_recv(..) scif_send(..)/scif_recv(..)
|
||||
|
||||
/* Register memory */
|
||||
scif_register(..) scif_register(..)
|
||||
|
||||
/* RDMA */
|
||||
scif_readfrom(..)/scif_writeto(..) scif_readfrom(..)/scif_writeto(..)
|
||||
|
||||
/* Fence DMAs */
|
||||
scif_fence_signal(..) scif_fence_signal(..)
|
||||
|
||||
mmap(..) mmap(..)
|
||||
|
||||
/* Access remote registered memory */
|
||||
|
||||
/* Close the endpoints */
|
||||
scif_close(..) scif_close(..)
|
||||
16
MAINTAINERS
16
MAINTAINERS
@@ -8976,22 +8976,6 @@ S: Supported
|
||||
W: https://01.org/linux-acpi
|
||||
F: drivers/platform/x86/intel_menlow.c
|
||||
|
||||
INTEL MIC DRIVERS (mic)
|
||||
M: Sudeep Dutt <sudeep.dutt@intel.com>
|
||||
M: Ashutosh Dixit <ashutosh.dixit@intel.com>
|
||||
S: Supported
|
||||
W: https://github.com/sudeepdutt/mic
|
||||
W: http://software.intel.com/en-us/mic-developer
|
||||
F: Documentation/misc-devices/mic/
|
||||
F: drivers/dma/mic_x100_dma.c
|
||||
F: drivers/dma/mic_x100_dma.h
|
||||
F: drivers/misc/mic/
|
||||
F: include/linux/mic_bus.h
|
||||
F: include/linux/scif.h
|
||||
F: include/uapi/linux/mic_common.h
|
||||
F: include/uapi/linux/mic_ioctl.h
|
||||
F: include/uapi/linux/scif_ioctl.h
|
||||
|
||||
INTEL P-Unit IPC DRIVER
|
||||
M: Zha Qipeng <qipeng.zha@intel.com>
|
||||
L: platform-driver-x86@vger.kernel.org
|
||||
|
||||
@@ -318,24 +318,6 @@ config INTEL_IOP_ADMA
|
||||
help
|
||||
Enable support for the Intel(R) IOP Series RAID engines.
|
||||
|
||||
config INTEL_MIC_X100_DMA
|
||||
tristate "Intel MIC X100 DMA Driver"
|
||||
depends on 64BIT && X86 && INTEL_MIC_BUS
|
||||
select DMA_ENGINE
|
||||
help
|
||||
This enables DMA support for the Intel Many Integrated Core
|
||||
(MIC) family of PCIe form factor coprocessor X100 devices that
|
||||
run a 64 bit Linux OS. This driver will be used by both MIC
|
||||
host and card drivers.
|
||||
|
||||
If you are building host kernel with a MIC device or a card
|
||||
kernel for a MIC device, then say M (recommended) or Y, else
|
||||
say N. If unsure say N.
|
||||
|
||||
More information about the Intel MIC family as well as the Linux
|
||||
OS and tools for MIC to use with this driver are available from
|
||||
<http://software.intel.com/en-us/mic-developer>.
|
||||
|
||||
config K3_DMA
|
||||
tristate "Hisilicon K3 DMA support"
|
||||
depends on ARCH_HI3xxx || ARCH_HISI || COMPILE_TEST
|
||||
|
||||
@@ -44,7 +44,6 @@ obj-$(CONFIG_INTEL_IDMA64) += idma64.o
|
||||
obj-$(CONFIG_INTEL_IOATDMA) += ioat/
|
||||
obj-$(CONFIG_INTEL_IDXD) += idxd/
|
||||
obj-$(CONFIG_INTEL_IOP_ADMA) += iop-adma.o
|
||||
obj-$(CONFIG_INTEL_MIC_X100_DMA) += mic_x100_dma.o
|
||||
obj-$(CONFIG_K3_DMA) += k3dma.o
|
||||
obj-$(CONFIG_LPC18XX_DMAMUX) += lpc18xx-dmamux.o
|
||||
obj-$(CONFIG_MILBEAUT_HDMAC) += milbeaut-hdmac.o
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,275 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Intel MIC Platform Software Stack (MPSS)
|
||||
*
|
||||
* Copyright(c) 2014 Intel Corporation.
|
||||
*
|
||||
* Intel MIC X100 DMA Driver.
|
||||
*
|
||||
* Adapted from IOAT dma driver.
|
||||
*/
|
||||
#ifndef _MIC_X100_DMA_H_
|
||||
#define _MIC_X100_DMA_H_
|
||||
|
||||
#include <linux/kernel.h>
|
||||
#include <linux/delay.h>
|
||||
#include <linux/sched.h>
|
||||
#include <linux/debugfs.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/interrupt.h>
|
||||
#include <linux/mic_bus.h>
|
||||
|
||||
#include "dmaengine.h"
|
||||
|
||||
/*
|
||||
* MIC has a total of 8 dma channels.
|
||||
* Four channels are assigned for host SW use & the remaining for MIC SW.
|
||||
* MIC DMA transfer size & addresses need to be 64 byte aligned.
|
||||
*/
|
||||
#define MIC_DMA_MAX_NUM_CHAN 8
|
||||
#define MIC_DMA_NUM_CHAN 4
|
||||
#define MIC_DMA_ALIGN_SHIFT DMAENGINE_ALIGN_64_BYTES
|
||||
#define MIC_DMA_ALIGN_BYTES (1 << MIC_DMA_ALIGN_SHIFT)
|
||||
#define MIC_DMA_DESC_RX_SIZE (128 * 1024 - 4)
|
||||
|
||||
/*
|
||||
* Register descriptions
|
||||
* All the registers are 32 bit registers.
|
||||
* DCR is a global register and all others are per-channel.
|
||||
* DCR - bits 0, 2, 4, 6, 8, 10, 12, 14 - enable bits for channels 0 to 7
|
||||
* bits 1, 3, 5, 7, 9, 11, 13, 15 - owner bits for channels 0 to 7
|
||||
* DCAR - bit 24 & 25 interrupt masks for mic owned & host owned channels
|
||||
* DHPR - head of the descriptor ring updated by s/w
|
||||
* DTPR - tail of the descriptor ring updated by h/w
|
||||
* DRAR_LO - lower 32 bits of descriptor ring's mic address
|
||||
* DRAR_HI - 3:0 - remaining 4 bits of descriptor ring's mic address
|
||||
* 20:4 descriptor ring size
|
||||
* 25:21 mic smpt entry number
|
||||
* DSTAT - 16:0 h/w completion count; 31:28 dma engine status
|
||||
* DCHERR - this register is non-zero on error
|
||||
* DCHERRMSK - interrupt mask register
|
||||
*/
|
||||
#define MIC_DMA_HW_CMP_CNT_MASK 0x1ffff
|
||||
#define MIC_DMA_CHAN_QUIESCE 0x20000000
|
||||
#define MIC_DMA_SBOX_BASE 0x00010000
|
||||
#define MIC_DMA_SBOX_DCR 0x0000A280
|
||||
#define MIC_DMA_SBOX_CH_BASE 0x0001A000
|
||||
#define MIC_DMA_SBOX_CHAN_OFF 0x40
|
||||
#define MIC_DMA_SBOX_DCAR_IM0 (0x1 << 24)
|
||||
#define MIC_DMA_SBOX_DCAR_IM1 (0x1 << 25)
|
||||
#define MIC_DMA_SBOX_DRARHI_SYS_MASK (0x1 << 26)
|
||||
#define MIC_DMA_REG_DCAR 0
|
||||
#define MIC_DMA_REG_DHPR 4
|
||||
#define MIC_DMA_REG_DTPR 8
|
||||
#define MIC_DMA_REG_DRAR_LO 20
|
||||
#define MIC_DMA_REG_DRAR_HI 24
|
||||
#define MIC_DMA_REG_DSTAT 32
|
||||
#define MIC_DMA_REG_DCHERR 44
|
||||
#define MIC_DMA_REG_DCHERRMSK 48
|
||||
|
||||
/* HW dma desc */
|
||||
struct mic_dma_desc {
|
||||
u64 qw0;
|
||||
u64 qw1;
|
||||
};
|
||||
|
||||
enum mic_dma_chan_owner {
|
||||
MIC_DMA_CHAN_MIC = 0,
|
||||
MIC_DMA_CHAN_HOST
|
||||
};
|
||||
|
||||
/*
|
||||
* mic_dma_chan - channel specific information
|
||||
* @ch_num: channel number
|
||||
* @owner: owner of this channel
|
||||
* @last_tail: cached value of descriptor ring tail
|
||||
* @head: index of next descriptor in desc_ring
|
||||
* @issued: hardware notification point
|
||||
* @submitted: index that will be used to submit descriptors to h/w
|
||||
* @api_ch: dma engine api channel
|
||||
* @desc_ring: dma descriptor ring
|
||||
* @desc_ring_micpa: mic physical address of desc_ring
|
||||
* @status_dest: destination for status (fence) descriptor
|
||||
* @status_dest_micpa: mic address for status_dest,
|
||||
* DMA controller uses this address
|
||||
* @tx_array: array of async_tx
|
||||
* @cleanup_lock: lock held when processing completed tx
|
||||
* @prep_lock: lock held in prep_memcpy & released in tx_submit
|
||||
* @issue_lock: lock used to synchronize writes to head
|
||||
* @cookie: mic_irq cookie used with mic irq request
|
||||
*/
|
||||
struct mic_dma_chan {
|
||||
int ch_num;
|
||||
enum mic_dma_chan_owner owner;
|
||||
u32 last_tail;
|
||||
u32 head;
|
||||
u32 issued;
|
||||
u32 submitted;
|
||||
struct dma_chan api_ch;
|
||||
struct mic_dma_desc *desc_ring;
|
||||
dma_addr_t desc_ring_micpa;
|
||||
u64 *status_dest;
|
||||
dma_addr_t status_dest_micpa;
|
||||
struct dma_async_tx_descriptor *tx_array;
|
||||
spinlock_t cleanup_lock;
|
||||
spinlock_t prep_lock;
|
||||
spinlock_t issue_lock;
|
||||
struct mic_irq *cookie;
|
||||
};
|
||||
|
||||
/*
|
||||
* struct mic_dma_device - per mic device
|
||||
* @mic_ch: dma channels
|
||||
* @dma_dev: underlying dma device
|
||||
* @mbdev: mic bus dma device
|
||||
* @mmio: virtual address of the mmio space
|
||||
* @dbg_dir: debugfs directory
|
||||
* @start_ch: first channel number that can be used
|
||||
* @max_xfer_size: maximum transfer size per dma descriptor
|
||||
*/
|
||||
struct mic_dma_device {
|
||||
struct mic_dma_chan mic_ch[MIC_DMA_MAX_NUM_CHAN];
|
||||
struct dma_device dma_dev;
|
||||
struct mbus_device *mbdev;
|
||||
void __iomem *mmio;
|
||||
struct dentry *dbg_dir;
|
||||
int start_ch;
|
||||
size_t max_xfer_size;
|
||||
};
|
||||
|
||||
static inline struct mic_dma_chan *to_mic_dma_chan(struct dma_chan *ch)
|
||||
{
|
||||
return container_of(ch, struct mic_dma_chan, api_ch);
|
||||
}
|
||||
|
||||
static inline struct mic_dma_device *to_mic_dma_dev(struct mic_dma_chan *ch)
|
||||
{
|
||||
return
|
||||
container_of((const typeof(((struct mic_dma_device *)0)->mic_ch)*)
|
||||
(ch - ch->ch_num), struct mic_dma_device, mic_ch);
|
||||
}
|
||||
|
||||
static inline struct mbus_device *to_mbus_device(struct mic_dma_chan *ch)
|
||||
{
|
||||
return to_mic_dma_dev(ch)->mbdev;
|
||||
}
|
||||
|
||||
static inline struct mbus_hw_ops *to_mbus_hw_ops(struct mic_dma_chan *ch)
|
||||
{
|
||||
return to_mbus_device(ch)->hw_ops;
|
||||
}
|
||||
|
||||
static inline struct device *mic_dma_ch_to_device(struct mic_dma_chan *ch)
|
||||
{
|
||||
return to_mic_dma_dev(ch)->dma_dev.dev;
|
||||
}
|
||||
|
||||
static inline void __iomem *mic_dma_chan_to_mmio(struct mic_dma_chan *ch)
|
||||
{
|
||||
return to_mic_dma_dev(ch)->mmio;
|
||||
}
|
||||
|
||||
static inline u32 mic_dma_read_reg(struct mic_dma_chan *ch, u32 reg)
|
||||
{
|
||||
return ioread32(mic_dma_chan_to_mmio(ch) + MIC_DMA_SBOX_CH_BASE +
|
||||
ch->ch_num * MIC_DMA_SBOX_CHAN_OFF + reg);
|
||||
}
|
||||
|
||||
static inline void mic_dma_write_reg(struct mic_dma_chan *ch, u32 reg, u32 val)
|
||||
{
|
||||
iowrite32(val, mic_dma_chan_to_mmio(ch) + MIC_DMA_SBOX_CH_BASE +
|
||||
ch->ch_num * MIC_DMA_SBOX_CHAN_OFF + reg);
|
||||
}
|
||||
|
||||
static inline u32 mic_dma_mmio_read(struct mic_dma_chan *ch, u32 offset)
|
||||
{
|
||||
return ioread32(mic_dma_chan_to_mmio(ch) + offset);
|
||||
}
|
||||
|
||||
static inline void mic_dma_mmio_write(struct mic_dma_chan *ch, u32 val,
|
||||
u32 offset)
|
||||
{
|
||||
iowrite32(val, mic_dma_chan_to_mmio(ch) + offset);
|
||||
}
|
||||
|
||||
static inline u32 mic_dma_read_cmp_cnt(struct mic_dma_chan *ch)
|
||||
{
|
||||
return mic_dma_read_reg(ch, MIC_DMA_REG_DSTAT) &
|
||||
MIC_DMA_HW_CMP_CNT_MASK;
|
||||
}
|
||||
|
||||
static inline void mic_dma_chan_set_owner(struct mic_dma_chan *ch)
|
||||
{
|
||||
u32 dcr = mic_dma_mmio_read(ch, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
|
||||
u32 chan_num = ch->ch_num;
|
||||
|
||||
dcr = (dcr & ~(0x1 << (chan_num * 2))) | (ch->owner << (chan_num * 2));
|
||||
mic_dma_mmio_write(ch, dcr, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
|
||||
}
|
||||
|
||||
static inline void mic_dma_enable_chan(struct mic_dma_chan *ch)
|
||||
{
|
||||
u32 dcr = mic_dma_mmio_read(ch, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
|
||||
|
||||
dcr |= 2 << (ch->ch_num << 1);
|
||||
mic_dma_mmio_write(ch, dcr, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
|
||||
}
|
||||
|
||||
static inline void mic_dma_disable_chan(struct mic_dma_chan *ch)
|
||||
{
|
||||
u32 dcr = mic_dma_mmio_read(ch, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
|
||||
|
||||
dcr &= ~(2 << (ch->ch_num << 1));
|
||||
mic_dma_mmio_write(ch, dcr, MIC_DMA_SBOX_BASE + MIC_DMA_SBOX_DCR);
|
||||
}
|
||||
|
||||
static void mic_dma_chan_set_desc_ring(struct mic_dma_chan *ch)
|
||||
{
|
||||
u32 drar_hi;
|
||||
dma_addr_t desc_ring_micpa = ch->desc_ring_micpa;
|
||||
|
||||
drar_hi = (MIC_DMA_DESC_RX_SIZE & 0x1ffff) << 4;
|
||||
if (MIC_DMA_CHAN_MIC == ch->owner) {
|
||||
drar_hi |= (desc_ring_micpa >> 32) & 0xf;
|
||||
} else {
|
||||
drar_hi |= MIC_DMA_SBOX_DRARHI_SYS_MASK;
|
||||
drar_hi |= ((desc_ring_micpa >> 34)
|
||||
& 0x1f) << 21;
|
||||
drar_hi |= (desc_ring_micpa >> 32) & 0x3;
|
||||
}
|
||||
mic_dma_write_reg(ch, MIC_DMA_REG_DRAR_LO, (u32) desc_ring_micpa);
|
||||
mic_dma_write_reg(ch, MIC_DMA_REG_DRAR_HI, drar_hi);
|
||||
}
|
||||
|
||||
static inline void mic_dma_chan_mask_intr(struct mic_dma_chan *ch)
|
||||
{
|
||||
u32 dcar = mic_dma_read_reg(ch, MIC_DMA_REG_DCAR);
|
||||
|
||||
if (MIC_DMA_CHAN_MIC == ch->owner)
|
||||
dcar |= MIC_DMA_SBOX_DCAR_IM0;
|
||||
else
|
||||
dcar |= MIC_DMA_SBOX_DCAR_IM1;
|
||||
mic_dma_write_reg(ch, MIC_DMA_REG_DCAR, dcar);
|
||||
}
|
||||
|
||||
static inline void mic_dma_chan_unmask_intr(struct mic_dma_chan *ch)
|
||||
{
|
||||
u32 dcar = mic_dma_read_reg(ch, MIC_DMA_REG_DCAR);
|
||||
|
||||
if (MIC_DMA_CHAN_MIC == ch->owner)
|
||||
dcar &= ~MIC_DMA_SBOX_DCAR_IM0;
|
||||
else
|
||||
dcar &= ~MIC_DMA_SBOX_DCAR_IM1;
|
||||
mic_dma_write_reg(ch, MIC_DMA_REG_DCAR, dcar);
|
||||
}
|
||||
|
||||
static void mic_dma_ack_interrupt(struct mic_dma_chan *ch)
|
||||
{
|
||||
if (MIC_DMA_CHAN_MIC == ch->owner) {
|
||||
/* HW errata */
|
||||
mic_dma_chan_mask_intr(ch);
|
||||
mic_dma_chan_unmask_intr(ch);
|
||||
}
|
||||
to_mbus_hw_ops(ch)->ack_interrupt(to_mbus_device(ch), ch->ch_num);
|
||||
}
|
||||
#endif
|
||||
@@ -474,7 +474,6 @@ source "drivers/misc/lis3lv02d/Kconfig"
|
||||
source "drivers/misc/altera-stapl/Kconfig"
|
||||
source "drivers/misc/mei/Kconfig"
|
||||
source "drivers/misc/vmw_vmci/Kconfig"
|
||||
source "drivers/misc/mic/Kconfig"
|
||||
source "drivers/misc/genwqe/Kconfig"
|
||||
source "drivers/misc/echo/Kconfig"
|
||||
source "drivers/misc/cxl/Kconfig"
|
||||
|
||||
@@ -46,7 +46,6 @@ obj-$(CONFIG_VMWARE_VMCI) += vmw_vmci/
|
||||
obj-$(CONFIG_LATTICE_ECP3_CONFIG) += lattice-ecp3-config.o
|
||||
obj-$(CONFIG_SRAM) += sram.o
|
||||
obj-$(CONFIG_SRAM_EXEC) += sram-exec.o
|
||||
obj-y += mic/
|
||||
obj-$(CONFIG_GENWQE) += genwqe/
|
||||
obj-$(CONFIG_ECHO) += echo/
|
||||
obj-$(CONFIG_CXL_BASE) += cxl/
|
||||
|
||||
@@ -1,141 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
menu "Intel MIC & related support"
|
||||
|
||||
config INTEL_MIC_BUS
|
||||
tristate "Intel MIC Bus Driver"
|
||||
depends on 64BIT && PCI && X86
|
||||
select DMA_OPS
|
||||
help
|
||||
This option is selected by any driver which registers a
|
||||
device or driver on the MIC Bus, such as CONFIG_INTEL_MIC_HOST,
|
||||
CONFIG_INTEL_MIC_CARD, CONFIG_INTEL_MIC_X100_DMA etc.
|
||||
|
||||
If you are building a host/card kernel with an Intel MIC device
|
||||
then say M (recommended) or Y, else say N. If unsure say N.
|
||||
|
||||
More information about the Intel MIC family as well as the Linux
|
||||
OS and tools for MIC to use with this driver are available from
|
||||
<http://software.intel.com/en-us/mic-developer>.
|
||||
|
||||
config SCIF_BUS
|
||||
tristate "SCIF Bus Driver"
|
||||
depends on 64BIT && PCI && X86
|
||||
select DMA_OPS
|
||||
help
|
||||
This option is selected by any driver which registers a
|
||||
device or driver on the SCIF Bus, such as CONFIG_INTEL_MIC_HOST
|
||||
and CONFIG_INTEL_MIC_CARD.
|
||||
|
||||
If you are building a host/card kernel with an Intel MIC device
|
||||
then say M (recommended) or Y, else say N. If unsure say N.
|
||||
|
||||
More information about the Intel MIC family as well as the Linux
|
||||
OS and tools for MIC to use with this driver are available from
|
||||
<http://software.intel.com/en-us/mic-developer>.
|
||||
|
||||
config VOP_BUS
|
||||
tristate "VOP Bus Driver"
|
||||
depends on HAS_DMA
|
||||
select DMA_OPS
|
||||
help
|
||||
This option is selected by any driver which registers a
|
||||
device or driver on the VOP Bus, such as CONFIG_INTEL_MIC_HOST
|
||||
and CONFIG_INTEL_MIC_CARD.
|
||||
|
||||
If you are building a host/card kernel with an Intel MIC device
|
||||
then say M (recommended) or Y, else say N. If unsure say N.
|
||||
|
||||
More information about the Intel MIC family as well as the Linux
|
||||
OS and tools for MIC to use with this driver are available from
|
||||
<http://software.intel.com/en-us/mic-developer>.
|
||||
|
||||
config INTEL_MIC_HOST
|
||||
tristate "Intel MIC Host Driver"
|
||||
depends on 64BIT && PCI && X86
|
||||
depends on INTEL_MIC_BUS && SCIF_BUS && MIC_COSM && VOP_BUS
|
||||
select DMA_OPS
|
||||
help
|
||||
This enables Host Driver support for the Intel Many Integrated
|
||||
Core (MIC) family of PCIe form factor coprocessor devices that
|
||||
run a 64 bit Linux OS. The driver manages card OS state and
|
||||
enables communication between host and card. Intel MIC X100
|
||||
devices are currently supported.
|
||||
|
||||
If you are building a host kernel with an Intel MIC device then
|
||||
say M (recommended) or Y, else say N. If unsure say N.
|
||||
|
||||
More information about the Intel MIC family as well as the Linux
|
||||
OS and tools for MIC to use with this driver are available from
|
||||
<http://software.intel.com/en-us/mic-developer>.
|
||||
|
||||
config INTEL_MIC_CARD
|
||||
tristate "Intel MIC Card Driver"
|
||||
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
|
||||
Core (MIC) device family. The card driver communicates shutdown/
|
||||
crash events to the host and allows registration/configuration of
|
||||
virtio devices. Intel MIC X100 devices are currently supported.
|
||||
|
||||
If you are building a card kernel for an Intel MIC device then
|
||||
say M (recommended) or Y, else say N. If unsure say N.
|
||||
|
||||
For more information see
|
||||
<http://software.intel.com/en-us/mic-developer>.
|
||||
|
||||
config SCIF
|
||||
tristate "SCIF Driver"
|
||||
depends on 64BIT && PCI && X86 && SCIF_BUS && IOMMU_SUPPORT
|
||||
select IOMMU_IOVA
|
||||
help
|
||||
This enables SCIF Driver support for the Intel Many Integrated
|
||||
Core (MIC) family of PCIe form factor coprocessor devices that
|
||||
run a 64 bit Linux OS. The Symmetric Communication Interface
|
||||
(SCIF (pronounced as skiff)) is a low level communications API
|
||||
across PCIe currently implemented for MIC.
|
||||
|
||||
If you are building a host kernel with an Intel MIC device then
|
||||
say M (recommended) or Y, else say N. If unsure say N.
|
||||
|
||||
More information about the Intel MIC family as well as the Linux
|
||||
OS and tools for MIC to use with this driver are available from
|
||||
<http://software.intel.com/en-us/mic-developer>.
|
||||
|
||||
config MIC_COSM
|
||||
tristate "Intel MIC Coprocessor State Management (COSM) Drivers"
|
||||
depends on 64BIT && PCI && X86 && SCIF
|
||||
help
|
||||
This enables COSM driver support for the Intel Many
|
||||
Integrated Core (MIC) family of PCIe form factor coprocessor
|
||||
devices. COSM drivers implement functions such as boot,
|
||||
shutdown, reset and reboot of MIC devices.
|
||||
|
||||
If you are building a host kernel with an Intel MIC device then
|
||||
say M (recommended) or Y, else say N. If unsure say N.
|
||||
|
||||
More information about the Intel MIC family as well as the Linux
|
||||
OS and tools for MIC to use with this driver are available from
|
||||
<http://software.intel.com/en-us/mic-developer>.
|
||||
|
||||
config VOP
|
||||
tristate "VOP Driver"
|
||||
depends on VOP_BUS
|
||||
select VHOST_RING
|
||||
select VIRTIO
|
||||
help
|
||||
This enables VOP (Virtio over PCIe) Driver support for the Intel
|
||||
Many Integrated Core (MIC) family of PCIe form factor coprocessor
|
||||
devices. The VOP driver allows virtio drivers, e.g. net, console
|
||||
and block drivers, on the card connect to user space virtio
|
||||
devices on the host.
|
||||
|
||||
If you are building a host kernel with an Intel MIC device then
|
||||
say M (recommended) or Y, else say N. If unsure say N.
|
||||
|
||||
More information about the Intel MIC family as well as the Linux
|
||||
OS and tools for MIC to use with this driver are available from
|
||||
<http://software.intel.com/en-us/mic-developer>.
|
||||
|
||||
endmenu
|
||||
@@ -1,12 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0
|
||||
#
|
||||
# Makefile - Intel MIC Linux driver.
|
||||
# Copyright(c) 2013, Intel Corporation.
|
||||
#
|
||||
obj-$(CONFIG_INTEL_MIC_HOST) += host/
|
||||
obj-$(CONFIG_INTEL_MIC_CARD) += card/
|
||||
obj-y += bus/
|
||||
obj-$(CONFIG_SCIF) += scif/
|
||||
obj-$(CONFIG_MIC_COSM) += cosm/
|
||||
obj-$(CONFIG_MIC_COSM) += cosm_client/
|
||||
obj-$(CONFIG_VOP) += vop/
|
||||
@@ -1,9 +0,0 @@
|
||||
# SPDX-License-Identifier: GPL-2.0-only
|
||||
#
|
||||
# Makefile - Intel MIC Linux driver.
|
||||
# Copyright(c) 2014, Intel Corporation.
|
||||
#
|
||||
obj-$(CONFIG_INTEL_MIC_BUS) += mic_bus.o
|
||||
obj-$(CONFIG_SCIF_BUS) += scif_bus.o
|
||||
obj-$(CONFIG_MIC_COSM) += cosm_bus.o
|
||||
obj-$(CONFIG_VOP_BUS) += vop_bus.o
|
||||
@@ -1,130 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Intel MIC Platform Software Stack (MPSS)
|
||||
*
|
||||
* Copyright(c) 2015 Intel Corporation.
|
||||
*
|
||||
* Intel MIC COSM Bus Driver
|
||||
*/
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/idr.h>
|
||||
#include "cosm_bus.h"
|
||||
|
||||
/* Unique numbering for cosm devices. */
|
||||
static DEFINE_IDA(cosm_index_ida);
|
||||
|
||||
static int cosm_dev_probe(struct device *d)
|
||||
{
|
||||
struct cosm_device *dev = dev_to_cosm(d);
|
||||
struct cosm_driver *drv = drv_to_cosm(dev->dev.driver);
|
||||
|
||||
return drv->probe(dev);
|
||||
}
|
||||
|
||||
static int cosm_dev_remove(struct device *d)
|
||||
{
|
||||
struct cosm_device *dev = dev_to_cosm(d);
|
||||
struct cosm_driver *drv = drv_to_cosm(dev->dev.driver);
|
||||
|
||||
drv->remove(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct bus_type cosm_bus = {
|
||||
.name = "cosm_bus",
|
||||
.probe = cosm_dev_probe,
|
||||
.remove = cosm_dev_remove,
|
||||
};
|
||||
|
||||
int cosm_register_driver(struct cosm_driver *driver)
|
||||
{
|
||||
driver->driver.bus = &cosm_bus;
|
||||
return driver_register(&driver->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cosm_register_driver);
|
||||
|
||||
void cosm_unregister_driver(struct cosm_driver *driver)
|
||||
{
|
||||
driver_unregister(&driver->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cosm_unregister_driver);
|
||||
|
||||
static inline void cosm_release_dev(struct device *d)
|
||||
{
|
||||
struct cosm_device *cdev = dev_to_cosm(d);
|
||||
|
||||
kfree(cdev);
|
||||
}
|
||||
|
||||
struct cosm_device *
|
||||
cosm_register_device(struct device *pdev, struct cosm_hw_ops *hw_ops)
|
||||
{
|
||||
struct cosm_device *cdev;
|
||||
int ret;
|
||||
|
||||
cdev = kzalloc(sizeof(*cdev), GFP_KERNEL);
|
||||
if (!cdev)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
cdev->dev.parent = pdev;
|
||||
cdev->dev.release = cosm_release_dev;
|
||||
cdev->hw_ops = hw_ops;
|
||||
dev_set_drvdata(&cdev->dev, cdev);
|
||||
cdev->dev.bus = &cosm_bus;
|
||||
|
||||
/* Assign a unique device index and hence name */
|
||||
ret = ida_simple_get(&cosm_index_ida, 0, 0, GFP_KERNEL);
|
||||
if (ret < 0)
|
||||
goto free_cdev;
|
||||
|
||||
cdev->index = ret;
|
||||
cdev->dev.id = ret;
|
||||
dev_set_name(&cdev->dev, "cosm-dev%u", cdev->index);
|
||||
|
||||
ret = device_register(&cdev->dev);
|
||||
if (ret)
|
||||
goto ida_remove;
|
||||
return cdev;
|
||||
ida_remove:
|
||||
ida_simple_remove(&cosm_index_ida, cdev->index);
|
||||
free_cdev:
|
||||
put_device(&cdev->dev);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cosm_register_device);
|
||||
|
||||
void cosm_unregister_device(struct cosm_device *dev)
|
||||
{
|
||||
int index = dev->index; /* save for after device release */
|
||||
|
||||
device_unregister(&dev->dev);
|
||||
ida_simple_remove(&cosm_index_ida, index);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cosm_unregister_device);
|
||||
|
||||
struct cosm_device *cosm_find_cdev_by_id(int id)
|
||||
{
|
||||
struct device *dev = subsys_find_device_by_id(&cosm_bus, id, NULL);
|
||||
|
||||
return dev ? container_of(dev, struct cosm_device, dev) : NULL;
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(cosm_find_cdev_by_id);
|
||||
|
||||
static int __init cosm_init(void)
|
||||
{
|
||||
return bus_register(&cosm_bus);
|
||||
}
|
||||
|
||||
static void __exit cosm_exit(void)
|
||||
{
|
||||
bus_unregister(&cosm_bus);
|
||||
ida_destroy(&cosm_index_ida);
|
||||
}
|
||||
|
||||
core_initcall(cosm_init);
|
||||
module_exit(cosm_exit);
|
||||
|
||||
MODULE_AUTHOR("Intel Corporation");
|
||||
MODULE_DESCRIPTION("Intel(R) MIC card OS state management bus driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
@@ -1,125 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Intel MIC Platform Software Stack (MPSS)
|
||||
*
|
||||
* Copyright(c) 2015 Intel Corporation.
|
||||
*
|
||||
* Intel MIC COSM Bus Driver
|
||||
*/
|
||||
#ifndef _COSM_BUS_H_
|
||||
#define _COSM_BUS_H_
|
||||
|
||||
#include <linux/scif.h>
|
||||
#include <linux/mic_common.h>
|
||||
#include "../common/mic_dev.h"
|
||||
|
||||
/**
|
||||
* cosm_device - representation of a cosm device
|
||||
*
|
||||
* @attr_group: Pointer to list of sysfs attribute groups.
|
||||
* @sdev: Device for sysfs entries.
|
||||
* @state: MIC state.
|
||||
* @prev_state: MIC state previous to MIC_RESETTING
|
||||
* @shutdown_status: MIC status reported by card for shutdown/crashes.
|
||||
* @shutdown_status_int: Internal shutdown status maintained by the driver
|
||||
* @cosm_mutex: Mutex for synchronizing access to data structures.
|
||||
* @reset_trigger_work: Work for triggering reset requests.
|
||||
* @scif_work: Work for handling per device SCIF connections
|
||||
* @cmdline: Kernel command line.
|
||||
* @firmware: Firmware file name.
|
||||
* @ramdisk: Ramdisk file name.
|
||||
* @bootmode: Boot mode i.e. "linux" or "elf" for flash updates.
|
||||
* @log_buf_addr: Log buffer address for MIC.
|
||||
* @log_buf_len: Log buffer length address for MIC.
|
||||
* @state_sysfs: Sysfs dirent for notifying ring 3 about MIC state changes.
|
||||
* @hw_ops: the hardware bus ops for this device.
|
||||
* @dev: underlying device.
|
||||
* @index: unique position on the cosm bus
|
||||
* @dbg_dir: debug fs directory
|
||||
* @newepd: new endpoint from scif accept to be assigned to this cdev
|
||||
* @epd: SCIF endpoint for this cdev
|
||||
* @heartbeat_watchdog_enable: if heartbeat watchdog is enabled for this cdev
|
||||
* @sysfs_heartbeat_enable: sysfs setting for disabling heartbeat notification
|
||||
*/
|
||||
struct cosm_device {
|
||||
const struct attribute_group **attr_group;
|
||||
struct device *sdev;
|
||||
u8 state;
|
||||
u8 prev_state;
|
||||
u8 shutdown_status;
|
||||
u8 shutdown_status_int;
|
||||
struct mutex cosm_mutex;
|
||||
struct work_struct reset_trigger_work;
|
||||
struct work_struct scif_work;
|
||||
char *cmdline;
|
||||
char *firmware;
|
||||
char *ramdisk;
|
||||
char *bootmode;
|
||||
void *log_buf_addr;
|
||||
int *log_buf_len;
|
||||
struct kernfs_node *state_sysfs;
|
||||
struct cosm_hw_ops *hw_ops;
|
||||
struct device dev;
|
||||
int index;
|
||||
struct dentry *dbg_dir;
|
||||
scif_epd_t newepd;
|
||||
scif_epd_t epd;
|
||||
bool heartbeat_watchdog_enable;
|
||||
bool sysfs_heartbeat_enable;
|
||||
};
|
||||
|
||||
/**
|
||||
* cosm_driver - operations for a cosm driver
|
||||
*
|
||||
* @driver: underlying device driver (populate name and owner).
|
||||
* @probe: the function to call when a device is found. Returns 0 or -errno.
|
||||
* @remove: the function to call when a device is removed.
|
||||
*/
|
||||
struct cosm_driver {
|
||||
struct device_driver driver;
|
||||
int (*probe)(struct cosm_device *dev);
|
||||
void (*remove)(struct cosm_device *dev);
|
||||
};
|
||||
|
||||
/**
|
||||
* cosm_hw_ops - cosm bus ops
|
||||
*
|
||||
* @reset: trigger MIC reset
|
||||
* @force_reset: force MIC reset
|
||||
* @post_reset: inform MIC reset is complete
|
||||
* @ready: is MIC ready for OS download
|
||||
* @start: boot MIC
|
||||
* @stop: prepare MIC for reset
|
||||
* @family: return MIC HW family string
|
||||
* @stepping: return MIC HW stepping string
|
||||
* @aper: return MIC PCIe aperture
|
||||
*/
|
||||
struct cosm_hw_ops {
|
||||
void (*reset)(struct cosm_device *cdev);
|
||||
void (*force_reset)(struct cosm_device *cdev);
|
||||
void (*post_reset)(struct cosm_device *cdev, enum mic_states state);
|
||||
bool (*ready)(struct cosm_device *cdev);
|
||||
int (*start)(struct cosm_device *cdev, int id);
|
||||
void (*stop)(struct cosm_device *cdev, bool force);
|
||||
ssize_t (*family)(struct cosm_device *cdev, char *buf);
|
||||
ssize_t (*stepping)(struct cosm_device *cdev, char *buf);
|
||||
struct mic_mw *(*aper)(struct cosm_device *cdev);
|
||||
};
|
||||
|
||||
struct cosm_device *
|
||||
cosm_register_device(struct device *pdev, struct cosm_hw_ops *hw_ops);
|
||||
void cosm_unregister_device(struct cosm_device *dev);
|
||||
int cosm_register_driver(struct cosm_driver *drv);
|
||||
void cosm_unregister_driver(struct cosm_driver *drv);
|
||||
struct cosm_device *cosm_find_cdev_by_id(int id);
|
||||
|
||||
static inline struct cosm_device *dev_to_cosm(struct device *dev)
|
||||
{
|
||||
return container_of(dev, struct cosm_device, dev);
|
||||
}
|
||||
|
||||
static inline struct cosm_driver *drv_to_cosm(struct device_driver *drv)
|
||||
{
|
||||
return container_of(drv, struct cosm_driver, driver);
|
||||
}
|
||||
#endif /* _COSM_BUS_H */
|
||||
@@ -1,194 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Intel MIC Platform Software Stack (MPSS)
|
||||
*
|
||||
* Copyright(c) 2014 Intel Corporation.
|
||||
*
|
||||
* Intel MIC Bus driver.
|
||||
*
|
||||
* This implementation is very similar to the the virtio bus driver
|
||||
* implementation @ drivers/virtio/virtio.c
|
||||
*/
|
||||
#include <linux/dma-map-ops.h>
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/mic_bus.h>
|
||||
|
||||
static ssize_t device_show(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mbus_device *dev = dev_to_mbus(d);
|
||||
return sprintf(buf, "0x%04x\n", dev->id.device);
|
||||
}
|
||||
static DEVICE_ATTR_RO(device);
|
||||
|
||||
static ssize_t vendor_show(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mbus_device *dev = dev_to_mbus(d);
|
||||
return sprintf(buf, "0x%04x\n", dev->id.vendor);
|
||||
}
|
||||
static DEVICE_ATTR_RO(vendor);
|
||||
|
||||
static ssize_t modalias_show(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct mbus_device *dev = dev_to_mbus(d);
|
||||
return sprintf(buf, "mbus:d%08Xv%08X\n",
|
||||
dev->id.device, dev->id.vendor);
|
||||
}
|
||||
static DEVICE_ATTR_RO(modalias);
|
||||
|
||||
static struct attribute *mbus_dev_attrs[] = {
|
||||
&dev_attr_device.attr,
|
||||
&dev_attr_vendor.attr,
|
||||
&dev_attr_modalias.attr,
|
||||
NULL,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(mbus_dev);
|
||||
|
||||
static inline int mbus_id_match(const struct mbus_device *dev,
|
||||
const struct mbus_device_id *id)
|
||||
{
|
||||
if (id->device != dev->id.device && id->device != MBUS_DEV_ANY_ID)
|
||||
return 0;
|
||||
|
||||
return id->vendor == MBUS_DEV_ANY_ID || id->vendor == dev->id.vendor;
|
||||
}
|
||||
|
||||
/*
|
||||
* This looks through all the IDs a driver claims to support. If any of them
|
||||
* match, we return 1 and the kernel will call mbus_dev_probe().
|
||||
*/
|
||||
static int mbus_dev_match(struct device *dv, struct device_driver *dr)
|
||||
{
|
||||
unsigned int i;
|
||||
struct mbus_device *dev = dev_to_mbus(dv);
|
||||
const struct mbus_device_id *ids;
|
||||
|
||||
ids = drv_to_mbus(dr)->id_table;
|
||||
for (i = 0; ids[i].device; i++)
|
||||
if (mbus_id_match(dev, &ids[i]))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mbus_uevent(struct device *dv, struct kobj_uevent_env *env)
|
||||
{
|
||||
struct mbus_device *dev = dev_to_mbus(dv);
|
||||
|
||||
return add_uevent_var(env, "MODALIAS=mbus:d%08Xv%08X",
|
||||
dev->id.device, dev->id.vendor);
|
||||
}
|
||||
|
||||
static int mbus_dev_probe(struct device *d)
|
||||
{
|
||||
int err;
|
||||
struct mbus_device *dev = dev_to_mbus(d);
|
||||
struct mbus_driver *drv = drv_to_mbus(dev->dev.driver);
|
||||
|
||||
err = drv->probe(dev);
|
||||
if (!err)
|
||||
if (drv->scan)
|
||||
drv->scan(dev);
|
||||
return err;
|
||||
}
|
||||
|
||||
static int mbus_dev_remove(struct device *d)
|
||||
{
|
||||
struct mbus_device *dev = dev_to_mbus(d);
|
||||
struct mbus_driver *drv = drv_to_mbus(dev->dev.driver);
|
||||
|
||||
drv->remove(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct bus_type mic_bus = {
|
||||
.name = "mic_bus",
|
||||
.match = mbus_dev_match,
|
||||
.dev_groups = mbus_dev_groups,
|
||||
.uevent = mbus_uevent,
|
||||
.probe = mbus_dev_probe,
|
||||
.remove = mbus_dev_remove,
|
||||
};
|
||||
|
||||
int mbus_register_driver(struct mbus_driver *driver)
|
||||
{
|
||||
driver->driver.bus = &mic_bus;
|
||||
return driver_register(&driver->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mbus_register_driver);
|
||||
|
||||
void mbus_unregister_driver(struct mbus_driver *driver)
|
||||
{
|
||||
driver_unregister(&driver->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mbus_unregister_driver);
|
||||
|
||||
static void mbus_release_dev(struct device *d)
|
||||
{
|
||||
struct mbus_device *mbdev = dev_to_mbus(d);
|
||||
kfree(mbdev);
|
||||
}
|
||||
|
||||
struct mbus_device *
|
||||
mbus_register_device(struct device *pdev, int id, const struct dma_map_ops *dma_ops,
|
||||
struct mbus_hw_ops *hw_ops, int index,
|
||||
void __iomem *mmio_va)
|
||||
{
|
||||
int ret;
|
||||
struct mbus_device *mbdev;
|
||||
|
||||
mbdev = kzalloc(sizeof(*mbdev), GFP_KERNEL);
|
||||
if (!mbdev)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
mbdev->mmio_va = mmio_va;
|
||||
mbdev->dev.parent = pdev;
|
||||
mbdev->id.device = id;
|
||||
mbdev->id.vendor = MBUS_DEV_ANY_ID;
|
||||
mbdev->dev.dma_ops = dma_ops;
|
||||
mbdev->dev.dma_mask = &mbdev->dev.coherent_dma_mask;
|
||||
dma_set_mask(&mbdev->dev, DMA_BIT_MASK(64));
|
||||
mbdev->dev.release = mbus_release_dev;
|
||||
mbdev->hw_ops = hw_ops;
|
||||
mbdev->dev.bus = &mic_bus;
|
||||
mbdev->index = index;
|
||||
dev_set_name(&mbdev->dev, "mbus-dev%u", mbdev->index);
|
||||
/*
|
||||
* device_register() causes the bus infrastructure to look for a
|
||||
* matching driver.
|
||||
*/
|
||||
ret = device_register(&mbdev->dev);
|
||||
if (ret)
|
||||
goto free_mbdev;
|
||||
return mbdev;
|
||||
free_mbdev:
|
||||
put_device(&mbdev->dev);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mbus_register_device);
|
||||
|
||||
void mbus_unregister_device(struct mbus_device *mbdev)
|
||||
{
|
||||
device_unregister(&mbdev->dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(mbus_unregister_device);
|
||||
|
||||
static int __init mbus_init(void)
|
||||
{
|
||||
return bus_register(&mic_bus);
|
||||
}
|
||||
|
||||
static void __exit mbus_exit(void)
|
||||
{
|
||||
bus_unregister(&mic_bus);
|
||||
}
|
||||
|
||||
core_initcall(mbus_init);
|
||||
module_exit(mbus_exit);
|
||||
|
||||
MODULE_AUTHOR("Intel Corporation");
|
||||
MODULE_DESCRIPTION("Intel(R) MIC Bus driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
@@ -1,201 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Intel MIC Platform Software Stack (MPSS)
|
||||
*
|
||||
* Copyright(c) 2014 Intel Corporation.
|
||||
*
|
||||
* Intel Symmetric Communications Interface Bus driver.
|
||||
*/
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/dma-map-ops.h>
|
||||
|
||||
#include "scif_bus.h"
|
||||
|
||||
static ssize_t device_show(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct scif_hw_dev *dev = dev_to_scif(d);
|
||||
|
||||
return sprintf(buf, "0x%04x\n", dev->id.device);
|
||||
}
|
||||
static DEVICE_ATTR_RO(device);
|
||||
|
||||
static ssize_t vendor_show(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct scif_hw_dev *dev = dev_to_scif(d);
|
||||
|
||||
return sprintf(buf, "0x%04x\n", dev->id.vendor);
|
||||
}
|
||||
static DEVICE_ATTR_RO(vendor);
|
||||
|
||||
static ssize_t modalias_show(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct scif_hw_dev *dev = dev_to_scif(d);
|
||||
|
||||
return sprintf(buf, "scif:d%08Xv%08X\n",
|
||||
dev->id.device, dev->id.vendor);
|
||||
}
|
||||
static DEVICE_ATTR_RO(modalias);
|
||||
|
||||
static struct attribute *scif_dev_attrs[] = {
|
||||
&dev_attr_device.attr,
|
||||
&dev_attr_vendor.attr,
|
||||
&dev_attr_modalias.attr,
|
||||
NULL,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(scif_dev);
|
||||
|
||||
static inline int scif_id_match(const struct scif_hw_dev *dev,
|
||||
const struct scif_hw_dev_id *id)
|
||||
{
|
||||
if (id->device != dev->id.device && id->device != SCIF_DEV_ANY_ID)
|
||||
return 0;
|
||||
|
||||
return id->vendor == SCIF_DEV_ANY_ID || id->vendor == dev->id.vendor;
|
||||
}
|
||||
|
||||
/*
|
||||
* This looks through all the IDs a driver claims to support. If any of them
|
||||
* match, we return 1 and the kernel will call scif_dev_probe().
|
||||
*/
|
||||
static int scif_dev_match(struct device *dv, struct device_driver *dr)
|
||||
{
|
||||
unsigned int i;
|
||||
struct scif_hw_dev *dev = dev_to_scif(dv);
|
||||
const struct scif_hw_dev_id *ids;
|
||||
|
||||
ids = drv_to_scif(dr)->id_table;
|
||||
for (i = 0; ids[i].device; i++)
|
||||
if (scif_id_match(dev, &ids[i]))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int scif_uevent(struct device *dv, struct kobj_uevent_env *env)
|
||||
{
|
||||
struct scif_hw_dev *dev = dev_to_scif(dv);
|
||||
|
||||
return add_uevent_var(env, "MODALIAS=scif:d%08Xv%08X",
|
||||
dev->id.device, dev->id.vendor);
|
||||
}
|
||||
|
||||
static int scif_dev_probe(struct device *d)
|
||||
{
|
||||
struct scif_hw_dev *dev = dev_to_scif(d);
|
||||
struct scif_driver *drv = drv_to_scif(dev->dev.driver);
|
||||
|
||||
return drv->probe(dev);
|
||||
}
|
||||
|
||||
static int scif_dev_remove(struct device *d)
|
||||
{
|
||||
struct scif_hw_dev *dev = dev_to_scif(d);
|
||||
struct scif_driver *drv = drv_to_scif(dev->dev.driver);
|
||||
|
||||
drv->remove(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct bus_type scif_bus = {
|
||||
.name = "scif_bus",
|
||||
.match = scif_dev_match,
|
||||
.dev_groups = scif_dev_groups,
|
||||
.uevent = scif_uevent,
|
||||
.probe = scif_dev_probe,
|
||||
.remove = scif_dev_remove,
|
||||
};
|
||||
|
||||
int scif_register_driver(struct scif_driver *driver)
|
||||
{
|
||||
driver->driver.bus = &scif_bus;
|
||||
return driver_register(&driver->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(scif_register_driver);
|
||||
|
||||
void scif_unregister_driver(struct scif_driver *driver)
|
||||
{
|
||||
driver_unregister(&driver->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(scif_unregister_driver);
|
||||
|
||||
static void scif_release_dev(struct device *d)
|
||||
{
|
||||
struct scif_hw_dev *sdev = dev_to_scif(d);
|
||||
|
||||
kfree(sdev);
|
||||
}
|
||||
|
||||
struct scif_hw_dev *
|
||||
scif_register_device(struct device *pdev, int id, const struct dma_map_ops *dma_ops,
|
||||
struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
|
||||
struct mic_mw *mmio, struct mic_mw *aper, void *dp,
|
||||
void __iomem *rdp, struct dma_chan **chan, int num_chan,
|
||||
bool card_rel_da)
|
||||
{
|
||||
int ret;
|
||||
struct scif_hw_dev *sdev;
|
||||
|
||||
sdev = kzalloc(sizeof(*sdev), GFP_KERNEL);
|
||||
if (!sdev)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
sdev->dev.parent = pdev;
|
||||
sdev->id.device = id;
|
||||
sdev->id.vendor = SCIF_DEV_ANY_ID;
|
||||
sdev->dev.dma_ops = dma_ops;
|
||||
sdev->dev.release = scif_release_dev;
|
||||
sdev->hw_ops = hw_ops;
|
||||
sdev->dnode = dnode;
|
||||
sdev->snode = snode;
|
||||
dev_set_drvdata(&sdev->dev, sdev);
|
||||
sdev->dev.bus = &scif_bus;
|
||||
sdev->mmio = mmio;
|
||||
sdev->aper = aper;
|
||||
sdev->dp = dp;
|
||||
sdev->rdp = rdp;
|
||||
sdev->dev.dma_mask = &sdev->dev.coherent_dma_mask;
|
||||
dma_set_mask(&sdev->dev, DMA_BIT_MASK(64));
|
||||
sdev->dma_ch = chan;
|
||||
sdev->num_dma_ch = num_chan;
|
||||
sdev->card_rel_da = card_rel_da;
|
||||
dev_set_name(&sdev->dev, "scif-dev%u", sdev->dnode);
|
||||
/*
|
||||
* device_register() causes the bus infrastructure to look for a
|
||||
* matching driver.
|
||||
*/
|
||||
ret = device_register(&sdev->dev);
|
||||
if (ret)
|
||||
goto free_sdev;
|
||||
return sdev;
|
||||
free_sdev:
|
||||
put_device(&sdev->dev);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(scif_register_device);
|
||||
|
||||
void scif_unregister_device(struct scif_hw_dev *sdev)
|
||||
{
|
||||
device_unregister(&sdev->dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(scif_unregister_device);
|
||||
|
||||
static int __init scif_init(void)
|
||||
{
|
||||
return bus_register(&scif_bus);
|
||||
}
|
||||
|
||||
static void __exit scif_exit(void)
|
||||
{
|
||||
bus_unregister(&scif_bus);
|
||||
}
|
||||
|
||||
core_initcall(scif_init);
|
||||
module_exit(scif_exit);
|
||||
|
||||
MODULE_AUTHOR("Intel Corporation");
|
||||
MODULE_DESCRIPTION("Intel(R) SCIF Bus driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
@@ -1,125 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Intel MIC Platform Software Stack (MPSS)
|
||||
*
|
||||
* Copyright(c) 2014 Intel Corporation.
|
||||
*
|
||||
* Intel Symmetric Communications Interface Bus driver.
|
||||
*/
|
||||
#ifndef _SCIF_BUS_H_
|
||||
#define _SCIF_BUS_H_
|
||||
/*
|
||||
* Everything a scif driver needs to work with any particular scif
|
||||
* hardware abstraction layer.
|
||||
*/
|
||||
#include <linux/dma-map-ops.h>
|
||||
|
||||
#include <linux/mic_common.h>
|
||||
#include "../common/mic_dev.h"
|
||||
|
||||
struct scif_hw_dev_id {
|
||||
u32 device;
|
||||
u32 vendor;
|
||||
};
|
||||
|
||||
#define MIC_SCIF_DEV 1
|
||||
#define SCIF_DEV_ANY_ID 0xffffffff
|
||||
|
||||
/**
|
||||
* scif_hw_dev - representation of a hardware device abstracted for scif
|
||||
* @hw_ops: the hardware ops supported by this device
|
||||
* @id: the device type identification (used to match it with a driver)
|
||||
* @mmio: MMIO memory window
|
||||
* @aper: Aperture memory window
|
||||
* @dev: underlying device
|
||||
* @dnode - The destination node which this device will communicate with.
|
||||
* @snode - The source node for this device.
|
||||
* @dp - Self device page
|
||||
* @rdp - Remote device page
|
||||
* @dma_ch - Array of DMA channels
|
||||
* @num_dma_ch - Number of DMA channels available
|
||||
* @card_rel_da - Set to true if DMA addresses programmed in the DMA engine
|
||||
* are relative to the card point of view
|
||||
*/
|
||||
struct scif_hw_dev {
|
||||
struct scif_hw_ops *hw_ops;
|
||||
struct scif_hw_dev_id id;
|
||||
struct mic_mw *mmio;
|
||||
struct mic_mw *aper;
|
||||
struct device dev;
|
||||
u8 dnode;
|
||||
u8 snode;
|
||||
void *dp;
|
||||
void __iomem *rdp;
|
||||
struct dma_chan **dma_ch;
|
||||
int num_dma_ch;
|
||||
bool card_rel_da;
|
||||
};
|
||||
|
||||
/**
|
||||
* scif_driver - operations for a scif I/O driver
|
||||
* @driver: underlying device driver (populate name and owner).
|
||||
* @id_table: the ids serviced by this driver.
|
||||
* @probe: the function to call when a device is found. Returns 0 or -errno.
|
||||
* @remove: the function to call when a device is removed.
|
||||
*/
|
||||
struct scif_driver {
|
||||
struct device_driver driver;
|
||||
const struct scif_hw_dev_id *id_table;
|
||||
int (*probe)(struct scif_hw_dev *dev);
|
||||
void (*remove)(struct scif_hw_dev *dev);
|
||||
};
|
||||
|
||||
/**
|
||||
* scif_hw_ops - Hardware operations for accessing a SCIF device on the SCIF bus.
|
||||
*
|
||||
* @next_db: Obtain the next available doorbell.
|
||||
* @request_irq: Request an interrupt on a particular doorbell.
|
||||
* @free_irq: Free an interrupt requested previously.
|
||||
* @ack_interrupt: acknowledge an interrupt in the ISR.
|
||||
* @send_intr: Send an interrupt to the remote node on a specified doorbell.
|
||||
* @send_p2p_intr: Send an interrupt to the peer node on a specified doorbell
|
||||
* which is specifically targeted for a peer to peer node.
|
||||
* @remap: Map a buffer with the specified physical address and length.
|
||||
* @unmap: Unmap a buffer previously mapped.
|
||||
*/
|
||||
struct scif_hw_ops {
|
||||
int (*next_db)(struct scif_hw_dev *sdev);
|
||||
struct mic_irq * (*request_irq)(struct scif_hw_dev *sdev,
|
||||
irqreturn_t (*func)(int irq,
|
||||
void *data),
|
||||
const char *name, void *data,
|
||||
int db);
|
||||
void (*free_irq)(struct scif_hw_dev *sdev,
|
||||
struct mic_irq *cookie, void *data);
|
||||
void (*ack_interrupt)(struct scif_hw_dev *sdev, int num);
|
||||
void (*send_intr)(struct scif_hw_dev *sdev, int db);
|
||||
void (*send_p2p_intr)(struct scif_hw_dev *sdev, int db,
|
||||
struct mic_mw *mw);
|
||||
void __iomem * (*remap)(struct scif_hw_dev *sdev,
|
||||
phys_addr_t pa, size_t len);
|
||||
void (*unmap)(struct scif_hw_dev *sdev, void __iomem *va);
|
||||
};
|
||||
|
||||
int scif_register_driver(struct scif_driver *driver);
|
||||
void scif_unregister_driver(struct scif_driver *driver);
|
||||
struct scif_hw_dev *
|
||||
scif_register_device(struct device *pdev, int id,
|
||||
const struct dma_map_ops *dma_ops,
|
||||
struct scif_hw_ops *hw_ops, u8 dnode, u8 snode,
|
||||
struct mic_mw *mmio, struct mic_mw *aper,
|
||||
void *dp, void __iomem *rdp,
|
||||
struct dma_chan **chan, int num_chan,
|
||||
bool card_rel_da);
|
||||
void scif_unregister_device(struct scif_hw_dev *sdev);
|
||||
|
||||
static inline struct scif_hw_dev *dev_to_scif(struct device *dev)
|
||||
{
|
||||
return container_of(dev, struct scif_hw_dev, dev);
|
||||
}
|
||||
|
||||
static inline struct scif_driver *drv_to_scif(struct device_driver *drv)
|
||||
{
|
||||
return container_of(drv, struct scif_driver, driver);
|
||||
}
|
||||
#endif /* _SCIF_BUS_H */
|
||||
@@ -1,194 +0,0 @@
|
||||
// SPDX-License-Identifier: GPL-2.0-only
|
||||
/*
|
||||
* Intel MIC Platform Software Stack (MPSS)
|
||||
*
|
||||
* Copyright(c) 2016 Intel Corporation.
|
||||
*
|
||||
* Intel Virtio Over PCIe (VOP) Bus driver.
|
||||
*/
|
||||
#include <linux/slab.h>
|
||||
#include <linux/module.h>
|
||||
#include <linux/idr.h>
|
||||
#include <linux/dma-map-ops.h>
|
||||
|
||||
#include "vop_bus.h"
|
||||
|
||||
static ssize_t device_show(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct vop_device *dev = dev_to_vop(d);
|
||||
|
||||
return sprintf(buf, "0x%04x\n", dev->id.device);
|
||||
}
|
||||
static DEVICE_ATTR_RO(device);
|
||||
|
||||
static ssize_t vendor_show(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct vop_device *dev = dev_to_vop(d);
|
||||
|
||||
return sprintf(buf, "0x%04x\n", dev->id.vendor);
|
||||
}
|
||||
static DEVICE_ATTR_RO(vendor);
|
||||
|
||||
static ssize_t modalias_show(struct device *d,
|
||||
struct device_attribute *attr, char *buf)
|
||||
{
|
||||
struct vop_device *dev = dev_to_vop(d);
|
||||
|
||||
return sprintf(buf, "vop:d%08Xv%08X\n",
|
||||
dev->id.device, dev->id.vendor);
|
||||
}
|
||||
static DEVICE_ATTR_RO(modalias);
|
||||
|
||||
static struct attribute *vop_dev_attrs[] = {
|
||||
&dev_attr_device.attr,
|
||||
&dev_attr_vendor.attr,
|
||||
&dev_attr_modalias.attr,
|
||||
NULL,
|
||||
};
|
||||
ATTRIBUTE_GROUPS(vop_dev);
|
||||
|
||||
static inline int vop_id_match(const struct vop_device *dev,
|
||||
const struct vop_device_id *id)
|
||||
{
|
||||
if (id->device != dev->id.device && id->device != VOP_DEV_ANY_ID)
|
||||
return 0;
|
||||
|
||||
return id->vendor == VOP_DEV_ANY_ID || id->vendor == dev->id.vendor;
|
||||
}
|
||||
|
||||
/*
|
||||
* This looks through all the IDs a driver claims to support. If any of them
|
||||
* match, we return 1 and the kernel will call vop_dev_probe().
|
||||
*/
|
||||
static int vop_dev_match(struct device *dv, struct device_driver *dr)
|
||||
{
|
||||
unsigned int i;
|
||||
struct vop_device *dev = dev_to_vop(dv);
|
||||
const struct vop_device_id *ids;
|
||||
|
||||
ids = drv_to_vop(dr)->id_table;
|
||||
for (i = 0; ids[i].device; i++)
|
||||
if (vop_id_match(dev, &ids[i]))
|
||||
return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int vop_uevent(struct device *dv, struct kobj_uevent_env *env)
|
||||
{
|
||||
struct vop_device *dev = dev_to_vop(dv);
|
||||
|
||||
return add_uevent_var(env, "MODALIAS=vop:d%08Xv%08X",
|
||||
dev->id.device, dev->id.vendor);
|
||||
}
|
||||
|
||||
static int vop_dev_probe(struct device *d)
|
||||
{
|
||||
struct vop_device *dev = dev_to_vop(d);
|
||||
struct vop_driver *drv = drv_to_vop(dev->dev.driver);
|
||||
|
||||
return drv->probe(dev);
|
||||
}
|
||||
|
||||
static int vop_dev_remove(struct device *d)
|
||||
{
|
||||
struct vop_device *dev = dev_to_vop(d);
|
||||
struct vop_driver *drv = drv_to_vop(dev->dev.driver);
|
||||
|
||||
drv->remove(dev);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct bus_type vop_bus = {
|
||||
.name = "vop_bus",
|
||||
.match = vop_dev_match,
|
||||
.dev_groups = vop_dev_groups,
|
||||
.uevent = vop_uevent,
|
||||
.probe = vop_dev_probe,
|
||||
.remove = vop_dev_remove,
|
||||
};
|
||||
|
||||
int vop_register_driver(struct vop_driver *driver)
|
||||
{
|
||||
driver->driver.bus = &vop_bus;
|
||||
return driver_register(&driver->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vop_register_driver);
|
||||
|
||||
void vop_unregister_driver(struct vop_driver *driver)
|
||||
{
|
||||
driver_unregister(&driver->driver);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vop_unregister_driver);
|
||||
|
||||
static void vop_release_dev(struct device *d)
|
||||
{
|
||||
struct vop_device *dev = dev_to_vop(d);
|
||||
|
||||
kfree(dev);
|
||||
}
|
||||
|
||||
struct vop_device *
|
||||
vop_register_device(struct device *pdev, int id,
|
||||
const struct dma_map_ops *dma_ops,
|
||||
struct vop_hw_ops *hw_ops, u8 dnode, struct mic_mw *aper,
|
||||
struct dma_chan *chan)
|
||||
{
|
||||
int ret;
|
||||
struct vop_device *vdev;
|
||||
|
||||
vdev = kzalloc(sizeof(*vdev), GFP_KERNEL);
|
||||
if (!vdev)
|
||||
return ERR_PTR(-ENOMEM);
|
||||
|
||||
vdev->dev.parent = pdev;
|
||||
vdev->id.device = id;
|
||||
vdev->id.vendor = VOP_DEV_ANY_ID;
|
||||
vdev->dev.dma_ops = dma_ops;
|
||||
vdev->dev.dma_mask = &vdev->dev.coherent_dma_mask;
|
||||
dma_set_mask(&vdev->dev, DMA_BIT_MASK(64));
|
||||
vdev->dev.release = vop_release_dev;
|
||||
vdev->hw_ops = hw_ops;
|
||||
vdev->dev.bus = &vop_bus;
|
||||
vdev->dnode = dnode;
|
||||
vdev->aper = aper;
|
||||
vdev->dma_ch = chan;
|
||||
vdev->index = dnode - 1;
|
||||
dev_set_name(&vdev->dev, "vop-dev%u", vdev->index);
|
||||
/*
|
||||
* device_register() causes the bus infrastructure to look for a
|
||||
* matching driver.
|
||||
*/
|
||||
ret = device_register(&vdev->dev);
|
||||
if (ret)
|
||||
goto free_vdev;
|
||||
return vdev;
|
||||
free_vdev:
|
||||
put_device(&vdev->dev);
|
||||
return ERR_PTR(ret);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vop_register_device);
|
||||
|
||||
void vop_unregister_device(struct vop_device *dev)
|
||||
{
|
||||
device_unregister(&dev->dev);
|
||||
}
|
||||
EXPORT_SYMBOL_GPL(vop_unregister_device);
|
||||
|
||||
static int __init vop_init(void)
|
||||
{
|
||||
return bus_register(&vop_bus);
|
||||
}
|
||||
|
||||
static void __exit vop_exit(void)
|
||||
{
|
||||
bus_unregister(&vop_bus);
|
||||
}
|
||||
|
||||
core_initcall(vop_init);
|
||||
module_exit(vop_exit);
|
||||
|
||||
MODULE_AUTHOR("Intel Corporation");
|
||||
MODULE_DESCRIPTION("Intel(R) VOP Bus driver");
|
||||
MODULE_LICENSE("GPL v2");
|
||||
@@ -1,129 +0,0 @@
|
||||
/* SPDX-License-Identifier: GPL-2.0-only */
|
||||
/*
|
||||
* Intel MIC Platform Software Stack (MPSS)
|
||||
*
|
||||
* Copyright(c) 2016 Intel Corporation.
|
||||
*
|
||||
* Intel Virtio over PCIe Bus driver.
|
||||
*/
|
||||
#ifndef _VOP_BUS_H_
|
||||
#define _VOP_BUS_H_
|
||||
/*
|
||||
* Everything a vop driver needs to work with any particular vop
|
||||
* implementation.
|
||||
*/
|
||||
#include <linux/dmaengine.h>
|
||||
#include <linux/interrupt.h>
|
||||
|
||||
#include "../common/mic_dev.h"
|
||||
|
||||
struct vop_device_id {
|
||||
u32 device;
|
||||
u32 vendor;
|
||||
};
|
||||
|
||||
#define VOP_DEV_TRNSP 1
|
||||
#define VOP_DEV_ANY_ID 0xffffffff
|
||||
/*
|
||||
* Size of the internal buffer used during DMA's as an intermediate buffer
|
||||
* for copy to/from user. Must be an integral number of pages.
|
||||
*/
|
||||
#define VOP_INT_DMA_BUF_SIZE PAGE_ALIGN(64 * 1024ULL)
|
||||
|
||||
/**
|
||||
* vop_device - representation of a device using vop
|
||||
* @hw_ops: the hardware ops supported by this device.
|
||||
* @id: the device type identification (used to match it with a driver).
|
||||
* @dev: underlying device.
|
||||
* @dnode - The destination node which this device will communicate with.
|
||||
* @aper: Aperture memory window
|
||||
* @dma_ch - DMA channel
|
||||
* @index: unique position on the vop bus
|
||||
*/
|
||||
struct vop_device {
|
||||
struct vop_hw_ops *hw_ops;
|
||||
struct vop_device_id id;
|
||||
struct device dev;
|
||||
u8 dnode;
|
||||
struct mic_mw *aper;
|
||||
struct dma_chan *dma_ch;
|
||||
int index;
|
||||
};
|
||||
|
||||
/**
|
||||
* vop_driver - operations for a vop I/O driver
|
||||
* @driver: underlying device driver (populate name and owner).
|
||||
* @id_table: the ids serviced by this driver.
|
||||
* @probe: the function to call when a device is found. Returns 0 or -errno.
|
||||
* @remove: the function to call when a device is removed.
|
||||
*/
|
||||
struct vop_driver {
|
||||
struct device_driver driver;
|
||||
const struct vop_device_id *id_table;
|
||||
int (*probe)(struct vop_device *dev);
|
||||
void (*remove)(struct vop_device *dev);
|
||||
};
|
||||
|
||||
/**
|
||||
* vop_hw_ops - Hardware operations for accessing a VOP device on the VOP bus.
|
||||
*
|
||||
* @next_db: Obtain the next available doorbell.
|
||||
* @request_irq: Request an interrupt on a particular doorbell.
|
||||
* @free_irq: Free an interrupt requested previously.
|
||||
* @ack_interrupt: acknowledge an interrupt in the ISR.
|
||||
* @get_remote_dp: Get access to the virtio device page used by the remote
|
||||
* node to add/remove/configure virtio devices.
|
||||
* @get_dp: Get access to the virtio device page used by the self
|
||||
* node to add/remove/configure virtio devices.
|
||||
* @send_intr: Send an interrupt to the peer node on a specified doorbell.
|
||||
* @remap: Map a buffer with the specified DMA address and length.
|
||||
* @unmap: Unmap a buffer previously mapped.
|
||||
* @dma_filter: The DMA filter function to use for obtaining access to
|
||||
* a DMA channel on the peer node.
|
||||
*/
|
||||
struct vop_hw_ops {
|
||||
int (*next_db)(struct vop_device *vpdev);
|
||||
struct mic_irq *(*request_irq)(struct vop_device *vpdev,
|
||||
irqreturn_t (*func)(int irq, void *data),
|
||||
const char *name, void *data,
|
||||
int intr_src);
|
||||
void (*free_irq)(struct vop_device *vpdev,
|
||||
struct mic_irq *cookie, void *data);
|
||||
void (*ack_interrupt)(struct vop_device *vpdev, int num);
|
||||
void __iomem * (*get_remote_dp)(struct vop_device *vpdev);
|
||||
void * (*get_dp)(struct vop_device *vpdev);
|
||||
void (*send_intr)(struct vop_device *vpdev, int db);
|
||||
void __iomem * (*remap)(struct vop_device *vpdev,
|
||||
dma_addr_t pa, size_t len);
|
||||
void (*unmap)(struct vop_device *vpdev, void __iomem *va);
|
||||
};
|
||||
|
||||
struct vop_device *
|
||||
vop_register_device(struct device *pdev, int id,
|
||||
const struct dma_map_ops *dma_ops,
|
||||
struct vop_hw_ops *hw_ops, u8 dnode, struct mic_mw *aper,
|
||||
struct dma_chan *chan);
|
||||
void vop_unregister_device(struct vop_device *dev);
|
||||
int vop_register_driver(struct vop_driver *drv);
|
||||
void vop_unregister_driver(struct vop_driver *drv);
|
||||
|
||||
/*
|
||||
* module_vop_driver() - Helper macro for drivers that don't do
|
||||
* anything special in module init/exit. This eliminates a lot of
|
||||
* boilerplate. Each module may only use this macro once, and
|
||||
* calling it replaces module_init() and module_exit()
|
||||
*/
|
||||
#define module_vop_driver(__vop_driver) \
|
||||
module_driver(__vop_driver, vop_register_driver, \
|
||||
vop_unregister_driver)
|
||||
|
||||
static inline struct vop_device *dev_to_vop(struct device *dev)
|
||||
{
|
||||
return container_of(dev, struct vop_device, dev);
|
||||
}
|
||||
|
||||
static inline struct vop_driver *drv_to_vop(struct device_driver *drv)
|
||||
{
|
||||
return container_of(drv, struct vop_driver, driver);
|
||||
}
|
||||
#endif /* _VOP_BUS_H */
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user