diff --git a/drivers/nvme/target/pci-epf.c b/drivers/nvme/target/pci-epf.c index 2afe8f4d0e46..b1ba2d0bea6d 100644 --- a/drivers/nvme/target/pci-epf.c +++ b/drivers/nvme/target/pci-epf.c @@ -210,9 +210,7 @@ struct nvmet_pci_epf { bool dma_enabled; struct dma_chan *dma_tx_chan; - struct mutex dma_tx_lock; struct dma_chan *dma_rx_chan; - struct mutex dma_rx_lock; struct mutex mmio_lock; @@ -295,9 +293,6 @@ static void nvmet_pci_epf_init_dma(struct nvmet_pci_epf *nvme_epf) struct dma_chan *chan; dma_cap_mask_t mask; - mutex_init(&nvme_epf->dma_rx_lock); - mutex_init(&nvme_epf->dma_tx_lock); - dma_cap_zero(mask); dma_cap_set(DMA_SLAVE, mask); @@ -336,8 +331,6 @@ static void nvmet_pci_epf_init_dma(struct nvmet_pci_epf *nvme_epf) nvme_epf->dma_rx_chan = NULL; out_dma_no_rx: - mutex_destroy(&nvme_epf->dma_rx_lock); - mutex_destroy(&nvme_epf->dma_tx_lock); nvme_epf->dma_enabled = false; dev_info(&epf->dev, "DMA not supported, falling back to MMIO\n"); @@ -352,8 +345,6 @@ static void nvmet_pci_epf_deinit_dma(struct nvmet_pci_epf *nvme_epf) nvme_epf->dma_tx_chan = NULL; dma_release_channel(nvme_epf->dma_rx_chan); nvme_epf->dma_rx_chan = NULL; - mutex_destroy(&nvme_epf->dma_rx_lock); - mutex_destroy(&nvme_epf->dma_tx_lock); nvme_epf->dma_enabled = false; } @@ -368,18 +359,15 @@ static int nvmet_pci_epf_dma_transfer(struct nvmet_pci_epf *nvme_epf, struct dma_chan *chan; dma_cookie_t cookie; dma_addr_t dma_addr; - struct mutex *lock; int ret; switch (dir) { case DMA_FROM_DEVICE: - lock = &nvme_epf->dma_rx_lock; chan = nvme_epf->dma_rx_chan; sconf.direction = DMA_DEV_TO_MEM; sconf.src_addr = seg->pci_addr; break; case DMA_TO_DEVICE: - lock = &nvme_epf->dma_tx_lock; chan = nvme_epf->dma_tx_chan; sconf.direction = DMA_MEM_TO_DEV; sconf.dst_addr = seg->pci_addr; @@ -388,22 +376,15 @@ static int nvmet_pci_epf_dma_transfer(struct nvmet_pci_epf *nvme_epf, return -EINVAL; } - mutex_lock(lock); - dma_dev = dmaengine_get_dma_device(chan); dma_addr = dma_map_single(dma_dev, seg->buf, seg->length, dir); ret = dma_mapping_error(dma_dev, dma_addr); if (ret) - goto unlock; + return ret; - ret = dmaengine_slave_config(chan, &sconf); - if (ret) { - dev_err(dev, "Failed to configure DMA channel\n"); - goto unmap; - } - - desc = dmaengine_prep_slave_single(chan, dma_addr, seg->length, - sconf.direction, DMA_CTRL_ACK); + desc = dmaengine_prep_config_single_safe(chan, dma_addr, seg->length, + sconf.direction, + DMA_CTRL_ACK, &sconf); if (!desc) { dev_err(dev, "Failed to prepare DMA\n"); ret = -EIO; @@ -426,9 +407,6 @@ static int nvmet_pci_epf_dma_transfer(struct nvmet_pci_epf *nvme_epf, unmap: dma_unmap_single(dma_dev, dma_addr, seg->length, dir); -unlock: - mutex_unlock(lock); - return ret; }