Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp1269219pxj; Wed, 19 May 2021 02:06:10 -0700 (PDT) X-Google-Smtp-Source: ABdhPJzXXtgum41x3UniqMLQTj2ySebJd2wlCfvuUASJwPHbhlhZNb+0OZWUSvdjyFnSvACUUsjl X-Received: by 2002:a05:6402:50d2:: with SMTP id h18mr13385690edb.10.1621415170272; Wed, 19 May 2021 02:06:10 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1621415170; cv=none; d=google.com; s=arc-20160816; b=brYexqVbGcqxXWOmoW0Gv4IUAxXzohaNQSzdf7k0AnZXsyC9pUpOMSqKpRsa5GDtEZ F/6jKJp5n2/xWReGixYykCcuDJtZSk+aBn6nUMxzHxaATgjNtDBZeX077YAcwEJqlouM yu+8UsO96/pFPKGe/DWX9zc2t8agTiSOjzKx2tAoeaOyH3urUY6S+ln4bBRdwsgSEB6O SlEqmFYKOauRJ4xEepXFYPNCGVCOmNyAmbkxcIHflcYjkxZu5kwXFmAGZqSnry+MMyx5 /S82d9ATYeMcw38midDvxmZ1TMR+b8k8OYcFOzpqStAB2r8e1BDzHnzdEb9QtlhATFy7 tV5Q== 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:dmarc-filter :sender:dkim-signature; bh=our1eT9PPR2xC+61fn+sydgDdNIFwrvlcoBFRV9/vMA=; b=lL1Ii1fHIKKBVMwI7YFf78EdpKc4vQME+Cm4HkZklLf1hXSxHAsHzwv3o5up4ZgpV3 qNoijG1GRsqM1dj+SEf+W6w3JOqI+QevziyigKh16LoWlB4ta617ZNjbcLIJGOW6BfCG eWluOToQzP7Dizv4bGzN6BbnlCeYmefv3Q9YI4+P4rg0FdgMKUSa5bS/SnrFMU10Mgw1 +Qb2ZzPb0dWtKXQYrqTN/P4lc499CLIWT4R/nvYWE62fjodf/ZkOO9l01Gfj10fT4PZB CN+EljNzMbaQIXqv/tas9JRjXc3AjU0UVqyFxbeM+8E4Smj1fZ0fJwID5VpidpigWyfi HwiA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@mg.codeaurora.org header.s=smtp header.b=TcuPP44i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id nd7si6288489ejc.747.2021.05.19.02.05.47; Wed, 19 May 2021 02:06:10 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-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=@mg.codeaurora.org header.s=smtp header.b=TcuPP44i; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1343498AbhEQXJl (ORCPT + 99 others); Mon, 17 May 2021 19:09:41 -0400 Received: from m43-7.mailgun.net ([69.72.43.7]:13831 "EHLO m43-7.mailgun.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233727AbhEQXJk (ORCPT ); Mon, 17 May 2021 19:09:40 -0400 DKIM-Signature: a=rsa-sha256; v=1; c=relaxed/relaxed; d=mg.codeaurora.org; q=dns/txt; s=smtp; t=1621292902; h=Message-Id: Date: Subject: Cc: To: From: Sender; bh=our1eT9PPR2xC+61fn+sydgDdNIFwrvlcoBFRV9/vMA=; b=TcuPP44i733GDjmK+ibDirYZy1wYjQi8hCqPKRx+Wg4Szry1DTzKCCX2bziAlIKs36lryRuc KLmVkVRGAow/st+fAte2GMcyZby0MHRjhTvVjTwkaESdTtdSligRdbp8ul7elWEsXsomr7lJ ZweDmjPspLcibzUIbodqjX518LI= X-Mailgun-Sending-Ip: 69.72.43.7 X-Mailgun-Sid: WyI0MWYwYSIsICJsaW51eC1rZXJuZWxAdmdlci5rZXJuZWwub3JnIiwgImJlOWU0YSJd Received: from smtp.codeaurora.org (ec2-35-166-182-171.us-west-2.compute.amazonaws.com [35.166.182.171]) by smtp-out-n04.prod.us-west-2.postgun.com with SMTP id 60a2f7667b9a7a2b6c3a7f60 (version=TLS1.2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256); Mon, 17 May 2021 23:08:22 GMT Sender: sidgup=codeaurora.org@mg.codeaurora.org Received: by smtp.codeaurora.org (Postfix, from userid 1001) id F2CA8C433F1; Mon, 17 May 2021 23:08:21 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-caf-mail-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-2.9 required=2.0 tests=ALL_TRUSTED,BAYES_00,SPF_FAIL, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.0 Received: from sidgup-linux.qualcomm.com (i-global254.qualcomm.com [199.106.103.254]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-SHA256 (128/128 bits)) (No client certificate requested) (Authenticated sender: sidgup) by smtp.codeaurora.org (Postfix) with ESMTPSA id 0BD19C433D3; Mon, 17 May 2021 23:08:20 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.3.2 smtp.codeaurora.org 0BD19C433D3 Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; dmarc=none (p=none dis=none) header.from=codeaurora.org Authentication-Results: aws-us-west-2-caf-mail-1.web.codeaurora.org; spf=fail smtp.mailfrom=sidgup@codeaurora.org From: Siddharth Gupta To: bjorn.andersson@linaro.org, ohad@wizery.com, linux-remoteproc@vger.kernel.org Cc: Siddharth Gupta , linux-kernel@vger.kernel.org, linux-arm-msm@vger.kernel.org, linux-arm-kernel@lists.infradead.org, psodagud@codeaurora.org Subject: [PATCH] remoteproc: core: Invoke subdev callbacks in list order Date: Mon, 17 May 2021 16:08:13 -0700 Message-Id: <1621292893-18827-1-git-send-email-sidgup@codeaurora.org> X-Mailer: git-send-email 2.7.4 Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Subdevices at the beginning of the subdev list should have higher priority than those at the end of the list. Reverse traversal of the list causes priority inversion, which can impact the performance of the device. For example a device adds the glink, sysmon and ssr subdevs to its list. During a crash the ssr notification would go before the glink and sysmon notifications. This can cause a degraded response when a client driver waits for a response from the crashed rproc. Signed-off-by: Siddharth Gupta --- drivers/remoteproc/remoteproc_core.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/drivers/remoteproc/remoteproc_core.c b/drivers/remoteproc/remoteproc_core.c index 626a6b90f..ac8fc42 100644 --- a/drivers/remoteproc/remoteproc_core.c +++ b/drivers/remoteproc/remoteproc_core.c @@ -1167,7 +1167,7 @@ static int rproc_handle_resources(struct rproc *rproc, static int rproc_prepare_subdevices(struct rproc *rproc) { - struct rproc_subdev *subdev; + struct rproc_subdev *subdev, *itr; int ret; list_for_each_entry(subdev, &rproc->subdevs, node) { @@ -1181,9 +1181,11 @@ static int rproc_prepare_subdevices(struct rproc *rproc) return 0; unroll_preparation: - list_for_each_entry_continue_reverse(subdev, &rproc->subdevs, node) { - if (subdev->unprepare) - subdev->unprepare(subdev); + list_for_each_entry(itr, &rproc->subdevs, node) { + if (itr == subdev) + break; + if (itr->unprepare) + itr->unprepare(subdev); } return ret; @@ -1191,7 +1193,7 @@ static int rproc_prepare_subdevices(struct rproc *rproc) static int rproc_start_subdevices(struct rproc *rproc) { - struct rproc_subdev *subdev; + struct rproc_subdev *subdev, *itr; int ret; list_for_each_entry(subdev, &rproc->subdevs, node) { @@ -1205,9 +1207,11 @@ static int rproc_start_subdevices(struct rproc *rproc) return 0; unroll_registration: - list_for_each_entry_continue_reverse(subdev, &rproc->subdevs, node) { - if (subdev->stop) - subdev->stop(subdev, true); + list_for_each_entry(itr, &rproc->subdevs, node) { + if (itr == subdev) + break; + if (itr->stop) + itr->stop(itr, true); } return ret; @@ -1217,7 +1221,7 @@ static void rproc_stop_subdevices(struct rproc *rproc, bool crashed) { struct rproc_subdev *subdev; - list_for_each_entry_reverse(subdev, &rproc->subdevs, node) { + list_for_each_entry(subdev, &rproc->subdevs, node) { if (subdev->stop) subdev->stop(subdev, crashed); } @@ -1227,7 +1231,7 @@ static void rproc_unprepare_subdevices(struct rproc *rproc) { struct rproc_subdev *subdev; - list_for_each_entry_reverse(subdev, &rproc->subdevs, node) { + list_for_each_entry(subdev, &rproc->subdevs, node) { if (subdev->unprepare) subdev->unprepare(subdev); } -- Qualcomm Innovation Center, Inc. is a member of the Code Aurora Forum, a Linux Foundation Collaborative Project