Merge feature/hvlite_virtio_pmem/5.15 into v5.15

* commit '9194f84de8a58bc1a83125054286d649e35054be':
  virtio-pmem: Set DRIVER_OK status prior to creating pmem region
  virtio-pmem: Support PCI BAR-relative addresses
This commit is contained in:
Mitchell Levy 2024-10-10 15:55:56 -07:00
Родитель c778c50143 9194f84de8
Коммит ea6d6059d6
2 изменённых файлов: 26 добавлений и 4 удалений

Просмотреть файл

@ -37,6 +37,8 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
struct virtio_pmem *vpmem; struct virtio_pmem *vpmem;
struct resource res; struct resource res;
int err = 0; int err = 0;
bool have_shm_region;
struct virtio_shm_region pmem_region;
if (!vdev->config->get) { if (!vdev->config->get) {
dev_err(&vdev->dev, "%s failure: config access disabled\n", dev_err(&vdev->dev, "%s failure: config access disabled\n",
@ -58,10 +60,21 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
goto out_err; goto out_err;
} }
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config, /* Retrieve the pmem device's address and size. It may have been supplied
start, &vpmem->start); * as a PCI BAR-relative shared memory region, or as a guest absolute address.
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config, */
size, &vpmem->size); have_shm_region = virtio_get_shm_region(vpmem->vdev, &pmem_region,
VIRTIO_PMEM_SHMCAP_ID_PMEM_REGION);
if (have_shm_region) {
vpmem->start = pmem_region.addr;
vpmem->size = pmem_region.len;
} else {
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config,
start, &vpmem->start);
virtio_cread_le(vpmem->vdev, struct virtio_pmem_config,
size, &vpmem->size);
}
res.start = vpmem->start; res.start = vpmem->start;
res.end = vpmem->start + vpmem->size - 1; res.end = vpmem->start + vpmem->size - 1;
@ -78,6 +91,11 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
dev_set_drvdata(&vdev->dev, vpmem->nvdimm_bus); dev_set_drvdata(&vdev->dev, vpmem->nvdimm_bus);
/* Online the device prior to creating a pmem region, to ensure that
* the region is never touched while the device is offline.
*/
virtio_device_ready(vdev);
ndr_desc.res = &res; ndr_desc.res = &res;
ndr_desc.numa_node = nid; ndr_desc.numa_node = nid;
ndr_desc.flush = async_pmem_flush; ndr_desc.flush = async_pmem_flush;
@ -92,6 +110,7 @@ static int virtio_pmem_probe(struct virtio_device *vdev)
nd_region->provider_data = dev_to_virtio(nd_region->dev.parent->parent); nd_region->provider_data = dev_to_virtio(nd_region->dev.parent->parent);
return 0; return 0;
out_nd: out_nd:
vdev->config->reset(vdev);
nvdimm_bus_unregister(vpmem->nvdimm_bus); nvdimm_bus_unregister(vpmem->nvdimm_bus);
out_vq: out_vq:
vdev->config->del_vqs(vdev); vdev->config->del_vqs(vdev);

Просмотреть файл

@ -50,6 +50,9 @@ struct virtio_pmem {
__u64 size; __u64 size;
}; };
/* For the id field in virtio_pci_shm_cap */
#define VIRTIO_PMEM_SHMCAP_ID_PMEM_REGION 0
void virtio_pmem_host_ack(struct virtqueue *vq); void virtio_pmem_host_ack(struct virtqueue *vq);
int async_pmem_flush(struct nd_region *nd_region, struct bio *bio); int async_pmem_flush(struct nd_region *nd_region, struct bio *bio);
#endif #endif