@@ -313,6 +313,8 @@ static ssize_t tegra_bpmp_channel_write(struct tegra_bpmp_channel *channel,
313313 return __tegra_bpmp_channel_write (channel , mrq , flags , data , size );
314314}
315315
316+ static int __maybe_unused tegra_bpmp_resume (struct device * dev );
317+
316318int tegra_bpmp_transfer_atomic (struct tegra_bpmp * bpmp ,
317319 struct tegra_bpmp_message * msg )
318320{
@@ -325,6 +327,14 @@ int tegra_bpmp_transfer_atomic(struct tegra_bpmp *bpmp,
325327 if (!tegra_bpmp_message_valid (msg ))
326328 return - EINVAL ;
327329
330+ if (bpmp -> suspended ) {
331+ /* Reset BPMP IPC channels during resume based on flags passed */
332+ if (msg -> flags & TEGRA_BPMP_MESSAGE_RESET )
333+ tegra_bpmp_resume (bpmp -> dev );
334+ else
335+ return - EAGAIN ;
336+ }
337+
328338 channel = bpmp -> tx_channel ;
329339
330340 spin_lock (& bpmp -> atomic_tx_lock );
@@ -364,6 +374,14 @@ int tegra_bpmp_transfer(struct tegra_bpmp *bpmp,
364374 if (!tegra_bpmp_message_valid (msg ))
365375 return - EINVAL ;
366376
377+ if (bpmp -> suspended ) {
378+ /* Reset BPMP IPC channels during resume based on flags passed */
379+ if (msg -> flags & TEGRA_BPMP_MESSAGE_RESET )
380+ tegra_bpmp_resume (bpmp -> dev );
381+ else
382+ return - EAGAIN ;
383+ }
384+
367385 channel = tegra_bpmp_write_threaded (bpmp , msg -> mrq , msg -> tx .data ,
368386 msg -> tx .size );
369387 if (IS_ERR (channel ))
@@ -796,17 +814,29 @@ static int tegra_bpmp_probe(struct platform_device *pdev)
796814 return err ;
797815}
798816
817+ static int __maybe_unused tegra_bpmp_suspend (struct device * dev )
818+ {
819+ struct tegra_bpmp * bpmp = dev_get_drvdata (dev );
820+
821+ bpmp -> suspended = true;
822+
823+ return 0 ;
824+ }
825+
799826static int __maybe_unused tegra_bpmp_resume (struct device * dev )
800827{
801828 struct tegra_bpmp * bpmp = dev_get_drvdata (dev );
802829
830+ bpmp -> suspended = false;
831+
803832 if (bpmp -> soc -> ops -> resume )
804833 return bpmp -> soc -> ops -> resume (bpmp );
805834 else
806835 return 0 ;
807836}
808837
809838static const struct dev_pm_ops tegra_bpmp_pm_ops = {
839+ .suspend_noirq = tegra_bpmp_suspend ,
810840 .resume_noirq = tegra_bpmp_resume ,
811841};
812842
0 commit comments