Skip to content

Commit 124bb4e

Browse files
committed
Merge tag 'mhi-for-v6.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mani/mhi into char-misc-next
Manivannan writes: MHI Host ======== - Remove unused mhi_device_get() and mhi_queue_dma() APIs. - Add support for SA8775p MHI endpoint device with IP_SW0 channel. - Fix the race between mhi_unprepare_from_transfer() and mhi_queue_buf(). * tag 'mhi-for-v6.15' of ssh://gitolite.kernel.org/pub/scm/linux/kernel/git/mani/mhi: bus: mhi: host: Fix race between unprepare and queue_buf bus: mhi: host: pci_generic: Add support for SA8775P endpoint bus: mhi: host: Remove unused functions
2 parents a425990 + 0686a81 commit 124bb4e

File tree

4 files changed

+44
-57
lines changed

4 files changed

+44
-57
lines changed

drivers/bus/mhi/host/main.c

Lines changed: 10 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1181,37 +1181,23 @@ int mhi_queue_skb(struct mhi_device *mhi_dev, enum dma_data_direction dir,
11811181
}
11821182
EXPORT_SYMBOL_GPL(mhi_queue_skb);
11831183

1184-
int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir,
1185-
struct mhi_buf *mhi_buf, size_t len, enum mhi_flags mflags)
1186-
{
1187-
struct mhi_chan *mhi_chan = (dir == DMA_TO_DEVICE) ? mhi_dev->ul_chan :
1188-
mhi_dev->dl_chan;
1189-
struct mhi_buf_info buf_info = { };
1190-
1191-
buf_info.p_addr = mhi_buf->dma_addr;
1192-
buf_info.cb_buf = mhi_buf;
1193-
buf_info.pre_mapped = true;
1194-
buf_info.len = len;
1195-
1196-
if (unlikely(mhi_chan->pre_alloc))
1197-
return -EINVAL;
1198-
1199-
return mhi_queue(mhi_dev, &buf_info, dir, mflags);
1200-
}
1201-
EXPORT_SYMBOL_GPL(mhi_queue_dma);
1202-
12031184
int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
12041185
struct mhi_buf_info *info, enum mhi_flags flags)
12051186
{
12061187
struct mhi_ring *buf_ring, *tre_ring;
12071188
struct mhi_ring_element *mhi_tre;
12081189
struct mhi_buf_info *buf_info;
12091190
int eot, eob, chain, bei;
1210-
int ret;
1191+
int ret = 0;
12111192

12121193
/* Protect accesses for reading and incrementing WP */
12131194
write_lock_bh(&mhi_chan->lock);
12141195

1196+
if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) {
1197+
ret = -ENODEV;
1198+
goto out;
1199+
}
1200+
12151201
buf_ring = &mhi_chan->buf_ring;
12161202
tre_ring = &mhi_chan->tre_ring;
12171203

@@ -1229,10 +1215,8 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
12291215

12301216
if (!info->pre_mapped) {
12311217
ret = mhi_cntrl->map_single(mhi_cntrl, buf_info);
1232-
if (ret) {
1233-
write_unlock_bh(&mhi_chan->lock);
1234-
return ret;
1235-
}
1218+
if (ret)
1219+
goto out;
12361220
}
12371221

12381222
eob = !!(flags & MHI_EOB);
@@ -1250,9 +1234,10 @@ int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan,
12501234
mhi_add_ring_element(mhi_cntrl, tre_ring);
12511235
mhi_add_ring_element(mhi_cntrl, buf_ring);
12521236

1237+
out:
12531238
write_unlock_bh(&mhi_chan->lock);
12541239

1255-
return 0;
1240+
return ret;
12561241
}
12571242

12581243
int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,

drivers/bus/mhi/host/pci_generic.c

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -297,6 +297,19 @@ static const struct mhi_pci_dev_info mhi_qcom_qdu100_info = {
297297
.sideband_wake = false,
298298
};
299299

300+
static const struct mhi_channel_config mhi_qcom_sa8775p_channels[] = {
301+
MHI_CHANNEL_CONFIG_UL(46, "IP_SW0", 2048, 1),
302+
MHI_CHANNEL_CONFIG_DL(47, "IP_SW0", 2048, 2),
303+
};
304+
305+
static struct mhi_event_config mhi_qcom_sa8775p_events[] = {
306+
/* first ring is control+data ring */
307+
MHI_EVENT_CONFIG_CTRL(0, 64),
308+
/* Software channels dedicated event ring */
309+
MHI_EVENT_CONFIG_SW_DATA(1, 64),
310+
MHI_EVENT_CONFIG_SW_DATA(2, 64),
311+
};
312+
300313
static const struct mhi_channel_config modem_qcom_v1_mhi_channels[] = {
301314
MHI_CHANNEL_CONFIG_UL(4, "DIAG", 16, 1),
302315
MHI_CHANNEL_CONFIG_DL(5, "DIAG", 16, 1),
@@ -327,6 +340,15 @@ static struct mhi_event_config modem_qcom_v1_mhi_events[] = {
327340
MHI_EVENT_CONFIG_HW_DATA(5, 2048, 101)
328341
};
329342

343+
static const struct mhi_controller_config mhi_qcom_sa8775p_config = {
344+
.max_channels = 128,
345+
.timeout_ms = 8000,
346+
.num_channels = ARRAY_SIZE(mhi_qcom_sa8775p_channels),
347+
.ch_cfg = mhi_qcom_sa8775p_channels,
348+
.num_events = ARRAY_SIZE(mhi_qcom_sa8775p_events),
349+
.event_cfg = mhi_qcom_sa8775p_events,
350+
};
351+
330352
static const struct mhi_controller_config modem_qcom_v2_mhiv_config = {
331353
.max_channels = 128,
332354
.timeout_ms = 8000,
@@ -346,6 +368,16 @@ static const struct mhi_controller_config modem_qcom_v1_mhiv_config = {
346368
.event_cfg = modem_qcom_v1_mhi_events,
347369
};
348370

371+
static const struct mhi_pci_dev_info mhi_qcom_sa8775p_info = {
372+
.name = "qcom-sa8775p",
373+
.edl_trigger = false,
374+
.config = &mhi_qcom_sa8775p_config,
375+
.bar_num = MHI_PCI_DEFAULT_BAR_NUM,
376+
.dma_data_width = 32,
377+
.mru_default = 32768,
378+
.sideband_wake = false,
379+
};
380+
349381
static const struct mhi_pci_dev_info mhi_qcom_sdx75_info = {
350382
.name = "qcom-sdx75m",
351383
.fw = "qcom/sdx75m/xbl.elf",
@@ -772,6 +804,8 @@ static const struct mhi_pci_dev_info mhi_netprisma_fcun69_info = {
772804

773805
/* Keep the list sorted based on the PID. New VID should be added as the last entry */
774806
static const struct pci_device_id mhi_pci_id_table[] = {
807+
{PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0116),
808+
.driver_data = (kernel_ulong_t) &mhi_qcom_sa8775p_info },
775809
{ PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0304),
776810
.driver_data = (kernel_ulong_t) &mhi_qcom_sdx24_info },
777811
{ PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x0306, PCI_VENDOR_ID_QCOM, 0x010c),

drivers/bus/mhi/host/pm.c

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1296,20 +1296,6 @@ int mhi_force_rddm_mode(struct mhi_controller *mhi_cntrl)
12961296
}
12971297
EXPORT_SYMBOL_GPL(mhi_force_rddm_mode);
12981298

1299-
void mhi_device_get(struct mhi_device *mhi_dev)
1300-
{
1301-
struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
1302-
1303-
mhi_dev->dev_wake++;
1304-
read_lock_bh(&mhi_cntrl->pm_lock);
1305-
if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state))
1306-
mhi_trigger_resume(mhi_cntrl);
1307-
1308-
mhi_cntrl->wake_get(mhi_cntrl, true);
1309-
read_unlock_bh(&mhi_cntrl->pm_lock);
1310-
}
1311-
EXPORT_SYMBOL_GPL(mhi_device_get);
1312-
13131299
int mhi_device_get_sync(struct mhi_device *mhi_dev)
13141300
{
13151301
struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;

include/linux/mhi.h

Lines changed: 0 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -720,12 +720,6 @@ enum mhi_state mhi_get_mhi_state(struct mhi_controller *mhi_cntrl);
720720
*/
721721
void mhi_soc_reset(struct mhi_controller *mhi_cntrl);
722722

723-
/**
724-
* mhi_device_get - Disable device low power mode
725-
* @mhi_dev: Device associated with the channel
726-
*/
727-
void mhi_device_get(struct mhi_device *mhi_dev);
728-
729723
/**
730724
* mhi_device_get_sync - Disable device low power mode. Synchronously
731725
* take the controller out of suspended state
@@ -776,18 +770,6 @@ int mhi_prepare_for_transfer_autoqueue(struct mhi_device *mhi_dev);
776770
*/
777771
void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev);
778772

779-
/**
780-
* mhi_queue_dma - Send or receive DMA mapped buffers from client device
781-
* over MHI channel
782-
* @mhi_dev: Device associated with the channels
783-
* @dir: DMA direction for the channel
784-
* @mhi_buf: Buffer for holding the DMA mapped data
785-
* @len: Buffer length
786-
* @mflags: MHI transfer flags used for the transfer
787-
*/
788-
int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir,
789-
struct mhi_buf *mhi_buf, size_t len, enum mhi_flags mflags);
790-
791773
/**
792774
* mhi_queue_buf - Send or receive raw buffers from client device over MHI
793775
* channel

0 commit comments

Comments
 (0)