Commit 6e9eca78 authored by Darek Stojaczyk's avatar Darek Stojaczyk Committed by Changpeng Liu
Browse files

virtio: switch to spdk_*malloc().



spdk_dma_*malloc() is about to be deprecated.

Change-Id: Iacf9f6536ba5baca7b245e639d0d42a89720ba58
Signed-off-by: default avatarDarek Stojaczyk <dariusz.stojaczyk@intel.com>
Reviewed-on: https://review.gerrithub.io/c/spdk/spdk/+/448173


Tested-by: default avatarSPDK CI Jenkins <sys_sgci@intel.com>
Reviewed-by: default avatarJim Harris <james.r.harris@intel.com>
Reviewed-by: default avatarChangpeng Liu <changpeng.liu@intel.com>
parent 2edc6529
Loading
Loading
Loading
Loading
+8 −6
Original line number Diff line number Diff line
@@ -264,8 +264,9 @@ virtio_scsi_dev_init(struct virtio_scsi_dev *svdev, uint16_t max_queues)

	eventq = vdev->vqs[VIRTIO_SCSI_EVENTQ];
	num_events = spdk_min(eventq->vq_nentries, VIRTIO_SCSI_EVENTQ_BUFFER_COUNT);
	svdev->eventq_ios = spdk_dma_zmalloc(sizeof(*svdev->eventq_ios) * num_events,
					     0, NULL);
	svdev->eventq_ios = spdk_zmalloc(sizeof(*svdev->eventq_ios) * num_events,
					 0, NULL, SPDK_ENV_LCORE_ID_ANY,
					 SPDK_MALLOC_DMA);
	if (svdev->eventq_ios == NULL) {
		SPDK_ERRLOG("cannot allocate memory for %"PRIu16" eventq buffers\n",
			    num_events);
@@ -1050,7 +1051,7 @@ _virtio_scsi_dev_scan_finish(struct virtio_scsi_scan_base *base, int errnum)
	}

	if (base->cb_fn == NULL) {
		spdk_dma_free(base);
		spdk_free(base);
		return;
	}

@@ -1063,7 +1064,7 @@ _virtio_scsi_dev_scan_finish(struct virtio_scsi_scan_base *base, int errnum)
	}

	base->cb_fn(base->cb_arg, errnum, bdevs, bdevs_cnt);
	spdk_dma_free(base);
	spdk_free(base);
}

static int
@@ -1648,7 +1649,8 @@ _virtio_scsi_dev_scan_init(struct virtio_scsi_dev *svdev)
		return -EBUSY;
	}

	base = spdk_dma_zmalloc(sizeof(*base), 64, NULL);
	base = spdk_zmalloc(sizeof(*base), 64, NULL,
			    SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
	if (base == NULL) {
		SPDK_ERRLOG("couldn't allocate memory for scsi target scan.\n");
		return -ENOMEM;
@@ -1843,7 +1845,7 @@ _virtio_scsi_dev_unregister_cb(void *io_device)

	remove_cb = svdev->remove_cb;
	remove_ctx = svdev->remove_ctx;
	spdk_dma_free(svdev->eventq_ios);
	spdk_free(svdev->eventq_ios);
	free(svdev);

	if (remove_cb) {
+3 −2
Original line number Diff line number Diff line
@@ -652,8 +652,9 @@ alloc_task_pool(struct spdk_vhost_blk_session *bvsession)
			free_task_pool(bvsession);
			return -1;
		}
		vq->tasks = spdk_dma_zmalloc(sizeof(struct spdk_vhost_blk_task) * task_cnt,
					     SPDK_CACHE_LINE_SIZE, NULL);
		vq->tasks = spdk_zmalloc(sizeof(struct spdk_vhost_blk_task) * task_cnt,
					 SPDK_CACHE_LINE_SIZE, NULL,
					 SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
		if (vq->tasks == NULL) {
			SPDK_ERRLOG("Controller %s: failed to allocate %"PRIu32" tasks for virtqueue %"PRIu16"\n",
				    bvdev->vdev.name, task_cnt, i);
+3 −2
Original line number Diff line number Diff line
@@ -1060,8 +1060,9 @@ alloc_task_pool(struct spdk_vhost_nvme_dev *nvme)
	entries = nvme->num_io_queues * MAX_QUEUE_ENTRIES_SUPPORTED;

	for (i = 0; i < entries; i++) {
		task = spdk_dma_zmalloc(sizeof(struct spdk_vhost_nvme_task),
					SPDK_CACHE_LINE_SIZE, NULL);
		task = spdk_zmalloc(sizeof(struct spdk_vhost_nvme_task),
				    SPDK_CACHE_LINE_SIZE, NULL,
				    SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
		if (task == NULL) {
			SPDK_ERRLOG("Controller %s alloc task pool failed\n",
				    nvme->vdev.name);
+3 −2
Original line number Diff line number Diff line
@@ -1236,8 +1236,9 @@ alloc_task_pool(struct spdk_vhost_scsi_session *svsession)
			free_task_pool(svsession);
			return -1;
		}
		vq->tasks = spdk_dma_zmalloc(sizeof(struct spdk_vhost_scsi_task) * task_cnt,
					     SPDK_CACHE_LINE_SIZE, NULL);
		vq->tasks = spdk_zmalloc(sizeof(struct spdk_vhost_scsi_task) * task_cnt,
					 SPDK_CACHE_LINE_SIZE, NULL,
					 SPDK_ENV_LCORE_ID_ANY, SPDK_MALLOC_DMA);
		if (vq->tasks == NULL) {
			SPDK_ERRLOG("Controller %s: failed to allocate %"PRIu32" tasks for virtqueue %"PRIu16"\n",
				    svdev->vdev.name, task_cnt, i);