Commit 2b09841c authored by Alex Elder's avatar Alex Elder Committed by David S. Miller
Browse files

net: ipa: replace ipa->suspend_ref with a flag bit



We take a clock reference in ipa_config() in order to prevent the
the IPA clock from being shutdown until a power management suspend
request arrives.  An atomic field in the IPA structure records
whether that extra reference had been taken.

Rather than using an atomic to represent a Boolean value, define
a new flags bitmap, and define a "clock held" flag to represent
whether the extra clock reference has been taken.

Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parent 0305b709
Loading
Loading
Loading
Loading
+12 −2
Original line number Diff line number Diff line
@@ -27,15 +27,25 @@ struct ipa_clock;
struct ipa_smp2p;
struct ipa_interrupt;

/**
 * enum ipa_flag - IPA state flags
 * @IPA_FLAG_CLOCK_HELD:	Whether IPA clock is held to prevent suspend
 * @IPA_FLAG_COUNT:		Number of defined IPA flags
 */
enum ipa_flag {
	IPA_FLAG_CLOCK_HELD,
	IPA_FLAG_COUNT,		/* Last; not a flag */
};

/**
 * struct ipa - IPA information
 * @gsi:		Embedded GSI structure
 * @flags:		Boolean state flags
 * @version:		IPA hardware version
 * @pdev:		Platform device
 * @modem_rproc:	Remoteproc handle for modem subsystem
 * @smp2p:		SMP2P information
 * @clock:		IPA clocking information
 * @suspend_ref:	Whether clock reference preventing suspend taken
 * @table_addr:		DMA address of filter/route table content
 * @table_virt:		Virtual address of filter/route table content
 * @interrupt:		IPA Interrupt information
@@ -70,6 +80,7 @@ struct ipa_interrupt;
 */
struct ipa {
	struct gsi gsi;
	DECLARE_BITMAP(flags, IPA_FLAG_COUNT);
	enum ipa_version version;
	struct platform_device *pdev;
	struct rproc *modem_rproc;
@@ -77,7 +88,6 @@ struct ipa {
	void *notifier;
	struct ipa_smp2p *smp2p;
	struct ipa_clock *clock;
	atomic_t suspend_ref;

	dma_addr_t table_addr;
	__le64 *table_virt;
+7 −7
Original line number Diff line number Diff line
@@ -84,7 +84,7 @@ static void ipa_suspend_handler(struct ipa *ipa, enum ipa_irq_id irq_id)
	 * endpoints will be resumed as a result.  This reference will
	 * be dropped when we get a power management suspend request.
	 */
	if (!atomic_xchg(&ipa->suspend_ref, 1))
	if (!test_and_set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags))
		ipa_clock_get(ipa);

	/* Acknowledge/clear the suspend interrupt on all endpoints */
@@ -508,7 +508,7 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data)
	 * is held after initialization completes, and won't get dropped
	 * unless/until a system suspend request arrives.
	 */
	atomic_set(&ipa->suspend_ref, 1);
	__set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
	ipa_clock_get(ipa);

	ipa_hardware_config(ipa);
@@ -544,7 +544,7 @@ static int ipa_config(struct ipa *ipa, const struct ipa_data *data)
err_hardware_deconfig:
	ipa_hardware_deconfig(ipa);
	ipa_clock_put(ipa);
	atomic_set(&ipa->suspend_ref, 0);
	__clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);

	return ret;
}
@@ -562,7 +562,7 @@ static void ipa_deconfig(struct ipa *ipa)
	ipa_endpoint_deconfig(ipa);
	ipa_hardware_deconfig(ipa);
	ipa_clock_put(ipa);
	atomic_set(&ipa->suspend_ref, 0);
	__clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
}

static int ipa_firmware_load(struct device *dev)
@@ -777,7 +777,7 @@ static int ipa_probe(struct platform_device *pdev)
	dev_set_drvdata(dev, ipa);
	ipa->modem_rproc = rproc;
	ipa->clock = clock;
	atomic_set(&ipa->suspend_ref, 0);
	__clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
	ipa->wakeup_source = wakeup_source;
	ipa->version = data->version;

@@ -913,7 +913,7 @@ static int ipa_suspend(struct device *dev)
	struct ipa *ipa = dev_get_drvdata(dev);

	ipa_clock_put(ipa);
	atomic_set(&ipa->suspend_ref, 0);
	__clear_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);

	return 0;
}
@@ -933,7 +933,7 @@ static int ipa_resume(struct device *dev)
	/* This clock reference will keep the IPA out of suspend
	 * until we get a power management suspend request.
	 */
	atomic_set(&ipa->suspend_ref, 1);
	__set_bit(IPA_FLAG_CLOCK_HELD, ipa->flags);
	ipa_clock_get(ipa);

	return 0;