Lines Matching +full:channel +full:-

1 // SPDX-License-Identifier: GPL-2.0
3 /* Copyright (c) 2015-2018, The Linux Foundation. All rights reserved.
4 * Copyright (C) 2018-2024 Linaro Ltd.
29 * providing a well-defined communication layer between the AP subsystem
32 * -------- ---------
34 * | AP +<---. .----+ Modem |
35 * | +--. | | .->+ |
37 * -------- | | | | ---------
39 * --+-+---+-+--
41 * |-----------|
45 * -------------
52 * of data to or from the IPA. A channel is implemented as a ring buffer,
53 * with a DRAM-resident array of "transfer elements" (TREs) available to
58 * Each TRE refers to a block of data--also located in DRAM. After writing
59 * one or more TREs to a channel, the writer (either the IPA or an EE) writes
63 * Each channel has a GSI "event ring" associated with it. An event ring
64 * is implemented very much like a channel ring, but is always directed from
65 * the IPA to an EE. The IPA notifies an EE (such as the AP) about channel
66 * events by adding an entry to the event ring associated with the channel.
69 * to the channel TRE whose completion the event represents.
71 * Each TRE in a channel ring has a set of flags. One flag indicates whether
73 * an interrupt) in the channel's event ring. Other flags allow transfer
76 * to signal completion of channel transfers.
78 * Elements in channel and event rings are completed (or consumed) strictly
83 * Note that all GSI registers are little-endian, which is the assumed
113 /** gsi_channel_scratch_gpi - GPI protocol scratch register
116 * on a channel (in bytes). This determines the amount of prefetch
118 * the TLV FIFO for the channel.
121 * should update the channel doorbell. We configure this to equal
132 /** gsi_channel_scratch - channel scratch configuration area
134 * The exact interpretation of this register is protocol-specific.
153 /* Code assumes the size of channel and event ring element are in gsi_validate_build()
166 /* Return the channel id associated with a given channel */
167 static u32 gsi_channel_id(struct gsi_channel *channel) in gsi_channel_id() argument
169 return channel - &channel->gsi->channel[0]; in gsi_channel_id()
172 /* An initialized channel has a non-null GSI pointer */
173 static bool gsi_channel_initialized(struct gsi_channel *channel) in gsi_channel_initialized() argument
175 return !!channel->gsi; in gsi_channel_initialized()
178 /* Encode the channel protocol for the CH_C_CNTXT_0 register */
199 gsi->type_enabled_bitmap = val; in gsi_irq_type_update()
200 iowrite32(val, gsi->virt + reg_offset(reg)); in gsi_irq_type_update()
205 gsi_irq_type_update(gsi, gsi->type_enabled_bitmap | type_id); in gsi_irq_type_enable()
210 gsi_irq_type_update(gsi, gsi->type_enabled_bitmap & ~type_id); in gsi_irq_type_disable()
228 iowrite32(~0, gsi->virt + reg_offset(reg)); in gsi_irq_ev_ctrl_enable()
231 iowrite32(val, gsi->virt + reg_offset(reg)); in gsi_irq_ev_ctrl_enable()
243 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_ev_ctrl_disable()
246 /* Channel commands are performed one at a time. Their completion is
247 * signaled by the channel control GSI interrupt type, which is only
248 * enabled when we issue a channel command. Only the channel being
261 iowrite32(~0, gsi->virt + reg_offset(reg)); in gsi_irq_ch_ctrl_enable()
264 iowrite32(val, gsi->virt + reg_offset(reg)); in gsi_irq_ch_ctrl_enable()
269 /* Disable channel control interrupts */
277 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_ch_ctrl_disable()
282 bool enable_ieob = !gsi->ieob_enabled_bitmap; in gsi_irq_ieob_enable_one()
286 gsi->ieob_enabled_bitmap |= BIT(evt_ring_id); in gsi_irq_ieob_enable_one()
289 val = gsi->ieob_enabled_bitmap; in gsi_irq_ieob_enable_one()
290 iowrite32(val, gsi->virt + reg_offset(reg)); in gsi_irq_ieob_enable_one()
292 /* Enable the interrupt type if this is the first channel enabled */ in gsi_irq_ieob_enable_one()
302 gsi->ieob_enabled_bitmap &= ~event_mask; in gsi_irq_ieob_disable()
304 /* Disable the interrupt type if this was the last enabled channel */ in gsi_irq_ieob_disable()
305 if (!gsi->ieob_enabled_bitmap) in gsi_irq_ieob_disable()
309 val = gsi->ieob_enabled_bitmap; in gsi_irq_ieob_disable()
310 iowrite32(val, gsi->virt + reg_offset(reg)); in gsi_irq_ieob_disable()
328 iowrite32(ERROR_INT, gsi->virt + reg_offset(reg)); in gsi_irq_enable()
330 gsi_irq_type_update(gsi, gsi->type_enabled_bitmap | GSI_GLOB_EE); in gsi_irq_enable()
341 iowrite32(val, gsi->virt + reg_offset(reg)); in gsi_irq_enable()
343 gsi_irq_type_update(gsi, gsi->type_enabled_bitmap | GSI_GENERAL); in gsi_irq_enable()
353 /* Clear the type-specific interrupt masks set by gsi_irq_enable() */ in gsi_irq_disable()
355 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_disable()
358 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_disable()
365 return ring->virt + (index % ring->count) * GSI_RING_ELEMENT_SIZE; in gsi_ring_virt()
368 /* Return the 32-bit DMA address associated with a ring index */
371 return lower_32_bits(ring->addr) + index * GSI_RING_ELEMENT_SIZE; in gsi_ring_addr()
374 /* Return the ring index of a 32-bit ring offset */
377 return (offset - gsi_ring_addr(ring, 0)) / GSI_RING_ELEMENT_SIZE; in gsi_ring_index()
387 struct completion *completion = &gsi->completion; in gsi_command()
391 iowrite32(val, gsi->virt + reg); in gsi_command()
403 val = ioread32(gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_state()
412 struct device *dev = gsi->dev; in gsi_evt_ring_command()
443 dev_err(gsi->dev, "event ring %u bad state %u before alloc\n", in gsi_evt_ring_alloc_command()
445 return -EINVAL; in gsi_evt_ring_alloc_command()
455 dev_err(gsi->dev, "event ring %u bad state %u after alloc\n", in gsi_evt_ring_alloc_command()
458 return -EIO; in gsi_evt_ring_alloc_command()
469 dev_err(gsi->dev, "event ring %u bad state %u before reset\n", in gsi_evt_ring_reset_command()
481 dev_err(gsi->dev, "event ring %u bad state %u after reset\n", in gsi_evt_ring_reset_command()
485 /* Issue a hardware de-allocation request for an allocated event ring */
492 dev_err(gsi->dev, "event ring %u state %u before dealloc\n", in gsi_evt_ring_de_alloc_command()
504 dev_err(gsi->dev, "event ring %u bad state %u after dealloc\n", in gsi_evt_ring_de_alloc_command()
508 /* Fetch the current state of a channel from hardware */
509 static enum gsi_channel_state gsi_channel_state(struct gsi_channel *channel) in gsi_channel_state() argument
511 const struct reg *reg = gsi_reg(channel->gsi, CH_C_CNTXT_0); in gsi_channel_state()
512 u32 channel_id = gsi_channel_id(channel); in gsi_channel_state()
513 struct gsi *gsi = channel->gsi; in gsi_channel_state()
514 void __iomem *virt = gsi->virt; in gsi_channel_state()
523 /* Issue a channel command and wait for it to complete */
525 gsi_channel_command(struct gsi_channel *channel, enum gsi_ch_cmd_opcode opcode) in gsi_channel_command() argument
527 u32 channel_id = gsi_channel_id(channel); in gsi_channel_command()
528 struct gsi *gsi = channel->gsi; in gsi_channel_command()
529 struct device *dev = gsi->dev; in gsi_channel_command()
548 dev_err(dev, "GSI command %u for channel %u timed out, state %u\n", in gsi_channel_command()
549 opcode, channel_id, gsi_channel_state(channel)); in gsi_channel_command()
552 /* Allocate GSI channel in NOT_ALLOCATED state */
555 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_alloc_command() local
556 struct device *dev = gsi->dev; in gsi_channel_alloc_command()
559 /* Get initial channel state */ in gsi_channel_alloc_command()
560 state = gsi_channel_state(channel); in gsi_channel_alloc_command()
562 dev_err(dev, "channel %u bad state %u before alloc\n", in gsi_channel_alloc_command()
564 return -EINVAL; in gsi_channel_alloc_command()
567 gsi_channel_command(channel, GSI_CH_ALLOCATE); in gsi_channel_alloc_command()
569 /* If successful the channel state will have changed */ in gsi_channel_alloc_command()
570 state = gsi_channel_state(channel); in gsi_channel_alloc_command()
574 dev_err(dev, "channel %u bad state %u after alloc\n", in gsi_channel_alloc_command()
577 return -EIO; in gsi_channel_alloc_command()
580 /* Start an ALLOCATED channel */
581 static int gsi_channel_start_command(struct gsi_channel *channel) in gsi_channel_start_command() argument
583 struct device *dev = channel->gsi->dev; in gsi_channel_start_command()
586 state = gsi_channel_state(channel); in gsi_channel_start_command()
589 dev_err(dev, "channel %u bad state %u before start\n", in gsi_channel_start_command()
590 gsi_channel_id(channel), state); in gsi_channel_start_command()
591 return -EINVAL; in gsi_channel_start_command()
594 gsi_channel_command(channel, GSI_CH_START); in gsi_channel_start_command()
596 /* If successful the channel state will have changed */ in gsi_channel_start_command()
597 state = gsi_channel_state(channel); in gsi_channel_start_command()
601 dev_err(dev, "channel %u bad state %u after start\n", in gsi_channel_start_command()
602 gsi_channel_id(channel), state); in gsi_channel_start_command()
604 return -EIO; in gsi_channel_start_command()
607 /* Stop a GSI channel in STARTED state */
608 static int gsi_channel_stop_command(struct gsi_channel *channel) in gsi_channel_stop_command() argument
610 struct device *dev = channel->gsi->dev; in gsi_channel_stop_command()
613 state = gsi_channel_state(channel); in gsi_channel_stop_command()
615 /* Channel could have entered STOPPED state since last call in gsi_channel_stop_command()
623 dev_err(dev, "channel %u bad state %u before stop\n", in gsi_channel_stop_command()
624 gsi_channel_id(channel), state); in gsi_channel_stop_command()
625 return -EINVAL; in gsi_channel_stop_command()
628 gsi_channel_command(channel, GSI_CH_STOP); in gsi_channel_stop_command()
630 /* If successful the channel state will have changed */ in gsi_channel_stop_command()
631 state = gsi_channel_state(channel); in gsi_channel_stop_command()
637 return -EAGAIN; in gsi_channel_stop_command()
639 dev_err(dev, "channel %u bad state %u after stop\n", in gsi_channel_stop_command()
640 gsi_channel_id(channel), state); in gsi_channel_stop_command()
642 return -EIO; in gsi_channel_stop_command()
645 /* Reset a GSI channel in ALLOCATED or ERROR state. */
646 static void gsi_channel_reset_command(struct gsi_channel *channel) in gsi_channel_reset_command() argument
648 struct device *dev = channel->gsi->dev; in gsi_channel_reset_command()
654 state = gsi_channel_state(channel); in gsi_channel_reset_command()
657 /* No need to reset a channel already in ALLOCATED state */ in gsi_channel_reset_command()
659 dev_err(dev, "channel %u bad state %u before reset\n", in gsi_channel_reset_command()
660 gsi_channel_id(channel), state); in gsi_channel_reset_command()
664 gsi_channel_command(channel, GSI_CH_RESET); in gsi_channel_reset_command()
666 /* If successful the channel state will have changed */ in gsi_channel_reset_command()
667 state = gsi_channel_state(channel); in gsi_channel_reset_command()
669 dev_err(dev, "channel %u bad state %u after reset\n", in gsi_channel_reset_command()
670 gsi_channel_id(channel), state); in gsi_channel_reset_command()
673 /* Deallocate an ALLOCATED GSI channel */
676 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_de_alloc_command() local
677 struct device *dev = gsi->dev; in gsi_channel_de_alloc_command()
680 state = gsi_channel_state(channel); in gsi_channel_de_alloc_command()
682 dev_err(dev, "channel %u bad state %u before dealloc\n", in gsi_channel_de_alloc_command()
687 gsi_channel_command(channel, GSI_CH_DE_ALLOC); in gsi_channel_de_alloc_command()
689 /* If successful the channel state will have changed */ in gsi_channel_de_alloc_command()
690 state = gsi_channel_state(channel); in gsi_channel_de_alloc_command()
693 dev_err(dev, "channel %u bad state %u after dealloc\n", in gsi_channel_de_alloc_command()
705 struct gsi_ring *ring = &gsi->evt_ring[evt_ring_id].ring; in gsi_evt_ring_doorbell()
708 ring->index = index; /* Next unused entry */ in gsi_evt_ring_doorbell()
711 val = gsi_ring_addr(ring, (index - 1) % ring->count); in gsi_evt_ring_doorbell()
712 iowrite32(val, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_doorbell()
718 struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; in gsi_evt_ring_program()
719 struct gsi_ring *ring = &evt_ring->ring; in gsi_evt_ring_program()
729 iowrite32(val, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
732 val = reg_encode(reg, R_LENGTH, ring->count * GSI_RING_ELEMENT_SIZE); in gsi_evt_ring_program()
733 iowrite32(val, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
735 /* The context 2 and 3 registers store the low-order and in gsi_evt_ring_program()
736 * high-order 32 bits of the address of the event ring, in gsi_evt_ring_program()
740 val = lower_32_bits(ring->addr); in gsi_evt_ring_program()
741 iowrite32(val, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
744 val = upper_32_bits(ring->addr); in gsi_evt_ring_program()
745 iowrite32(val, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
750 val |= reg_encode(reg, EV_MODC, 1); /* comes from channel */ in gsi_evt_ring_program()
751 /* EV_MOD_CNT is 0 (no counter-based interrupt coalescing) */ in gsi_evt_ring_program()
752 iowrite32(val, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
756 iowrite32(0, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
759 iowrite32(0, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
762 iowrite32(0, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
766 iowrite32(0, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
769 iowrite32(0, gsi->virt + reg_n_offset(reg, evt_ring_id)); in gsi_evt_ring_program()
772 gsi_evt_ring_doorbell(gsi, evt_ring_id, ring->index); in gsi_evt_ring_program()
775 /* Find the transaction whose completion indicates a channel is quiesced */
776 static struct gsi_trans *gsi_channel_trans_last(struct gsi_channel *channel) in gsi_channel_trans_last() argument
778 struct gsi_trans_info *trans_info = &channel->trans_info; in gsi_channel_trans_last()
779 u32 pending_id = trans_info->pending_id; in gsi_channel_trans_last()
783 if (channel->toward_ipa && pending_id != trans_info->free_id) { in gsi_channel_trans_last()
789 trans_id = trans_info->free_id - 1; in gsi_channel_trans_last()
790 } else if (trans_info->polled_id != pending_id) { in gsi_channel_trans_last()
797 trans_id = pending_id - 1; in gsi_channel_trans_last()
803 trans = &trans_info->trans[trans_id % channel->tre_count]; in gsi_channel_trans_last()
804 refcount_inc(&trans->refcount); in gsi_channel_trans_last()
809 /* Wait for transaction activity on a channel to complete */
810 static void gsi_channel_trans_quiesce(struct gsi_channel *channel) in gsi_channel_trans_quiesce() argument
815 trans = gsi_channel_trans_last(channel); in gsi_channel_trans_quiesce()
817 wait_for_completion(&trans->completion); in gsi_channel_trans_quiesce()
822 /* Program a channel for use; there is no gsi_channel_deprogram() */
823 static void gsi_channel_program(struct gsi_channel *channel, bool doorbell) in gsi_channel_program() argument
825 size_t size = channel->tre_ring.count * GSI_RING_ELEMENT_SIZE; in gsi_channel_program()
826 u32 channel_id = gsi_channel_id(channel); in gsi_channel_program()
829 struct gsi *gsi = channel->gsi; in gsi_channel_program()
838 val = ch_c_cntxt_0_type_encode(gsi->version, reg, GSI_CHANNEL_TYPE_GPI); in gsi_channel_program()
839 if (channel->toward_ipa) in gsi_channel_program()
841 if (gsi->version < IPA_VERSION_5_0) in gsi_channel_program()
842 val |= reg_encode(reg, ERINDEX, channel->evt_ring_id); in gsi_channel_program()
844 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id)); in gsi_channel_program()
848 if (gsi->version >= IPA_VERSION_5_0) in gsi_channel_program()
849 val |= reg_encode(reg, CH_ERINDEX, channel->evt_ring_id); in gsi_channel_program()
850 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id)); in gsi_channel_program()
852 /* The context 2 and 3 registers store the low-order and in gsi_channel_program()
853 * high-order 32 bits of the address of the channel ring, in gsi_channel_program()
857 val = lower_32_bits(channel->tre_ring.addr); in gsi_channel_program()
858 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id)); in gsi_channel_program()
861 val = upper_32_bits(channel->tre_ring.addr); in gsi_channel_program()
862 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id)); in gsi_channel_program()
866 /* Command channel gets low weighted round-robin priority */ in gsi_channel_program()
867 if (channel->command) in gsi_channel_program()
874 if (gsi->version < IPA_VERSION_4_0 && doorbell) in gsi_channel_program()
878 * on all but the AP command channel. in gsi_channel_program()
880 if (gsi->version >= IPA_VERSION_4_0 && !channel->command) { in gsi_channel_program()
882 if (gsi->version < IPA_VERSION_4_5) in gsi_channel_program()
888 if (gsi->version >= IPA_VERSION_4_9) in gsi_channel_program()
891 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id)); in gsi_channel_program()
895 gpi->max_outstanding_tre = channel->trans_tre_max * in gsi_channel_program()
897 gpi->outstanding_threshold = 2 * GSI_RING_ELEMENT_SIZE; in gsi_channel_program()
901 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id)); in gsi_channel_program()
905 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id)); in gsi_channel_program()
909 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id)); in gsi_channel_program()
917 val = ioread32(gsi->virt + offset); in gsi_channel_program()
919 iowrite32(val, gsi->virt + offset); in gsi_channel_program()
924 static int __gsi_channel_start(struct gsi_channel *channel, bool resume) in __gsi_channel_start() argument
926 struct gsi *gsi = channel->gsi; in __gsi_channel_start()
930 if (resume && gsi->version < IPA_VERSION_4_0) in __gsi_channel_start()
933 mutex_lock(&gsi->mutex); in __gsi_channel_start()
935 ret = gsi_channel_start_command(channel); in __gsi_channel_start()
937 mutex_unlock(&gsi->mutex); in __gsi_channel_start()
942 /* Start an allocated GSI channel */
945 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_start() local
949 napi_enable(&channel->napi); in gsi_channel_start()
950 gsi_irq_ieob_enable_one(gsi, channel->evt_ring_id); in gsi_channel_start()
952 ret = __gsi_channel_start(channel, false); in gsi_channel_start()
954 gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); in gsi_channel_start()
955 napi_disable(&channel->napi); in gsi_channel_start()
961 static int gsi_channel_stop_retry(struct gsi_channel *channel) in gsi_channel_stop_retry() argument
967 ret = gsi_channel_stop_command(channel); in gsi_channel_stop_retry()
968 if (ret != -EAGAIN) in gsi_channel_stop_retry()
971 } while (retries--); in gsi_channel_stop_retry()
976 static int __gsi_channel_stop(struct gsi_channel *channel, bool suspend) in __gsi_channel_stop() argument
978 struct gsi *gsi = channel->gsi; in __gsi_channel_stop()
982 gsi_channel_trans_quiesce(channel); in __gsi_channel_stop()
985 if (suspend && gsi->version < IPA_VERSION_4_0) in __gsi_channel_stop()
988 mutex_lock(&gsi->mutex); in __gsi_channel_stop()
990 ret = gsi_channel_stop_retry(channel); in __gsi_channel_stop()
992 mutex_unlock(&gsi->mutex); in __gsi_channel_stop()
997 /* Stop a started channel */
1000 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_stop() local
1003 ret = __gsi_channel_stop(channel, false); in gsi_channel_stop()
1008 gsi_irq_ieob_disable_one(gsi, channel->evt_ring_id); in gsi_channel_stop()
1009 napi_disable(&channel->napi); in gsi_channel_stop()
1014 /* Reset and reconfigure a channel, (possibly) enabling the doorbell engine */
1017 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_reset() local
1019 mutex_lock(&gsi->mutex); in gsi_channel_reset()
1021 gsi_channel_reset_command(channel); in gsi_channel_reset()
1023 if (gsi->version < IPA_VERSION_4_0 && !channel->toward_ipa) in gsi_channel_reset()
1024 gsi_channel_reset_command(channel); in gsi_channel_reset()
1027 channel->tre_ring.index = 0; in gsi_channel_reset()
1028 gsi_channel_program(channel, doorbell); in gsi_channel_reset()
1029 gsi_channel_trans_cancel_pending(channel); in gsi_channel_reset()
1031 mutex_unlock(&gsi->mutex); in gsi_channel_reset()
1034 /* Stop a started channel for suspend */
1037 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_suspend() local
1040 ret = __gsi_channel_stop(channel, true); in gsi_channel_suspend()
1045 napi_synchronize(&channel->napi); in gsi_channel_suspend()
1050 /* Resume a suspended channel (starting if stopped) */
1053 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_resume() local
1055 return __gsi_channel_start(channel, true); in gsi_channel_resume()
1061 disable_irq(gsi->irq); in gsi_suspend()
1067 enable_irq(gsi->irq); in gsi_resume()
1072 struct gsi_channel *channel = &trans->gsi->channel[trans->channel_id]; in gsi_trans_tx_committed() local
1074 channel->trans_count++; in gsi_trans_tx_committed()
1075 channel->byte_count += trans->len; in gsi_trans_tx_committed()
1077 trans->trans_count = channel->trans_count; in gsi_trans_tx_committed()
1078 trans->byte_count = channel->byte_count; in gsi_trans_tx_committed()
1083 u32 channel_id = trans->channel_id; in gsi_trans_tx_queued()
1084 struct gsi *gsi = trans->gsi; in gsi_trans_tx_queued()
1085 struct gsi_channel *channel; in gsi_trans_tx_queued() local
1089 channel = &gsi->channel[channel_id]; in gsi_trans_tx_queued()
1091 byte_count = channel->byte_count - channel->queued_byte_count; in gsi_trans_tx_queued()
1092 trans_count = channel->trans_count - channel->queued_trans_count; in gsi_trans_tx_queued()
1093 channel->queued_byte_count = channel->byte_count; in gsi_trans_tx_queued()
1094 channel->queued_trans_count = channel->trans_count; in gsi_trans_tx_queued()
1100 * gsi_trans_tx_completed() - Report completed TX transactions
1101 * @trans: TX channel transaction that has completed
1103 * Report that a transaction on a TX channel has completed. At the time a
1104 * transaction is committed, we record *in the transaction* its channel's
1106 * order, and the difference between the channel's byte/transaction count
1116 u32 channel_id = trans->channel_id; in gsi_trans_tx_completed()
1117 struct gsi *gsi = trans->gsi; in gsi_trans_tx_completed()
1118 struct gsi_channel *channel; in gsi_trans_tx_completed() local
1122 channel = &gsi->channel[channel_id]; in gsi_trans_tx_completed()
1123 trans_count = trans->trans_count - channel->compl_trans_count; in gsi_trans_tx_completed()
1124 byte_count = trans->byte_count - channel->compl_byte_count; in gsi_trans_tx_completed()
1126 channel->compl_trans_count += trans_count; in gsi_trans_tx_completed()
1127 channel->compl_byte_count += byte_count; in gsi_trans_tx_completed()
1132 /* Channel control interrupt handler */
1139 channel_mask = ioread32(gsi->virt + reg_offset(reg)); in gsi_isr_chan_ctrl()
1142 iowrite32(channel_mask, gsi->virt + reg_offset(reg)); in gsi_isr_chan_ctrl()
1149 complete(&gsi->completion); in gsi_isr_chan_ctrl()
1160 event_mask = ioread32(gsi->virt + reg_offset(reg)); in gsi_isr_evt_ctrl()
1163 iowrite32(event_mask, gsi->virt + reg_offset(reg)); in gsi_isr_evt_ctrl()
1170 complete(&gsi->completion); in gsi_isr_evt_ctrl()
1174 /* Global channel error interrupt handler */
1179 dev_err(gsi->dev, "channel %u out of resources\n", channel_id); in gsi_isr_glob_chan_err()
1180 complete(&gsi->completion); in gsi_isr_glob_chan_err()
1185 dev_err(gsi->dev, "channel %u global error ee 0x%08x code 0x%08x\n", in gsi_isr_glob_chan_err()
1194 struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; in gsi_isr_glob_evt_err()
1195 u32 channel_id = gsi_channel_id(evt_ring->channel); in gsi_isr_glob_evt_err()
1197 complete(&gsi->completion); in gsi_isr_glob_evt_err()
1198 dev_err(gsi->dev, "evt_ring for channel %u out of resources\n", in gsi_isr_glob_evt_err()
1204 dev_err(gsi->dev, "event ring %u global error ee %u code 0x%08x\n", in gsi_isr_glob_evt_err()
1223 val = ioread32(gsi->virt + offset); in gsi_isr_glob_err()
1224 iowrite32(0, gsi->virt + offset); in gsi_isr_glob_err()
1227 iowrite32(~0, gsi->virt + reg_offset(clr_reg)); in gsi_isr_glob_err()
1240 dev_err(gsi->dev, "unexpected global error 0x%08x\n", type); in gsi_isr_glob_err()
1254 * way of knowing whether a modem channel's state has been changed. in gsi_isr_gp_int1()
1256 * We also use GENERIC commands to enable/disable channel flow in gsi_isr_gp_int1()
1260 * when shutting down, but it's possible the channel isn't running in gsi_isr_gp_int1()
1262 * that case, but it's harmless (the channel is already halted). in gsi_isr_gp_int1()
1264 * on a channel because it's not in the proper state. in gsi_isr_gp_int1()
1270 val = ioread32(gsi->virt + reg_offset(reg)); in gsi_isr_gp_int1()
1276 gsi->result = 0; in gsi_isr_gp_int1()
1280 gsi->result = -EAGAIN; in gsi_isr_gp_int1()
1284 dev_err(gsi->dev, "global INT1 generic result %u\n", result); in gsi_isr_gp_int1()
1285 gsi->result = -EIO; in gsi_isr_gp_int1()
1289 complete(&gsi->completion); in gsi_isr_gp_int1()
1292 /* Inter-EE interrupt handler */
1299 val = ioread32(gsi->virt + reg_offset(reg)); in gsi_isr_glob_ee()
1305 iowrite32(val, gsi->virt + reg_offset(reg)); in gsi_isr_glob_ee()
1315 dev_err(gsi->dev, "unexpected global interrupt 0x%08x\n", val); in gsi_isr_glob_ee()
1325 event_mask = ioread32(gsi->virt + reg_offset(reg)); in gsi_isr_ieob()
1330 iowrite32(event_mask, gsi->virt + reg_offset(reg)); in gsi_isr_ieob()
1337 napi_schedule(&gsi->evt_ring[evt_ring_id].channel->napi); in gsi_isr_ieob()
1344 struct device *dev = gsi->dev; in gsi_isr_general()
1349 val = ioread32(gsi->virt + reg_offset(reg)); in gsi_isr_general()
1352 iowrite32(val, gsi->virt + reg_offset(reg)); in gsi_isr_general()
1358 * gsi_isr() - Top level GSI interrupt service routine
1377 while ((intr_mask = ioread32(gsi->virt + offset))) { in gsi_isr()
1385 * when the type-specific register is updated. in gsi_isr()
1404 dev_err(gsi->dev, in gsi_isr()
1412 dev_err(gsi->dev, "interrupt flood\n"); in gsi_isr()
1427 return ret ? : -EINVAL; in gsi_irq_init()
1429 gsi->irq = ret; in gsi_irq_init()
1438 u32 channel_id = event->chid; in gsi_event_trans()
1439 struct gsi_channel *channel; in gsi_event_trans() local
1444 channel = &gsi->channel[channel_id]; in gsi_event_trans()
1445 if (WARN(!channel->gsi, "event has bad channel %u\n", channel_id)) in gsi_event_trans()
1449 tre_offset = lower_32_bits(le64_to_cpu(event->xfer_ptr)); in gsi_event_trans()
1450 tre_index = gsi_ring_index(&channel->tre_ring, tre_offset); in gsi_event_trans()
1452 trans = gsi_channel_trans_mapped(channel, tre_index); in gsi_event_trans()
1454 if (WARN(!trans, "channel %u event with no transaction\n", channel_id)) in gsi_event_trans()
1461 * gsi_evt_ring_update() - Update transaction state from hardware
1470 * When an event for a TX channel arrives we use information in the
1486 struct gsi_evt_ring *evt_ring = &gsi->evt_ring[evt_ring_id]; in gsi_evt_ring_update()
1487 struct gsi_ring *ring = &evt_ring->ring; in gsi_evt_ring_update()
1493 /* Starting with the oldest un-processed event, determine which in gsi_evt_ring_update()
1494 * transaction (and which channel) is associated with the event. in gsi_evt_ring_update()
1500 old_index = ring->index; in gsi_evt_ring_update()
1506 event_avail = ring->count - old_index % ring->count; in gsi_evt_ring_update()
1515 if (trans->direction == DMA_FROM_DEVICE) in gsi_evt_ring_update()
1516 trans->len = __le16_to_cpu(event->len); in gsi_evt_ring_update()
1523 if (--event_avail) in gsi_evt_ring_update()
1537 struct device *dev = gsi->dev; in gsi_ring_alloc()
1542 * be a power-of-2 number of pages, which satisfies the requirement. in gsi_ring_alloc()
1544 ring->virt = dma_alloc_coherent(dev, size, &addr, GFP_KERNEL); in gsi_ring_alloc()
1545 if (!ring->virt) in gsi_ring_alloc()
1546 return -ENOMEM; in gsi_ring_alloc()
1548 ring->addr = addr; in gsi_ring_alloc()
1549 ring->count = count; in gsi_ring_alloc()
1550 ring->index = 0; in gsi_ring_alloc()
1555 /* Free a previously-allocated ring */
1558 size_t size = ring->count * GSI_RING_ELEMENT_SIZE; in gsi_ring_free()
1560 dma_free_coherent(gsi->dev, size, ring->virt, ring->addr); in gsi_ring_free()
1568 if (gsi->event_bitmap == ~0U) { in gsi_evt_ring_id_alloc()
1569 dev_err(gsi->dev, "event rings exhausted\n"); in gsi_evt_ring_id_alloc()
1570 return -ENOSPC; in gsi_evt_ring_id_alloc()
1573 evt_ring_id = ffz(gsi->event_bitmap); in gsi_evt_ring_id_alloc()
1574 gsi->event_bitmap |= BIT(evt_ring_id); in gsi_evt_ring_id_alloc()
1579 /* Free a previously-allocated event ring id */
1582 gsi->event_bitmap &= ~BIT(evt_ring_id); in gsi_evt_ring_id_free()
1585 /* Ring a channel doorbell, reporting the first un-filled entry */
1586 void gsi_channel_doorbell(struct gsi_channel *channel) in gsi_channel_doorbell() argument
1588 struct gsi_ring *tre_ring = &channel->tre_ring; in gsi_channel_doorbell()
1589 u32 channel_id = gsi_channel_id(channel); in gsi_channel_doorbell()
1590 struct gsi *gsi = channel->gsi; in gsi_channel_doorbell()
1596 val = gsi_ring_addr(tre_ring, tre_ring->index % tre_ring->count); in gsi_channel_doorbell()
1597 iowrite32(val, gsi->virt + reg_n_offset(reg, channel_id)); in gsi_channel_doorbell()
1601 void gsi_channel_update(struct gsi_channel *channel) in gsi_channel_update() argument
1603 u32 evt_ring_id = channel->evt_ring_id; in gsi_channel_update()
1604 struct gsi *gsi = channel->gsi; in gsi_channel_update()
1612 evt_ring = &gsi->evt_ring[evt_ring_id]; in gsi_channel_update()
1613 ring = &evt_ring->ring; in gsi_channel_update()
1620 index = gsi_ring_index(ring, ioread32(gsi->virt + offset)); in gsi_channel_update()
1621 if (index == ring->index % ring->count) in gsi_channel_update()
1625 trans = gsi_event_trans(gsi, gsi_ring_virt(ring, index - 1)); in gsi_channel_update()
1638 * gsi_channel_poll_one() - Return a single completed transaction on a channel
1639 * @channel: Channel to be polled
1643 * This function returns the first of a channel's completed transactions.
1649 static struct gsi_trans *gsi_channel_poll_one(struct gsi_channel *channel) in gsi_channel_poll_one() argument
1654 trans = gsi_channel_trans_complete(channel); in gsi_channel_poll_one()
1662 * gsi_channel_poll() - NAPI poll function for a channel
1663 * @napi: NAPI structure for the channel
1675 struct gsi_channel *channel; in gsi_channel_poll() local
1678 channel = container_of(napi, struct gsi_channel, napi); in gsi_channel_poll()
1682 trans = gsi_channel_poll_one(channel); in gsi_channel_poll()
1689 gsi_irq_ieob_enable_one(channel->gsi, channel->evt_ring_id); in gsi_channel_poll()
1701 u32 event_bitmap = GENMASK(BITS_PER_LONG - 1, evt_ring_max); in gsi_event_bitmap_init()
1708 /* Setup function for a single channel */
1711 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_setup_one() local
1712 u32 evt_ring_id = channel->evt_ring_id; in gsi_channel_setup_one()
1715 if (!gsi_channel_initialized(channel)) in gsi_channel_setup_one()
1728 gsi_channel_program(channel, true); in gsi_channel_setup_one()
1730 if (channel->toward_ipa) in gsi_channel_setup_one()
1731 netif_napi_add_tx(gsi->dummy_dev, &channel->napi, in gsi_channel_setup_one()
1734 netif_napi_add(gsi->dummy_dev, &channel->napi, in gsi_channel_setup_one()
1749 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_teardown_one() local
1750 u32 evt_ring_id = channel->evt_ring_id; in gsi_channel_teardown_one()
1752 if (!gsi_channel_initialized(channel)) in gsi_channel_teardown_one()
1755 netif_napi_del(&channel->napi); in gsi_channel_teardown_one()
1763 * the ability to determine channel state for a modem channel, so we simply
1781 * channel), and only from this function. So we enable the GP_INT1 in gsi_generic_command()
1786 iowrite32(val, gsi->virt + reg_offset(reg)); in gsi_generic_command()
1791 val = ioread32(gsi->virt + offset); in gsi_generic_command()
1794 iowrite32(val, gsi->virt + offset); in gsi_generic_command()
1801 if (gsi->version >= IPA_VERSION_4_11) in gsi_generic_command()
1808 iowrite32(ERROR_INT, gsi->virt + reg_offset(reg)); in gsi_generic_command()
1811 return gsi->result; in gsi_generic_command()
1813 dev_err(gsi->dev, "GSI generic command %u to channel %u timed out\n", in gsi_generic_command()
1816 return -ETIMEDOUT; in gsi_generic_command()
1833 while (ret == -EAGAIN && retries--); in gsi_modem_channel_halt()
1836 dev_err(gsi->dev, "error %d halting modem channel %u\n", in gsi_modem_channel_halt()
1840 /* Enable or disable flow control for a modem GSI TX channel (IPA v4.2+) */
1850 /* Disabling flow control on IPA v4.11+ can return -EAGAIN if enable in gsi_modem_channel_flow_control()
1853 if (!enable && gsi->version >= IPA_VERSION_4_11) in gsi_modem_channel_flow_control()
1858 while (ret == -EAGAIN && retries--); in gsi_modem_channel_flow_control()
1861 dev_err(gsi->dev, in gsi_modem_channel_flow_control()
1862 "error %d %sabling mode channel %u flow control\n", in gsi_modem_channel_flow_control()
1875 mutex_lock(&gsi->mutex); in gsi_channel_setup()
1881 } while (++channel_id < gsi->channel_count); in gsi_channel_setup()
1885 struct gsi_channel *channel = &gsi->channel[channel_id++]; in gsi_channel_setup() local
1887 if (!gsi_channel_initialized(channel)) in gsi_channel_setup()
1890 ret = -EINVAL; in gsi_channel_setup()
1891 dev_err(gsi->dev, "channel %u not supported by hardware\n", in gsi_channel_setup()
1892 channel_id - 1); in gsi_channel_setup()
1893 channel_id = gsi->channel_count; in gsi_channel_setup()
1898 mask = gsi->modem_channel_bitmap; in gsi_channel_setup()
1910 mutex_unlock(&gsi->mutex); in gsi_channel_setup()
1916 mask ^= gsi->modem_channel_bitmap; in gsi_channel_setup()
1926 while (channel_id--) in gsi_channel_setup()
1929 mutex_unlock(&gsi->mutex); in gsi_channel_setup()
1939 u32 mask = gsi->modem_channel_bitmap; in gsi_channel_teardown()
1942 mutex_lock(&gsi->mutex); in gsi_channel_teardown()
1952 channel_id = gsi->channel_count - 1; in gsi_channel_teardown()
1955 while (channel_id--); in gsi_channel_teardown()
1957 mutex_unlock(&gsi->mutex); in gsi_channel_teardown()
1970 iowrite32(reg_bit(reg, INTYPE), gsi->virt + reg_offset(reg)); in gsi_irq_setup()
1975 /* Clear all type-specific interrupt masks */ in gsi_irq_setup()
1977 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_setup()
1980 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_setup()
1983 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_setup()
1986 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_setup()
1988 /* The inter-EE interrupts are not supported for IPA v3.0-v3.1 */ in gsi_irq_setup()
1989 if (gsi->version > IPA_VERSION_3_1) { in gsi_irq_setup()
1991 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_setup()
1994 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_setup()
1998 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_irq_setup()
2000 ret = request_irq(gsi->irq, gsi_isr, 0, "gsi", gsi); in gsi_irq_setup()
2002 dev_err(gsi->dev, "error %d requesting \"gsi\" IRQ\n", ret); in gsi_irq_setup()
2009 free_irq(gsi->irq, gsi); in gsi_irq_teardown()
2012 /* Get # supported channel and event rings; there is no gsi_ring_teardown() */
2015 struct device *dev = gsi->dev; in gsi_ring_setup()
2020 if (gsi->version < IPA_VERSION_3_5_1) { in gsi_ring_setup()
2022 gsi->channel_count = GSI_CHANNEL_COUNT_MAX; in gsi_ring_setup()
2023 gsi->evt_ring_count = GSI_EVT_RING_COUNT_MAX; in gsi_ring_setup()
2029 val = ioread32(gsi->virt + reg_offset(reg)); in gsi_ring_setup()
2034 return -EINVAL; in gsi_ring_setup()
2041 gsi->channel_count = count; in gsi_ring_setup()
2043 if (gsi->version < IPA_VERSION_5_0) { in gsi_ring_setup()
2051 return -EINVAL; in gsi_ring_setup()
2059 gsi->evt_ring_count = count; in gsi_ring_setup()
2073 val = ioread32(gsi->virt + reg_offset(reg)); in gsi_setup()
2075 dev_err(gsi->dev, "GSI has not been enabled\n"); in gsi_setup()
2076 return -EIO; in gsi_setup()
2089 iowrite32(0, gsi->virt + reg_offset(reg)); in gsi_setup()
2110 /* Initialize a channel's event ring */
2111 static int gsi_channel_evt_ring_init(struct gsi_channel *channel) in gsi_channel_evt_ring_init() argument
2113 struct gsi *gsi = channel->gsi; in gsi_channel_evt_ring_init()
2120 channel->evt_ring_id = ret; in gsi_channel_evt_ring_init()
2122 evt_ring = &gsi->evt_ring[channel->evt_ring_id]; in gsi_channel_evt_ring_init()
2123 evt_ring->channel = channel; in gsi_channel_evt_ring_init()
2125 ret = gsi_ring_alloc(gsi, &evt_ring->ring, channel->event_count); in gsi_channel_evt_ring_init()
2129 dev_err(gsi->dev, "error %d allocating channel %u event ring\n", in gsi_channel_evt_ring_init()
2130 ret, gsi_channel_id(channel)); in gsi_channel_evt_ring_init()
2132 gsi_evt_ring_id_free(gsi, channel->evt_ring_id); in gsi_channel_evt_ring_init()
2138 static void gsi_channel_evt_ring_exit(struct gsi_channel *channel) in gsi_channel_evt_ring_exit() argument
2140 u32 evt_ring_id = channel->evt_ring_id; in gsi_channel_evt_ring_exit()
2141 struct gsi *gsi = channel->gsi; in gsi_channel_evt_ring_exit()
2144 evt_ring = &gsi->evt_ring[evt_ring_id]; in gsi_channel_evt_ring_exit()
2145 gsi_ring_free(gsi, &evt_ring->ring); in gsi_channel_evt_ring_exit()
2153 u32 channel_id = data->channel_id; in gsi_channel_data_valid()
2154 struct device *dev = gsi->dev; in gsi_channel_data_valid()
2156 /* Make sure channel ids are in the range driver supports */ in gsi_channel_data_valid()
2158 dev_err(dev, "bad channel id %u; must be less than %u\n", in gsi_channel_data_valid()
2163 if (data->ee_id != GSI_EE_AP && data->ee_id != GSI_EE_MODEM) { in gsi_channel_data_valid()
2164 dev_err(dev, "bad EE id %u; not AP or modem\n", data->ee_id); in gsi_channel_data_valid()
2168 if (command && !data->toward_ipa) { in gsi_channel_data_valid()
2169 dev_err(dev, "command channel %u is not TX\n", channel_id); in gsi_channel_data_valid()
2173 channel_data = &data->channel; in gsi_channel_data_valid()
2175 if (!channel_data->tlv_count || in gsi_channel_data_valid()
2176 channel_data->tlv_count > GSI_TLV_MAX) { in gsi_channel_data_valid()
2177 dev_err(dev, "channel %u bad tlv_count %u; must be 1..%u\n", in gsi_channel_data_valid()
2178 channel_id, channel_data->tlv_count, GSI_TLV_MAX); in gsi_channel_data_valid()
2182 if (command && IPA_COMMAND_TRANS_TRE_MAX > channel_data->tlv_count) { in gsi_channel_data_valid()
2183 dev_err(dev, "command TRE max too big for channel %u (%u > %u)\n", in gsi_channel_data_valid()
2185 channel_data->tlv_count); in gsi_channel_data_valid()
2189 /* We have to allow at least one maximally-sized transaction to in gsi_channel_data_valid()
2194 if (channel_data->tre_count < 2 * channel_data->tlv_count - 1) { in gsi_channel_data_valid()
2195 dev_err(dev, "channel %u TLV count %u exceeds TRE count %u\n", in gsi_channel_data_valid()
2196 channel_id, channel_data->tlv_count, in gsi_channel_data_valid()
2197 channel_data->tre_count); in gsi_channel_data_valid()
2201 if (!is_power_of_2(channel_data->tre_count)) { in gsi_channel_data_valid()
2202 dev_err(dev, "channel %u bad tre_count %u; not power of 2\n", in gsi_channel_data_valid()
2203 channel_id, channel_data->tre_count); in gsi_channel_data_valid()
2207 if (!is_power_of_2(channel_data->event_count)) { in gsi_channel_data_valid()
2208 dev_err(dev, "channel %u bad event_count %u; not power of 2\n", in gsi_channel_data_valid()
2209 channel_id, channel_data->event_count); in gsi_channel_data_valid()
2216 /* Init function for a single channel */
2221 struct gsi_channel *channel; in gsi_channel_init_one() local
2226 return -EINVAL; in gsi_channel_init_one()
2229 if (data->channel.tre_count > data->channel.event_count) { in gsi_channel_init_one()
2230 tre_count = data->channel.event_count; in gsi_channel_init_one()
2231 dev_warn(gsi->dev, "channel %u limited to %u TREs\n", in gsi_channel_init_one()
2232 data->channel_id, tre_count); in gsi_channel_init_one()
2234 tre_count = data->channel.tre_count; in gsi_channel_init_one()
2237 channel = &gsi->channel[data->channel_id]; in gsi_channel_init_one()
2238 memset(channel, 0, sizeof(*channel)); in gsi_channel_init_one()
2240 channel->gsi = gsi; in gsi_channel_init_one()
2241 channel->toward_ipa = data->toward_ipa; in gsi_channel_init_one()
2242 channel->command = command; in gsi_channel_init_one()
2243 channel->trans_tre_max = data->channel.tlv_count; in gsi_channel_init_one()
2244 channel->tre_count = tre_count; in gsi_channel_init_one()
2245 channel->event_count = data->channel.event_count; in gsi_channel_init_one()
2247 ret = gsi_channel_evt_ring_init(channel); in gsi_channel_init_one()
2251 ret = gsi_ring_alloc(gsi, &channel->tre_ring, data->channel.tre_count); in gsi_channel_init_one()
2253 dev_err(gsi->dev, "error %d allocating channel %u ring\n", in gsi_channel_init_one()
2254 ret, data->channel_id); in gsi_channel_init_one()
2258 ret = gsi_channel_trans_init(gsi, data->channel_id); in gsi_channel_init_one()
2263 u32 tre_max = gsi_channel_tre_max(gsi, data->channel_id); in gsi_channel_init_one()
2265 ret = ipa_cmd_pool_init(channel, tre_max); in gsi_channel_init_one()
2270 gsi_channel_trans_exit(channel); in gsi_channel_init_one()
2272 gsi_ring_free(gsi, &channel->tre_ring); in gsi_channel_init_one()
2274 gsi_channel_evt_ring_exit(channel); in gsi_channel_init_one()
2276 channel->gsi = NULL; /* Mark it not (fully) initialized */ in gsi_channel_init_one()
2282 static void gsi_channel_exit_one(struct gsi_channel *channel) in gsi_channel_exit_one() argument
2284 if (!gsi_channel_initialized(channel)) in gsi_channel_exit_one()
2287 if (channel->command) in gsi_channel_exit_one()
2288 ipa_cmd_pool_exit(channel); in gsi_channel_exit_one()
2289 gsi_channel_trans_exit(channel); in gsi_channel_exit_one()
2290 gsi_ring_free(channel->gsi, &channel->tre_ring); in gsi_channel_exit_one()
2291 gsi_channel_evt_ring_exit(channel); in gsi_channel_exit_one()
2303 modem_alloc = gsi->version == IPA_VERSION_4_2; in gsi_channel_init()
2305 gsi->event_bitmap = gsi_event_bitmap_init(GSI_EVT_RING_COUNT_MAX); in gsi_channel_init()
2306 gsi->ieob_enabled_bitmap = 0; in gsi_channel_init()
2318 gsi->modem_channel_bitmap |= in gsi_channel_init()
2331 while (i--) { in gsi_channel_init()
2335 gsi->modem_channel_bitmap &= ~BIT(data[i].channel_id); in gsi_channel_init()
2338 gsi_channel_exit_one(&gsi->channel[data->channel_id]); in gsi_channel_init()
2347 u32 channel_id = GSI_CHANNEL_COUNT_MAX - 1; in gsi_channel_exit()
2350 gsi_channel_exit_one(&gsi->channel[channel_id]); in gsi_channel_exit()
2351 while (channel_id--); in gsi_channel_exit()
2352 gsi->modem_channel_bitmap = 0; in gsi_channel_exit()
2364 gsi->dev = &pdev->dev; in gsi_init()
2365 gsi->version = version; in gsi_init()
2368 * for the channel NAPI contexts to be associated with. in gsi_init()
2370 gsi->dummy_dev = alloc_netdev_dummy(0); in gsi_init()
2371 if (!gsi->dummy_dev) in gsi_init()
2372 return -ENOMEM; in gsi_init()
2373 init_completion(&gsi->completion); in gsi_init()
2387 mutex_init(&gsi->mutex); in gsi_init()
2392 free_netdev(gsi->dummy_dev); in gsi_init()
2401 mutex_destroy(&gsi->mutex); in gsi_exit()
2403 free_netdev(gsi->dummy_dev); in gsi_exit()
2407 /* The maximum number of outstanding TREs on a channel. This limits
2408 * a channel's maximum number of transactions outstanding (worst case
2411 * The absolute limit is the number of TREs in the channel's TRE ring,
2415 * would be (tre_count - 1).
2423 * a pool to avoid crossing that power-of-2 boundary, and this can
2429 struct gsi_channel *channel = &gsi->channel[channel_id]; in gsi_channel_tre_max() local
2431 /* Hardware limit is channel->tre_count - 1 */ in gsi_channel_tre_max()
2432 return channel->tre_count - (channel->trans_tre_max - 1); in gsi_channel_tre_max()