Skip to content

Commit deee748

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: "A small number of improvements all over the place: - vdpa/octeon support for multiple interrupts - virtio-pci support for error recovery - vp_vdpa support for notification with data - vhost/net fix to set num_buffers for spec compliance - virtio-mem now works with kdump on s390 And small cleanups all over the place" * tag 'for_linus' of git://git.kernel.org/pub/scm/linux/kernel/git/mst/vhost: (23 commits) virtio_blk: Add support for transport error recovery virtio_pci: Add support for PCIe Function Level Reset vhost/net: Set num_buffers for virtio 1.0 vdpa/octeon_ep: read vendor-specific PCI capability virtio-pci: define type and header for PCI vendor data vdpa/octeon_ep: handle device config change events vdpa/octeon_ep: enable support for multiple interrupts per device vdpa: solidrun: Replace deprecated PCI functions s390/kdump: virtio-mem kdump support (CONFIG_PROC_VMCORE_DEVICE_RAM) virtio-mem: support CONFIG_PROC_VMCORE_DEVICE_RAM virtio-mem: remember usable region size virtio-mem: mark device ready before registering callbacks in kdump mode fs/proc/vmcore: introduce PROC_VMCORE_DEVICE_RAM to detect device RAM ranges in 2nd kernel fs/proc/vmcore: factor out freeing a list of vmcore ranges fs/proc/vmcore: factor out allocating a vmcore range and adding it to a list fs/proc/vmcore: move vmcore definitions out of kcore.h fs/proc/vmcore: prefix all pr_* with "vmcore:" fs/proc/vmcore: disallow vmcore modifications while the vmcore is open fs/proc/vmcore: replace vmcoredd_mutex by vmcore_mutex fs/proc/vmcore: convert vmcore_cb_lock into vmcore_mutex ...
2 parents 805ba04 + 5820a3b commit deee748

File tree

20 files changed

+735
-193
lines changed

20 files changed

+735
-193
lines changed

arch/s390/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,7 @@ config S390
244244
select MODULES_USE_ELF_RELA
245245
select NEED_DMA_MAP_STATE if PCI
246246
select NEED_PER_CPU_EMBED_FIRST_CHUNK
247+
select NEED_PROC_VMCORE_DEVICE_RAM if PROC_VMCORE
247248
select NEED_SG_DMA_LENGTH if PCI
248249
select OLD_SIGACTION
249250
select OLD_SIGSUSPEND3

arch/s390/kernel/crash_dump.c

Lines changed: 31 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -506,6 +506,19 @@ static int get_mem_chunk_cnt(void)
506506
return cnt;
507507
}
508508

509+
static void fill_ptload(Elf64_Phdr *phdr, unsigned long paddr,
510+
unsigned long vaddr, unsigned long size)
511+
{
512+
phdr->p_type = PT_LOAD;
513+
phdr->p_vaddr = vaddr;
514+
phdr->p_offset = paddr;
515+
phdr->p_paddr = paddr;
516+
phdr->p_filesz = size;
517+
phdr->p_memsz = size;
518+
phdr->p_flags = PF_R | PF_W | PF_X;
519+
phdr->p_align = PAGE_SIZE;
520+
}
521+
509522
/*
510523
* Initialize ELF loads (new kernel)
511524
*/
@@ -518,14 +531,8 @@ static void loads_init(Elf64_Phdr *phdr, bool os_info_has_vm)
518531
if (os_info_has_vm)
519532
old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);
520533
for_each_physmem_range(idx, &oldmem_type, &start, &end) {
521-
phdr->p_type = PT_LOAD;
522-
phdr->p_vaddr = old_identity_base + start;
523-
phdr->p_offset = start;
524-
phdr->p_paddr = start;
525-
phdr->p_filesz = end - start;
526-
phdr->p_memsz = end - start;
527-
phdr->p_flags = PF_R | PF_W | PF_X;
528-
phdr->p_align = PAGE_SIZE;
534+
fill_ptload(phdr, start, old_identity_base + start,
535+
end - start);
529536
phdr++;
530537
}
531538
}
@@ -535,6 +542,22 @@ static bool os_info_has_vm(void)
535542
return os_info_old_value(OS_INFO_KASLR_OFFSET);
536543
}
537544

545+
#ifdef CONFIG_PROC_VMCORE_DEVICE_RAM
546+
/*
547+
* Fill PT_LOAD for a physical memory range owned by a device and detected by
548+
* its device driver.
549+
*/
550+
void elfcorehdr_fill_device_ram_ptload_elf64(Elf64_Phdr *phdr,
551+
unsigned long long paddr, unsigned long long size)
552+
{
553+
unsigned long old_identity_base = 0;
554+
555+
if (os_info_has_vm())
556+
old_identity_base = os_info_old_value(OS_INFO_IDENTITY_BASE);
557+
fill_ptload(phdr, paddr, old_identity_base + paddr, size);
558+
}
559+
#endif
560+
538561
/*
539562
* Prepare PT_LOAD type program header for kernel image region
540563
*/

drivers/block/virtio_blk.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1579,8 +1579,7 @@ static void virtblk_remove(struct virtio_device *vdev)
15791579
put_disk(vblk->disk);
15801580
}
15811581

1582-
#ifdef CONFIG_PM_SLEEP
1583-
static int virtblk_freeze(struct virtio_device *vdev)
1582+
static int virtblk_freeze_priv(struct virtio_device *vdev)
15841583
{
15851584
struct virtio_blk *vblk = vdev->priv;
15861585
struct request_queue *q = vblk->disk->queue;
@@ -1602,7 +1601,7 @@ static int virtblk_freeze(struct virtio_device *vdev)
16021601
return 0;
16031602
}
16041603

1605-
static int virtblk_restore(struct virtio_device *vdev)
1604+
static int virtblk_restore_priv(struct virtio_device *vdev)
16061605
{
16071606
struct virtio_blk *vblk = vdev->priv;
16081607
int ret;
@@ -1616,8 +1615,29 @@ static int virtblk_restore(struct virtio_device *vdev)
16161615

16171616
return 0;
16181617
}
1618+
1619+
#ifdef CONFIG_PM_SLEEP
1620+
static int virtblk_freeze(struct virtio_device *vdev)
1621+
{
1622+
return virtblk_freeze_priv(vdev);
1623+
}
1624+
1625+
static int virtblk_restore(struct virtio_device *vdev)
1626+
{
1627+
return virtblk_restore_priv(vdev);
1628+
}
16191629
#endif
16201630

1631+
static int virtblk_reset_prepare(struct virtio_device *vdev)
1632+
{
1633+
return virtblk_freeze_priv(vdev);
1634+
}
1635+
1636+
static int virtblk_reset_done(struct virtio_device *vdev)
1637+
{
1638+
return virtblk_restore_priv(vdev);
1639+
}
1640+
16211641
static const struct virtio_device_id id_table[] = {
16221642
{ VIRTIO_ID_BLOCK, VIRTIO_DEV_ANY_ID },
16231643
{ 0 },
@@ -1653,6 +1673,8 @@ static struct virtio_driver virtio_blk = {
16531673
.freeze = virtblk_freeze,
16541674
.restore = virtblk_restore,
16551675
#endif
1676+
.reset_prepare = virtblk_reset_prepare,
1677+
.reset_done = virtblk_reset_done,
16561678
};
16571679

16581680
static int __init virtio_blk_init(void)

drivers/vdpa/octeon_ep/octep_vdpa.h

Lines changed: 26 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
#include <linux/pci_regs.h>
99
#include <linux/vdpa.h>
1010
#include <linux/virtio_pci_modern.h>
11+
#include <uapi/linux/virtio_crypto.h>
1112
#include <uapi/linux/virtio_net.h>
1213
#include <uapi/linux/virtio_blk.h>
1314
#include <uapi/linux/virtio_config.h>
@@ -29,12 +30,12 @@
2930
#define OCTEP_EPF_RINFO(x) (0x000209f0 | ((x) << 25))
3031
#define OCTEP_VF_MBOX_DATA(x) (0x00010210 | ((x) << 17))
3132
#define OCTEP_PF_MBOX_DATA(x) (0x00022000 | ((x) << 4))
32-
33-
#define OCTEP_EPF_RINFO_RPVF(val) (((val) >> 32) & 0xF)
34-
#define OCTEP_EPF_RINFO_NVFS(val) (((val) >> 48) & 0x7F)
33+
#define OCTEP_VF_IN_CTRL(x) (0x00010000 | ((x) << 17))
34+
#define OCTEP_VF_IN_CTRL_RPVF(val) (((val) >> 48) & 0xF)
3535

3636
#define OCTEP_FW_READY_SIGNATURE0 0xFEEDFEED
3737
#define OCTEP_FW_READY_SIGNATURE1 0x3355ffaa
38+
#define OCTEP_MAX_CB_INTR 8
3839

3940
enum octep_vdpa_dev_status {
4041
OCTEP_VDPA_DEV_STATUS_INVALID,
@@ -48,9 +49,26 @@ enum octep_vdpa_dev_status {
4849
struct octep_vring_info {
4950
struct vdpa_callback cb;
5051
void __iomem *notify_addr;
51-
u32 __iomem *cb_notify_addr;
52+
void __iomem *cb_notify_addr;
5253
phys_addr_t notify_pa;
53-
char msix_name[256];
54+
};
55+
56+
enum octep_pci_vndr_cfg_type {
57+
OCTEP_PCI_VNDR_CFG_TYPE_VIRTIO_ID,
58+
OCTEP_PCI_VNDR_CFG_TYPE_MAX,
59+
};
60+
61+
struct octep_pci_vndr_data {
62+
struct virtio_pci_vndr_data hdr;
63+
u8 id;
64+
u8 bar;
65+
union {
66+
u64 data;
67+
struct {
68+
u32 offset;
69+
u32 length;
70+
};
71+
};
5472
};
5573

5674
struct octep_hw {
@@ -68,7 +86,9 @@ struct octep_hw {
6886
u64 features;
6987
u16 nr_vring;
7088
u32 config_size;
71-
int irq;
89+
int nb_irqs;
90+
int *irqs;
91+
u8 dev_id;
7292
};
7393

7494
u8 octep_hw_get_status(struct octep_hw *oct_hw);

drivers/vdpa/octeon_ep/octep_vdpa_hw.c

Lines changed: 35 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
/* Copyright (C) 2024 Marvell. */
33

44
#include <linux/iopoll.h>
5+
#include <linux/build_bug.h>
56

67
#include "octep_vdpa.h"
78

@@ -358,7 +359,14 @@ u16 octep_get_vq_size(struct octep_hw *oct_hw)
358359

359360
static u32 octep_get_config_size(struct octep_hw *oct_hw)
360361
{
361-
return sizeof(struct virtio_net_config);
362+
switch (oct_hw->dev_id) {
363+
case VIRTIO_ID_NET:
364+
return sizeof(struct virtio_net_config);
365+
case VIRTIO_ID_CRYPTO:
366+
return sizeof(struct virtio_crypto_config);
367+
default:
368+
return 0;
369+
}
362370
}
363371

364372
static void __iomem *octep_get_cap_addr(struct octep_hw *oct_hw, struct virtio_pci_cap *cap)
@@ -416,8 +424,25 @@ static int octep_pci_signature_verify(struct octep_hw *oct_hw)
416424
return 0;
417425
}
418426

427+
static void octep_vndr_data_process(struct octep_hw *oct_hw,
428+
struct octep_pci_vndr_data *vndr_data)
429+
{
430+
BUILD_BUG_ON(sizeof(struct octep_pci_vndr_data) % 4 != 0);
431+
432+
switch (vndr_data->id) {
433+
case OCTEP_PCI_VNDR_CFG_TYPE_VIRTIO_ID:
434+
oct_hw->dev_id = (u8)vndr_data->data;
435+
break;
436+
default:
437+
dev_err(&oct_hw->pdev->dev, "Invalid vendor data id %u\n",
438+
vndr_data->id);
439+
break;
440+
}
441+
}
442+
419443
int octep_hw_caps_read(struct octep_hw *oct_hw, struct pci_dev *pdev)
420444
{
445+
struct octep_pci_vndr_data vndr_data;
421446
struct octep_mbox __iomem *mbox;
422447
struct device *dev = &pdev->dev;
423448
struct virtio_pci_cap cap;
@@ -466,6 +491,15 @@ int octep_hw_caps_read(struct octep_hw *oct_hw, struct pci_dev *pdev)
466491
case VIRTIO_PCI_CAP_ISR_CFG:
467492
oct_hw->isr = octep_get_cap_addr(oct_hw, &cap);
468493
break;
494+
case VIRTIO_PCI_CAP_VENDOR_CFG:
495+
octep_pci_caps_read(oct_hw, &vndr_data, sizeof(vndr_data), pos);
496+
if (vndr_data.hdr.vendor_id != PCI_VENDOR_ID_CAVIUM) {
497+
dev_err(dev, "Invalid vendor data\n");
498+
return -EINVAL;
499+
}
500+
501+
octep_vndr_data_process(oct_hw, &vndr_data);
502+
break;
469503
}
470504

471505
pos = cap.cap_next;
@@ -495,8 +529,6 @@ int octep_hw_caps_read(struct octep_hw *oct_hw, struct pci_dev *pdev)
495529
if (!oct_hw->vqs)
496530
return -ENOMEM;
497531

498-
oct_hw->irq = -1;
499-
500532
dev_info(&pdev->dev, "Device features : %llx\n", oct_hw->features);
501533
dev_info(&pdev->dev, "Maximum queues : %u\n", oct_hw->nr_vring);
502534

0 commit comments

Comments
 (0)