Commit 7ece9eaa authored by Alex Elder's avatar Alex Elder Committed by Jakub Kicinski

net: ipa: GSI only needs one completion

A mutex ensures we never submit more than one GSI command of any
kind at once.  This means the per-channel and per-event ring
completion structures provide no benefit.  Instead, just use the
single (existing) GSI completion to signal the completion of GSI
commands of all types.

This makes gsi_evt_ring_init() a trivial function with no inverse,
so open-code it in its sole caller and get rid of the function.
Signed-off-by: default avatarAlex Elder <elder@linaro.org>
Signed-off-by: default avatarJakub Kicinski <kuba@kernel.org>
parent 1b65bbcc
...@@ -339,10 +339,10 @@ static u32 gsi_ring_index(struct gsi_ring *ring, u32 offset) ...@@ -339,10 +339,10 @@ static u32 gsi_ring_index(struct gsi_ring *ring, u32 offset)
* completion to be signaled. Returns true if the command completes * completion to be signaled. Returns true if the command completes
* or false if it times out. * or false if it times out.
*/ */
static bool static bool gsi_command(struct gsi *gsi, u32 reg, u32 val)
gsi_command(struct gsi *gsi, u32 reg, u32 val, struct completion *completion)
{ {
unsigned long timeout = msecs_to_jiffies(GSI_CMD_TIMEOUT); unsigned long timeout = msecs_to_jiffies(GSI_CMD_TIMEOUT);
struct completion *completion = &gsi->completion;
reinit_completion(completion); reinit_completion(completion);
...@@ -366,8 +366,6 @@ gsi_evt_ring_state(struct gsi *gsi, u32 evt_ring_id) ...@@ -366,8 +366,6 @@ gsi_evt_ring_state(struct gsi *gsi, u32 evt_ring_id)
static void gsi_evt_ring_command(struct gsi *gsi, u32 evt_ring_id, static void gsi_evt_ring_command(struct gsi *gsi, u32 evt_ring_id,
enum gsi_evt_cmd_opcode opcode) enum gsi_evt_cmd_opcode opcode)
{ {
struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id];
struct completion *completion = &evt_ring->completion;
struct device *dev = gsi->dev; struct device *dev = gsi->dev;
bool timeout; bool timeout;
u32 val; u32 val;
...@@ -378,7 +376,7 @@ static void gsi_evt_ring_command(struct gsi *gsi, u32 evt_ring_id, ...@@ -378,7 +376,7 @@ static void gsi_evt_ring_command(struct gsi *gsi, u32 evt_ring_id,
val = u32_encode_bits(evt_ring_id, EV_CHID_FMASK); val = u32_encode_bits(evt_ring_id, EV_CHID_FMASK);
val |= u32_encode_bits(opcode, EV_OPCODE_FMASK); val |= u32_encode_bits(opcode, EV_OPCODE_FMASK);
timeout = !gsi_command(gsi, GSI_EV_CH_CMD_OFFSET, val, completion); timeout = !gsi_command(gsi, GSI_EV_CH_CMD_OFFSET, val);
gsi_irq_ev_ctrl_disable(gsi); gsi_irq_ev_ctrl_disable(gsi);
...@@ -478,7 +476,6 @@ static enum gsi_channel_state gsi_channel_state(struct gsi_channel *channel) ...@@ -478,7 +476,6 @@ static enum gsi_channel_state gsi_channel_state(struct gsi_channel *channel)
static void static void
gsi_channel_command(struct gsi_channel *channel, enum gsi_ch_cmd_opcode opcode) gsi_channel_command(struct gsi_channel *channel, enum gsi_ch_cmd_opcode opcode)
{ {
struct completion *completion = &channel->completion;
u32 channel_id = gsi_channel_id(channel); u32 channel_id = gsi_channel_id(channel);
struct gsi *gsi = channel->gsi; struct gsi *gsi = channel->gsi;
struct device *dev = gsi->dev; struct device *dev = gsi->dev;
...@@ -490,7 +487,7 @@ gsi_channel_command(struct gsi_channel *channel, enum gsi_ch_cmd_opcode opcode) ...@@ -490,7 +487,7 @@ gsi_channel_command(struct gsi_channel *channel, enum gsi_ch_cmd_opcode opcode)
val = u32_encode_bits(channel_id, CH_CHID_FMASK); val = u32_encode_bits(channel_id, CH_CHID_FMASK);
val |= u32_encode_bits(opcode, CH_OPCODE_FMASK); val |= u32_encode_bits(opcode, CH_OPCODE_FMASK);
timeout = !gsi_command(gsi, GSI_CH_CMD_OFFSET, val, completion); timeout = !gsi_command(gsi, GSI_CH_CMD_OFFSET, val);
gsi_irq_ch_ctrl_disable(gsi); gsi_irq_ch_ctrl_disable(gsi);
...@@ -1074,13 +1071,10 @@ static void gsi_isr_chan_ctrl(struct gsi *gsi) ...@@ -1074,13 +1071,10 @@ static void gsi_isr_chan_ctrl(struct gsi *gsi)
while (channel_mask) { while (channel_mask) {
u32 channel_id = __ffs(channel_mask); u32 channel_id = __ffs(channel_mask);
struct gsi_channel *channel;
channel_mask ^= BIT(channel_id); channel_mask ^= BIT(channel_id);
channel = &gsi->channel[channel_id]; complete(&gsi->completion);
complete(&channel->completion);
} }
} }
...@@ -1094,13 +1088,10 @@ static void gsi_isr_evt_ctrl(struct gsi *gsi) ...@@ -1094,13 +1088,10 @@ static void gsi_isr_evt_ctrl(struct gsi *gsi)
while (event_mask) { while (event_mask) {
u32 evt_ring_id = __ffs(event_mask); u32 evt_ring_id = __ffs(event_mask);
struct gsi_evt_ring *evt_ring;
event_mask ^= BIT(evt_ring_id); event_mask ^= BIT(evt_ring_id);
evt_ring = &gsi->evt_ring[evt_ring_id]; complete(&gsi->completion);
complete(&evt_ring->completion);
} }
} }
...@@ -1110,7 +1101,7 @@ gsi_isr_glob_chan_err(struct gsi *gsi, u32 err_ee, u32 channel_id, u32 code) ...@@ -1110,7 +1101,7 @@ gsi_isr_glob_chan_err(struct gsi *gsi, u32 err_ee, u32 channel_id, u32 code)
{ {
if (code == GSI_OUT_OF_RESOURCES) { if (code == GSI_OUT_OF_RESOURCES) {
dev_err(gsi->dev, "channel %u out of resources\n", channel_id); dev_err(gsi->dev, "channel %u out of resources\n", channel_id);
complete(&gsi->channel[channel_id].completion); complete(&gsi->completion);
return; return;
} }
...@@ -1127,7 +1118,7 @@ gsi_isr_glob_evt_err(struct gsi *gsi, u32 err_ee, u32 evt_ring_id, u32 code) ...@@ -1127,7 +1118,7 @@ gsi_isr_glob_evt_err(struct gsi *gsi, u32 err_ee, u32 evt_ring_id, u32 code)
struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id];
u32 channel_id = gsi_channel_id(evt_ring->channel); u32 channel_id = gsi_channel_id(evt_ring->channel);
complete(&evt_ring->completion); complete(&gsi->completion);
dev_err(gsi->dev, "evt_ring for channel %u out of resources\n", dev_err(gsi->dev, "evt_ring for channel %u out of resources\n",
channel_id); channel_id);
return; return;
...@@ -1651,7 +1642,6 @@ static void gsi_channel_teardown_one(struct gsi *gsi, u32 channel_id) ...@@ -1651,7 +1642,6 @@ static void gsi_channel_teardown_one(struct gsi *gsi, u32 channel_id)
static int gsi_generic_command(struct gsi *gsi, u32 channel_id, static int gsi_generic_command(struct gsi *gsi, u32 channel_id,
enum gsi_generic_cmd_opcode opcode) enum gsi_generic_cmd_opcode opcode)
{ {
struct completion *completion = &gsi->completion;
bool timeout; bool timeout;
u32 val; u32 val;
...@@ -1675,7 +1665,7 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id, ...@@ -1675,7 +1665,7 @@ static int gsi_generic_command(struct gsi *gsi, u32 channel_id,
val |= u32_encode_bits(channel_id, GENERIC_CHID_FMASK); val |= u32_encode_bits(channel_id, GENERIC_CHID_FMASK);
val |= u32_encode_bits(GSI_EE_MODEM, GENERIC_EE_FMASK); val |= u32_encode_bits(GSI_EE_MODEM, GENERIC_EE_FMASK);
timeout = !gsi_command(gsi, GSI_GENERIC_CMD_OFFSET, val, completion); timeout = !gsi_command(gsi, GSI_GENERIC_CMD_OFFSET, val);
/* Disable the GP_INT1 IRQ type again */ /* Disable the GP_INT1 IRQ type again */
iowrite32(BIT(ERROR_INT), gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET); iowrite32(BIT(ERROR_INT), gsi->virt + GSI_CNTXT_GLOB_IRQ_EN_OFFSET);
...@@ -1975,18 +1965,6 @@ static void gsi_channel_evt_ring_exit(struct gsi_channel *channel) ...@@ -1975,18 +1965,6 @@ static void gsi_channel_evt_ring_exit(struct gsi_channel *channel)
gsi_evt_ring_id_free(gsi, evt_ring_id); gsi_evt_ring_id_free(gsi, evt_ring_id);
} }
/* Init function for event rings; there is no gsi_evt_ring_exit() */
static void gsi_evt_ring_init(struct gsi *gsi)
{
u32 evt_ring_id = 0;
gsi->event_bitmap = gsi_event_bitmap_init(GSI_EVT_RING_COUNT_MAX);
gsi->ieob_enabled_bitmap = 0;
do
init_completion(&gsi->evt_ring[evt_ring_id].completion);
while (++evt_ring_id < GSI_EVT_RING_COUNT_MAX);
}
static bool gsi_channel_data_valid(struct gsi *gsi, static bool gsi_channel_data_valid(struct gsi *gsi,
const struct ipa_gsi_endpoint_data *data) const struct ipa_gsi_endpoint_data *data)
{ {
...@@ -2069,7 +2047,6 @@ static int gsi_channel_init_one(struct gsi *gsi, ...@@ -2069,7 +2047,6 @@ static int gsi_channel_init_one(struct gsi *gsi,
channel->tlv_count = data->channel.tlv_count; channel->tlv_count = data->channel.tlv_count;
channel->tre_count = tre_count; channel->tre_count = tre_count;
channel->event_count = data->channel.event_count; channel->event_count = data->channel.event_count;
init_completion(&channel->completion);
ret = gsi_channel_evt_ring_init(channel); ret = gsi_channel_evt_ring_init(channel);
if (ret) if (ret)
...@@ -2129,7 +2106,8 @@ static int gsi_channel_init(struct gsi *gsi, u32 count, ...@@ -2129,7 +2106,8 @@ static int gsi_channel_init(struct gsi *gsi, u32 count,
/* IPA v4.2 requires the AP to allocate channels for the modem */ /* IPA v4.2 requires the AP to allocate channels for the modem */
modem_alloc = gsi->version == IPA_VERSION_4_2; modem_alloc = gsi->version == IPA_VERSION_4_2;
gsi_evt_ring_init(gsi); /* No matching exit required */ gsi->event_bitmap = gsi_event_bitmap_init(GSI_EVT_RING_COUNT_MAX);
gsi->ieob_enabled_bitmap = 0;
/* The endpoint data array is indexed by endpoint name */ /* The endpoint data array is indexed by endpoint name */
for (i = 0; i < count; i++) { for (i = 0; i < count; i++) {
......
...@@ -114,8 +114,6 @@ struct gsi_channel { ...@@ -114,8 +114,6 @@ struct gsi_channel {
u16 tre_count; u16 tre_count;
u16 event_count; u16 event_count;
struct completion completion; /* signals channel command completion */
struct gsi_ring tre_ring; struct gsi_ring tre_ring;
u32 evt_ring_id; u32 evt_ring_id;
...@@ -141,7 +139,6 @@ enum gsi_evt_ring_state { ...@@ -141,7 +139,6 @@ enum gsi_evt_ring_state {
struct gsi_evt_ring { struct gsi_evt_ring {
struct gsi_channel *channel; struct gsi_channel *channel;
struct completion completion; /* signals event ring state changes */
struct gsi_ring ring; struct gsi_ring ring;
}; };
...@@ -160,7 +157,7 @@ struct gsi { ...@@ -160,7 +157,7 @@ struct gsi {
u32 modem_channel_bitmap; /* modem channels to allocate */ u32 modem_channel_bitmap; /* modem channels to allocate */
u32 type_enabled_bitmap; /* GSI IRQ types enabled */ u32 type_enabled_bitmap; /* GSI IRQ types enabled */
u32 ieob_enabled_bitmap; /* IEOB IRQ enabled (event rings) */ u32 ieob_enabled_bitmap; /* IEOB IRQ enabled (event rings) */
struct completion completion; /* for global EE commands */ struct completion completion; /* Signals GSI command completion */
int result; /* Negative errno (generic commands) */ int result; /* Negative errno (generic commands) */
struct mutex mutex; /* protects commands, programming */ struct mutex mutex; /* protects commands, programming */
}; };
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment