Pull block fixes from Jens Axboe: "Just a few NVMe fixes that should go into the 6.2 release, adding a quirk and fixing two issues introduced in this release: - NVMe fixes via Christoph: - Always return an ERR_PTR from nvme_pci_alloc_dev (Irvin Cote) - Add bogus ID quirk for ADATA SX6000PNP (Daniel Wagner) - Set the DMA mask earlier (Christoph Hellwig)" * tag 'block-6.2-2023-02-16' of git://git.kernel.dk/linux: nvme-pci: always return an ERR_PTR from nvme_pci_alloc_dev nvme-pci: set the DMA mask earlier nvme-pci: add bogus ID quirk for ADATA SX6000PNP
Unified · Split
| @@ -2509,18 +2509,12 @@ static int nvme_pci_enable(struct nvme_dev *dev) · 2508 unmodified lines | ||
| 2509 | 2509 | { |
| 2510 | 2510 | int result = -ENOMEM; |
| 2511 | 2511 | struct pci_dev *pdev = to_pci_dev(dev->dev); |
| 2512 | − int dma_address_bits = 64; | |
| 2513 | 2512 | |
| 2514 | 2513 | if (pci_enable_device_mem(pdev)) |
| 2515 | 2514 | return result; |
| 2516 | 2515 | |
| 2517 | 2516 | pci_set_master(pdev); |
| 2518 | 2517 | |
| 2519 | − if (dev->ctrl.quirks & NVME_QUIRK_DMA_ADDRESS_BITS_48) | |
| 2520 | − dma_address_bits = 48; | |
| 2521 | − if (dma_set_mask_and_coherent(dev->dev, DMA_BIT_MASK(dma_address_bits))) | |
| 2522 | − goto disable; | |
| 2523 | − | |
| 2524 | 2518 | if (readl(dev->bar + NVME_REG_CSTS) == -1) { |
| 2525 | 2519 | result = -ENODEV; |
| 2526 | 2520 | goto disable; |
| @@ -2970,7 +2964,7 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev, · 443 unmodified lines | ||
| 2970 | 2964 | |
| 2971 | 2965 | dev = kzalloc_node(sizeof(*dev), GFP_KERNEL, node); |
| 2972 | 2966 | if (!dev) |
| 2973 | − return NULL; | |
| 2967 | + return ERR_PTR(-ENOMEM); | |
| 2974 | 2968 | INIT_WORK(&dev->ctrl.reset_work, nvme_reset_work); |
| 2975 | 2969 | mutex_init(&dev->shutdown_lock); |
| 2976 | 2970 | |
| @@ -2998,7 +2992,11 @@ static struct nvme_dev *nvme_pci_alloc_dev(struct pci_dev *pdev, · 21 unmodified lines | ||
| 2998 | 2992 | quirks); |
| 2999 | 2993 | if (ret) |
| 3000 | 2994 | goto out_put_device; |
| 3001 | − | |
| 2995 | + | |
| 2996 | + if (dev->ctrl.quirks & NVME_QUIRK_DMA_ADDRESS_BITS_48) | |
| 2997 | + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(48)); | |
| 2998 | + else | |
| 2999 | + dma_set_mask_and_coherent(&pdev->dev, DMA_BIT_MASK(64)); | |
| 3002 | 3000 | dma_set_min_align_mask(&pdev->dev, NVME_CTRL_PAGE_SIZE - 1); |
| 3003 | 3001 | dma_set_max_seg_size(&pdev->dev, 0xffffffff); |
| 3004 | 3002 | |
| @@ -3031,8 +3029,8 @@ static int nvme_probe(struct pci_dev *pdev, const struct pci_device_id *id) · 26 unmodified lines | ||
| 3031 | 3029 | int result = -ENOMEM; |
| 3032 | 3030 | |
| 3033 | 3031 | dev = nvme_pci_alloc_dev(pdev, id); |
| 3034 | − if (!dev) | |
| 3035 | − return -ENOMEM; | |
| 3032 | + if (IS_ERR(dev)) | |
| 3033 | + return PTR_ERR(dev); | |
| 3036 | 3034 | |
| 3037 | 3035 | result = nvme_dev_map(dev); |
| 3038 | 3036 | if (result) |
| @@ -3423,6 +3421,8 @@ static const struct pci_device_id nvme_id_table[] = { · 384 unmodified lines | ||
| 3423 | 3421 | { PCI_DEVICE(0x10ec, 0x5762), /* ADATA SX6000LNP */ |
| 3424 | 3422 | .driver_data = NVME_QUIRK_IGNORE_DEV_SUBNQN | |
| 3425 | 3423 | NVME_QUIRK_BOGUS_NID, }, |
| 3424 | + { PCI_DEVICE(0x10ec, 0x5763), /* ADATA SX6000PNP */ | |
| 3425 | + .driver_data = NVME_QUIRK_BOGUS_NID, }, | |
| 3426 | 3426 | { PCI_DEVICE(0x1cc1, 0x8201), /* ADATA SX8200PNP 512GB */ |
| 3427 | 3427 | .driver_data = NVME_QUIRK_NO_DEEPEST_PS | |
| 3428 | 3428 | NVME_QUIRK_IGNORE_DEV_SUBNQN, }, |