misc: mic: cleanups for "--strict" checkpatch.
These changes were mostly authored by Joe Perches <joe@perches.com> @ https://lkml.org/lkml/2013/9/5/602 Reported-by: Joe Perches <joe@perches.com> Signed-off-by: Ashutosh Dixit <ashutosh.dixit@intel.com> Signed-off-by: Dasaratharaman Chandramouli <dasaratharaman.chandramouli@intel.com> Signed-off-by: Nikhil Rao <nikhil.rao@intel.com> Signed-off-by: Harshavardhan R Kharche <harshavardhan.r.kharche@intel.com> Signed-off-by: Sudeep Dutt <sudeep.dutt@intel.com> Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
This commit is contained in:
parent
4aa79961a5
commit
ced2c60fb5
12 changed files with 158 additions and 167 deletions
|
@ -246,7 +246,7 @@ static int tun_alloc(struct mic_info *mic, char *dev)
|
||||||
if (*dev)
|
if (*dev)
|
||||||
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
|
strncpy(ifr.ifr_name, dev, IFNAMSIZ);
|
||||||
|
|
||||||
err = ioctl(fd, TUNSETIFF, (void *) &ifr);
|
err = ioctl(fd, TUNSETIFF, (void *)&ifr);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
mpsslog("%s %s %d TUNSETIFF failed %s\n",
|
mpsslog("%s %s %d TUNSETIFF failed %s\n",
|
||||||
mic->name, __func__, __LINE__, strerror(errno));
|
mic->name, __func__, __LINE__, strerror(errno));
|
||||||
|
@ -363,7 +363,7 @@ static inline void verify_out_len(struct mic_info *mic,
|
||||||
{
|
{
|
||||||
if (copy->out_len != sum_iovec_len(copy)) {
|
if (copy->out_len != sum_iovec_len(copy)) {
|
||||||
mpsslog("%s %s %d BUG copy->out_len 0x%x len 0x%x\n",
|
mpsslog("%s %s %d BUG copy->out_len 0x%x len 0x%x\n",
|
||||||
mic->name, __func__, __LINE__,
|
mic->name, __func__, __LINE__,
|
||||||
copy->out_len, sum_iovec_len(copy));
|
copy->out_len, sum_iovec_len(copy));
|
||||||
assert(copy->out_len == sum_iovec_len(copy));
|
assert(copy->out_len == sum_iovec_len(copy));
|
||||||
}
|
}
|
||||||
|
@ -372,7 +372,7 @@ static inline void verify_out_len(struct mic_info *mic,
|
||||||
/* Display an iovec */
|
/* Display an iovec */
|
||||||
static void
|
static void
|
||||||
disp_iovec(struct mic_info *mic, struct mic_copy_desc *copy,
|
disp_iovec(struct mic_info *mic, struct mic_copy_desc *copy,
|
||||||
const char *s, int line)
|
const char *s, int line)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
|
@ -401,7 +401,7 @@ static inline void txrx_prepare(int type, bool tx, struct mic_vring *vr,
|
||||||
/* Central API which triggers the copies */
|
/* Central API which triggers the copies */
|
||||||
static int
|
static int
|
||||||
mic_virtio_copy(struct mic_info *mic, int fd,
|
mic_virtio_copy(struct mic_info *mic, int fd,
|
||||||
struct mic_vring *vr, struct mic_copy_desc *copy)
|
struct mic_vring *vr, struct mic_copy_desc *copy)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
|
@ -440,7 +440,7 @@ init_vr(struct mic_info *mic, int fd, int type,
|
||||||
vr0->info = vr0->va +
|
vr0->info = vr0->va +
|
||||||
vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN);
|
vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN);
|
||||||
vring_init(&vr0->vr,
|
vring_init(&vr0->vr,
|
||||||
MIC_VRING_ENTRIES, vr0->va, MIC_VIRTIO_RING_ALIGN);
|
MIC_VRING_ENTRIES, vr0->va, MIC_VIRTIO_RING_ALIGN);
|
||||||
mpsslog("%s %s vr0 %p vr0->info %p vr_size 0x%x vring 0x%x ",
|
mpsslog("%s %s vr0 %p vr0->info %p vr_size 0x%x vring 0x%x ",
|
||||||
__func__, mic->name, vr0->va, vr0->info, vr_size,
|
__func__, mic->name, vr0->va, vr0->info, vr_size,
|
||||||
vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN));
|
vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN));
|
||||||
|
@ -453,7 +453,7 @@ init_vr(struct mic_info *mic, int fd, int type,
|
||||||
vr1->info = vr1->va + vring_size(MIC_VRING_ENTRIES,
|
vr1->info = vr1->va + vring_size(MIC_VRING_ENTRIES,
|
||||||
MIC_VIRTIO_RING_ALIGN);
|
MIC_VIRTIO_RING_ALIGN);
|
||||||
vring_init(&vr1->vr,
|
vring_init(&vr1->vr,
|
||||||
MIC_VRING_ENTRIES, vr1->va, MIC_VIRTIO_RING_ALIGN);
|
MIC_VRING_ENTRIES, vr1->va, MIC_VIRTIO_RING_ALIGN);
|
||||||
mpsslog("%s %s vr1 %p vr1->info %p vr_size 0x%x vring 0x%x ",
|
mpsslog("%s %s vr1 %p vr1->info %p vr_size 0x%x vring 0x%x ",
|
||||||
__func__, mic->name, vr1->va, vr1->info, vr_size,
|
__func__, mic->name, vr1->va, vr1->info, vr_size,
|
||||||
vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN));
|
vring_size(MIC_VRING_ENTRIES, MIC_VIRTIO_RING_ALIGN));
|
||||||
|
@ -551,7 +551,7 @@ virtio_net(void *arg)
|
||||||
net_poll[NET_FD_TUN].events = POLLIN;
|
net_poll[NET_FD_TUN].events = POLLIN;
|
||||||
|
|
||||||
if (MAP_FAILED == init_vr(mic, mic->mic_net.virtio_net_fd,
|
if (MAP_FAILED == init_vr(mic, mic->mic_net.virtio_net_fd,
|
||||||
VIRTIO_ID_NET, &tx_vr, &rx_vr,
|
VIRTIO_ID_NET, &tx_vr, &rx_vr,
|
||||||
virtnet_dev_page.dd.num_vq)) {
|
virtnet_dev_page.dd.num_vq)) {
|
||||||
mpsslog("%s init_vr failed %s\n",
|
mpsslog("%s init_vr failed %s\n",
|
||||||
mic->name, strerror(errno));
|
mic->name, strerror(errno));
|
||||||
|
@ -576,7 +576,7 @@ virtio_net(void *arg)
|
||||||
}
|
}
|
||||||
if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK))
|
if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK))
|
||||||
wait_for_card_driver(mic, mic->mic_net.virtio_net_fd,
|
wait_for_card_driver(mic, mic->mic_net.virtio_net_fd,
|
||||||
VIRTIO_ID_NET);
|
VIRTIO_ID_NET);
|
||||||
/*
|
/*
|
||||||
* Check if there is data to be read from TUN and write to
|
* Check if there is data to be read from TUN and write to
|
||||||
* virtio net fd if there is.
|
* virtio net fd if there is.
|
||||||
|
@ -587,7 +587,7 @@ virtio_net(void *arg)
|
||||||
copy.iov, copy.iovcnt);
|
copy.iov, copy.iovcnt);
|
||||||
if (len > 0) {
|
if (len > 0) {
|
||||||
struct virtio_net_hdr *hdr
|
struct virtio_net_hdr *hdr
|
||||||
= (struct virtio_net_hdr *) vnet_hdr[0];
|
= (struct virtio_net_hdr *)vnet_hdr[0];
|
||||||
|
|
||||||
/* Disable checksums on the card since we are on
|
/* Disable checksums on the card since we are on
|
||||||
a reliable PCIe link */
|
a reliable PCIe link */
|
||||||
|
@ -606,7 +606,7 @@ virtio_net(void *arg)
|
||||||
#endif
|
#endif
|
||||||
spin_for_descriptors(mic, &tx_vr);
|
spin_for_descriptors(mic, &tx_vr);
|
||||||
txrx_prepare(VIRTIO_ID_NET, 1, &tx_vr, ©,
|
txrx_prepare(VIRTIO_ID_NET, 1, &tx_vr, ©,
|
||||||
len);
|
len);
|
||||||
|
|
||||||
err = mic_virtio_copy(mic,
|
err = mic_virtio_copy(mic,
|
||||||
mic->mic_net.virtio_net_fd, &tx_vr,
|
mic->mic_net.virtio_net_fd, &tx_vr,
|
||||||
|
@ -644,7 +644,7 @@ virtio_net(void *arg)
|
||||||
le16toh(rx_vr.vr.avail->idx)) {
|
le16toh(rx_vr.vr.avail->idx)) {
|
||||||
copy.iov = iov1;
|
copy.iov = iov1;
|
||||||
txrx_prepare(VIRTIO_ID_NET, 0, &rx_vr, ©,
|
txrx_prepare(VIRTIO_ID_NET, 0, &rx_vr, ©,
|
||||||
MAX_NET_PKT_SIZE
|
MAX_NET_PKT_SIZE
|
||||||
+ sizeof(struct virtio_net_hdr));
|
+ sizeof(struct virtio_net_hdr));
|
||||||
|
|
||||||
err = mic_virtio_copy(mic,
|
err = mic_virtio_copy(mic,
|
||||||
|
@ -669,7 +669,7 @@ virtio_net(void *arg)
|
||||||
verify_out_len(mic, ©);
|
verify_out_len(mic, ©);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
disp_iovec(mic, copy, __func__,
|
disp_iovec(mic, copy, __func__,
|
||||||
__LINE__);
|
__LINE__);
|
||||||
mpsslog("%s %s %d ",
|
mpsslog("%s %s %d ",
|
||||||
mic->name, __func__, __LINE__);
|
mic->name, __func__, __LINE__);
|
||||||
mpsslog("read from net 0x%lx\n",
|
mpsslog("read from net 0x%lx\n",
|
||||||
|
@ -686,7 +686,7 @@ virtio_net(void *arg)
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
disp_iovec(mic, ©, __func__,
|
disp_iovec(mic, ©, __func__,
|
||||||
__LINE__);
|
__LINE__);
|
||||||
mpsslog("%s %s %d ",
|
mpsslog("%s %s %d ",
|
||||||
mic->name, __func__,
|
mic->name, __func__,
|
||||||
__LINE__);
|
__LINE__);
|
||||||
|
@ -750,13 +750,13 @@ virtio_console(void *arg)
|
||||||
err = grantpt(pty_fd);
|
err = grantpt(pty_fd);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
mpsslog("can't grant access: %s %s\n",
|
mpsslog("can't grant access: %s %s\n",
|
||||||
pts_name, strerror(errno));
|
pts_name, strerror(errno));
|
||||||
goto _close_pty;
|
goto _close_pty;
|
||||||
}
|
}
|
||||||
err = unlockpt(pty_fd);
|
err = unlockpt(pty_fd);
|
||||||
if (err < 0) {
|
if (err < 0) {
|
||||||
mpsslog("can't unlock a pseudoterminal: %s %s\n",
|
mpsslog("can't unlock a pseudoterminal: %s %s\n",
|
||||||
pts_name, strerror(errno));
|
pts_name, strerror(errno));
|
||||||
goto _close_pty;
|
goto _close_pty;
|
||||||
}
|
}
|
||||||
console_poll[MONITOR_FD].fd = pty_fd;
|
console_poll[MONITOR_FD].fd = pty_fd;
|
||||||
|
@ -766,7 +766,7 @@ virtio_console(void *arg)
|
||||||
console_poll[VIRTIO_CONSOLE_FD].events = POLLIN;
|
console_poll[VIRTIO_CONSOLE_FD].events = POLLIN;
|
||||||
|
|
||||||
if (MAP_FAILED == init_vr(mic, mic->mic_console.virtio_console_fd,
|
if (MAP_FAILED == init_vr(mic, mic->mic_console.virtio_console_fd,
|
||||||
VIRTIO_ID_CONSOLE, &tx_vr, &rx_vr,
|
VIRTIO_ID_CONSOLE, &tx_vr, &rx_vr,
|
||||||
virtcons_dev_page.dd.num_vq)) {
|
virtcons_dev_page.dd.num_vq)) {
|
||||||
mpsslog("%s init_vr failed %s\n",
|
mpsslog("%s init_vr failed %s\n",
|
||||||
mic->name, strerror(errno));
|
mic->name, strerror(errno));
|
||||||
|
@ -787,7 +787,7 @@ virtio_console(void *arg)
|
||||||
}
|
}
|
||||||
if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK))
|
if (!(desc->status & VIRTIO_CONFIG_S_DRIVER_OK))
|
||||||
wait_for_card_driver(mic,
|
wait_for_card_driver(mic,
|
||||||
mic->mic_console.virtio_console_fd,
|
mic->mic_console.virtio_console_fd,
|
||||||
VIRTIO_ID_CONSOLE);
|
VIRTIO_ID_CONSOLE);
|
||||||
|
|
||||||
if (console_poll[MONITOR_FD].revents & POLLIN) {
|
if (console_poll[MONITOR_FD].revents & POLLIN) {
|
||||||
|
@ -802,7 +802,7 @@ virtio_console(void *arg)
|
||||||
#endif
|
#endif
|
||||||
spin_for_descriptors(mic, &tx_vr);
|
spin_for_descriptors(mic, &tx_vr);
|
||||||
txrx_prepare(VIRTIO_ID_CONSOLE, 1, &tx_vr,
|
txrx_prepare(VIRTIO_ID_CONSOLE, 1, &tx_vr,
|
||||||
©, len);
|
©, len);
|
||||||
|
|
||||||
err = mic_virtio_copy(mic,
|
err = mic_virtio_copy(mic,
|
||||||
mic->mic_console.virtio_console_fd,
|
mic->mic_console.virtio_console_fd,
|
||||||
|
@ -837,7 +837,7 @@ virtio_console(void *arg)
|
||||||
le16toh(rx_vr.vr.avail->idx)) {
|
le16toh(rx_vr.vr.avail->idx)) {
|
||||||
copy.iov = iov1;
|
copy.iov = iov1;
|
||||||
txrx_prepare(VIRTIO_ID_CONSOLE, 0, &rx_vr,
|
txrx_prepare(VIRTIO_ID_CONSOLE, 0, &rx_vr,
|
||||||
©, PAGE_SIZE);
|
©, PAGE_SIZE);
|
||||||
|
|
||||||
err = mic_virtio_copy(mic,
|
err = mic_virtio_copy(mic,
|
||||||
mic->mic_console.virtio_console_fd,
|
mic->mic_console.virtio_console_fd,
|
||||||
|
@ -848,7 +848,7 @@ virtio_console(void *arg)
|
||||||
verify_out_len(mic, ©);
|
verify_out_len(mic, ©);
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
disp_iovec(mic, copy, __func__,
|
disp_iovec(mic, copy, __func__,
|
||||||
__LINE__);
|
__LINE__);
|
||||||
mpsslog("%s %s %d ",
|
mpsslog("%s %s %d ",
|
||||||
mic->name, __func__, __LINE__);
|
mic->name, __func__, __LINE__);
|
||||||
mpsslog("read from net 0x%lx\n",
|
mpsslog("read from net 0x%lx\n",
|
||||||
|
@ -865,7 +865,7 @@ virtio_console(void *arg)
|
||||||
} else {
|
} else {
|
||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
disp_iovec(mic, copy, __func__,
|
disp_iovec(mic, copy, __func__,
|
||||||
__LINE__);
|
__LINE__);
|
||||||
mpsslog("%s %s %d ",
|
mpsslog("%s %s %d ",
|
||||||
mic->name, __func__,
|
mic->name, __func__,
|
||||||
__LINE__);
|
__LINE__);
|
||||||
|
@ -1033,7 +1033,8 @@ start_virtblk(struct mic_info *mic, struct mic_vring *vring)
|
||||||
}
|
}
|
||||||
add_virtio_device(mic, &virtblk_dev_page.dd);
|
add_virtio_device(mic, &virtblk_dev_page.dd);
|
||||||
if (MAP_FAILED == init_vr(mic, mic->mic_virtblk.virtio_block_fd,
|
if (MAP_FAILED == init_vr(mic, mic->mic_virtblk.virtio_block_fd,
|
||||||
VIRTIO_ID_BLOCK, vring, NULL, virtblk_dev_page.dd.num_vq)) {
|
VIRTIO_ID_BLOCK, vring, NULL,
|
||||||
|
virtblk_dev_page.dd.num_vq)) {
|
||||||
mpsslog("%s init_vr failed %s\n",
|
mpsslog("%s init_vr failed %s\n",
|
||||||
mic->name, strerror(errno));
|
mic->name, strerror(errno));
|
||||||
return false;
|
return false;
|
||||||
|
@ -1060,7 +1061,7 @@ header_error_check(struct vring_desc *desc)
|
||||||
{
|
{
|
||||||
if (le32toh(desc->len) != sizeof(struct virtio_blk_outhdr)) {
|
if (le32toh(desc->len) != sizeof(struct virtio_blk_outhdr)) {
|
||||||
mpsslog("%s() %d: length is not sizeof(virtio_blk_outhd)\n",
|
mpsslog("%s() %d: length is not sizeof(virtio_blk_outhd)\n",
|
||||||
__func__, __LINE__);
|
__func__, __LINE__);
|
||||||
return -EIO;
|
return -EIO;
|
||||||
}
|
}
|
||||||
if (!(le16toh(desc->flags) & VRING_DESC_F_NEXT)) {
|
if (!(le16toh(desc->flags) & VRING_DESC_F_NEXT)) {
|
||||||
|
@ -1132,7 +1133,7 @@ write_status(int fd, __u8 *status)
|
||||||
static void *
|
static void *
|
||||||
virtio_block(void *arg)
|
virtio_block(void *arg)
|
||||||
{
|
{
|
||||||
struct mic_info *mic = (struct mic_info *) arg;
|
struct mic_info *mic = (struct mic_info *)arg;
|
||||||
int ret;
|
int ret;
|
||||||
struct pollfd block_poll;
|
struct pollfd block_poll;
|
||||||
struct mic_vring vring;
|
struct mic_vring vring;
|
||||||
|
@ -1219,8 +1220,8 @@ virtio_block(void *arg)
|
||||||
status = 0;
|
status = 0;
|
||||||
fos = mic->mic_virtblk.backend_addr +
|
fos = mic->mic_virtblk.backend_addr +
|
||||||
(hdr.sector * SECTOR_SIZE);
|
(hdr.sector * SECTOR_SIZE);
|
||||||
buffer_desc_idx = desc_idx =
|
buffer_desc_idx = next_desc(desc);
|
||||||
next_desc(desc);
|
desc_idx = buffer_desc_idx;
|
||||||
for (desc = &vring.vr.desc[buffer_desc_idx];
|
for (desc = &vring.vr.desc[buffer_desc_idx];
|
||||||
desc->flags & VRING_DESC_F_NEXT;
|
desc->flags & VRING_DESC_F_NEXT;
|
||||||
desc_idx = next_desc(desc),
|
desc_idx = next_desc(desc),
|
||||||
|
@ -1255,7 +1256,7 @@ virtio_block(void *arg)
|
||||||
iovec,
|
iovec,
|
||||||
piov - iovec);
|
piov - iovec);
|
||||||
if (ret < 0 &&
|
if (ret < 0 &&
|
||||||
status != 0)
|
status != 0)
|
||||||
status = ret;
|
status = ret;
|
||||||
}
|
}
|
||||||
/* write status and update used pointer */
|
/* write status and update used pointer */
|
||||||
|
@ -1391,7 +1392,7 @@ mic_config(void *arg)
|
||||||
char value[4096];
|
char value[4096];
|
||||||
|
|
||||||
snprintf(pathname, PATH_MAX - 1, "%s/%s/%s",
|
snprintf(pathname, PATH_MAX - 1, "%s/%s/%s",
|
||||||
MICSYSFSDIR, mic->name, "state");
|
MICSYSFSDIR, mic->name, "state");
|
||||||
|
|
||||||
fd = open(pathname, O_RDONLY);
|
fd = open(pathname, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -1560,22 +1561,22 @@ init_mic(struct mic_info *mic)
|
||||||
virtio_console, mic);
|
virtio_console, mic);
|
||||||
if (err)
|
if (err)
|
||||||
mpsslog("%s virtcons pthread_create failed %s\n",
|
mpsslog("%s virtcons pthread_create failed %s\n",
|
||||||
mic->name, strerror(err));
|
mic->name, strerror(err));
|
||||||
err = pthread_create(&mic->mic_net.net_thread, NULL,
|
err = pthread_create(&mic->mic_net.net_thread, NULL,
|
||||||
virtio_net, mic);
|
virtio_net, mic);
|
||||||
if (err)
|
if (err)
|
||||||
mpsslog("%s virtnet pthread_create failed %s\n",
|
mpsslog("%s virtnet pthread_create failed %s\n",
|
||||||
mic->name, strerror(err));
|
mic->name, strerror(err));
|
||||||
err = pthread_create(&mic->mic_virtblk.block_thread, NULL,
|
err = pthread_create(&mic->mic_virtblk.block_thread, NULL,
|
||||||
virtio_block, mic);
|
virtio_block, mic);
|
||||||
if (err)
|
if (err)
|
||||||
mpsslog("%s virtblk pthread_create failed %s\n",
|
mpsslog("%s virtblk pthread_create failed %s\n",
|
||||||
mic->name, strerror(err));
|
mic->name, strerror(err));
|
||||||
sigemptyset(&act.sa_mask);
|
sigemptyset(&act.sa_mask);
|
||||||
err = sigaction(SIGUSR1, &act, NULL);
|
err = sigaction(SIGUSR1, &act, NULL);
|
||||||
if (err)
|
if (err)
|
||||||
mpsslog("%s sigaction SIGUSR1 failed %s\n",
|
mpsslog("%s sigaction SIGUSR1 failed %s\n",
|
||||||
mic->name, strerror(errno));
|
mic->name, strerror(errno));
|
||||||
while (1)
|
while (1)
|
||||||
sleep(60);
|
sleep(60);
|
||||||
case -1:
|
case -1:
|
||||||
|
|
|
@ -35,7 +35,7 @@ readsysfs(char *dir, char *entry)
|
||||||
snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry);
|
snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry);
|
||||||
else
|
else
|
||||||
snprintf(filename, PATH_MAX,
|
snprintf(filename, PATH_MAX,
|
||||||
"%s/%s/%s", MICSYSFSDIR, dir, entry);
|
"%s/%s/%s", MICSYSFSDIR, dir, entry);
|
||||||
|
|
||||||
fd = open(filename, O_RDONLY);
|
fd = open(filename, O_RDONLY);
|
||||||
if (fd < 0) {
|
if (fd < 0) {
|
||||||
|
@ -75,7 +75,7 @@ setsysfs(char *dir, char *entry, char *value)
|
||||||
snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry);
|
snprintf(filename, PATH_MAX, "%s/%s", MICSYSFSDIR, entry);
|
||||||
else
|
else
|
||||||
snprintf(filename, PATH_MAX, "%s/%s/%s",
|
snprintf(filename, PATH_MAX, "%s/%s/%s",
|
||||||
MICSYSFSDIR, dir, entry);
|
MICSYSFSDIR, dir, entry);
|
||||||
|
|
||||||
oldvalue = readsysfs(dir, entry);
|
oldvalue = readsysfs(dir, entry);
|
||||||
|
|
||||||
|
|
|
@ -167,7 +167,6 @@ struct mic_irq *mic_request_card_irq(irqreturn_t (*func)(int irq, void *data),
|
||||||
return (struct mic_irq *)cookie;
|
return (struct mic_irq *)cookie;
|
||||||
err:
|
err:
|
||||||
return ERR_PTR(rc);
|
return ERR_PTR(rc);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -103,7 +103,7 @@ static void mic_finalize_features(struct virtio_device *vdev)
|
||||||
for (i = 0; i < bits; i++) {
|
for (i = 0; i < bits; i++) {
|
||||||
if (test_bit(i, vdev->features))
|
if (test_bit(i, vdev->features))
|
||||||
iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)),
|
iowrite8(ioread8(&out_features[i / 8]) | (1 << (i % 8)),
|
||||||
&out_features[i / 8]);
|
&out_features[i / 8]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -197,10 +197,9 @@ static void mic_notify(struct virtqueue *vq)
|
||||||
static void mic_del_vq(struct virtqueue *vq, int n)
|
static void mic_del_vq(struct virtqueue *vq, int n)
|
||||||
{
|
{
|
||||||
struct mic_vdev *mvdev = to_micvdev(vq->vdev);
|
struct mic_vdev *mvdev = to_micvdev(vq->vdev);
|
||||||
struct vring *vr = (struct vring *) (vq + 1);
|
struct vring *vr = (struct vring *)(vq + 1);
|
||||||
|
|
||||||
free_pages((unsigned long) vr->used,
|
free_pages((unsigned long) vr->used, get_order(mvdev->used_size[n]));
|
||||||
get_order(mvdev->used_size[n]));
|
|
||||||
vring_del_virtqueue(vq);
|
vring_del_virtqueue(vq);
|
||||||
mic_card_unmap(mvdev->mdev, mvdev->vr[n]);
|
mic_card_unmap(mvdev->mdev, mvdev->vr[n]);
|
||||||
mvdev->vr[n] = NULL;
|
mvdev->vr[n] = NULL;
|
||||||
|
@ -274,8 +273,8 @@ static struct virtqueue *mic_find_vq(struct virtio_device *vdev,
|
||||||
/* Allocate and reassign used ring now */
|
/* Allocate and reassign used ring now */
|
||||||
mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 +
|
mvdev->used_size[index] = PAGE_ALIGN(sizeof(__u16) * 3 +
|
||||||
sizeof(struct vring_used_elem) * config.num);
|
sizeof(struct vring_used_elem) * config.num);
|
||||||
used = (void *) __get_free_pages(GFP_KERNEL | __GFP_ZERO,
|
used = (void *)__get_free_pages(GFP_KERNEL | __GFP_ZERO,
|
||||||
get_order(mvdev->used_size[index]));
|
get_order(mvdev->used_size[index]));
|
||||||
if (!used) {
|
if (!used) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
||||||
|
@ -291,7 +290,7 @@ static struct virtqueue *mic_find_vq(struct virtio_device *vdev,
|
||||||
* vring_new_virtqueue() would ensure that
|
* vring_new_virtqueue() would ensure that
|
||||||
* (&vq->vring == (struct vring *) (&vq->vq + 1));
|
* (&vq->vring == (struct vring *) (&vq->vq + 1));
|
||||||
*/
|
*/
|
||||||
vr = (struct vring *) (vq + 1);
|
vr = (struct vring *)(vq + 1);
|
||||||
vr->used = used;
|
vr->used = used;
|
||||||
|
|
||||||
vq->priv = mvdev;
|
vq->priv = mvdev;
|
||||||
|
@ -544,7 +543,7 @@ static void mic_scan_devices(struct mic_driver *mdrv, bool remove)
|
||||||
if (dev) {
|
if (dev) {
|
||||||
if (remove)
|
if (remove)
|
||||||
iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE,
|
iowrite8(MIC_VIRTIO_PARAM_DEV_REMOVE,
|
||||||
&dc->config_change);
|
&dc->config_change);
|
||||||
put_device(dev);
|
put_device(dev);
|
||||||
mic_handle_config_change(d, i, mdrv);
|
mic_handle_config_change(d, i, mdrv);
|
||||||
ret = mic_remove_device(d, i, mdrv);
|
ret = mic_remove_device(d, i, mdrv);
|
||||||
|
@ -559,7 +558,7 @@ static void mic_scan_devices(struct mic_driver *mdrv, bool remove)
|
||||||
|
|
||||||
/* new device */
|
/* new device */
|
||||||
dev_dbg(mdrv->dev, "%s %d Adding new virtio device %p\n",
|
dev_dbg(mdrv->dev, "%s %d Adding new virtio device %p\n",
|
||||||
__func__, __LINE__, d);
|
__func__, __LINE__, d);
|
||||||
if (!remove)
|
if (!remove)
|
||||||
mic_add_device(d, i, mdrv);
|
mic_add_device(d, i, mdrv);
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,8 +66,8 @@ void mic_send_intr(struct mic_device *mdev, int doorbell)
|
||||||
/* Ensure that the interrupt is ordered w.r.t previous stores. */
|
/* Ensure that the interrupt is ordered w.r.t previous stores. */
|
||||||
wmb();
|
wmb();
|
||||||
mic_mmio_write(mw, MIC_X100_SBOX_SDBIC0_DBREQ_BIT,
|
mic_mmio_write(mw, MIC_X100_SBOX_SDBIC0_DBREQ_BIT,
|
||||||
MIC_X100_SBOX_BASE_ADDRESS +
|
MIC_X100_SBOX_BASE_ADDRESS +
|
||||||
(MIC_X100_SBOX_SDBIC0 + (4 * doorbell)));
|
(MIC_X100_SBOX_SDBIC0 + (4 * doorbell)));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -103,7 +103,7 @@ static int mic_smpt_show(struct seq_file *s, void *pos)
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
|
|
||||||
seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n",
|
seq_printf(s, "MIC %-2d |%-10s| %-14s %-10s\n",
|
||||||
mdev->id, "SMPT entry", "SW DMA addr", "RefCount");
|
mdev->id, "SMPT entry", "SW DMA addr", "RefCount");
|
||||||
seq_puts(s, "====================================================\n");
|
seq_puts(s, "====================================================\n");
|
||||||
|
|
||||||
if (mdev->smpt) {
|
if (mdev->smpt) {
|
||||||
|
@ -111,8 +111,8 @@ static int mic_smpt_show(struct seq_file *s, void *pos)
|
||||||
spin_lock_irqsave(&smpt_info->smpt_lock, flags);
|
spin_lock_irqsave(&smpt_info->smpt_lock, flags);
|
||||||
for (i = 0; i < smpt_info->info.num_reg; i++) {
|
for (i = 0; i < smpt_info->info.num_reg; i++) {
|
||||||
seq_printf(s, "%9s|%-10d| %-#14llx %-10lld\n",
|
seq_printf(s, "%9s|%-10d| %-#14llx %-10lld\n",
|
||||||
" ", i, smpt_info->entry[i].dma_addr,
|
" ", i, smpt_info->entry[i].dma_addr,
|
||||||
smpt_info->entry[i].ref_count);
|
smpt_info->entry[i].ref_count);
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
|
spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
|
||||||
}
|
}
|
||||||
|
@ -203,17 +203,17 @@ static int mic_dp_show(struct seq_file *s, void *pos)
|
||||||
int i, j;
|
int i, j;
|
||||||
|
|
||||||
seq_printf(s, "Bootparam: magic 0x%x\n",
|
seq_printf(s, "Bootparam: magic 0x%x\n",
|
||||||
bootparam->magic);
|
bootparam->magic);
|
||||||
seq_printf(s, "Bootparam: h2c_shutdown_db %d\n",
|
seq_printf(s, "Bootparam: h2c_shutdown_db %d\n",
|
||||||
bootparam->h2c_shutdown_db);
|
bootparam->h2c_shutdown_db);
|
||||||
seq_printf(s, "Bootparam: h2c_config_db %d\n",
|
seq_printf(s, "Bootparam: h2c_config_db %d\n",
|
||||||
bootparam->h2c_config_db);
|
bootparam->h2c_config_db);
|
||||||
seq_printf(s, "Bootparam: c2h_shutdown_db %d\n",
|
seq_printf(s, "Bootparam: c2h_shutdown_db %d\n",
|
||||||
bootparam->c2h_shutdown_db);
|
bootparam->c2h_shutdown_db);
|
||||||
seq_printf(s, "Bootparam: shutdown_status %d\n",
|
seq_printf(s, "Bootparam: shutdown_status %d\n",
|
||||||
bootparam->shutdown_status);
|
bootparam->shutdown_status);
|
||||||
seq_printf(s, "Bootparam: shutdown_card %d\n",
|
seq_printf(s, "Bootparam: shutdown_card %d\n",
|
||||||
bootparam->shutdown_card);
|
bootparam->shutdown_card);
|
||||||
|
|
||||||
for (i = sizeof(*bootparam); i < MIC_DP_SIZE;
|
for (i = sizeof(*bootparam); i < MIC_DP_SIZE;
|
||||||
i += mic_total_desc_size(d)) {
|
i += mic_total_desc_size(d)) {
|
||||||
|
@ -239,10 +239,10 @@ static int mic_dp_show(struct seq_file *s, void *pos)
|
||||||
seq_printf(s, "address 0x%llx ", vqconfig->address);
|
seq_printf(s, "address 0x%llx ", vqconfig->address);
|
||||||
seq_printf(s, "num %d ", vqconfig->num);
|
seq_printf(s, "num %d ", vqconfig->num);
|
||||||
seq_printf(s, "used address 0x%llx\n",
|
seq_printf(s, "used address 0x%llx\n",
|
||||||
vqconfig->used_address);
|
vqconfig->used_address);
|
||||||
}
|
}
|
||||||
|
|
||||||
features = (__u32 *) mic_vq_features(d);
|
features = (__u32 *)mic_vq_features(d);
|
||||||
seq_printf(s, "Features: Host 0x%x ", features[0]);
|
seq_printf(s, "Features: Host 0x%x ", features[0]);
|
||||||
seq_printf(s, "Guest 0x%x\n", features[1]);
|
seq_printf(s, "Guest 0x%x\n", features[1]);
|
||||||
|
|
||||||
|
@ -256,7 +256,7 @@ static int mic_dp_show(struct seq_file *s, void *pos)
|
||||||
seq_printf(s, "Guest Ack %d ", dc->guest_ack);
|
seq_printf(s, "Guest Ack %d ", dc->guest_ack);
|
||||||
seq_printf(s, "Host ack %d\n", dc->host_ack);
|
seq_printf(s, "Host ack %d\n", dc->host_ack);
|
||||||
seq_printf(s, "Used address updated %d ",
|
seq_printf(s, "Used address updated %d ",
|
||||||
dc->used_address_updated);
|
dc->used_address_updated);
|
||||||
seq_printf(s, "Vdev 0x%llx\n", dc->vdev);
|
seq_printf(s, "Vdev 0x%llx\n", dc->vdev);
|
||||||
seq_printf(s, "c2h doorbell %d ", dc->c2h_vdev_db);
|
seq_printf(s, "c2h doorbell %d ", dc->c2h_vdev_db);
|
||||||
seq_printf(s, "h2c doorbell %d\n", dc->h2c_vdev_db);
|
seq_printf(s, "h2c doorbell %d\n", dc->h2c_vdev_db);
|
||||||
|
@ -294,10 +294,10 @@ static int mic_vdev_info_show(struct seq_file *s, void *unused)
|
||||||
list_for_each_safe(pos, tmp, &mdev->vdev_list) {
|
list_for_each_safe(pos, tmp, &mdev->vdev_list) {
|
||||||
mvdev = list_entry(pos, struct mic_vdev, list);
|
mvdev = list_entry(pos, struct mic_vdev, list);
|
||||||
seq_printf(s, "VDEV type %d state %s in %ld out %ld\n",
|
seq_printf(s, "VDEV type %d state %s in %ld out %ld\n",
|
||||||
mvdev->virtio_id,
|
mvdev->virtio_id,
|
||||||
mic_vdevup(mvdev) ? "UP" : "DOWN",
|
mic_vdevup(mvdev) ? "UP" : "DOWN",
|
||||||
mvdev->in_bytes,
|
mvdev->in_bytes,
|
||||||
mvdev->out_bytes);
|
mvdev->out_bytes);
|
||||||
for (i = 0; i < MIC_MAX_VRINGS; i++) {
|
for (i = 0; i < MIC_MAX_VRINGS; i++) {
|
||||||
struct vring_desc *desc;
|
struct vring_desc *desc;
|
||||||
struct vring_avail *avail;
|
struct vring_avail *avail;
|
||||||
|
@ -309,38 +309,38 @@ static int mic_vdev_info_show(struct seq_file *s, void *unused)
|
||||||
continue;
|
continue;
|
||||||
desc = vrh->vring.desc;
|
desc = vrh->vring.desc;
|
||||||
seq_printf(s, "vring i %d avail_idx %d",
|
seq_printf(s, "vring i %d avail_idx %d",
|
||||||
i, mvr->vring.info->avail_idx & (num - 1));
|
i, mvr->vring.info->avail_idx & (num - 1));
|
||||||
seq_printf(s, " vring i %d avail_idx %d\n",
|
seq_printf(s, " vring i %d avail_idx %d\n",
|
||||||
i, mvr->vring.info->avail_idx);
|
i, mvr->vring.info->avail_idx);
|
||||||
seq_printf(s, "vrh i %d weak_barriers %d",
|
seq_printf(s, "vrh i %d weak_barriers %d",
|
||||||
i, vrh->weak_barriers);
|
i, vrh->weak_barriers);
|
||||||
seq_printf(s, " last_avail_idx %d last_used_idx %d",
|
seq_printf(s, " last_avail_idx %d last_used_idx %d",
|
||||||
vrh->last_avail_idx, vrh->last_used_idx);
|
vrh->last_avail_idx, vrh->last_used_idx);
|
||||||
seq_printf(s, " completed %d\n", vrh->completed);
|
seq_printf(s, " completed %d\n", vrh->completed);
|
||||||
for (j = 0; j < num; j++) {
|
for (j = 0; j < num; j++) {
|
||||||
seq_printf(s, "desc[%d] addr 0x%llx len %d",
|
seq_printf(s, "desc[%d] addr 0x%llx len %d",
|
||||||
j, desc->addr, desc->len);
|
j, desc->addr, desc->len);
|
||||||
seq_printf(s, " flags 0x%x next %d\n",
|
seq_printf(s, " flags 0x%x next %d\n",
|
||||||
desc->flags,
|
desc->flags, desc->next);
|
||||||
desc->next);
|
|
||||||
desc++;
|
desc++;
|
||||||
}
|
}
|
||||||
avail = vrh->vring.avail;
|
avail = vrh->vring.avail;
|
||||||
seq_printf(s, "avail flags 0x%x idx %d\n",
|
seq_printf(s, "avail flags 0x%x idx %d\n",
|
||||||
avail->flags, avail->idx & (num - 1));
|
avail->flags, avail->idx & (num - 1));
|
||||||
seq_printf(s, "avail flags 0x%x idx %d\n",
|
seq_printf(s, "avail flags 0x%x idx %d\n",
|
||||||
avail->flags, avail->idx);
|
avail->flags, avail->idx);
|
||||||
for (j = 0; j < num; j++)
|
for (j = 0; j < num; j++)
|
||||||
seq_printf(s, "avail ring[%d] %d\n",
|
seq_printf(s, "avail ring[%d] %d\n",
|
||||||
j, avail->ring[j]);
|
j, avail->ring[j]);
|
||||||
used = vrh->vring.used;
|
used = vrh->vring.used;
|
||||||
seq_printf(s, "used flags 0x%x idx %d\n",
|
seq_printf(s, "used flags 0x%x idx %d\n",
|
||||||
used->flags, used->idx & (num - 1));
|
used->flags, used->idx & (num - 1));
|
||||||
seq_printf(s, "used flags 0x%x idx %d\n",
|
seq_printf(s, "used flags 0x%x idx %d\n",
|
||||||
used->flags, used->idx);
|
used->flags, used->idx);
|
||||||
for (j = 0; j < num; j++)
|
for (j = 0; j < num; j++)
|
||||||
seq_printf(s, "used ring[%d] id %d len %d\n",
|
seq_printf(s, "used ring[%d] id %d len %d\n",
|
||||||
j, used->ring[j].id, used->ring[j].len);
|
j, used->ring[j].id,
|
||||||
|
used->ring[j].len);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
mutex_unlock(&mdev->mic_mutex);
|
mutex_unlock(&mdev->mic_mutex);
|
||||||
|
@ -389,7 +389,7 @@ static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
|
||||||
reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry);
|
reg = mdev->intr_ops->read_msi_to_src_map(mdev, entry);
|
||||||
|
|
||||||
seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n",
|
seq_printf(s, "%s %-10d %s %-10d MXAR[%d]: %08X\n",
|
||||||
"IRQ:", vector, "Entry:", entry, i, reg);
|
"IRQ:", vector, "Entry:", entry, i, reg);
|
||||||
|
|
||||||
seq_printf(s, "%-10s", "offset:");
|
seq_printf(s, "%-10s", "offset:");
|
||||||
for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
|
for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
|
||||||
|
@ -400,8 +400,8 @@ static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
|
||||||
seq_printf(s, "%-10s", "count:");
|
seq_printf(s, "%-10s", "count:");
|
||||||
for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
|
for (j = (MIC_NUM_OFFSETS - 1); j >= 0; j--)
|
||||||
seq_printf(s, "%4d ",
|
seq_printf(s, "%4d ",
|
||||||
(mdev->irq_info.mic_msi_map[i] & BIT(j)) ?
|
(mdev->irq_info.mic_msi_map[i] &
|
||||||
1 : 0);
|
BIT(j)) ? 1 : 0);
|
||||||
seq_puts(s, "\n\n");
|
seq_puts(s, "\n\n");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
@ -409,7 +409,6 @@ static int mic_msi_irq_info_show(struct seq_file *s, void *pos)
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static int mic_msi_irq_info_debug_open(struct inode *inode, struct file *file)
|
static int mic_msi_irq_info_debug_open(struct inode *inode, struct file *file)
|
||||||
|
@ -443,26 +442,23 @@ void mic_create_debug_dir(struct mic_device *mdev)
|
||||||
if (!mdev->dbg_dir)
|
if (!mdev->dbg_dir)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
debugfs_create_file("log_buf", 0444, mdev->dbg_dir,
|
debugfs_create_file("log_buf", 0444, mdev->dbg_dir, mdev, &log_buf_ops);
|
||||||
mdev, &log_buf_ops);
|
|
||||||
|
|
||||||
debugfs_create_file("smpt", 0444, mdev->dbg_dir,
|
debugfs_create_file("smpt", 0444, mdev->dbg_dir, mdev, &smpt_file_ops);
|
||||||
mdev, &smpt_file_ops);
|
|
||||||
|
|
||||||
debugfs_create_file("soft_reset", 0444, mdev->dbg_dir,
|
debugfs_create_file("soft_reset", 0444, mdev->dbg_dir, mdev,
|
||||||
mdev, &soft_reset_ops);
|
&soft_reset_ops);
|
||||||
|
|
||||||
debugfs_create_file("post_code", 0444, mdev->dbg_dir,
|
debugfs_create_file("post_code", 0444, mdev->dbg_dir, mdev,
|
||||||
mdev, &post_code_ops);
|
&post_code_ops);
|
||||||
|
|
||||||
debugfs_create_file("dp", 0444, mdev->dbg_dir,
|
debugfs_create_file("dp", 0444, mdev->dbg_dir, mdev, &dp_ops);
|
||||||
mdev, &dp_ops);
|
|
||||||
|
|
||||||
debugfs_create_file("vdev_info", 0444, mdev->dbg_dir,
|
debugfs_create_file("vdev_info", 0444, mdev->dbg_dir, mdev,
|
||||||
mdev, &vdev_info_ops);
|
&vdev_info_ops);
|
||||||
|
|
||||||
debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir,
|
debugfs_create_file("msi_irq_info", 0444, mdev->dbg_dir, mdev,
|
||||||
mdev, &msi_irq_info_ops);
|
&msi_irq_info_ops);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -140,9 +140,9 @@ unsigned int mic_poll(struct file *f, poll_table *wait)
|
||||||
|
|
||||||
poll_wait(f, &mvdev->waitq, wait);
|
poll_wait(f, &mvdev->waitq, wait);
|
||||||
|
|
||||||
if (mic_vdev_inited(mvdev))
|
if (mic_vdev_inited(mvdev)) {
|
||||||
mask = POLLERR;
|
mask = POLLERR;
|
||||||
else if (mvdev->poll_wake) {
|
} else if (mvdev->poll_wake) {
|
||||||
mvdev->poll_wake = 0;
|
mvdev->poll_wake = 0;
|
||||||
mask = POLLIN | POLLOUT;
|
mask = POLLIN | POLLOUT;
|
||||||
}
|
}
|
||||||
|
@ -152,7 +152,7 @@ unsigned int mic_poll(struct file *f, poll_table *wait)
|
||||||
|
|
||||||
static inline int
|
static inline int
|
||||||
mic_query_offset(struct mic_vdev *mvdev, unsigned long offset,
|
mic_query_offset(struct mic_vdev *mvdev, unsigned long offset,
|
||||||
unsigned long *size, unsigned long *pa)
|
unsigned long *size, unsigned long *pa)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = mvdev->mdev;
|
struct mic_device *mdev = mvdev->mdev;
|
||||||
unsigned long start = MIC_DP_SIZE;
|
unsigned long start = MIC_DP_SIZE;
|
||||||
|
|
|
@ -71,8 +71,8 @@ static irqreturn_t mic_interrupt(int irq, void *dev)
|
||||||
|
|
||||||
/* Return the interrupt offset from the index. Index is 0 based. */
|
/* Return the interrupt offset from the index. Index is 0 based. */
|
||||||
static u16 mic_map_src_to_offset(struct mic_device *mdev,
|
static u16 mic_map_src_to_offset(struct mic_device *mdev,
|
||||||
int intr_src, enum mic_intr_type type) {
|
int intr_src, enum mic_intr_type type)
|
||||||
|
{
|
||||||
if (type >= MIC_NUM_INTR_TYPES)
|
if (type >= MIC_NUM_INTR_TYPES)
|
||||||
return MIC_NUM_OFFSETS;
|
return MIC_NUM_OFFSETS;
|
||||||
if (intr_src >= mdev->intr_info->intr_len[type])
|
if (intr_src >= mdev->intr_info->intr_len[type])
|
||||||
|
@ -112,7 +112,7 @@ static struct mic_intr_cb *mic_register_intr_callback(struct mic_device *mdev,
|
||||||
struct mic_intr_cb *intr_cb;
|
struct mic_intr_cb *intr_cb;
|
||||||
unsigned long flags;
|
unsigned long flags;
|
||||||
int rc;
|
int rc;
|
||||||
intr_cb = kmalloc(sizeof(struct mic_intr_cb), GFP_KERNEL);
|
intr_cb = kmalloc(sizeof(*intr_cb), GFP_KERNEL);
|
||||||
|
|
||||||
if (!intr_cb)
|
if (!intr_cb)
|
||||||
return ERR_PTR(-ENOMEM);
|
return ERR_PTR(-ENOMEM);
|
||||||
|
@ -159,7 +159,7 @@ static u8 mic_unregister_intr_callback(struct mic_device *mdev, u32 idx)
|
||||||
if (intr_cb->cb_id == idx) {
|
if (intr_cb->cb_id == idx) {
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
ida_simple_remove(&mdev->irq_info.cb_ida,
|
ida_simple_remove(&mdev->irq_info.cb_ida,
|
||||||
intr_cb->cb_id);
|
intr_cb->cb_id);
|
||||||
kfree(intr_cb);
|
kfree(intr_cb);
|
||||||
spin_unlock_irqrestore(
|
spin_unlock_irqrestore(
|
||||||
&mdev->irq_info.mic_intr_lock, flags);
|
&mdev->irq_info.mic_intr_lock, flags);
|
||||||
|
@ -182,9 +182,10 @@ static u8 mic_unregister_intr_callback(struct mic_device *mdev, u32 idx)
|
||||||
static int mic_setup_msix(struct mic_device *mdev, struct pci_dev *pdev)
|
static int mic_setup_msix(struct mic_device *mdev, struct pci_dev *pdev)
|
||||||
{
|
{
|
||||||
int rc, i;
|
int rc, i;
|
||||||
|
int entry_size = sizeof(*mdev->irq_info.msix_entries);
|
||||||
|
|
||||||
mdev->irq_info.msix_entries = kmalloc(sizeof(struct msix_entry) *
|
mdev->irq_info.msix_entries = kmalloc_array(MIC_MIN_MSIX,
|
||||||
MIC_MIN_MSIX, GFP_KERNEL);
|
entry_size, GFP_KERNEL);
|
||||||
if (!mdev->irq_info.msix_entries) {
|
if (!mdev->irq_info.msix_entries) {
|
||||||
rc = -ENOMEM;
|
rc = -ENOMEM;
|
||||||
goto err_nomem1;
|
goto err_nomem1;
|
||||||
|
@ -231,8 +232,9 @@ static int mic_setup_callbacks(struct mic_device *mdev)
|
||||||
{
|
{
|
||||||
int i;
|
int i;
|
||||||
|
|
||||||
mdev->irq_info.cb_list = kmalloc(sizeof(struct list_head) *
|
mdev->irq_info.cb_list = kmalloc_array(MIC_NUM_OFFSETS,
|
||||||
MIC_NUM_OFFSETS, GFP_KERNEL);
|
sizeof(*mdev->irq_info.cb_list),
|
||||||
|
GFP_KERNEL);
|
||||||
if (!mdev->irq_info.cb_list)
|
if (!mdev->irq_info.cb_list)
|
||||||
return -ENOMEM;
|
return -ENOMEM;
|
||||||
|
|
||||||
|
@ -261,7 +263,7 @@ static void mic_release_callbacks(struct mic_device *mdev)
|
||||||
|
|
||||||
if (list_empty(&mdev->irq_info.cb_list[i])) {
|
if (list_empty(&mdev->irq_info.cb_list[i])) {
|
||||||
spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock,
|
spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock,
|
||||||
flags);
|
flags);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -269,7 +271,7 @@ static void mic_release_callbacks(struct mic_device *mdev)
|
||||||
intr_cb = list_entry(pos, struct mic_intr_cb, list);
|
intr_cb = list_entry(pos, struct mic_intr_cb, list);
|
||||||
list_del(pos);
|
list_del(pos);
|
||||||
ida_simple_remove(&mdev->irq_info.cb_ida,
|
ida_simple_remove(&mdev->irq_info.cb_ida,
|
||||||
intr_cb->cb_id);
|
intr_cb->cb_id);
|
||||||
kfree(intr_cb);
|
kfree(intr_cb);
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock, flags);
|
spin_unlock_irqrestore(&mdev->irq_info.mic_intr_lock, flags);
|
||||||
|
@ -427,8 +429,8 @@ struct mic_irq *mic_request_irq(struct mic_device *mdev,
|
||||||
offset = mic_map_src_to_offset(mdev, intr_src, type);
|
offset = mic_map_src_to_offset(mdev, intr_src, type);
|
||||||
if (offset >= MIC_NUM_OFFSETS) {
|
if (offset >= MIC_NUM_OFFSETS) {
|
||||||
dev_err(mdev->sdev->parent,
|
dev_err(mdev->sdev->parent,
|
||||||
"Error mapping index %d to a valid source id.\n",
|
"Error mapping index %d to a valid source id.\n",
|
||||||
intr_src);
|
intr_src);
|
||||||
rc = -EINVAL;
|
rc = -EINVAL;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -437,7 +439,7 @@ struct mic_irq *mic_request_irq(struct mic_device *mdev,
|
||||||
msix = mic_get_available_vector(mdev);
|
msix = mic_get_available_vector(mdev);
|
||||||
if (!msix) {
|
if (!msix) {
|
||||||
dev_err(mdev->sdev->parent,
|
dev_err(mdev->sdev->parent,
|
||||||
"No MSIx vectors available for use.\n");
|
"No MSIx vectors available for use.\n");
|
||||||
rc = -ENOSPC;
|
rc = -ENOSPC;
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -460,7 +462,7 @@ struct mic_irq *mic_request_irq(struct mic_device *mdev,
|
||||||
offset, func, data);
|
offset, func, data);
|
||||||
if (IS_ERR(intr_cb)) {
|
if (IS_ERR(intr_cb)) {
|
||||||
dev_err(mdev->sdev->parent,
|
dev_err(mdev->sdev->parent,
|
||||||
"No available callback entries for use\n");
|
"No available callback entries for use\n");
|
||||||
rc = PTR_ERR(intr_cb);
|
rc = PTR_ERR(intr_cb);
|
||||||
goto err;
|
goto err;
|
||||||
}
|
}
|
||||||
|
@ -506,7 +508,7 @@ void mic_free_irq(struct mic_device *mdev,
|
||||||
if (mdev->irq_info.num_vectors > 1) {
|
if (mdev->irq_info.num_vectors > 1) {
|
||||||
if (entry >= mdev->irq_info.num_vectors) {
|
if (entry >= mdev->irq_info.num_vectors) {
|
||||||
dev_warn(mdev->sdev->parent,
|
dev_warn(mdev->sdev->parent,
|
||||||
"entry %d should be < num_irq %d\n",
|
"entry %d should be < num_irq %d\n",
|
||||||
entry, mdev->irq_info.num_vectors);
|
entry, mdev->irq_info.num_vectors);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -581,7 +583,7 @@ void mic_free_interrupts(struct mic_device *mdev, struct pci_dev *pdev)
|
||||||
for (i = 0; i < mdev->irq_info.num_vectors; i++) {
|
for (i = 0; i < mdev->irq_info.num_vectors; i++) {
|
||||||
if (mdev->irq_info.mic_msi_map[i])
|
if (mdev->irq_info.mic_msi_map[i])
|
||||||
dev_warn(&pdev->dev, "irq %d may still be in use.\n",
|
dev_warn(&pdev->dev, "irq %d may still be in use.\n",
|
||||||
mdev->irq_info.msix_entries[i].vector);
|
mdev->irq_info.msix_entries[i].vector);
|
||||||
}
|
}
|
||||||
kfree(mdev->irq_info.mic_msi_map);
|
kfree(mdev->irq_info.mic_msi_map);
|
||||||
kfree(mdev->irq_info.msix_entries);
|
kfree(mdev->irq_info.msix_entries);
|
||||||
|
|
|
@ -84,7 +84,7 @@ static void mic_add_smpt_entry(int spt, s64 *ref, u64 addr,
|
||||||
for (i = spt; i < spt + entries; i++,
|
for (i = spt; i < spt + entries; i++,
|
||||||
addr += smpt_info->info.page_size) {
|
addr += smpt_info->info.page_size) {
|
||||||
if (!smpt_info->entry[i].ref_count &&
|
if (!smpt_info->entry[i].ref_count &&
|
||||||
(smpt_info->entry[i].dma_addr != addr)) {
|
(smpt_info->entry[i].dma_addr != addr)) {
|
||||||
mdev->smpt_ops->set(mdev, addr, i);
|
mdev->smpt_ops->set(mdev, addr, i);
|
||||||
smpt_info->entry[i].dma_addr = addr;
|
smpt_info->entry[i].dma_addr = addr;
|
||||||
}
|
}
|
||||||
|
@ -183,7 +183,7 @@ mic_to_dma_addr(struct mic_device *mdev, dma_addr_t mic_addr)
|
||||||
|
|
||||||
if (!mic_is_system_addr(mdev, mic_addr)) {
|
if (!mic_is_system_addr(mdev, mic_addr)) {
|
||||||
dev_err(mdev->sdev->parent,
|
dev_err(mdev->sdev->parent,
|
||||||
"mic_addr is invalid. mic_addr = 0x%llx\n", mic_addr);
|
"mic_addr is invalid. mic_addr = 0x%llx\n", mic_addr);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
}
|
}
|
||||||
spt = mic_sys_addr_to_smpt(mdev, mic_addr);
|
spt = mic_sys_addr_to_smpt(mdev, mic_addr);
|
||||||
|
@ -286,7 +286,7 @@ void mic_unmap(struct mic_device *mdev, dma_addr_t mic_addr, size_t size)
|
||||||
smpt_info->entry[i].ref_count -= ref[i - spt];
|
smpt_info->entry[i].ref_count -= ref[i - spt];
|
||||||
if (smpt_info->entry[i].ref_count < 0)
|
if (smpt_info->entry[i].ref_count < 0)
|
||||||
dev_warn(mdev->sdev->parent,
|
dev_warn(mdev->sdev->parent,
|
||||||
"ref count for entry %d is negative\n", i);
|
"ref count for entry %d is negative\n", i);
|
||||||
}
|
}
|
||||||
spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
|
spin_unlock_irqrestore(&smpt_info->smpt_lock, flags);
|
||||||
kfree(ref);
|
kfree(ref);
|
||||||
|
@ -320,7 +320,7 @@ dma_addr_t mic_map_single(struct mic_device *mdev, void *va, size_t size)
|
||||||
"mic_map failed dma_addr 0x%llx size 0x%lx\n",
|
"mic_map failed dma_addr 0x%llx size 0x%lx\n",
|
||||||
dma_addr, size);
|
dma_addr, size);
|
||||||
pci_unmap_single(pdev, dma_addr,
|
pci_unmap_single(pdev, dma_addr,
|
||||||
size, PCI_DMA_BIDIRECTIONAL);
|
size, PCI_DMA_BIDIRECTIONAL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return mic_addr;
|
return mic_addr;
|
||||||
|
@ -366,8 +366,8 @@ int mic_smpt_init(struct mic_device *mdev)
|
||||||
|
|
||||||
smpt_info = mdev->smpt;
|
smpt_info = mdev->smpt;
|
||||||
mdev->smpt_ops->init(mdev);
|
mdev->smpt_ops->init(mdev);
|
||||||
smpt_info->entry = kmalloc(sizeof(struct mic_smpt)
|
smpt_info->entry = kmalloc_array(smpt_info->info.num_reg,
|
||||||
* smpt_info->info.num_reg, GFP_KERNEL);
|
sizeof(*smpt_info->entry), GFP_KERNEL);
|
||||||
if (!smpt_info->entry) {
|
if (!smpt_info->entry) {
|
||||||
err = -ENOMEM;
|
err = -ENOMEM;
|
||||||
goto free_smpt;
|
goto free_smpt;
|
||||||
|
@ -412,7 +412,7 @@ void mic_smpt_uninit(struct mic_device *mdev)
|
||||||
smpt_info->entry[i].ref_count);
|
smpt_info->entry[i].ref_count);
|
||||||
if (smpt_info->entry[i].ref_count)
|
if (smpt_info->entry[i].ref_count)
|
||||||
dev_warn(mdev->sdev->parent,
|
dev_warn(mdev->sdev->parent,
|
||||||
"ref count for entry %d is not zero\n", i);
|
"ref count for entry %d is not zero\n", i);
|
||||||
}
|
}
|
||||||
kfree(smpt_info->entry);
|
kfree(smpt_info->entry);
|
||||||
kfree(smpt_info);
|
kfree(smpt_info);
|
||||||
|
|
|
@ -130,7 +130,7 @@ state_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
state_store(struct device *dev, struct device_attribute *attr,
|
state_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
int rc = 0;
|
int rc = 0;
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
|
@ -163,7 +163,7 @@ done:
|
||||||
static DEVICE_ATTR_RW(state);
|
static DEVICE_ATTR_RW(state);
|
||||||
|
|
||||||
static ssize_t shutdown_status_show(struct device *dev,
|
static ssize_t shutdown_status_show(struct device *dev,
|
||||||
struct device_attribute *attr, char *buf)
|
struct device_attribute *attr, char *buf)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
|
|
||||||
|
@ -193,7 +193,7 @@ cmdline_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
cmdline_store(struct device *dev, struct device_attribute *attr,
|
cmdline_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
|
|
||||||
|
@ -239,7 +239,7 @@ firmware_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
firmware_store(struct device *dev, struct device_attribute *attr,
|
firmware_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
|
|
||||||
|
@ -284,7 +284,7 @@ ramdisk_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
ramdisk_store(struct device *dev, struct device_attribute *attr,
|
ramdisk_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
|
|
||||||
|
@ -330,7 +330,7 @@ bootmode_show(struct device *dev, struct device_attribute *attr, char *buf)
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
bootmode_store(struct device *dev, struct device_attribute *attr,
|
bootmode_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
|
|
||||||
|
@ -363,7 +363,7 @@ static DEVICE_ATTR_RW(bootmode);
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
log_buf_addr_show(struct device *dev, struct device_attribute *attr,
|
log_buf_addr_show(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
|
|
||||||
|
@ -375,7 +375,7 @@ log_buf_addr_show(struct device *dev, struct device_attribute *attr,
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
log_buf_addr_store(struct device *dev, struct device_attribute *attr,
|
log_buf_addr_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
int ret;
|
int ret;
|
||||||
|
@ -397,7 +397,7 @@ static DEVICE_ATTR_RW(log_buf_addr);
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
log_buf_len_show(struct device *dev, struct device_attribute *attr,
|
log_buf_len_show(struct device *dev, struct device_attribute *attr,
|
||||||
char *buf)
|
char *buf)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
|
|
||||||
|
@ -409,7 +409,7 @@ log_buf_len_show(struct device *dev, struct device_attribute *attr,
|
||||||
|
|
||||||
static ssize_t
|
static ssize_t
|
||||||
log_buf_len_store(struct device *dev, struct device_attribute *attr,
|
log_buf_len_store(struct device *dev, struct device_attribute *attr,
|
||||||
const char *buf, size_t count)
|
const char *buf, size_t count)
|
||||||
{
|
{
|
||||||
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
struct mic_device *mdev = dev_get_drvdata(dev->parent);
|
||||||
int ret;
|
int ret;
|
||||||
|
|
|
@ -195,7 +195,7 @@ static int _mic_virtio_copy(struct mic_vdev *mvdev,
|
||||||
MIC_VRINGH_READ, &out_len);
|
MIC_VRINGH_READ, &out_len);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
||||||
__func__, __LINE__, ret);
|
__func__, __LINE__, ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len -= out_len;
|
len -= out_len;
|
||||||
|
@ -206,7 +206,7 @@ static int _mic_virtio_copy(struct mic_vdev *mvdev,
|
||||||
!MIC_VRINGH_READ, &out_len);
|
!MIC_VRINGH_READ, &out_len);
|
||||||
if (ret) {
|
if (ret) {
|
||||||
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
||||||
__func__, __LINE__, ret);
|
__func__, __LINE__, ret);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
len -= out_len;
|
len -= out_len;
|
||||||
|
@ -225,8 +225,7 @@ static int _mic_virtio_copy(struct mic_vdev *mvdev,
|
||||||
* Update the used ring if a descriptor was available and some data was
|
* Update the used ring if a descriptor was available and some data was
|
||||||
* copied in/out and the user asked for a used ring update.
|
* copied in/out and the user asked for a used ring update.
|
||||||
*/
|
*/
|
||||||
if (*head != USHRT_MAX && copy->out_len &&
|
if (*head != USHRT_MAX && copy->out_len && copy->update_used) {
|
||||||
copy->update_used) {
|
|
||||||
u32 total = 0;
|
u32 total = 0;
|
||||||
|
|
||||||
/* Determine the total data consumed */
|
/* Determine the total data consumed */
|
||||||
|
@ -367,7 +366,6 @@ void mic_bh_handler(struct work_struct *work)
|
||||||
|
|
||||||
static irqreturn_t mic_virtio_intr_handler(int irq, void *data)
|
static irqreturn_t mic_virtio_intr_handler(int irq, void *data)
|
||||||
{
|
{
|
||||||
|
|
||||||
struct mic_vdev *mvdev = data;
|
struct mic_vdev *mvdev = data;
|
||||||
struct mic_device *mdev = mvdev->mdev;
|
struct mic_device *mdev = mvdev->mdev;
|
||||||
|
|
||||||
|
@ -394,7 +392,7 @@ int mic_virtio_config_change(struct mic_vdev *mvdev,
|
||||||
}
|
}
|
||||||
|
|
||||||
if (copy_from_user(mic_vq_configspace(mvdev->dd),
|
if (copy_from_user(mic_vq_configspace(mvdev->dd),
|
||||||
argp, mvdev->dd->config_len)) {
|
argp, mvdev->dd->config_len)) {
|
||||||
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
||||||
__func__, __LINE__, -EFAULT);
|
__func__, __LINE__, -EFAULT);
|
||||||
ret = -EFAULT;
|
ret = -EFAULT;
|
||||||
|
@ -438,8 +436,8 @@ static int mic_copy_dp_entry(struct mic_vdev *mvdev,
|
||||||
return -EFAULT;
|
return -EFAULT;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mic_aligned_desc_size(&dd) > MIC_MAX_DESC_BLK_SIZE
|
if (mic_aligned_desc_size(&dd) > MIC_MAX_DESC_BLK_SIZE ||
|
||||||
|| dd.num_vq > MIC_MAX_VRINGS) {
|
dd.num_vq > MIC_MAX_VRINGS) {
|
||||||
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
||||||
__func__, __LINE__, -EINVAL);
|
__func__, __LINE__, -EINVAL);
|
||||||
return -EINVAL;
|
return -EINVAL;
|
||||||
|
@ -503,7 +501,7 @@ static void mic_init_device_ctrl(struct mic_vdev *mvdev,
|
||||||
{
|
{
|
||||||
struct mic_device_ctrl *dc;
|
struct mic_device_ctrl *dc;
|
||||||
|
|
||||||
dc = mvdev->dc = (void *)devpage + mic_aligned_desc_size(devpage);
|
dc = (void *)devpage + mic_aligned_desc_size(devpage);
|
||||||
|
|
||||||
dc->config_change = 0;
|
dc->config_change = 0;
|
||||||
dc->guest_ack = 0;
|
dc->guest_ack = 0;
|
||||||
|
@ -512,6 +510,7 @@ static void mic_init_device_ctrl(struct mic_vdev *mvdev,
|
||||||
dc->used_address_updated = 0;
|
dc->used_address_updated = 0;
|
||||||
dc->c2h_vdev_db = -1;
|
dc->c2h_vdev_db = -1;
|
||||||
dc->h2c_vdev_db = -1;
|
dc->h2c_vdev_db = -1;
|
||||||
|
mvdev->dc = dc;
|
||||||
}
|
}
|
||||||
|
|
||||||
int mic_virtio_add_device(struct mic_vdev *mvdev,
|
int mic_virtio_add_device(struct mic_vdev *mvdev,
|
||||||
|
@ -551,7 +550,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
|
||||||
sizeof(struct _mic_vring_info));
|
sizeof(struct _mic_vring_info));
|
||||||
vr->va = (void *)
|
vr->va = (void *)
|
||||||
__get_free_pages(GFP_KERNEL | __GFP_ZERO,
|
__get_free_pages(GFP_KERNEL | __GFP_ZERO,
|
||||||
get_order(vr_size));
|
get_order(vr_size));
|
||||||
if (!vr->va) {
|
if (!vr->va) {
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
||||||
|
@ -564,8 +563,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
|
||||||
vqconfig[i].address = mic_map_single(mdev,
|
vqconfig[i].address = mic_map_single(mdev,
|
||||||
vr->va, vr_size);
|
vr->va, vr_size);
|
||||||
if (mic_map_error(vqconfig[i].address)) {
|
if (mic_map_error(vqconfig[i].address)) {
|
||||||
free_pages((unsigned long)vr->va,
|
free_pages((unsigned long)vr->va, get_order(vr_size));
|
||||||
get_order(vr_size));
|
|
||||||
ret = -ENOMEM;
|
ret = -ENOMEM;
|
||||||
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
dev_err(mic_dev(mvdev), "%s %d err %d\n",
|
||||||
__func__, __LINE__, ret);
|
__func__, __LINE__, ret);
|
||||||
|
@ -573,8 +571,7 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
|
||||||
}
|
}
|
||||||
vqconfig[i].address = cpu_to_le64(vqconfig[i].address);
|
vqconfig[i].address = cpu_to_le64(vqconfig[i].address);
|
||||||
|
|
||||||
vring_init(&vr->vr, num,
|
vring_init(&vr->vr, num, vr->va, MIC_VIRTIO_RING_ALIGN);
|
||||||
vr->va, MIC_VIRTIO_RING_ALIGN);
|
|
||||||
ret = vringh_init_kern(&mvr->vrh,
|
ret = vringh_init_kern(&mvr->vrh,
|
||||||
*(u32 *)mic_vq_features(mvdev->dd), num, false,
|
*(u32 *)mic_vq_features(mvdev->dd), num, false,
|
||||||
vr->vr.desc, vr->vr.avail, vr->vr.used);
|
vr->vr.desc, vr->vr.avail, vr->vr.used);
|
||||||
|
@ -593,8 +590,8 @@ int mic_virtio_add_device(struct mic_vdev *mvdev,
|
||||||
__func__, __LINE__, i, vr->va, vr->info, vr_size);
|
__func__, __LINE__, i, vr->va, vr->info, vr_size);
|
||||||
}
|
}
|
||||||
|
|
||||||
snprintf(irqname, sizeof(irqname),
|
snprintf(irqname, sizeof(irqname), "mic%dvirtio%d", mdev->id,
|
||||||
"mic%dvirtio%d", mdev->id, mvdev->virtio_id);
|
mvdev->virtio_id);
|
||||||
mvdev->virtio_db = mic_next_db(mdev);
|
mvdev->virtio_db = mic_next_db(mdev);
|
||||||
mvdev->virtio_cookie = mic_request_irq(mdev, mic_virtio_intr_handler,
|
mvdev->virtio_cookie = mic_request_irq(mdev, mic_virtio_intr_handler,
|
||||||
irqname, mvdev, mvdev->virtio_db, MIC_INTR_DB);
|
irqname, mvdev, mvdev->virtio_db, MIC_INTR_DB);
|
||||||
|
@ -628,9 +625,9 @@ err:
|
||||||
for (j = 0; j < i; j++) {
|
for (j = 0; j < i; j++) {
|
||||||
struct mic_vringh *mvr = &mvdev->mvr[j];
|
struct mic_vringh *mvr = &mvdev->mvr[j];
|
||||||
mic_unmap_single(mdev, le64_to_cpu(vqconfig[j].address),
|
mic_unmap_single(mdev, le64_to_cpu(vqconfig[j].address),
|
||||||
mvr->vring.len);
|
mvr->vring.len);
|
||||||
free_pages((unsigned long)mvr->vring.va,
|
free_pages((unsigned long)mvr->vring.va,
|
||||||
get_order(mvr->vring.len));
|
get_order(mvr->vring.len));
|
||||||
}
|
}
|
||||||
mutex_unlock(&mdev->mic_mutex);
|
mutex_unlock(&mdev->mic_mutex);
|
||||||
return ret;
|
return ret;
|
||||||
|
@ -676,9 +673,9 @@ skip_hot_remove:
|
||||||
vringh_kiov_cleanup(&mvr->riov);
|
vringh_kiov_cleanup(&mvr->riov);
|
||||||
vringh_kiov_cleanup(&mvr->wiov);
|
vringh_kiov_cleanup(&mvr->wiov);
|
||||||
mic_unmap_single(mdev, le64_to_cpu(vqconfig[i].address),
|
mic_unmap_single(mdev, le64_to_cpu(vqconfig[i].address),
|
||||||
mvr->vring.len);
|
mvr->vring.len);
|
||||||
free_pages((unsigned long)mvr->vring.va,
|
free_pages((unsigned long)mvr->vring.va,
|
||||||
get_order(mvr->vring.len));
|
get_order(mvr->vring.len));
|
||||||
}
|
}
|
||||||
|
|
||||||
list_for_each_safe(pos, tmp, &mdev->vdev_list) {
|
list_for_each_safe(pos, tmp, &mdev->vdev_list) {
|
||||||
|
|
|
@ -46,8 +46,8 @@ mic_x100_write_spad(struct mic_device *mdev, unsigned int idx, u32 val)
|
||||||
dev_dbg(mdev->sdev->parent, "Writing 0x%x to scratch pad index %d\n",
|
dev_dbg(mdev->sdev->parent, "Writing 0x%x to scratch pad index %d\n",
|
||||||
val, idx);
|
val, idx);
|
||||||
mic_mmio_write(&mdev->mmio, val,
|
mic_mmio_write(&mdev->mmio, val,
|
||||||
MIC_X100_SBOX_BASE_ADDRESS +
|
MIC_X100_SBOX_BASE_ADDRESS +
|
||||||
MIC_X100_SBOX_SPAD0 + idx * 4);
|
MIC_X100_SBOX_SPAD0 + idx * 4);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -130,8 +130,8 @@ static void mic_x100_send_sbox_intr(struct mic_device *mdev,
|
||||||
{
|
{
|
||||||
struct mic_mw *mw = &mdev->mmio;
|
struct mic_mw *mw = &mdev->mmio;
|
||||||
u64 apic_icr_offset = MIC_X100_SBOX_APICICR0 + doorbell * 8;
|
u64 apic_icr_offset = MIC_X100_SBOX_APICICR0 + doorbell * 8;
|
||||||
u32 apicicr_low = mic_mmio_read(mw,
|
u32 apicicr_low = mic_mmio_read(mw, MIC_X100_SBOX_BASE_ADDRESS +
|
||||||
MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
|
apic_icr_offset);
|
||||||
|
|
||||||
/* for MIC we need to make sure we "hit" the send_icr bit (13) */
|
/* for MIC we need to make sure we "hit" the send_icr bit (13) */
|
||||||
apicicr_low = (apicicr_low | (1 << 13));
|
apicicr_low = (apicicr_low | (1 << 13));
|
||||||
|
@ -139,7 +139,7 @@ static void mic_x100_send_sbox_intr(struct mic_device *mdev,
|
||||||
/* Ensure that the interrupt is ordered w.r.t. previous stores. */
|
/* Ensure that the interrupt is ordered w.r.t. previous stores. */
|
||||||
wmb();
|
wmb();
|
||||||
mic_mmio_write(mw, apicicr_low,
|
mic_mmio_write(mw, apicicr_low,
|
||||||
MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
|
MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -153,7 +153,7 @@ static void mic_x100_send_rdmasr_intr(struct mic_device *mdev,
|
||||||
/* Ensure that the interrupt is ordered w.r.t. previous stores. */
|
/* Ensure that the interrupt is ordered w.r.t. previous stores. */
|
||||||
wmb();
|
wmb();
|
||||||
mic_mmio_write(&mdev->mmio, 0,
|
mic_mmio_write(&mdev->mmio, 0,
|
||||||
MIC_X100_SBOX_BASE_ADDRESS + rdmasr_offset);
|
MIC_X100_SBOX_BASE_ADDRESS + rdmasr_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -212,7 +212,7 @@ done:
|
||||||
*/
|
*/
|
||||||
static void mic_x100_hw_intr_init(struct mic_device *mdev)
|
static void mic_x100_hw_intr_init(struct mic_device *mdev)
|
||||||
{
|
{
|
||||||
mdev->intr_info = (struct mic_intr_info *) mic_x100_intr_init;
|
mdev->intr_info = (struct mic_intr_info *)mic_x100_intr_init;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -244,7 +244,7 @@ mic_x100_read_msi_to_src_map(struct mic_device *mdev, int idx)
|
||||||
*/
|
*/
|
||||||
static void
|
static void
|
||||||
mic_x100_program_msi_to_src_map(struct mic_device *mdev,
|
mic_x100_program_msi_to_src_map(struct mic_device *mdev,
|
||||||
int idx, int offset, bool set)
|
int idx, int offset, bool set)
|
||||||
{
|
{
|
||||||
unsigned long reg;
|
unsigned long reg;
|
||||||
struct mic_mw *mw = &mdev->mmio;
|
struct mic_mw *mw = &mdev->mmio;
|
||||||
|
@ -308,12 +308,12 @@ static void mic_x100_send_firmware_intr(struct mic_device *mdev)
|
||||||
apicicr_low = (vector | (1 << 13));
|
apicicr_low = (vector | (1 << 13));
|
||||||
|
|
||||||
mic_mmio_write(mw, mic_x100_get_apic_id(mdev),
|
mic_mmio_write(mw, mic_x100_get_apic_id(mdev),
|
||||||
MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset + 4);
|
MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset + 4);
|
||||||
|
|
||||||
/* Ensure that the interrupt is ordered w.r.t. previous stores. */
|
/* Ensure that the interrupt is ordered w.r.t. previous stores. */
|
||||||
wmb();
|
wmb();
|
||||||
mic_mmio_write(mw, apicicr_low,
|
mic_mmio_write(mw, apicicr_low,
|
||||||
MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
|
MIC_X100_SBOX_BASE_ADDRESS + apic_icr_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -365,8 +365,7 @@ mic_x100_load_command_line(struct mic_device *mdev, const struct firmware *fw)
|
||||||
len += snprintf(buf, CMDLINE_SIZE - len,
|
len += snprintf(buf, CMDLINE_SIZE - len,
|
||||||
" mem=%dM", boot_mem);
|
" mem=%dM", boot_mem);
|
||||||
if (mdev->cmdline)
|
if (mdev->cmdline)
|
||||||
snprintf(buf + len, CMDLINE_SIZE - len,
|
snprintf(buf + len, CMDLINE_SIZE - len, " %s", mdev->cmdline);
|
||||||
" %s", mdev->cmdline);
|
|
||||||
memcpy_toio(cmd_line_va, buf, strlen(buf) + 1);
|
memcpy_toio(cmd_line_va, buf, strlen(buf) + 1);
|
||||||
kfree(buf);
|
kfree(buf);
|
||||||
return 0;
|
return 0;
|
||||||
|
@ -397,8 +396,7 @@ mic_x100_load_ramdisk(struct mic_device *mdev)
|
||||||
* Typically the bootaddr for card OS is 64M
|
* Typically the bootaddr for card OS is 64M
|
||||||
* so copy over the ramdisk @ 128M.
|
* so copy over the ramdisk @ 128M.
|
||||||
*/
|
*/
|
||||||
memcpy_toio(mdev->aper.va + (mdev->bootaddr << 1),
|
memcpy_toio(mdev->aper.va + (mdev->bootaddr << 1), fw->data, fw->size);
|
||||||
fw->data, fw->size);
|
|
||||||
iowrite32(cpu_to_le32(mdev->bootaddr << 1), &bp->hdr.ramdisk_image);
|
iowrite32(cpu_to_le32(mdev->bootaddr << 1), &bp->hdr.ramdisk_image);
|
||||||
iowrite32(cpu_to_le32(fw->size), &bp->hdr.ramdisk_size);
|
iowrite32(cpu_to_le32(fw->size), &bp->hdr.ramdisk_size);
|
||||||
release_firmware(fw);
|
release_firmware(fw);
|
||||||
|
@ -484,8 +482,7 @@ mic_x100_load_firmware(struct mic_device *mdev, const char *buf)
|
||||||
if (mdev->ramdisk)
|
if (mdev->ramdisk)
|
||||||
rc = mic_x100_load_ramdisk(mdev);
|
rc = mic_x100_load_ramdisk(mdev);
|
||||||
error:
|
error:
|
||||||
dev_dbg(mdev->sdev->parent, "%s %d rc %d\n",
|
dev_dbg(mdev->sdev->parent, "%s %d rc %d\n", __func__, __LINE__, rc);
|
||||||
__func__, __LINE__, rc);
|
|
||||||
done:
|
done:
|
||||||
return rc;
|
return rc;
|
||||||
}
|
}
|
||||||
|
@ -524,8 +521,8 @@ mic_x100_smpt_set(struct mic_device *mdev, dma_addr_t dma_addr, u8 index)
|
||||||
uint32_t smpt_reg_val = BUILD_SMPT(SNOOP_ON,
|
uint32_t smpt_reg_val = BUILD_SMPT(SNOOP_ON,
|
||||||
dma_addr >> mdev->smpt->info.page_shift);
|
dma_addr >> mdev->smpt->info.page_shift);
|
||||||
mic_mmio_write(&mdev->mmio, smpt_reg_val,
|
mic_mmio_write(&mdev->mmio, smpt_reg_val,
|
||||||
MIC_X100_SBOX_BASE_ADDRESS +
|
MIC_X100_SBOX_BASE_ADDRESS +
|
||||||
MIC_X100_SBOX_SMPT00 + (4 * index));
|
MIC_X100_SBOX_SMPT00 + (4 * index));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
Loading…
Reference in a new issue