Skip to content

Commit 4a2dd2c

Browse files
committed
Merge tag 'nvme-5.9-2020-09-17' of git://git.infradead.org/nvme into block-5.9
Pull NVMe fixes from Christoph: "nvme fixes for 5.9 - another quirk for the controller from hell (David Milburn) - fix a Kconfig dependency (Necip Fazil Yildiran) - char devices / passthrough refcount fixes (Chaitanya Kulkarni)" * tag 'nvme-5.9-2020-09-17' of git://git.infradead.org/nvme: nvmet: get transport reference for passthru ctrl nvme-core: get/put ctrl and transport module in nvme_dev_open/release() nvme-tcp: fix kconfig dependency warning when !CRYPTO nvme-pci: disable the write zeros command for Intel 600P/P3100
2 parents 709192d + 3a6b076 commit 4a2dd2c

File tree

4 files changed

+20
-1
lines changed

4 files changed

+20
-1
lines changed

drivers/nvme/host/Kconfig

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,7 @@ config NVME_TCP
7373
depends on INET
7474
depends on BLK_DEV_NVME
7575
select NVME_FABRICS
76+
select CRYPTO
7677
select CRYPTO_CRC32C
7778
help
7879
This provides support for the NVMe over Fabrics protocol using

drivers/nvme/host/core.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3261,10 +3261,24 @@ static int nvme_dev_open(struct inode *inode, struct file *file)
32613261
return -EWOULDBLOCK;
32623262
}
32633263

3264+
nvme_get_ctrl(ctrl);
3265+
if (!try_module_get(ctrl->ops->module))
3266+
return -EINVAL;
3267+
32643268
file->private_data = ctrl;
32653269
return 0;
32663270
}
32673271

3272+
static int nvme_dev_release(struct inode *inode, struct file *file)
3273+
{
3274+
struct nvme_ctrl *ctrl =
3275+
container_of(inode->i_cdev, struct nvme_ctrl, cdev);
3276+
3277+
module_put(ctrl->ops->module);
3278+
nvme_put_ctrl(ctrl);
3279+
return 0;
3280+
}
3281+
32683282
static int nvme_dev_user_cmd(struct nvme_ctrl *ctrl, void __user *argp)
32693283
{
32703284
struct nvme_ns *ns;
@@ -3327,6 +3341,7 @@ static long nvme_dev_ioctl(struct file *file, unsigned int cmd,
33273341
static const struct file_operations nvme_dev_fops = {
33283342
.owner = THIS_MODULE,
33293343
.open = nvme_dev_open,
3344+
.release = nvme_dev_release,
33303345
.unlocked_ioctl = nvme_dev_ioctl,
33313346
.compat_ioctl = compat_ptr_ioctl,
33323347
};

drivers/nvme/host/pci.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3153,7 +3153,8 @@ static const struct pci_device_id nvme_id_table[] = {
31533153
{ PCI_VDEVICE(INTEL, 0xf1a5), /* Intel 600P/P3100 */
31543154
.driver_data = NVME_QUIRK_NO_DEEPEST_PS |
31553155
NVME_QUIRK_MEDIUM_PRIO_SQ |
3156-
NVME_QUIRK_NO_TEMP_THRESH_CHANGE },
3156+
NVME_QUIRK_NO_TEMP_THRESH_CHANGE |
3157+
NVME_QUIRK_DISABLE_WRITE_ZEROES, },
31573158
{ PCI_VDEVICE(INTEL, 0xf1a6), /* Intel 760p/Pro 7600p */
31583159
.driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN, },
31593160
{ PCI_VDEVICE(INTEL, 0x5845), /* Qemu emulated controller */

drivers/nvme/target/passthru.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -517,6 +517,7 @@ int nvmet_passthru_ctrl_enable(struct nvmet_subsys *subsys)
517517
subsys->ver = NVME_VS(1, 2, 1);
518518
}
519519

520+
__module_get(subsys->passthru_ctrl->ops->module);
520521
mutex_unlock(&subsys->lock);
521522
return 0;
522523

@@ -531,6 +532,7 @@ static void __nvmet_passthru_ctrl_disable(struct nvmet_subsys *subsys)
531532
{
532533
if (subsys->passthru_ctrl) {
533534
xa_erase(&passthru_subsystems, subsys->passthru_ctrl->cntlid);
535+
module_put(subsys->passthru_ctrl->ops->module);
534536
nvme_put_ctrl(subsys->passthru_ctrl);
535537
}
536538
subsys->passthru_ctrl = NULL;

0 commit comments

Comments
 (0)