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

Commit 8b25b069 authored by qctecmdr Service's avatar qctecmdr Service Committed by Gerrit - the friendly Code Review server
Browse files

Merge "mhi: dev: uci: do not exceed maximum transfer size supported by mhi host"

parents 9de80467 c7b37e4d
Loading
Loading
Loading
Loading
+11 −5
Original line number Diff line number Diff line
@@ -251,7 +251,7 @@ static ssize_t mhi_uci_write(struct file *file,
	struct mhi_device *mhi_dev = uci_dev->mhi_dev;
	struct uci_chan *uci_chan = &uci_dev->ul_chan;
	size_t bytes_xfered = 0;
	int ret;
	int ret, nr_avail;

	if (!buf || !count)
		return -EINVAL;
@@ -275,8 +275,8 @@ static ssize_t mhi_uci_write(struct file *file,
		/* wait for free descriptors */
		ret = wait_event_interruptible(uci_chan->wq,
			(!uci_dev->enabled) ||
			mhi_get_no_free_descriptors
					       (mhi_dev, DMA_TO_DEVICE) > 0);
			(nr_avail = mhi_get_no_free_descriptors(mhi_dev,
							DMA_TO_DEVICE)) > 0);

		if (ret == -ERESTARTSYS) {
			MSG_LOG("Exit signal caught for node\n");
@@ -297,7 +297,13 @@ static ssize_t mhi_uci_write(struct file *file,
		}

		spin_lock_bh(&uci_chan->lock);
		flags = (count - xfer_size) ? MHI_EOB : MHI_EOT;

		/* if ring is full after this force EOT */
		if (nr_avail > 1 && (count - xfer_size))
			flags = MHI_CHAIN;
		else
			flags = MHI_EOT;

		if (uci_dev->enabled)
			ret = mhi_queue_transfer(mhi_dev, DMA_TO_DEVICE, kbuf,
						 xfer_size, flags);
@@ -586,7 +592,7 @@ static int mhi_uci_probe(struct mhi_device *mhi_dev,
		INIT_LIST_HEAD(&uci_chan->pending);
	};

	uci_dev->mtu = id->driver_data;
	uci_dev->mtu = min_t(size_t, id->driver_data, mhi_dev->mtu);
	mhi_device_set_devdata(mhi_dev, uci_dev);
	uci_dev->enabled = true;

+41 −10
Original line number Diff line number Diff line
/* Copyright (c) 2012-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2012-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -41,7 +41,7 @@ static int get_num(const char *const str[], const char *name)
	return -EINVAL;
}

static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,
static struct msm_bus_scale_pdata *get_pdata(struct device *dev,
	struct device_node *of_node)
{
	struct msm_bus_scale_pdata *pdata = NULL;
@@ -51,12 +51,12 @@ static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,
	const uint32_t *vec_arr = NULL;
	bool mem_err = false;

	if (!pdev) {
		pr_err("Error: Null Platform device\n");
	if (!dev) {
		pr_err("Error: Null device\n");
		return NULL;
	}

	pdata = devm_kzalloc(&pdev->dev, sizeof(struct msm_bus_scale_pdata),
	pdata = devm_kzalloc(dev, sizeof(struct msm_bus_scale_pdata),
		GFP_KERNEL);
	if (!pdata) {
		mem_err = true;
@@ -89,7 +89,7 @@ static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,
	pdata->alc = of_property_read_bool(of_node, "qcom,msm-bus,alc-voter");

	if (pdata->alc) {
		usecase_lat = devm_kzalloc(&pdev->dev,
		usecase_lat = devm_kzalloc(dev,
				(sizeof(struct msm_bus_lat_vectors) *
				pdata->num_usecases), GFP_KERNEL);
		if (!usecase_lat) {
@@ -122,7 +122,7 @@ static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,
		return pdata;
	}

	usecase = devm_kzalloc(&pdev->dev, (sizeof(struct msm_bus_paths) *
	usecase = devm_kzalloc(dev, (sizeof(struct msm_bus_paths) *
		pdata->num_usecases), GFP_KERNEL);
	if (!usecase) {
		mem_err = true;
@@ -149,7 +149,7 @@ static struct msm_bus_scale_pdata *get_pdata(struct platform_device *pdev,

	for (i = 0; i < num_usecases; i++) {
		usecase[i].num_paths = num_paths;
		usecase[i].vectors = devm_kzalloc(&pdev->dev, num_paths *
		usecase[i].vectors = devm_kzalloc(dev, num_paths *
			sizeof(struct msm_bus_vectors), GFP_KERNEL);
		if (!usecase[i].vectors) {
			mem_err = true;
@@ -206,7 +206,7 @@ struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev)
	}

	of_node = pdev->dev.of_node;
	pdata = get_pdata(pdev, of_node);
	pdata = get_pdata(&pdev->dev, of_node);
	if (!pdata) {
		pr_err("client has to provide missing entry for successful registration\n");
		return NULL;
@@ -216,6 +216,37 @@ struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev)
}
EXPORT_SYMBOL(msm_bus_cl_get_pdata);

/**
 * msm_bus_cl_get_pdata_from_dev() - Generate bus client data from device tree
 * provided by clients.
 *
 * of_node: Device tree node to extract information from
 *
 * The function returns a valid pointer to the allocated bus-scale-pdata
 * if the vectors were correctly read from the client's device node.
 * Any error in reading or parsing the device node will return NULL
 * to the caller.
 */
struct msm_bus_scale_pdata *msm_bus_cl_get_pdata_from_dev(struct device *dev)
{
	struct device_node *of_node;
	struct msm_bus_scale_pdata *pdata = NULL;

	of_node = dev->of_node;

	if (!of_node)
		return NULL;

	pdata = get_pdata(dev, of_node);
	if (!pdata) {
		pr_err("client has to provide missing entry for successful registration\n");
		return NULL;
	}

	return pdata;
}
EXPORT_SYMBOL(msm_bus_cl_get_pdata_from_dev);

/**
 * msm_bus_cl_pdata_from_node() - Generate bus client data from device tree
 * node provided by clients. This function should be used when a client
@@ -247,7 +278,7 @@ struct msm_bus_scale_pdata *msm_bus_pdata_from_node(
		return NULL;
	}

	pdata = get_pdata(pdev, of_node);
	pdata = get_pdata(&pdev->dev, of_node);
	if (!pdata) {
		pr_err("client has to provide missing entry for successful registration\n");
		return NULL;
+2 −1
Original line number Diff line number Diff line
/* Copyright (c) 2010-2017, The Linux Foundation. All rights reserved.
/* Copyright (c) 2010-2018, The Linux Foundation. All rights reserved.
 *
 * This program is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License version 2 and
@@ -217,6 +217,7 @@ static inline int msm_bus_scale_query_tcs_cmd_all(struct msm_bus_tcs_handle
struct msm_bus_scale_pdata *msm_bus_pdata_from_node(
		struct platform_device *pdev, struct device_node *of_node);
struct msm_bus_scale_pdata *msm_bus_cl_get_pdata(struct platform_device *pdev);
struct msm_bus_scale_pdata *msm_bus_cl_get_pdata_from_dev(struct device *dev);
void msm_bus_cl_clear_pdata(struct msm_bus_scale_pdata *pdata);
#else
static inline struct msm_bus_scale_pdata