From patchwork Fri Mar 5 17:02:23 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 393525 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp589059jai; Fri, 5 Mar 2021 08:54:56 -0800 (PST) X-Google-Smtp-Source: ABdhPJwDBOEWkynxGhaOXZ6t1WJNbo3AEI7uRltQQ5ZJxuvt1PB3xZ3Fv10wvs+ROO+EGum+jYrM X-Received: by 2002:a05:6402:350f:: with SMTP id b15mr9887002edd.6.1614963296685; Fri, 05 Mar 2021 08:54:56 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614963296; cv=none; d=google.com; s=arc-20160816; b=Zg02lTDGZVbBa2rA8oIhU48BLDiuwu5tuuCU//nOGzR6l6Fa/z4ZXQ2o8zhvGdrJGC UPsjBx87Sh8wj3V+MyKxBKtOI6y/H3QvOz5blrEpC+1qhCbAiDrJFaOlWEdzr8lNi+bp PkpnOIRmLPQopwFUgNrPay61z3aOlQXVdPnXuEM+wvQjNcLzH5yT1CfRDuX/pLhHQbHy OAJYTvFrchDErq9vChewtHdWmTTVtdLfDVrAMlHfipUUEdgdh6fyVTMgOrc+xmmldeAc GIWHd4rHGXcAv7R++gLtRSSHlDfQ+B3ijmIrWm6WvjjOLHyFeURMLrQG28r4cF1c9dXo 9vKQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:message-id:date:subject:cc:to:from :dkim-signature; bh=5J70pTkQkyyAAz/WqKWCkdjxdt7PeU6TvREyi5dArPk=; b=F6QBgrQu6VzaEWF3CI4cw5McnDfVUUEI5BxMfWUcyeDBPSVIArqhL/wyPaEF0WrRX5 QD/ECLF/hCtXnlc2q+lrNb63tZSGQOBNJiIdKaTK9XUdYx0QQEvgCSJreDpvLkGwvmzs 9mWOQla0DsCd1lGHZDUqdnpccXzYekf29bX6Htwng2SZ7F9ccXZpzi2HTJK8KfVjnwOy nSlM7+HjhDqyaEcnuJ+dyTylSUF6ksiNWuBmeXaW7ZdA+H8hv5O1Nn7peNBsO/AIaugP HmJ/V9SWFv+wgbmlO1JH/WaAnOLWHapWbgAAEQdc9/MBG9037jfh2EnWppGdfWkdi0lb ZUeQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wcNkpe9l; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co24si1725317edb.599.2021.03.05.08.54.55; Fri, 05 Mar 2021 08:54:56 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=wcNkpe9l; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229813AbhCEQyX (ORCPT + 16 others); Fri, 5 Mar 2021 11:54:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37170 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229719AbhCEQx7 (ORCPT ); Fri, 5 Mar 2021 11:53:59 -0500 Received: from mail-wm1-x329.google.com (mail-wm1-x329.google.com [IPv6:2a00:1450:4864:20::329]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B35B4C061574 for ; Fri, 5 Mar 2021 08:53:56 -0800 (PST) Received: by mail-wm1-x329.google.com with SMTP id u187so2034123wmg.4 for ; Fri, 05 Mar 2021 08:53:56 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id; bh=5J70pTkQkyyAAz/WqKWCkdjxdt7PeU6TvREyi5dArPk=; b=wcNkpe9lAi9L5cN2gVk2JDVZ+2XnDz+zQr4SFzDiWx+UoOjlvCPuwM0UDEL2sww61h qZC5xFxbUVgwxNDCEraUFwHt7A4FT1LAe4A8Nb1QsazBZPnGeiBjLWw6uEu8NI1P0x1c /rwP48bxUecfkn46AsP/FcGy7DJJkj0lTUvkiFCgcVmtFhEGvuvmIQf1naBy0POnPeFB CN4GITFggS3upUTriWUKQ+zOmzvzG8B2UhGbBR2b2IHBtCtYtkUrRWwK5SkwfnAPNjqy yOMxA6dmgER1WuCY7C6FSlWNCVfnjUvIr6n6YnuKZ87zCn2tnvSl0asLp73xWU1WEb8c 5dKg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=5J70pTkQkyyAAz/WqKWCkdjxdt7PeU6TvREyi5dArPk=; b=WeA3MXIHM3xCa1zjsQNRoYgjl+/TunGJ/MeE6YwQud8i3UeJ6AnvJ0rNI6iXYoZGsU ansNJoE79XgmBq5ntUUMSrcOrfC7EnkCkTSMGcxLPpxMXj1GA8kFcd6jkRUd6Xd/+5ox AT/izdzUBFWL0r5kvn4KgmAqZRLILg+9ZMSTQNqjnT89/rajNyCs3Ox7TAYagXCOt+Hd PdPSd2+a/Tu129ZHIxdF604IWlJmfL2nkuctOF58lLcph3CoF8Pbnz57I5Ri4YTyrHZQ Pc5h1phjDO0moogEQzdLfrzBxhkbdU3mV/aHWVD75l/tN+x5DV5SMrq7/+krnce/EwT8 k/2A== X-Gm-Message-State: AOAM533KDgGJvabKCC9oT+QkQtceP0J6srMi7Xm4WaLle8LF+Os2UrxI S0Lsyc4v+/JQYkGWSOcekFNqMw== X-Received: by 2002:a1c:4c10:: with SMTP id z16mr4824125wmf.136.1614963235022; Fri, 05 Mar 2021 08:53:55 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:82c:5f0:55da:a740:2edb:1c7e]) by smtp.gmail.com with ESMTPSA id c35sm4850414wmp.3.2021.03.05.08.53.54 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Mar 2021 08:53:54 -0800 (PST) From: Loic Poulain To: manivannan.sadhasivam@linaro.org, hemantk@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, Loic Poulain Subject: [PATCH 1/2] bus: mhi: core: Fix MHI runtime_pm behavior Date: Fri, 5 Mar 2021 18:02:23 +0100 Message-Id: <1614963744-25962-1-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org This change ensures that PM reference is always get during packet queueing and released either after queuing completion (RX) or once the buffer has been consumed (TX). This guarantees proper update for underlying MHI controller runtime status (e.g. last_busy timestamp) and prevents suspend to be triggered while TX packets are flying, or before we completed update of the RX ring. Signed-off-by: Loic Poulain --- drivers/bus/mhi/core/main.c | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) -- 2.7.4 diff --git a/drivers/bus/mhi/core/main.c b/drivers/bus/mhi/core/main.c index c780234..16b9640 100644 --- a/drivers/bus/mhi/core/main.c +++ b/drivers/bus/mhi/core/main.c @@ -584,8 +584,11 @@ static int parse_xfer_event(struct mhi_controller *mhi_cntrl, /* notify client */ mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); - if (mhi_chan->dir == DMA_TO_DEVICE) + if (mhi_chan->dir == DMA_TO_DEVICE) { atomic_dec(&mhi_cntrl->pending_pkts); + /* Release the reference got from mhi_queue() */ + mhi_cntrl->runtime_put(mhi_cntrl); + } /* * Recycle the buffer if buffer is pre-allocated, @@ -1021,9 +1024,11 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info, if (unlikely(ret)) goto exit_unlock; - /* trigger M3 exit if necessary */ - if (MHI_PM_IN_SUSPEND_STATE(mhi_cntrl->pm_state)) - mhi_trigger_resume(mhi_cntrl); + /* Packet is queued, take a usage ref to exit M3 if necessary + * for host->device buffer, balanced put is done on buffer completion + * for device->host buffer, balanced put is after ringing the DB + */ + mhi_cntrl->runtime_get(mhi_cntrl); /* Assert dev_wake (to exit/prevent M1/M2)*/ mhi_cntrl->wake_toggle(mhi_cntrl); @@ -1034,6 +1039,9 @@ static int mhi_queue(struct mhi_device *mhi_dev, struct mhi_buf_info *buf_info, if (likely(MHI_DB_ACCESS_VALID(mhi_cntrl))) mhi_ring_chan_db(mhi_cntrl, mhi_chan); + if (dir == DMA_FROM_DEVICE) + mhi_cntrl->runtime_put(mhi_cntrl); + exit_unlock: read_unlock_irqrestore(&mhi_cntrl->pm_lock, flags); @@ -1431,6 +1439,10 @@ static void mhi_reset_data_chan(struct mhi_controller *mhi_cntrl, result.buf_addr = buf_info->cb_buf; mhi_chan->xfer_cb(mhi_chan->mhi_dev, &result); } + + /* Release the reference got from mhi_queue() */ + if (mhi_chan->dir == DMA_TO_DEVICE) + mhi_cntrl->runtime_put(mhi_cntrl); } } From patchwork Fri Mar 5 17:02:24 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Loic Poulain X-Patchwork-Id: 393526 Delivered-To: patch@linaro.org Received: by 2002:a02:8562:0:0:0:0:0 with SMTP id g89csp589065jai; Fri, 5 Mar 2021 08:54:57 -0800 (PST) X-Google-Smtp-Source: ABdhPJxzLUuwmAmLMilbKbCbu5iG8MP0MNEEMnXpsyX3pmNsUkpi2OOvIr4Q5KX796YnvI8XCZtv X-Received: by 2002:a05:6402:b41:: with SMTP id bx1mr10043036edb.69.1614963297380; Fri, 05 Mar 2021 08:54:57 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1614963297; cv=none; d=google.com; s=arc-20160816; b=b14x5+KKz4xVRZZfKCwNzk7BLXgUs1V8PQ6RwYCORGcgCjdG6KWm8zkpH5GQlMneSW buOkMcj3gx3+NR4POnTRl8Uk/svy+yh7fADSLpm/V7AVOTHyHBB+WZj/FMsraESDfjWi O8Ub0kIxJE5uRoN3zxaXasUrrw6DZwNGoZ1p3F2TnUXAMJhvH9kOYvCqkJegmW3MtfEM UKQuVr0Eta1eC8l8QjTgIOaKQ7uKlOLmqDEVom5TW9bOKObb5NG8pSTSjIfkOE7Xm61M UGp+nj5fJptHcoCRtZVOCyu27HcKWWGnzEV56t4SvtCm/G9YTCI3UOLH9XiO9fkf2IsK PpPQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:references:in-reply-to:message-id:date:subject :cc:to:from:dkim-signature; bh=O4/mkTL6M9iIF5bbEVObqOvdJSPyd1/G7aJHXSgDKpw=; b=Xv2wVJnFa6n4dsDJGfk2ItvKA4fN3lSDhHNbg0ZEhZqv3VF8D8BNPcALp6DXxLLFOj YW6P8kzwrvCKK8G0sNpXSuGuPQwUffKIyA+l6dornlyxpfPsO0C4uB1VGqoaaveQHCYX 1YzqJEh1nkkDHFFJhgSoqk/v7eeQcJS2fkddFOzTCGfqzHPxuMEdvxbdTp7zL/JOasiH QCYgRbTmt/JGg/cdSezQx5sTCFRDislU4Gpl/uvSNISx3QfQ5m/nyfl4eoAUKbxUckcD piV9Mn4WPboRtmzoaANqnDYMGQl7WgW4m+XA/gBc73f+lngpYnyRmuOpEtaUS2YOej7e hImw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P6zc3Aqk; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id co24si1725317edb.599.2021.03.05.08.54.56; Fri, 05 Mar 2021 08:54:57 -0800 (PST) Received-SPF: pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=P6zc3Aqk; spf=pass (google.com: domain of linux-arm-msm-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-arm-msm-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229848AbhCEQyX (ORCPT + 16 others); Fri, 5 Mar 2021 11:54:23 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:37174 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229813AbhCEQx7 (ORCPT ); Fri, 5 Mar 2021 11:53:59 -0500 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1273AC061756 for ; Fri, 5 Mar 2021 08:53:58 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id d11so2818058wrj.7 for ; Fri, 05 Mar 2021 08:53:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=O4/mkTL6M9iIF5bbEVObqOvdJSPyd1/G7aJHXSgDKpw=; b=P6zc3Aqk8xXVDHk4SOmN0kixRtIq1PQqeb40LJzZjjPKp9p8kQkIuuyrX+R7VJj+qq JRhXNI2Zq3NLkluzxqWB6jygvesEqJV+wpIVP1a6TD2f0BoZDWsKkbmsP39GIWIafSt5 c9MJTkYukxlYiu2QSP6Ni9E91pflM2k15p2OauY5YgsBB84L3oMbvRHD98namkZ1svJS pAV9qDzIoAdj5rt6yq5bvUyJflX4+gIlhkYEY3AP6pmBbXptMe/t1/WRghxAMHZA7HHp xlf5cMBMkQzL0Fc41WrLD8vtbaBa3IvUQt7nXTZUjWMXnDDSHmncmVK2NaaXIG9+Hy9U gzxw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=O4/mkTL6M9iIF5bbEVObqOvdJSPyd1/G7aJHXSgDKpw=; b=Pt1dZe4CdcfOetUqlhZYpughnVR0yf5WsNIak66RoQwx3iiVgkz5zhheJlyW5GEhxn aa9Rydx2Y0sLl0NwHzy9lrQu0gHkxM6q7FOooXRZhKIzp8R2CqY/BahJ9pc3R6HsGOs5 aqt/p2s1eOfkpzTiMuFNKvL9TeAgYePYmt0WQL6n6psQi6idAagcIYTdPLQcDmP7yPuI wm75Dd+yZMAHjYTTHABjWZgzngFszx9NXrRXH9OLGXF9pGYJhKVWkETKPtHbx7M5RORv ktFA4gtdWgJ98lHUtWpsyjuX9CCK4dg4SEQQaUHQscw2XyLQ1l2rgWgfQ7OOmJsCxkXm h4/Q== X-Gm-Message-State: AOAM530EmYzAWA9IE44CE8m3H8XqZUjxZ/yUwDtJLNgIhdr3cuxbPSti 4ShU6xo3i/aCg6fQ/E9aTqxlYg== X-Received: by 2002:adf:d217:: with SMTP id j23mr10576262wrh.113.1614963236815; Fri, 05 Mar 2021 08:53:56 -0800 (PST) Received: from localhost.localdomain ([2a01:e0a:82c:5f0:55da:a740:2edb:1c7e]) by smtp.gmail.com with ESMTPSA id c35sm4850414wmp.3.2021.03.05.08.53.56 (version=TLS1_2 cipher=ECDHE-ECDSA-AES128-GCM-SHA256 bits=128/128); Fri, 05 Mar 2021 08:53:56 -0800 (PST) From: Loic Poulain To: manivannan.sadhasivam@linaro.org, hemantk@codeaurora.org Cc: linux-arm-msm@vger.kernel.org, Loic Poulain Subject: [PATCH 2/2] bus: mhi: pm: reduce PM state change verbosity Date: Fri, 5 Mar 2021 18:02:24 +0100 Message-Id: <1614963744-25962-2-git-send-email-loic.poulain@linaro.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1614963744-25962-1-git-send-email-loic.poulain@linaro.org> References: <1614963744-25962-1-git-send-email-loic.poulain@linaro.org> Precedence: bulk List-ID: X-Mailing-List: linux-arm-msm@vger.kernel.org Since M3 can be entered/exited quite a lot when used for runtime PM, keep the mhi suspend/resume transitions quiet. Signed-off-by: Loic Poulain --- drivers/bus/mhi/core/pm.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) -- 2.7.4 Reviewed-by: Bhaumik Bhatt diff --git a/drivers/bus/mhi/core/pm.c b/drivers/bus/mhi/core/pm.c index edd7794..0cd6445 100644 --- a/drivers/bus/mhi/core/pm.c +++ b/drivers/bus/mhi/core/pm.c @@ -858,7 +858,7 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl) return -EBUSY; } - dev_info(dev, "Allowing M3 transition\n"); + dev_dbg(dev, "Allowing M3 transition\n"); new_state = mhi_tryset_pm_state(mhi_cntrl, MHI_PM_M3_ENTER); if (new_state != MHI_PM_M3_ENTER) { write_unlock_irq(&mhi_cntrl->pm_lock); @@ -872,7 +872,7 @@ int mhi_pm_suspend(struct mhi_controller *mhi_cntrl) /* Set MHI to M3 and wait for completion */ mhi_set_mhi_state(mhi_cntrl, MHI_STATE_M3); write_unlock_irq(&mhi_cntrl->pm_lock); - dev_info(dev, "Wait for M3 completion\n"); + dev_dbg(dev, "Wait for M3 completion\n"); ret = wait_event_timeout(mhi_cntrl->state_event, mhi_cntrl->dev_state == MHI_STATE_M3 || @@ -906,7 +906,7 @@ int mhi_pm_resume(struct mhi_controller *mhi_cntrl) enum mhi_pm_state cur_state; int ret; - dev_info(dev, "Entered with PM state: %s, MHI state: %s\n", + dev_dbg(dev, "Entered with PM state: %s, MHI state: %s\n", to_mhi_pm_state_str(mhi_cntrl->pm_state), TO_MHI_STATE_STR(mhi_cntrl->dev_state));