Skip to content

Commit 85a087d

Browse files
Jeffrey Hugogregkh
authored andcommitted
bus: mhi: core: Remove link_status() callback
If the MHI core detects invalid data due to a PCI read, it calls into the controller via link_status() to double check that the link is infact down. All in all, this is pretty pointless, and racy. There are no good reasons for this, and only drawbacks. Its pointless because chances are, the controller is going to do the same thing to determine if the link is down - attempt a PCI access and compare the result. This does not make the link status decision any smarter. Its racy because its possible that the link was down at the time of the MHI core access, but then recovered before the controller access. In this case, the controller will indicate the link is not down, and the MHI core will precede to use a bad value as the MHI core does not attempt to retry the access. Retrying the access in the MHI core is a bad idea because again, it is racy - what if the link is down again? Furthermore, there may be some higher level state associated with the link status, that is now invalid because the link went down. The only reason why the MHI core could see "invalid" data when doing a PCI access, that is actually valid, is if the register actually contained the PCI spec defined sentinel for an invalid access. In this case, it is arguable that the MHI implementation broken, and should be fixed, not worked around. Therefore, remove the link_status() callback before anyone attempts to implement it. Signed-off-by: Jeffrey Hugo <[email protected]> Reviewed-by: Manivannan Sadhasivam <[email protected]> Reviewed-by: Hemant Kumar <[email protected]> Signed-off-by: Manivannan Sadhasivam <[email protected]> Link: https://lore.kernel.org/r/[email protected] Signed-off-by: Greg Kroah-Hartman <[email protected]>
1 parent ce31225 commit 85a087d

File tree

3 files changed

+4
-9
lines changed

3 files changed

+4
-9
lines changed

drivers/bus/mhi/core/init.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -812,10 +812,8 @@ int mhi_register_controller(struct mhi_controller *mhi_cntrl,
812812
if (!mhi_cntrl)
813813
return -EINVAL;
814814

815-
if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put)
816-
return -EINVAL;
817-
818-
if (!mhi_cntrl->status_cb || !mhi_cntrl->link_status)
815+
if (!mhi_cntrl->runtime_get || !mhi_cntrl->runtime_put ||
816+
!mhi_cntrl->status_cb)
819817
return -EINVAL;
820818

821819
ret = parse_config(mhi_cntrl, config);

drivers/bus/mhi/core/main.c

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,8 @@ int __must_check mhi_read_reg(struct mhi_controller *mhi_cntrl,
2020
{
2121
u32 tmp = readl(base + offset);
2222

23-
/* If there is any unexpected value, query the link status */
24-
if (PCI_INVALID_READ(tmp) &&
25-
mhi_cntrl->link_status(mhi_cntrl))
23+
/* If the value is invalid, the link is down */
24+
if (PCI_INVALID_READ(tmp))
2625
return -EIO;
2726

2827
*out = tmp;

include/linux/mhi.h

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -335,7 +335,6 @@ struct mhi_controller_config {
335335
* @syserr_worker: System error worker
336336
* @state_event: State change event
337337
* @status_cb: CB function to notify power states of the device (required)
338-
* @link_status: CB function to query link status of the device (required)
339338
* @wake_get: CB function to assert device wake (optional)
340339
* @wake_put: CB function to de-assert device wake (optional)
341340
* @wake_toggle: CB function to assert and de-assert device wake (optional)
@@ -417,7 +416,6 @@ struct mhi_controller {
417416

418417
void (*status_cb)(struct mhi_controller *mhi_cntrl,
419418
enum mhi_callback cb);
420-
int (*link_status)(struct mhi_controller *mhi_cntrl);
421419
void (*wake_get)(struct mhi_controller *mhi_cntrl, bool override);
422420
void (*wake_put)(struct mhi_controller *mhi_cntrl, bool override);
423421
void (*wake_toggle)(struct mhi_controller *mhi_cntrl);

0 commit comments

Comments
 (0)