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

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

mei: add mei_me_cl_by_uuid_id function



When handling dynamic clients there might be a race
scenario in which two me clients with the same me
address would be linked in the me clients list,
therefore we need to search by both uuid and me address.

Signed-off-by: default avatarTomas Winkler <tomas.winkler@intel.com>
Signed-off-by: default avatarGreg Kroah-Hartman <gregkh@linuxfoundation.org>
parent 25ca6472
Loading
Loading
Loading
Loading
+1 −0
Original line number Original line Diff line number Diff line
@@ -83,6 +83,7 @@ int mei_amthif_host_init(struct mei_device *dev)
	}
	}


	cl->me_client_id = me_cl->client_id;
	cl->me_client_id = me_cl->client_id;
	cl->cl_uuid = me_cl->props.protocol_name;


	/* Assign iamthif_mtu to the value received from ME  */
	/* Assign iamthif_mtu to the value received from ME  */


+2 −2
Original line number Original line Diff line number Diff line
@@ -147,7 +147,7 @@ static struct mei_cl *mei_bus_find_mei_cl_by_uuid(struct mei_device *dev,
	struct mei_cl *cl;
	struct mei_cl *cl;


	list_for_each_entry(cl, &dev->device_list, device_link) {
	list_for_each_entry(cl, &dev->device_list, device_link) {
		if (!uuid_le_cmp(uuid, cl->device_uuid))
		if (!uuid_le_cmp(uuid, cl->cl_uuid))
			return cl;
			return cl;
	}
	}


@@ -242,7 +242,7 @@ static int ___mei_cl_send(struct mei_cl *cl, u8 *buf, size_t length,
		return -ENODEV;
		return -ENODEV;


	/* Check if we have an ME client device */
	/* Check if we have an ME client device */
	me_cl = mei_me_cl_by_id(dev, cl->me_client_id);
	me_cl = mei_me_cl_by_uuid_id(dev, &cl->cl_uuid, cl->me_client_id);
	if (!me_cl)
	if (!me_cl)
		return -ENOTTY;
		return -ENOTTY;


+13 −1
Original line number Original line Diff line number Diff line
@@ -69,6 +69,18 @@ struct mei_me_client *mei_me_cl_by_id(struct mei_device *dev, u8 client_id)
	return NULL;
	return NULL;
}
}


struct mei_me_client *mei_me_cl_by_uuid_id(struct mei_device *dev,
					   const uuid_le *uuid, u8 client_id)
{
	struct mei_me_client *me_cl;

	list_for_each_entry(me_cl, &dev->me_clients, list)
		if (uuid_le_cmp(*uuid, me_cl->props.protocol_name) == 0 &&
		    me_cl->client_id == client_id)
			return me_cl;
	return NULL;
}

/**
/**
 * mei_me_cl_remove - remove me client matching uuid and client_id
 * mei_me_cl_remove - remove me client matching uuid and client_id
 *
 *
@@ -753,7 +765,7 @@ int mei_cl_read_start(struct mei_cl *cl, size_t length)
		cl_dbg(dev, cl, "read is pending.\n");
		cl_dbg(dev, cl, "read is pending.\n");
		return -EBUSY;
		return -EBUSY;
	}
	}
	me_cl = mei_me_cl_by_id(dev, cl->me_client_id);
	me_cl = mei_me_cl_by_uuid_id(dev, &cl->cl_uuid, cl->me_client_id);
	if (!me_cl) {
	if (!me_cl) {
		cl_err(dev, cl, "no such me client %d\n", cl->me_client_id);
		cl_err(dev, cl, "no such me client %d\n", cl->me_client_id);
		return  -ENOTTY;
		return  -ENOTTY;
+4 −0
Original line number Original line Diff line number Diff line
@@ -27,6 +27,10 @@
struct mei_me_client *mei_me_cl_by_uuid(const struct mei_device *dev,
struct mei_me_client *mei_me_cl_by_uuid(const struct mei_device *dev,
					const uuid_le *cuuid);
					const uuid_le *cuuid);
struct mei_me_client *mei_me_cl_by_id(struct mei_device *dev, u8 client_id);
struct mei_me_client *mei_me_cl_by_id(struct mei_device *dev, u8 client_id);

struct mei_me_client *mei_me_cl_by_uuid_id(struct mei_device *dev,
					   const uuid_le *uuid, u8 client_id);

void mei_me_cl_remove(struct mei_device *dev,
void mei_me_cl_remove(struct mei_device *dev,
		      const uuid_le *uuid, u8 client_id);
		      const uuid_le *uuid, u8 client_id);


+2 −1
Original line number Original line Diff line number Diff line
@@ -321,7 +321,7 @@ static ssize_t mei_write(struct file *file, const char __user *ubuf,
		goto out;
		goto out;
	}
	}


	me_cl = mei_me_cl_by_id(dev, cl->me_client_id);
	me_cl = mei_me_cl_by_uuid_id(dev, &cl->cl_uuid, cl->me_client_id);
	if (!me_cl) {
	if (!me_cl) {
		rets = -ENOTTY;
		rets = -ENOTTY;
		goto out;
		goto out;
@@ -459,6 +459,7 @@ static int mei_ioctl_connect_client(struct file *file,
	}
	}


	cl->me_client_id = me_cl->client_id;
	cl->me_client_id = me_cl->client_id;
	cl->cl_uuid = me_cl->props.protocol_name;


	dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n",
	dev_dbg(&dev->pdev->dev, "Connect to FW Client ID = %d\n",
			cl->me_client_id);
			cl->me_client_id);
Loading