Re: [PATCH v3 11/11] nvmet: Optionally use PCI P2P memory

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



> +				  const char *page, size_t count)
> +{
> +	struct nvmet_port *port = to_nvmet_port(item);
> +	struct device *dev;
> +	struct pci_dev *p2p_dev = NULL;
> +	bool use_p2pmem;
> +
> +	switch (page[0]) {
> +	case 'y':
> +	case 'Y':
> +	case 'a':
> +	case 'A':
> +		use_p2pmem = true;
> +		break;
> +	case 'n':
> +	case 'N':
> +		use_p2pmem = false;
> +		break;
> +	default:
> +		dev = bus_find_device_by_name(&pci_bus_type, NULL, page);
> +		if (!dev) {
> +			pr_err("No such PCI device: %s\n", page);
> +			return -ENODEV;
> +		}
> +
> +		use_p2pmem = true;
> +		p2p_dev = to_pci_dev(dev);
> +
> +		if (!pci_has_p2pmem(p2p_dev)) {
> +			pr_err("PCI device has no peer-to-peer memory: %s\n",
> +			       page);
> +			pci_dev_put(p2p_dev);
> +			return -ENODEV;
> +		}
> +	}

Yikes.  Shouldn't auto just be the normal yes case instead of this
string parsing mess?

> +	if (rsp->req.sg != &rsp->cmd->inline_sg) {
> +		if (rsp->req.p2p_dev)
> +			pci_p2pmem_free_sgl(rsp->req.p2p_dev, rsp->req.sg,
> +					    rsp->req.sg_cnt);
> +		else
> +			sgl_free(rsp->req.sg);
> +	}

Can we factor this into a helper, as the other target drivers (fc for now,
tcp soon) using sgl allocatins should share the code?

(same for the alloc side)




[Index of Archives]     [Linux RAID]     [Linux SCSI]     [Linux ATA RAID]     [IDE]     [Linux Wireless]     [Linux Kernel]     [ATH6KL]     [Linux Bluetooth]     [Linux Netdev]     [Kernel Newbies]     [Security]     [Git]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Device Mapper]

  Powered by Linux