Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 2bf94cab authored by Tomas Winkler's avatar Tomas Winkler Committed by Greg Kroah-Hartman
Browse files

mei: get rid of most of the pci dependencies in mei



For purpose of adding testing HW we would like
to get rid of pci dependency in generic mei code
This patch provides only straight forward changes
FW status and prob quirks need to be handled separately

Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 3a7e9b6c
Loading
Loading
Loading
Loading
+34 −34
Original line number Diff line number Diff line
@@ -78,7 +78,7 @@ int mei_amthif_host_init(struct mei_device *dev)

	me_cl = mei_me_cl_by_uuid(dev, &mei_amthif_guid);
	if (!me_cl) {
		dev_info(&dev->pdev->dev, "amthif: failed to find the client");
		dev_info(dev->dev, "amthif: failed to find the client");
		return -ENOTTY;
	}

@@ -88,7 +88,7 @@ int mei_amthif_host_init(struct mei_device *dev)
	/* Assign iamthif_mtu to the value received from ME  */

	dev->iamthif_mtu = me_cl->props.max_msg_length;
	dev_dbg(&dev->pdev->dev, "IAMTHIF_MTU = %d\n", dev->iamthif_mtu);
	dev_dbg(dev->dev, "IAMTHIF_MTU = %d\n", dev->iamthif_mtu);

	kfree(dev->iamthif_msg_buf);
	dev->iamthif_msg_buf = NULL;
@@ -104,7 +104,7 @@ int mei_amthif_host_init(struct mei_device *dev)
	ret = mei_cl_link(cl, MEI_IAMTHIF_HOST_CLIENT_ID);

	if (ret < 0) {
		dev_err(&dev->pdev->dev,
		dev_err(dev->dev,
			"amthif: failed link client %d\n", ret);
		return ret;
	}
@@ -164,11 +164,11 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,

	/* Only possible if we are in timeout */
	if (!cl) {
		dev_err(&dev->pdev->dev, "bad file ext.\n");
		dev_err(dev->dev, "bad file ext.\n");
		return -ETIME;
	}

	dev_dbg(&dev->pdev->dev, "checking amthif data\n");
	dev_dbg(dev->dev, "checking amthif data\n");
	cb = mei_amthif_find_read_list_entry(dev, file);

	/* Check for if we can block or not*/
@@ -176,7 +176,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
		return -EAGAIN;


	dev_dbg(&dev->pdev->dev, "waiting for amthif data\n");
	dev_dbg(dev->dev, "waiting for amthif data\n");
	while (cb == NULL) {
		/* unlock the Mutex */
		mutex_unlock(&dev->device_lock);
@@ -190,21 +190,21 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
		if (wait_ret)
			return -ERESTARTSYS;

		dev_dbg(&dev->pdev->dev, "woke up from sleep\n");
		dev_dbg(dev->dev, "woke up from sleep\n");
	}


	dev_dbg(&dev->pdev->dev, "Got amthif data\n");
	dev_dbg(dev->dev, "Got amthif data\n");
	dev->iamthif_timer = 0;

	if (cb) {
		timeout = cb->read_time +
			mei_secs_to_jiffies(MEI_IAMTHIF_READ_TIMER);
		dev_dbg(&dev->pdev->dev, "amthif timeout = %lud\n",
		dev_dbg(dev->dev, "amthif timeout = %lud\n",
				timeout);

		if  (time_after(jiffies, timeout)) {
			dev_dbg(&dev->pdev->dev, "amthif Time out\n");
			dev_dbg(dev->dev, "amthif Time out\n");
			/* 15 sec for the message has expired */
			list_del(&cb->list);
			rets = -ETIME;
@@ -224,16 +224,16 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
		 * remove message from deletion list
		 */

	dev_dbg(&dev->pdev->dev, "amthif cb->response_buffer size - %d\n",
	dev_dbg(dev->dev, "amthif cb->response_buffer size - %d\n",
	    cb->response_buffer.size);
	dev_dbg(&dev->pdev->dev, "amthif cb->buf_idx - %lu\n", cb->buf_idx);
	dev_dbg(dev->dev, "amthif cb->buf_idx - %lu\n", cb->buf_idx);

	/* length is being truncated to PAGE_SIZE, however,
	 * the buf_idx may point beyond */
	length = min_t(size_t, length, (cb->buf_idx - *offset));

	if (copy_to_user(ubuf, cb->response_buffer.data + *offset, length)) {
		dev_dbg(&dev->pdev->dev, "failed to copy data to userland\n");
		dev_dbg(dev->dev, "failed to copy data to userland\n");
		rets = -EFAULT;
	} else {
		rets = length;
@@ -243,7 +243,7 @@ int mei_amthif_read(struct mei_device *dev, struct file *file,
		}
	}
free:
	dev_dbg(&dev->pdev->dev, "free amthif cb memory.\n");
	dev_dbg(dev->dev, "free amthif cb memory.\n");
	*offset = 0;
	mei_io_cb_free(cb);
out:
@@ -267,7 +267,7 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
	if (!dev || !cb)
		return -ENODEV;

	dev_dbg(&dev->pdev->dev, "write data to amthif client.\n");
	dev_dbg(dev->dev, "write data to amthif client.\n");

	dev->iamthif_state = MEI_IAMTHIF_WRITING;
	dev->iamthif_current_cb = cb;
@@ -306,12 +306,12 @@ static int mei_amthif_send_cmd(struct mei_device *dev, struct mei_cl_cb *cb)
				return -EIO;
			dev->iamthif_flow_control_pending = true;
			dev->iamthif_state = MEI_IAMTHIF_FLOW_CONTROL;
			dev_dbg(&dev->pdev->dev, "add amthif cb to write waiting list\n");
			dev_dbg(dev->dev, "add amthif cb to write waiting list\n");
			dev->iamthif_current_cb = cb;
			dev->iamthif_file_object = cb->file_object;
			list_add_tail(&cb->list, &dev->write_waiting_list.list);
		} else {
			dev_dbg(&dev->pdev->dev, "message does not complete, so add amthif cb to write list.\n");
			dev_dbg(dev->dev, "message does not complete, so add amthif cb to write list.\n");
			list_add_tail(&cb->list, &dev->write_list.list);
		}
	} else {
@@ -344,9 +344,9 @@ int mei_amthif_write(struct mei_device *dev, struct mei_cl_cb *cb)

	if (!list_empty(&dev->amthif_cmd_list.list) ||
	    dev->iamthif_state != MEI_IAMTHIF_IDLE) {
		dev_dbg(&dev->pdev->dev,
		dev_dbg(dev->dev,
			"amthif state = %d\n", dev->iamthif_state);
		dev_dbg(&dev->pdev->dev, "AMTHIF: add cb to the wait list\n");
		dev_dbg(dev->dev, "AMTHIF: add cb to the wait list\n");
		list_add_tail(&cb->list, &dev->amthif_cmd_list.list);
		return 0;
	}
@@ -376,7 +376,7 @@ void mei_amthif_run_next_cmd(struct mei_device *dev)
	dev->iamthif_timer = 0;
	dev->iamthif_file_object = NULL;

	dev_dbg(&dev->pdev->dev, "complete amthif cmd_list cb.\n");
	dev_dbg(dev->dev, "complete amthif cmd_list cb.\n");

	list_for_each_entry_safe(cb, next, &dev->amthif_cmd_list.list, list) {
		list_del(&cb->list);
@@ -384,7 +384,7 @@ void mei_amthif_run_next_cmd(struct mei_device *dev)
			continue;
		status = mei_amthif_send_cmd(dev, cb);
		if (status)
			dev_warn(&dev->pdev->dev, "amthif write failed status = %d\n",
			dev_warn(dev->dev, "amthif write failed status = %d\n",
						status);
		break;
	}
@@ -407,7 +407,7 @@ unsigned int mei_amthif_poll(struct mei_device *dev,
		   dev->iamthif_file_object == file) {

		mask |= (POLLIN | POLLRDNORM);
		dev_dbg(&dev->pdev->dev, "run next amthif cb\n");
		dev_dbg(dev->dev, "run next amthif cb\n");
		mei_amthif_run_next_cmd(dev);
	}
	mutex_unlock(&dev->device_lock);
@@ -467,7 +467,7 @@ int mei_amthif_irq_write(struct mei_cl *cl, struct mei_cl_cb *cb,
		return 0;
	}

	dev_dbg(&dev->pdev->dev, MEI_HDR_FMT,  MEI_HDR_PRM(&mei_hdr));
	dev_dbg(dev->dev, MEI_HDR_FMT,  MEI_HDR_PRM(&mei_hdr));

	rets = mei_write_message(dev, &mei_hdr,
			dev->iamthif_msg_buf + dev->iamthif_msg_buf_index);
@@ -529,10 +529,10 @@ int mei_amthif_irq_read_msg(struct mei_device *dev,
	if (!mei_hdr->msg_complete)
		return 0;

	dev_dbg(&dev->pdev->dev, "amthif_message_buffer_index =%d\n",
	dev_dbg(dev->dev, "amthif_message_buffer_index =%d\n",
			mei_hdr->length);

	dev_dbg(&dev->pdev->dev, "completed amthif read.\n ");
	dev_dbg(dev->dev, "completed amthif read.\n ");
	if (!dev->iamthif_current_cb)
		return -ENODEV;

@@ -547,8 +547,8 @@ int mei_amthif_irq_read_msg(struct mei_device *dev,
	cb->read_time = jiffies;
	if (dev->iamthif_ioctl) {
		/* found the iamthif cb */
		dev_dbg(&dev->pdev->dev, "complete the amthif read cb.\n ");
		dev_dbg(&dev->pdev->dev, "add the amthif read cb to complete.\n ");
		dev_dbg(dev->dev, "complete the amthif read cb.\n ");
		dev_dbg(dev->dev, "add the amthif read cb to complete.\n ");
		list_add_tail(&cb->list, &complete_list->list);
	}
	return 0;
@@ -572,11 +572,11 @@ int mei_amthif_irq_read(struct mei_device *dev, s32 *slots)
	*slots -= msg_slots;

	if (mei_hbm_cl_flow_control_req(dev, &dev->iamthif_cl)) {
		dev_dbg(&dev->pdev->dev, "iamthif flow control failed\n");
		dev_dbg(dev->dev, "iamthif flow control failed\n");
		return -EIO;
	}

	dev_dbg(&dev->pdev->dev, "iamthif flow control success\n");
	dev_dbg(dev->dev, "iamthif flow control success\n");
	dev->iamthif_state = MEI_IAMTHIF_READING;
	dev->iamthif_flow_control_pending = false;
	dev->iamthif_msg_buf_index = 0;
@@ -601,15 +601,15 @@ void mei_amthif_complete(struct mei_device *dev, struct mei_cl_cb *cb)
				dev->iamthif_msg_buf,
				dev->iamthif_msg_buf_index);
		list_add_tail(&cb->list, &dev->amthif_rd_complete_list.list);
		dev_dbg(&dev->pdev->dev, "amthif read completed\n");
		dev_dbg(dev->dev, "amthif read completed\n");
		dev->iamthif_timer = jiffies;
		dev_dbg(&dev->pdev->dev, "dev->iamthif_timer = %ld\n",
		dev_dbg(dev->dev, "dev->iamthif_timer = %ld\n",
				dev->iamthif_timer);
	} else {
		mei_amthif_run_next_cmd(dev);
	}

	dev_dbg(&dev->pdev->dev, "completing amthif call back.\n");
	dev_dbg(dev->dev, "completing amthif call back.\n");
	wake_up_interruptible(&dev->iamthif_cl.wait);
}

@@ -715,11 +715,11 @@ int mei_amthif_release(struct mei_device *dev, struct file *file)
	if (dev->iamthif_file_object == file &&
	    dev->iamthif_state != MEI_IAMTHIF_IDLE) {

		dev_dbg(&dev->pdev->dev, "amthif canceled iamthif state %d\n",
		dev_dbg(dev->dev, "amthif canceled iamthif state %d\n",
		    dev->iamthif_state);
		dev->iamthif_canceled = true;
		if (dev->iamthif_state == MEI_IAMTHIF_READ_COMPLETE) {
			dev_dbg(&dev->pdev->dev, "run next amthif iamthif cb\n");
			dev_dbg(dev->dev, "run next amthif iamthif cb\n");
			mei_amthif_run_next_cmd(dev);
		}
	}
+5 −5
Original line number Diff line number Diff line
@@ -172,7 +172,7 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,
	device->cl = cl;
	device->ops = ops;

	device->dev.parent = &dev->pdev->dev;
	device->dev.parent = dev->dev;
	device->dev.bus = &mei_cl_bus_type;
	device->dev.type = &mei_cl_device_type;

@@ -180,7 +180,7 @@ struct mei_cl_device *mei_cl_add_device(struct mei_device *dev,

	status = device_register(&device->dev);
	if (status) {
		dev_err(&dev->pdev->dev, "Failed to register MEI device\n");
		dev_err(dev->dev, "Failed to register MEI device\n");
		kfree(device);
		return NULL;
	}
@@ -430,7 +430,7 @@ int mei_cl_enable_device(struct mei_cl_device *device)
	err = mei_cl_connect(cl, NULL);
	if (err < 0) {
		mutex_unlock(&dev->device_lock);
		dev_err(&dev->pdev->dev, "Could not connect to the ME client");
		dev_err(dev->dev, "Could not connect to the ME client");

		return err;
	}
@@ -462,7 +462,7 @@ int mei_cl_disable_device(struct mei_cl_device *device)

	if (cl->state != MEI_FILE_CONNECTED) {
		mutex_unlock(&dev->device_lock);
		dev_err(&dev->pdev->dev, "Already disconnected");
		dev_err(dev->dev, "Already disconnected");

		return 0;
	}
@@ -472,7 +472,7 @@ int mei_cl_disable_device(struct mei_cl_device *device)
	err = mei_cl_disconnect(cl);
	if (err < 0) {
		mutex_unlock(&dev->device_lock);
		dev_err(&dev->pdev->dev,
		dev_err(dev->dev,
			"Could not disconnect from the ME client");

		return err;
+23 −23
Original line number Diff line number Diff line
@@ -363,13 +363,13 @@ int mei_cl_link(struct mei_cl *cl, int id)
					MEI_CLIENTS_MAX);

	if (id >= MEI_CLIENTS_MAX) {
		dev_err(&dev->pdev->dev, "id exceeded %d", MEI_CLIENTS_MAX);
		dev_err(dev->dev, "id exceeded %d", MEI_CLIENTS_MAX);
		return -EMFILE;
	}

	open_handle_count = dev->open_handle_count + dev->iamthif_open_count;
	if (open_handle_count >= MEI_MAX_OPEN_HANDLE_COUNT) {
		dev_err(&dev->pdev->dev, "open_handle_count exceeded %d",
		dev_err(dev->dev, "open_handle_count exceeded %d",
			MEI_MAX_OPEN_HANDLE_COUNT);
		return -EMFILE;
	}
@@ -449,9 +449,9 @@ void mei_host_client_init(struct work_struct *work)

	mutex_unlock(&dev->device_lock);

	pm_runtime_mark_last_busy(&dev->pdev->dev);
	dev_dbg(&dev->pdev->dev, "rpm: autosuspend\n");
	pm_runtime_autosuspend(&dev->pdev->dev);
	pm_runtime_mark_last_busy(dev->dev);
	dev_dbg(dev->dev, "rpm: autosuspend\n");
	pm_runtime_autosuspend(dev->dev);
}

/**
@@ -464,12 +464,12 @@ bool mei_hbuf_acquire(struct mei_device *dev)
{
	if (mei_pg_state(dev) == MEI_PG_ON ||
	    dev->pg_event == MEI_PG_EVENT_WAIT) {
		dev_dbg(&dev->pdev->dev, "device is in pg\n");
		dev_dbg(dev->dev, "device is in pg\n");
		return false;
	}

	if (!dev->hbuf_is_ready) {
		dev_dbg(&dev->pdev->dev, "hbuf is not ready\n");
		dev_dbg(dev->dev, "hbuf is not ready\n");
		return false;
	}

@@ -503,9 +503,9 @@ int mei_cl_disconnect(struct mei_cl *cl)
	if (cl->state != MEI_FILE_DISCONNECTING)
		return 0;

	rets = pm_runtime_get(&dev->pdev->dev);
	rets = pm_runtime_get(dev->dev);
	if (rets < 0 && rets != -EINPROGRESS) {
		pm_runtime_put_noidle(&dev->pdev->dev);
		pm_runtime_put_noidle(dev->dev);
		cl_err(dev, cl, "rpm: get failed %d\n", rets);
		return rets;
	}
@@ -552,8 +552,8 @@ int mei_cl_disconnect(struct mei_cl *cl)
	mei_io_list_flush(&dev->ctrl_wr_list, cl);
free:
	cl_dbg(dev, cl, "rpm: autosuspend\n");
	pm_runtime_mark_last_busy(&dev->pdev->dev);
	pm_runtime_put_autosuspend(&dev->pdev->dev);
	pm_runtime_mark_last_busy(dev->dev);
	pm_runtime_put_autosuspend(dev->dev);

	mei_io_cb_free(cb);
	return rets;
@@ -609,9 +609,9 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)

	dev = cl->dev;

	rets = pm_runtime_get(&dev->pdev->dev);
	rets = pm_runtime_get(dev->dev);
	if (rets < 0 && rets != -EINPROGRESS) {
		pm_runtime_put_noidle(&dev->pdev->dev);
		pm_runtime_put_noidle(dev->dev);
		cl_err(dev, cl, "rpm: get failed %d\n", rets);
		return rets;
	}
@@ -659,8 +659,8 @@ int mei_cl_connect(struct mei_cl *cl, struct file *file)

out:
	cl_dbg(dev, cl, "rpm: autosuspend\n");
	pm_runtime_mark_last_busy(&dev->pdev->dev);
	pm_runtime_put_autosuspend(&dev->pdev->dev);
	pm_runtime_mark_last_busy(dev->dev);
	pm_runtime_put_autosuspend(dev->dev);

	mei_io_cb_free(cb);
	return rets;
@@ -772,9 +772,9 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length)
		return  -ENOTTY;
	}

	rets = pm_runtime_get(&dev->pdev->dev);
	rets = pm_runtime_get(dev->dev);
	if (rets < 0 && rets != -EINPROGRESS) {
		pm_runtime_put_noidle(&dev->pdev->dev);
		pm_runtime_put_noidle(dev->dev);
		cl_err(dev, cl, "rpm: get failed %d\n", rets);
		return rets;
	}
@@ -806,8 +806,8 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length)

out:
	cl_dbg(dev, cl, "rpm: autosuspend\n");
	pm_runtime_mark_last_busy(&dev->pdev->dev);
	pm_runtime_put_autosuspend(&dev->pdev->dev);
	pm_runtime_mark_last_busy(dev->dev);
	pm_runtime_put_autosuspend(dev->dev);

	if (rets)
		mei_io_cb_free(cb);
@@ -928,9 +928,9 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)

	cl_dbg(dev, cl, "mei_cl_write %d\n", buf->size);

	rets = pm_runtime_get(&dev->pdev->dev);
	rets = pm_runtime_get(dev->dev);
	if (rets < 0 && rets != -EINPROGRESS) {
		pm_runtime_put_noidle(&dev->pdev->dev);
		pm_runtime_put_noidle(dev->dev);
		cl_err(dev, cl, "rpm: get failed %d\n", rets);
		return rets;
	}
@@ -1005,8 +1005,8 @@ int mei_cl_write(struct mei_cl *cl, struct mei_cl_cb *cb, bool blocking)
	rets = buf->size;
err:
	cl_dbg(dev, cl, "rpm: autosuspend\n");
	pm_runtime_mark_last_busy(&dev->pdev->dev);
	pm_runtime_put_autosuspend(&dev->pdev->dev);
	pm_runtime_mark_last_busy(dev->dev);
	pm_runtime_put_autosuspend(dev->dev);

	return rets;
}
+2 −2
Original line number Diff line number Diff line
@@ -110,9 +110,9 @@ void mei_cl_all_write_clear(struct mei_device *dev);
#define MEI_CL_PRM(cl) (cl)->host_client_id, (cl)->me_client_id

#define cl_dbg(dev, cl, format, arg...) \
	dev_dbg(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)
	dev_dbg((dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)

#define cl_err(dev, cl, format, arg...) \
	dev_err(&(dev)->pdev->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)
	dev_err((dev)->dev, MEI_CL_FMT format, MEI_CL_PRM(cl), ##arg)

#endif /* _MEI_CLIENT_H_ */
+3 −3
Original line number Diff line number Diff line
@@ -187,19 +187,19 @@ int mei_dbgfs_register(struct mei_device *dev, const char *name)
	f = debugfs_create_file("meclients", S_IRUSR, dir,
				dev, &mei_dbgfs_fops_meclients);
	if (!f) {
		dev_err(&dev->pdev->dev, "meclients: registration failed\n");
		dev_err(dev->dev, "meclients: registration failed\n");
		goto err;
	}
	f = debugfs_create_file("active", S_IRUSR, dir,
				dev, &mei_dbgfs_fops_active);
	if (!f) {
		dev_err(&dev->pdev->dev, "meclients: registration failed\n");
		dev_err(dev->dev, "meclients: registration failed\n");
		goto err;
	}
	f = debugfs_create_file("devstate", S_IRUSR, dir,
				dev, &mei_dbgfs_fops_devstate);
	if (!f) {
		dev_err(&dev->pdev->dev, "devstate: registration failed\n");
		dev_err(dev->dev, "devstate: registration failed\n");
		goto err;
	}
	dev->dbgfs_dir = dir;
Loading