Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

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

+44 -57
+10 -25
drivers/bus/mhi/host/main.c
··· 1181 1181 } 1182 1182 EXPORT_SYMBOL_GPL(mhi_queue_skb); 1183 1183 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 - 1203 1184 int mhi_gen_tre(struct mhi_controller *mhi_cntrl, struct mhi_chan *mhi_chan, 1204 1185 struct mhi_buf_info *info, enum mhi_flags flags) 1205 1186 { ··· 1188 1207 struct mhi_ring_element *mhi_tre; 1189 1208 struct mhi_buf_info *buf_info; 1190 1209 int eot, eob, chain, bei; 1191 - int ret; 1210 + int ret = 0; 1192 1211 1193 1212 /* Protect accesses for reading and incrementing WP */ 1194 1213 write_lock_bh(&mhi_chan->lock); 1214 + 1215 + if (mhi_chan->ch_state != MHI_CH_STATE_ENABLED) { 1216 + ret = -ENODEV; 1217 + goto out; 1218 + } 1195 1219 1196 1220 buf_ring = &mhi_chan->buf_ring; 1197 1221 tre_ring = &mhi_chan->tre_ring; ··· 1215 1229 1216 1230 if (!info->pre_mapped) { 1217 1231 ret = mhi_cntrl->map_single(mhi_cntrl, buf_info); 1218 - if (ret) { 1219 - write_unlock_bh(&mhi_chan->lock); 1220 - return ret; 1221 - } 1232 + if (ret) 1233 + goto out; 1222 1234 } 1223 1235 1224 1236 eob = !!(flags & MHI_EOB); ··· 1234 1250 mhi_add_ring_element(mhi_cntrl, tre_ring); 1235 1251 mhi_add_ring_element(mhi_cntrl, buf_ring); 1236 1252 1253 + out: 1237 1254 write_unlock_bh(&mhi_chan->lock); 1238 1255 1239 - return 0; 1256 + return ret; 1240 1257 } 1241 1258 1242 1259 int mhi_queue_buf(struct mhi_device *mhi_dev, enum dma_data_direction dir,
+34
drivers/bus/mhi/host/pci_generic.c
··· 297 297 .sideband_wake = false, 298 298 }; 299 299 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 + 300 313 static const struct mhi_channel_config modem_qcom_v1_mhi_channels[] = { 301 314 MHI_CHANNEL_CONFIG_UL(4, "DIAG", 16, 1), 302 315 MHI_CHANNEL_CONFIG_DL(5, "DIAG", 16, 1), ··· 340 327 MHI_EVENT_CONFIG_HW_DATA(5, 2048, 101) 341 328 }; 342 329 330 + static const struct mhi_controller_config mhi_qcom_sa8775p_config = { 331 + .max_channels = 128, 332 + .timeout_ms = 8000, 333 + .num_channels = ARRAY_SIZE(mhi_qcom_sa8775p_channels), 334 + .ch_cfg = mhi_qcom_sa8775p_channels, 335 + .num_events = ARRAY_SIZE(mhi_qcom_sa8775p_events), 336 + .event_cfg = mhi_qcom_sa8775p_events, 337 + }; 338 + 343 339 static const struct mhi_controller_config modem_qcom_v2_mhiv_config = { 344 340 .max_channels = 128, 345 341 .timeout_ms = 8000, ··· 366 344 .ch_cfg = modem_qcom_v1_mhi_channels, 367 345 .num_events = ARRAY_SIZE(modem_qcom_v1_mhi_events), 368 346 .event_cfg = modem_qcom_v1_mhi_events, 347 + }; 348 + 349 + static const struct mhi_pci_dev_info mhi_qcom_sa8775p_info = { 350 + .name = "qcom-sa8775p", 351 + .edl_trigger = false, 352 + .config = &mhi_qcom_sa8775p_config, 353 + .bar_num = MHI_PCI_DEFAULT_BAR_NUM, 354 + .dma_data_width = 32, 355 + .mru_default = 32768, 356 + .sideband_wake = false, 369 357 }; 370 358 371 359 static const struct mhi_pci_dev_info mhi_qcom_sdx75_info = { ··· 804 772 805 773 /* Keep the list sorted based on the PID. New VID should be added as the last entry */ 806 774 static const struct pci_device_id mhi_pci_id_table[] = { 775 + {PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0116), 776 + .driver_data = (kernel_ulong_t) &mhi_qcom_sa8775p_info }, 807 777 { PCI_DEVICE(PCI_VENDOR_ID_QCOM, 0x0304), 808 778 .driver_data = (kernel_ulong_t) &mhi_qcom_sdx24_info }, 809 779 { PCI_DEVICE_SUB(PCI_VENDOR_ID_QCOM, 0x0306, PCI_VENDOR_ID_QCOM, 0x010c),
-14
drivers/bus/mhi/host/pm.c
··· 1296 1296 } 1297 1297 EXPORT_SYMBOL_GPL(mhi_force_rddm_mode); 1298 1298 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 - 1313 1299 int mhi_device_get_sync(struct mhi_device *mhi_dev) 1314 1300 { 1315 1301 struct mhi_controller *mhi_cntrl = mhi_dev->mhi_cntrl;
-18
include/linux/mhi.h
··· 721 721 void mhi_soc_reset(struct mhi_controller *mhi_cntrl); 722 722 723 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 - 729 - /** 730 724 * mhi_device_get_sync - Disable device low power mode. Synchronously 731 725 * take the controller out of suspended state 732 726 * @mhi_dev: Device associated with the channel ··· 769 775 * @mhi_dev: Device associated with the channels 770 776 */ 771 777 void mhi_unprepare_from_transfer(struct mhi_device *mhi_dev); 772 - 773 - /** 774 - * mhi_queue_dma - Send or receive DMA mapped buffers from client device 775 - * over MHI channel 776 - * @mhi_dev: Device associated with the channels 777 - * @dir: DMA direction for the channel 778 - * @mhi_buf: Buffer for holding the DMA mapped data 779 - * @len: Buffer length 780 - * @mflags: MHI transfer flags used for the transfer 781 - */ 782 - int mhi_queue_dma(struct mhi_device *mhi_dev, enum dma_data_direction dir, 783 - struct mhi_buf *mhi_buf, size_t len, enum mhi_flags mflags); 784 778 785 779 /** 786 780 * mhi_queue_buf - Send or receive raw buffers from client device over MHI