Commit 86a628be authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'ipa-device-pointer-access'



Alex Elder says:

====================
net: ipa: simplify device pointer access

This version of this patch series fixes the bugs in the first patch
(which were fixed in the second), where ipa_interrupt_config() had
two remaining spots that returned a pointer rather than an integer.

Outside of initialization, all uses of the platform device pointer
stored in the IPA structure determine the address of device
structure embedded within the platform device structure.

By changing some of the initialization functions to take a platform
device as argument we can simplify getting at the device structure
address by storing it (instead of the platform device pointer) in
the IPA structure.

The first two patches split the interrupt initialization code into
two parts--one done earlier than before.  The next four patches
update some initialization functions to take a platform device
pointer as argument.  And the last patch replaces the platform
device pointer with a device pointer, and converts all remaining
references to the &ipa->pdev->dev to use ipa->dev.
====================

Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents b78fcd0a 5245f4fd
Loading
Loading
Loading
Loading
+2 −3
Original line number Diff line number Diff line
@@ -21,7 +21,6 @@
struct clk;
struct icc_path;
struct net_device;
struct platform_device;

struct ipa_power;
struct ipa_smp2p;
@@ -31,7 +30,7 @@ struct ipa_interrupt;
 * struct ipa - IPA information
 * @gsi:		Embedded GSI structure
 * @version:		IPA hardware version
 * @pdev:		Platform device
 * @dev:		IPA device pointer
 * @completion:		Used to signal pipeline clear transfer complete
 * @nb:			Notifier block used for remoteproc SSR
 * @notifier:		Remoteproc SSR notifier
@@ -79,7 +78,7 @@ struct ipa_interrupt;
struct ipa {
	struct gsi gsi;
	enum ipa_version version;
	struct platform_device *pdev;
	struct device *dev;
	struct completion completion;
	struct notifier_block nb;
	void *notifier;
+3 −3
Original line number Diff line number Diff line
@@ -174,7 +174,7 @@ bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem,
	u32 offset_max = field_max(IP_FLTRT_FLAGS_NHASH_ADDR_FMASK);
	u32 size_max = field_max(IP_FLTRT_FLAGS_NHASH_SIZE_FMASK);
	const char *table = route ? "route" : "filter";
	struct device *dev = &ipa->pdev->dev;
	struct device *dev = ipa->dev;
	u32 size;

	size = route ? ipa->route_count : ipa->filter_count + 1;
@@ -204,7 +204,7 @@ bool ipa_cmd_table_init_valid(struct ipa *ipa, const struct ipa_mem *mem,
/* Validate the memory region that holds headers */
static bool ipa_cmd_header_init_local_valid(struct ipa *ipa)
{
	struct device *dev = &ipa->pdev->dev;
	struct device *dev = ipa->dev;
	const struct ipa_mem *mem;
	u32 offset_max;
	u32 size_max;
@@ -256,7 +256,7 @@ static bool ipa_cmd_register_write_offset_valid(struct ipa *ipa,
						const char *name, u32 offset)
{
	struct ipa_cmd_register_write *payload;
	struct device *dev = &ipa->pdev->dev;
	struct device *dev = ipa->dev;
	u32 offset_max;
	u32 bit_count;

+14 −15
Original line number Diff line number Diff line
@@ -233,8 +233,8 @@ static bool ipa_endpoint_data_valid_one(struct ipa *ipa, u32 count,
			    const struct ipa_gsi_endpoint_data *data)
{
	const struct ipa_gsi_endpoint_data *other_data;
	struct device *dev = &ipa->pdev->dev;
	enum ipa_endpoint_name other_name;
	struct device *dev = ipa->dev;

	if (ipa_gsi_endpoint_data_empty(data))
		return true;
@@ -388,7 +388,7 @@ static u32 ipa_endpoint_max(struct ipa *ipa, u32 count,
			    const struct ipa_gsi_endpoint_data *data)
{
	const struct ipa_gsi_endpoint_data *dp = data;
	struct device *dev = &ipa->pdev->dev;
	struct device *dev = ipa->dev;
	enum ipa_endpoint_name name;
	u32 max;

@@ -606,7 +606,7 @@ int ipa_endpoint_modem_exception_reset_all(struct ipa *ipa)
	count = ipa->modem_tx_count + ipa_cmd_pipeline_clear_count();
	trans = ipa_cmd_trans_alloc(ipa, count);
	if (!trans) {
		dev_err(&ipa->pdev->dev,
		dev_err(ipa->dev,
			"no transaction to reset modem exception endpoints\n");
		return -EBUSY;
	}
@@ -1498,8 +1498,7 @@ ipa_endpoint_status_tag_valid(struct ipa_endpoint *endpoint, const void *data)
	if (endpoint_id == command_endpoint->endpoint_id) {
		complete(&ipa->completion);
	} else {
		dev_err(&ipa->pdev->dev,
			"unexpected tagged packet from endpoint %u\n",
		dev_err(ipa->dev, "unexpected tagged packet from endpoint %u\n",
			endpoint_id);
	}

@@ -1536,6 +1535,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint,
	void *data = page_address(page) + NET_SKB_PAD;
	u32 unused = buffer_size - total_len;
	struct ipa *ipa = endpoint->ipa;
	struct device *dev = ipa->dev;
	u32 resid = total_len;

	while (resid) {
@@ -1544,7 +1544,7 @@ static void ipa_endpoint_status_parse(struct ipa_endpoint *endpoint,
		u32 len;

		if (resid < IPA_STATUS_SIZE) {
			dev_err(&endpoint->ipa->pdev->dev,
			dev_err(dev,
				"short message (%u bytes < %zu byte status)\n",
				resid, IPA_STATUS_SIZE);
			break;
@@ -1666,8 +1666,8 @@ void ipa_endpoint_default_route_clear(struct ipa *ipa)
 */
static int ipa_endpoint_reset_rx_aggr(struct ipa_endpoint *endpoint)
{
	struct device *dev = &endpoint->ipa->pdev->dev;
	struct ipa *ipa = endpoint->ipa;
	struct device *dev = ipa->dev;
	struct gsi *gsi = &ipa->gsi;
	bool suspended = false;
	dma_addr_t addr;
@@ -1769,7 +1769,7 @@ static void ipa_endpoint_reset(struct ipa_endpoint *endpoint)
		gsi_channel_reset(&ipa->gsi, channel_id, true);

	if (ret)
		dev_err(&ipa->pdev->dev,
		dev_err(ipa->dev,
			"error %d resetting channel %u for endpoint %u\n",
			ret, endpoint->channel_id, endpoint->endpoint_id);
}
@@ -1817,7 +1817,7 @@ int ipa_endpoint_enable_one(struct ipa_endpoint *endpoint)

	ret = gsi_channel_start(gsi, endpoint->channel_id);
	if (ret) {
		dev_err(&ipa->pdev->dev,
		dev_err(ipa->dev,
			"error %d starting %cX channel %u for endpoint %u\n",
			ret, endpoint->toward_ipa ? 'T' : 'R',
			endpoint->channel_id, endpoint_id);
@@ -1854,14 +1854,13 @@ void ipa_endpoint_disable_one(struct ipa_endpoint *endpoint)
	/* Note that if stop fails, the channel's state is not well-defined */
	ret = gsi_channel_stop(gsi, endpoint->channel_id);
	if (ret)
		dev_err(&ipa->pdev->dev,
			"error %d attempting to stop endpoint %u\n", ret,
			endpoint_id);
		dev_err(ipa->dev, "error %d attempting to stop endpoint %u\n",
			ret, endpoint_id);
}

void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint)
{
	struct device *dev = &endpoint->ipa->pdev->dev;
	struct device *dev = endpoint->ipa->dev;
	struct gsi *gsi = &endpoint->ipa->gsi;
	int ret;

@@ -1881,7 +1880,7 @@ void ipa_endpoint_suspend_one(struct ipa_endpoint *endpoint)

void ipa_endpoint_resume_one(struct ipa_endpoint *endpoint)
{
	struct device *dev = &endpoint->ipa->pdev->dev;
	struct device *dev = endpoint->ipa->dev;
	struct gsi *gsi = &endpoint->ipa->gsi;
	int ret;

@@ -1983,7 +1982,7 @@ void ipa_endpoint_deconfig(struct ipa *ipa)

int ipa_endpoint_config(struct ipa *ipa)
{
	struct device *dev = &ipa->pdev->dev;
	struct device *dev = ipa->dev;
	const struct reg *reg;
	u32 endpoint_id;
	u32 hw_limit;
+45 −24
Original line number Diff line number Diff line
@@ -19,6 +19,7 @@
 * time only these three are supported.
 */

#include <linux/platform_device.h>
#include <linux/types.h>
#include <linux/interrupt.h>
#include <linux/pm_runtime.h>
@@ -109,14 +110,13 @@ static irqreturn_t ipa_isr_thread(int irq, void *dev_id)
	struct ipa_interrupt *interrupt = dev_id;
	struct ipa *ipa = interrupt->ipa;
	u32 enabled = interrupt->enabled;
	struct device *dev = ipa->dev;
	const struct reg *reg;
	struct device *dev;
	u32 pending;
	u32 offset;
	u32 mask;
	int ret;

	dev = &ipa->pdev->dev;
	ret = pm_runtime_get_sync(dev);
	if (WARN_ON(ret < 0))
		goto out_power_put;
@@ -236,29 +236,17 @@ void ipa_interrupt_simulate_suspend(struct ipa_interrupt *interrupt)
}

/* Configure the IPA interrupt framework */
struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa)
int ipa_interrupt_config(struct ipa *ipa)
{
	struct device *dev = &ipa->pdev->dev;
	struct ipa_interrupt *interrupt;
	struct ipa_interrupt *interrupt = ipa->interrupt;
	unsigned int irq = interrupt->irq;
	struct device *dev = ipa->dev;
	const struct reg *reg;
	unsigned int irq;
	int ret;

	ret = platform_get_irq_byname(ipa->pdev, "ipa");
	if (ret <= 0) {
		dev_err(dev, "DT error %d getting \"ipa\" IRQ property\n",
			ret);
		return ERR_PTR(ret ? : -EINVAL);
	}
	irq = ret;

	interrupt = kzalloc(sizeof(*interrupt), GFP_KERNEL);
	if (!interrupt)
		return ERR_PTR(-ENOMEM);
	interrupt->ipa = ipa;
	interrupt->irq = irq;

	/* Start with all IPA interrupts disabled */
	/* Disable all IPA interrupt types */
	reg = ipa_reg(ipa, IPA_IRQ_EN);
	iowrite32(0, ipa->reg_virt + reg_offset(reg));

@@ -271,26 +259,59 @@ struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa)

	ret = dev_pm_set_wake_irq(dev, irq);
	if (ret) {
		dev_err(dev, "error %d registering \"ipa\" IRQ as wakeirq\n", ret);
		dev_err(dev, "error %d registering \"ipa\" IRQ as wakeirq\n",
			ret);
		goto err_free_irq;
	}

	return interrupt;
	ipa->interrupt = interrupt;

	return 0;

err_free_irq:
	free_irq(interrupt->irq, interrupt);
err_kfree:
	kfree(interrupt);

	return ERR_PTR(ret);
	return ret;
}

/* Inverse of ipa_interrupt_config() */
void ipa_interrupt_deconfig(struct ipa_interrupt *interrupt)
void ipa_interrupt_deconfig(struct ipa *ipa)
{
	struct device *dev = &interrupt->ipa->pdev->dev;
	struct ipa_interrupt *interrupt = ipa->interrupt;
	struct device *dev = ipa->dev;

	ipa->interrupt = NULL;

	dev_pm_clear_wake_irq(dev);
	free_irq(interrupt->irq, interrupt);
}

/* Initialize the IPA interrupt structure */
struct ipa_interrupt *ipa_interrupt_init(struct platform_device *pdev)
{
	struct device *dev = &pdev->dev;
	struct ipa_interrupt *interrupt;
	int irq;

	irq = platform_get_irq_byname(pdev, "ipa");
	if (irq <= 0) {
		dev_err(dev, "DT error %d getting \"ipa\" IRQ property\n", irq);

		return ERR_PTR(irq ? : -EINVAL);
	}

	interrupt = kzalloc(sizeof(*interrupt), GFP_KERNEL);
	if (!interrupt)
		return ERR_PTR(-ENOMEM);
	interrupt->irq = irq;

	return interrupt;
}

/* Inverse of ipa_interrupt_init() */
void ipa_interrupt_exit(struct ipa_interrupt *interrupt)
{
	kfree(interrupt);
}
+18 −4
Original line number Diff line number Diff line
@@ -76,17 +76,31 @@ void ipa_interrupt_irq_enable(struct ipa *ipa);
void ipa_interrupt_irq_disable(struct ipa *ipa);

/**
 * ipa_interrupt_config() - Configure the IPA interrupt framework
 * ipa_interrupt_config() - Configure IPA interrupts
 * @ipa:	IPA pointer
 *
 * Return:	Pointer to IPA SMP2P info, or a pointer-coded error
 * Return:	0 if successful, or a negative error code
 */
struct ipa_interrupt *ipa_interrupt_config(struct ipa *ipa);
int ipa_interrupt_config(struct ipa *ipa);

/**
 * ipa_interrupt_deconfig() - Inverse of ipa_interrupt_config()
 * @ipa:	IPA pointer
 */
void ipa_interrupt_deconfig(struct ipa *ipa);

/**
 * ipa_interrupt_init() - Initialize the IPA interrupt structure
 * @pdev:	IPA platform device pointer
 *
 * Return:	Pointer to an IPA interrupt structure, or a pointer-coded error
 */
struct ipa_interrupt *ipa_interrupt_init(struct platform_device *pdev);

/**
 * ipa_interrupt_exit() - Inverse of ipa_interrupt_init()
 * @interrupt:	IPA interrupt structure
 */
void ipa_interrupt_deconfig(struct ipa_interrupt *interrupt);
void ipa_interrupt_exit(struct ipa_interrupt *interrupt);

#endif /* _IPA_INTERRUPT_H_ */
Loading