[PATCH v2 3/4] nvme: Implement resume_from_suspend and sed block ioctl

Keith Busch keith.busch at intel.com
Wed Nov 30 16:50:41 PST 2016


On Tue, Nov 29, 2016 at 02:52:01PM -0700, Scott Bauer wrote:
> +static int nvme_sec_submit(void *data, u16 spsp, u8 secp, void *buffer,
> +			   size_t len, bool send)
> +{
> +	struct request_queue *q;
> +	struct request *req;
> +	struct nvme_ns *ns;
> +	struct nvme_command cmd = { 0 };
> +	int ret;
> +
> +	ns = data;
> +
> +	if (send)
> +		cmd.common.opcode = (u8)nvme_admin_security_send;
> +	else
> +		cmd.common.opcode = (u8)nvme_admin_security_recv;
> +
> +	cmd.common.nsid = ns->ns_id;
> +	cmd.common.cdw10[0] = cpu_to_le32(((u32)secp) << 24 | ((u32)spsp) << 8);
> +	cmd.common.cdw10[1] = cpu_to_le32(len);
> +
> +	q = ns->ctrl->admin_q;
> +
> +	req = nvme_alloc_request(q, &cmd, 0, NVME_QID_ANY);
> +	if (IS_ERR(req)) {
> +		ret = PTR_ERR(req);
> +		return ret;
> +	}
> +
> +	req->timeout = ADMIN_TIMEOUT;
> +	req->special = NULL;
> +
> +	if (buffer && len) {
> +		ret = blk_rq_map_kern(q, req, buffer, len, GFP_KERNEL);
> +		if (ret)
> +			goto out;
> +	}
> +
> +	ret = blk_execute_rq(req->q, ns->disk, req, 1);

I think you want to use the __nvme_submit_sync_command API instead of
duplicating some of the things it does for you.



More information about the Linux-nvme mailing list