Skip to content

Commit f5a3a3b

Browse files
committed
Merge feature/hvlite_virtio_pmem/6.6 into v6.6.75
* commit '7d955beb0207d880fa1862b1ace8487057b5aa6c': virtio-pmem: Support PCI BAR-relative addresses
2 parents 485fb5f + 7d955be commit f5a3a3b

File tree

2 files changed

+19
-4
lines changed

2 files changed

+19
-4
lines changed

drivers/nvdimm/virtio_pmem.c

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
3636
struct virtio_pmem *vpmem;
3737
struct resource res;
3838
int err = 0;
39+
bool have_shm_region;
40+
struct virtio_shm_region pmem_region;
3941

4042
if (!vdev->config->get) {
4143
dev_err(&vdev->dev, "%s failure: config access disabled\n",
@@ -57,10 +59,20 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
5759
goto out_err;
5860
}
5961

60-
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config,
61-
start, &vpmem->start);
62-
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config,
63-
size, &vpmem->size);
62+
/* Retrieve the pmem device's address and size. It may have been supplied
63+
* as a PCI BAR-relative shared memory region, or as a guest absolute address.
64+
*/
65+
have_shm_region = virtio_get_shm_region(vpmem->vdev, &pmem_region,
66+
VIRTIO_PMEM_SHMCAP_ID_PMEM_REGION);
67+
if (have_shm_region) {
68+
vpmem->start = pmem_region.addr;
69+
vpmem->size = pmem_region.len;
70+
} else {
71+
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config,
72+
start, &vpmem->start);
73+
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config,
74+
size, &vpmem->size);
75+
}
6476

6577
res.start = vpmem->start;
6678
res.end = vpmem->start + vpmem->size - 1;

drivers/nvdimm/virtio_pmem.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,9 @@ struct virtio_pmem {
5050
__u64 size;
5151
};
5252

53+
/* For the id field in virtio_pci_shm_cap */
54+
#define VIRTIO_PMEM_SHMCAP_ID_PMEM_REGION 0
55+
5356
void virtio_pmem_host_ack(struct virtqueue *vq);
5457
int async_pmem_flush(struct nd_region *nd_region, struct bio *bio);
5558
#endif

0 commit comments

Comments
 (0)