Skip to content

Commit 0910270

Browse files
committed
Merge tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost
Pull virtio updates from Michael Tsirkin: - virtio-mem: paravirtualized memory hotplug - support doorbell mapping for vdpa - config interrupt support in ifc - fixes all over the place * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (40 commits) vhost/test: fix up after API change virtio_mem: convert device block size into 64bit virtio-mem: drop unnecessary initialization ifcvf: implement config interrupt in IFCVF vhost: replace -1 with VHOST_FILE_UNBIND in ioctls vhost_vdpa: Support config interrupt in vdpa ifcvf: ignore continuous setting same status value virtio-mem: Don't rely on implicit compiler padding for requests virtio-mem: Try to unplug the complete online memory block first virtio-mem: Use -ETXTBSY as error code if the device is busy virtio-mem: Unplug subblocks right-to-left virtio-mem: Drop manual check for already present memory virtio-mem: Add parent resource for all added "System RAM" virtio-mem: Better retry handling virtio-mem: Offline and remove completely unplugged memory blocks mm/memory_hotplug: Introduce offline_and_remove_memory() virtio-mem: Allow to offline partially unplugged memory blocks mm: Allow to offline unmovable PageOffline() pages via MEM_GOING_OFFLINE virtio-mem: Paravirtualized memory hotunplug part 2 virtio-mem: Paravirtualized memory hotunplug part 1 ...
2 parents 84fc461 + 044e4b0 commit 0910270

36 files changed

+2722
-143
lines changed

MAINTAINERS

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18114,9 +18114,18 @@ F: drivers/virtio/
1811418114
F: include/linux/vdpa.h
1811518115
F: include/linux/virtio*.h
1811618116
F: include/uapi/linux/virtio_*.h
18117-
F: mm/balloon_compaction.c
1811818117
F: tools/virtio/
1811918118

18119+
VIRTIO BALLOON
18120+
M: "Michael S. Tsirkin" <[email protected]>
18121+
M: David Hildenbrand <[email protected]>
18122+
18123+
S: Maintained
18124+
F: drivers/virtio/virtio_balloon.c
18125+
F: include/uapi/linux/virtio_balloon.h
18126+
F: include/linux/balloon_compaction.h
18127+
F: mm/balloon_compaction.c
18128+
1812018129
VIRTIO CRYPTO DRIVER
1812118130
M: Gonglei <[email protected]>
1812218131
@@ -18182,6 +18191,13 @@ S: Maintained
1818218191
F: drivers/iommu/virtio-iommu.c
1818318192
F: include/uapi/linux/virtio_iommu.h
1818418193

18194+
VIRTIO MEM DRIVER
18195+
M: David Hildenbrand <[email protected]>
18196+
18197+
S: Maintained
18198+
F: drivers/virtio/virtio_mem.c
18199+
F: include/uapi/linux/virtio_mem.h
18200+
1818518201
VIRTUAL BOX GUEST DEVICE DRIVER
1818618202
M: Hans de Goede <[email protected]>
1818718203
M: Arnd Bergmann <[email protected]>

drivers/acpi/numa/srat.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ int pxm_to_node(int pxm)
3535
return NUMA_NO_NODE;
3636
return pxm_to_node_map[pxm];
3737
}
38+
EXPORT_SYMBOL(pxm_to_node);
3839

3940
int node_to_pxm(int node)
4041
{

drivers/crypto/virtio/virtio_crypto_algs.c

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -350,13 +350,18 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
350350
int err;
351351
unsigned long flags;
352352
struct scatterlist outhdr, iv_sg, status_sg, **sgs;
353-
int i;
354353
u64 dst_len;
355354
unsigned int num_out = 0, num_in = 0;
356355
int sg_total;
357356
uint8_t *iv;
357+
struct scatterlist *sg;
358358

359359
src_nents = sg_nents_for_len(req->src, req->cryptlen);
360+
if (src_nents < 0) {
361+
pr_err("Invalid number of src SG.\n");
362+
return src_nents;
363+
}
364+
360365
dst_nents = sg_nents(req->dst);
361366

362367
pr_debug("virtio_crypto: Number of sgs (src_nents: %d, dst_nents: %d)\n",
@@ -402,6 +407,7 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
402407
goto free;
403408
}
404409

410+
dst_len = min_t(unsigned int, req->cryptlen, dst_len);
405411
pr_debug("virtio_crypto: src_len: %u, dst_len: %llu\n",
406412
req->cryptlen, dst_len);
407413

@@ -442,12 +448,12 @@ __virtio_crypto_skcipher_do_req(struct virtio_crypto_sym_request *vc_sym_req,
442448
vc_sym_req->iv = iv;
443449

444450
/* Source data */
445-
for (i = 0; i < src_nents; i++)
446-
sgs[num_out++] = &req->src[i];
451+
for (sg = req->src; src_nents; sg = sg_next(sg), src_nents--)
452+
sgs[num_out++] = sg;
447453

448454
/* Destination data */
449-
for (i = 0; i < dst_nents; i++)
450-
sgs[num_out + num_in++] = &req->dst[i];
455+
for (sg = req->dst; sg; sg = sg_next(sg))
456+
sgs[num_out + num_in++] = sg;
451457

452458
/* Status */
453459
sg_init_one(&status_sg, &vc_req->status, sizeof(vc_req->status));
@@ -577,10 +583,11 @@ static void virtio_crypto_skcipher_finalize_req(
577583
scatterwalk_map_and_copy(req->iv, req->dst,
578584
req->cryptlen - AES_BLOCK_SIZE,
579585
AES_BLOCK_SIZE, 0);
580-
crypto_finalize_skcipher_request(vc_sym_req->base.dataq->engine,
581-
req, err);
582586
kzfree(vc_sym_req->iv);
583587
virtcrypto_clear_request(&vc_sym_req->base);
588+
589+
crypto_finalize_skcipher_request(vc_sym_req->base.dataq->engine,
590+
req, err);
584591
}
585592

586593
static struct virtio_crypto_algo virtio_crypto_algs[] = { {

drivers/misc/mic/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ config MIC_COSM
116116

117117
config VOP
118118
tristate "VOP Driver"
119-
depends on VOP_BUS && VHOST_DPN
119+
depends on VOP_BUS
120120
select VHOST_RING
121121
select VIRTIO
122122
help

drivers/net/caif/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ config CAIF_HSI
5050

5151
config CAIF_VIRTIO
5252
tristate "CAIF virtio transport driver"
53-
depends on CAIF && HAS_DMA && VHOST_DPN
53+
depends on CAIF && HAS_DMA
5454
select VHOST_RING
5555
select VIRTIO
5656
select GENERIC_ALLOCATOR

drivers/vdpa/Kconfig

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ if VDPA
1010

1111
config VDPA_SIM
1212
tristate "vDPA device simulator"
13-
depends on RUNTIME_TESTING_MENU && HAS_DMA && VHOST_DPN
13+
depends on RUNTIME_TESTING_MENU && HAS_DMA
1414
select VHOST_RING
1515
default n
1616
help

drivers/vdpa/ifcvf/ifcvf_base.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,6 +185,9 @@ void ifcvf_set_status(struct ifcvf_hw *hw, u8 status)
185185

186186
void ifcvf_reset(struct ifcvf_hw *hw)
187187
{
188+
hw->config_cb.callback = NULL;
189+
hw->config_cb.private = NULL;
190+
188191
ifcvf_set_status(hw, 0);
189192
/* flush set_status, make sure VF is stopped, reset */
190193
ifcvf_get_status(hw);

drivers/vdpa/ifcvf/ifcvf_base.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
((1ULL << VIRTIO_NET_F_MAC) | \
2828
(1ULL << VIRTIO_F_ANY_LAYOUT) | \
2929
(1ULL << VIRTIO_F_VERSION_1) | \
30+
(1ULL << VIRTIO_NET_F_STATUS) | \
3031
(1ULL << VIRTIO_F_ORDER_PLATFORM) | \
3132
(1ULL << VIRTIO_F_IOMMU_PLATFORM) | \
3233
(1ULL << VIRTIO_NET_F_MRG_RXBUF))
@@ -81,6 +82,9 @@ struct ifcvf_hw {
8182
void __iomem *net_cfg;
8283
struct vring_info vring[IFCVF_MAX_QUEUE_PAIRS * 2];
8384
void __iomem * const *base;
85+
char config_msix_name[256];
86+
struct vdpa_callback config_cb;
87+
8488
};
8589

8690
struct ifcvf_adapter {

drivers/vdpa/ifcvf/ifcvf_main.c

Lines changed: 98 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,16 @@
1818
#define DRIVER_AUTHOR "Intel Corporation"
1919
#define IFCVF_DRIVER_NAME "ifcvf"
2020

21+
static irqreturn_t ifcvf_config_changed(int irq, void *arg)
22+
{
23+
struct ifcvf_hw *vf = arg;
24+
25+
if (vf->config_cb.callback)
26+
return vf->config_cb.callback(vf->config_cb.private);
27+
28+
return IRQ_HANDLED;
29+
}
30+
2131
static irqreturn_t ifcvf_intr_handler(int irq, void *arg)
2232
{
2333
struct vring_info *vring = arg;
@@ -28,6 +38,68 @@ static irqreturn_t ifcvf_intr_handler(int irq, void *arg)
2838
return IRQ_HANDLED;
2939
}
3040

41+
static void ifcvf_free_irq_vectors(void *data)
42+
{
43+
pci_free_irq_vectors(data);
44+
}
45+
46+
static void ifcvf_free_irq(struct ifcvf_adapter *adapter, int queues)
47+
{
48+
struct pci_dev *pdev = adapter->pdev;
49+
struct ifcvf_hw *vf = &adapter->vf;
50+
int i;
51+
52+
53+
for (i = 0; i < queues; i++)
54+
devm_free_irq(&pdev->dev, vf->vring[i].irq, &vf->vring[i]);
55+
56+
ifcvf_free_irq_vectors(pdev);
57+
}
58+
59+
static int ifcvf_request_irq(struct ifcvf_adapter *adapter)
60+
{
61+
struct pci_dev *pdev = adapter->pdev;
62+
struct ifcvf_hw *vf = &adapter->vf;
63+
int vector, i, ret, irq;
64+
65+
ret = pci_alloc_irq_vectors(pdev, IFCVF_MAX_INTR,
66+
IFCVF_MAX_INTR, PCI_IRQ_MSIX);
67+
if (ret < 0) {
68+
IFCVF_ERR(pdev, "Failed to alloc IRQ vectors\n");
69+
return ret;
70+
}
71+
72+
snprintf(vf->config_msix_name, 256, "ifcvf[%s]-config\n",
73+
pci_name(pdev));
74+
vector = 0;
75+
irq = pci_irq_vector(pdev, vector);
76+
ret = devm_request_irq(&pdev->dev, irq,
77+
ifcvf_config_changed, 0,
78+
vf->config_msix_name, vf);
79+
80+
for (i = 0; i < IFCVF_MAX_QUEUE_PAIRS * 2; i++) {
81+
snprintf(vf->vring[i].msix_name, 256, "ifcvf[%s]-%d\n",
82+
pci_name(pdev), i);
83+
vector = i + IFCVF_MSI_QUEUE_OFF;
84+
irq = pci_irq_vector(pdev, vector);
85+
ret = devm_request_irq(&pdev->dev, irq,
86+
ifcvf_intr_handler, 0,
87+
vf->vring[i].msix_name,
88+
&vf->vring[i]);
89+
if (ret) {
90+
IFCVF_ERR(pdev,
91+
"Failed to request irq for vq %d\n", i);
92+
ifcvf_free_irq(adapter, i);
93+
94+
return ret;
95+
}
96+
97+
vf->vring[i].irq = irq;
98+
}
99+
100+
return 0;
101+
}
102+
31103
static int ifcvf_start_datapath(void *private)
32104
{
33105
struct ifcvf_hw *vf = ifcvf_private_to_vf(private);
@@ -118,17 +190,37 @@ static void ifcvf_vdpa_set_status(struct vdpa_device *vdpa_dev, u8 status)
118190
{
119191
struct ifcvf_adapter *adapter;
120192
struct ifcvf_hw *vf;
193+
u8 status_old;
194+
int ret;
121195

122196
vf = vdpa_to_vf(vdpa_dev);
123197
adapter = dev_get_drvdata(vdpa_dev->dev.parent);
198+
status_old = ifcvf_get_status(vf);
124199

125-
if (status == 0) {
200+
if (status_old == status)
201+
return;
202+
203+
if ((status_old & VIRTIO_CONFIG_S_DRIVER_OK) &&
204+
!(status & VIRTIO_CONFIG_S_DRIVER_OK)) {
126205
ifcvf_stop_datapath(adapter);
206+
ifcvf_free_irq(adapter, IFCVF_MAX_QUEUE_PAIRS * 2);
207+
}
208+
209+
if (status == 0) {
127210
ifcvf_reset_vring(adapter);
128211
return;
129212
}
130213

131-
if (status & VIRTIO_CONFIG_S_DRIVER_OK) {
214+
if ((status & VIRTIO_CONFIG_S_DRIVER_OK) &&
215+
!(status_old & VIRTIO_CONFIG_S_DRIVER_OK)) {
216+
ret = ifcvf_request_irq(adapter);
217+
if (ret) {
218+
status = ifcvf_get_status(vf);
219+
status |= VIRTIO_CONFIG_S_FAILED;
220+
ifcvf_set_status(vf, status);
221+
return;
222+
}
223+
132224
if (ifcvf_start_datapath(adapter) < 0)
133225
IFCVF_ERR(adapter->pdev,
134226
"Failed to set ifcvf vdpa status %u\n",
@@ -254,7 +346,10 @@ static void ifcvf_vdpa_set_config(struct vdpa_device *vdpa_dev,
254346
static void ifcvf_vdpa_set_config_cb(struct vdpa_device *vdpa_dev,
255347
struct vdpa_callback *cb)
256348
{
257-
/* We don't support config interrupt */
349+
struct ifcvf_hw *vf = vdpa_to_vf(vdpa_dev);
350+
351+
vf->config_cb.callback = cb->callback;
352+
vf->config_cb.private = cb->private;
258353
}
259354

260355
/*
@@ -284,38 +379,6 @@ static const struct vdpa_config_ops ifc_vdpa_ops = {
284379
.set_config_cb = ifcvf_vdpa_set_config_cb,
285380
};
286381

287-
static int ifcvf_request_irq(struct ifcvf_adapter *adapter)
288-
{
289-
struct pci_dev *pdev = adapter->pdev;
290-
struct ifcvf_hw *vf = &adapter->vf;
291-
int vector, i, ret, irq;
292-
293-
294-
for (i = 0; i < IFCVF_MAX_QUEUE_PAIRS * 2; i++) {
295-
snprintf(vf->vring[i].msix_name, 256, "ifcvf[%s]-%d\n",
296-
pci_name(pdev), i);
297-
vector = i + IFCVF_MSI_QUEUE_OFF;
298-
irq = pci_irq_vector(pdev, vector);
299-
ret = devm_request_irq(&pdev->dev, irq,
300-
ifcvf_intr_handler, 0,
301-
vf->vring[i].msix_name,
302-
&vf->vring[i]);
303-
if (ret) {
304-
IFCVF_ERR(pdev,
305-
"Failed to request irq for vq %d\n", i);
306-
return ret;
307-
}
308-
vf->vring[i].irq = irq;
309-
}
310-
311-
return 0;
312-
}
313-
314-
static void ifcvf_free_irq_vectors(void *data)
315-
{
316-
pci_free_irq_vectors(data);
317-
}
318-
319382
static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
320383
{
321384
struct device *dev = &pdev->dev;
@@ -349,13 +412,6 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
349412
return ret;
350413
}
351414

352-
ret = pci_alloc_irq_vectors(pdev, IFCVF_MAX_INTR,
353-
IFCVF_MAX_INTR, PCI_IRQ_MSIX);
354-
if (ret < 0) {
355-
IFCVF_ERR(pdev, "Failed to alloc irq vectors\n");
356-
return ret;
357-
}
358-
359415
ret = devm_add_action_or_reset(dev, ifcvf_free_irq_vectors, pdev);
360416
if (ret) {
361417
IFCVF_ERR(pdev,
@@ -379,12 +435,6 @@ static int ifcvf_probe(struct pci_dev *pdev, const struct pci_device_id *id)
379435
adapter->pdev = pdev;
380436
adapter->vdpa.dma_dev = &pdev->dev;
381437

382-
ret = ifcvf_request_irq(adapter);
383-
if (ret) {
384-
IFCVF_ERR(pdev, "Failed to request MSI-X irq\n");
385-
goto err;
386-
}
387-
388438
ret = ifcvf_init_hw(vf, pdev);
389439
if (ret) {
390440
IFCVF_ERR(pdev, "Failed to init IFCVF hw\n");

drivers/vdpa/vdpa_sim/vdpa_sim.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ static void vdpasim_queue_ready(struct vdpasim *vdpasim, unsigned int idx)
101101

102102
static void vdpasim_vq_reset(struct vdpasim_virtqueue *vq)
103103
{
104-
vq->ready = 0;
104+
vq->ready = false;
105105
vq->desc_addr = 0;
106106
vq->driver_addr = 0;
107107
vq->device_addr = 0;
@@ -131,9 +131,10 @@ static void vdpasim_work(struct work_struct *work)
131131
vdpasim, work);
132132
struct vdpasim_virtqueue *txq = &vdpasim->vqs[1];
133133
struct vdpasim_virtqueue *rxq = &vdpasim->vqs[0];
134-
size_t read, write, total_write;
135-
int err;
134+
ssize_t read, write;
135+
size_t total_write;
136136
int pkts = 0;
137+
int err;
137138

138139
spin_lock(&vdpasim->lock);
139140

0 commit comments

Comments
 (0)