From patchwork Wed May 17 03:30:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Clark Wang X-Patchwork-Id: 95030 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp856666vqo; Tue, 16 May 2023 20:48:47 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5IwzzS8QqSmt/QvZK9+kGUoNmpqsBX+DRnznv0ORlPbLTgGAbJ6/ZUT2m66z448Xh9ZvgL X-Received: by 2002:a05:6a00:150a:b0:643:98cb:ec1 with SMTP id q10-20020a056a00150a00b0064398cb0ec1mr56177861pfu.0.1684295326713; Tue, 16 May 2023 20:48:46 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1684295326; cv=pass; d=google.com; s=arc-20160816; b=wk8/xO6NLJc8VD8q74N9KiVvIs6LX5Aa2otjMUD6qQwFWAwLeDOM4BU2lyh3EzHh63 z+WrSfVCY1+fQF56XzChKDyvAEERm3C1wxsSc6bc+rrChttsOclFKv+sto1/JrTq5Zvt aJHRP0O9WSlDuPeOpOnD7hCDaP4QEdCvx1EM4IXKuAMW+K/ltjrSC2o1PWLSVhs0wNMT JpzFLkO0SlUorBNomo75wViObeVjbakrUUpfQ4NOVBGSMm1RYWHWzfAes291Y3+htAOj 71YAmBQdPp1GcOZNHN5zC/AwxYYUCNE/P8aRE07PcZPbAUIGzsBd9ttz8TtjYOaEXxLI Y2sQ== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:mime-version:content-transfer-encoding :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=k6UDB8E2n8bAgUVWPGnvbn8rYYpS/HEFe4VvdYFX4QQ=; b=kOUtlIWqteeoE9sN1BEbCYdjbhlak3DIZxodXOCU7qfBB5sBiIDoszD40DoQdVBuAq Wbx2amAn6dqAmdeXk5TeIqWzsbSFBGkRQZR6XSYdjto22dgZyxZzw60tyRWlS0UiP98o PnrvzjwPadJw9Rt+7G+O7AuM5vUmBM2atxzq+0GESMdWfrw8QxUpSbmtol0oyq3DjcuS +0Ou+pTEFeGqNz7U7rBiOJ6wP7KSlYocro2tEISJyQ2JgrKYkfDoVuH6G8DLbMzDywoa cEGs12Z2P8r6SG+gprlx0yQskee+E0mSFEXsA11uyrPqbI1437s6FRoi8lgAxAbuySqr O+Zg== ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=fJ1OZ4t+; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id n5-20020aa79845000000b0064391b0ea2csi20793125pfq.403.2023.05.16.20.48.32; Tue, 16 May 2023 20:48:46 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@nxp.com header.s=selector2 header.b=fJ1OZ4t+; arc=pass (i=1 spf=pass spfdomain=nxp.com dkim=pass dkdomain=nxp.com dmarc=pass fromdomain=nxp.com); spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=nxp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232457AbjEQDa1 (ORCPT + 99 others); Tue, 16 May 2023 23:30:27 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57316 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231485AbjEQDaV (ORCPT ); Tue, 16 May 2023 23:30:21 -0400 Received: from EUR02-VI1-obe.outbound.protection.outlook.com (mail-vi1eur02on2076.outbound.protection.outlook.com [40.107.241.76]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A5418118 for ; Tue, 16 May 2023 20:30:20 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=BqYGUiohrjo4MuYlZLw1JWkgvZ6XpNHFDxj4Ury70rJiOxKaUL4Y8D5CziwhJmIexwWbmXy/g0vOZXYsk+bIJnrVRHr0iMh2aO8HNa0n1gjMWbSfPRNndAxRGojVOXNYiXLSwgE82sCUZfzFYniJ6j9Gv6wUv0ZajVwcqJK051Eay9eej7XjsRA6PNEcLSoVwuLszjjjEE64B90oZEfxCb1nmrVWJoQ6ZqJS/5W3pn9p9WCnsKMVnUbHxf8TR7a1EmGFdyeRZz/CWtL2tvA4fv1/iCByUYs25Ovt9bqeh1NmtIK5lJXctP84Qf6a6NFMIgCV0EfuZvd6Sos1EGaWsw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=k6UDB8E2n8bAgUVWPGnvbn8rYYpS/HEFe4VvdYFX4QQ=; b=Lqx+IB/iVcIMQ6vWjqKqMTNECWIEuYntv/iTSM1DqDywfXLXpOBCROvrZ6Wkp1YafBo8g1lxb/FoMwqygSYmDhZmk4poTTbrq0xuYIw7IJdIjRJBtieCQ2zA77EQWmFDAnN11uB/xSaqGhzH6ha+5iZsNoheaPv4twbfoJpm7ADur6xS918jJ8cVAphZt3hJi4zkfhmn7OZRaDySXAp8aMuT7puNXL9aR+3/Am1+hQGOnGVVmk8IIkY6wbm0vIleKYtvCn+Yq41VLvrqF+z2KEDWqS2dj9y/pZFG9hIlvIsQ5IhWe2Om8aoOCYSP4cBVl82yOOz01a3zpNmXR6sTRA== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nxp.com; dmarc=pass action=none header.from=nxp.com; dkim=pass header.d=nxp.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=nxp.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=k6UDB8E2n8bAgUVWPGnvbn8rYYpS/HEFe4VvdYFX4QQ=; b=fJ1OZ4t+hKBH7HaQH5rLYgceoQjAXWf+PxJ0tBPfaI542EyV3o4k+ECAf679n5yvG4fvJYwuWTpprCPuBxl+5lb6Q+hV+gxoU0ElmZQsG10GvMGoECn/wOzcg/YRiXbFAtt+QreCpfxG6OpZ1wCPrAVdDjOZdpW3drjWjMcfWfI= Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nxp.com; Received: from AM0PR04MB5089.eurprd04.prod.outlook.com (2603:10a6:208:c6::21) by AS4PR04MB9243.eurprd04.prod.outlook.com (2603:10a6:20b:4e2::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.6387.33; Wed, 17 May 2023 03:30:18 +0000 Received: from AM0PR04MB5089.eurprd04.prod.outlook.com ([fe80::da0c:329a:5bbf:71dd]) by AM0PR04MB5089.eurprd04.prod.outlook.com ([fe80::da0c:329a:5bbf:71dd%4]) with mapi id 15.20.6387.032; Wed, 17 May 2023 03:30:18 +0000 From: Clark Wang To: miquel.raynal@bootlin.com, conor.culhane@silvaco.com, alexandre.belloni@bootlin.com Cc: linux-i3c@lists.infradead.org, linux-kernel@vger.kernel.org Subject: [PATCH] i3c: master: svc: fix cpu schedule in spin lock Date: Wed, 17 May 2023 11:30:29 +0800 Message-Id: <20230517033030.3068085-2-xiaoning.wang@nxp.com> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20230517033030.3068085-1-xiaoning.wang@nxp.com> References: <20230517033030.3068085-1-xiaoning.wang@nxp.com> X-ClientProxiedBy: SI2PR02CA0050.apcprd02.prod.outlook.com (2603:1096:4:196::11) To AM0PR04MB5089.eurprd04.prod.outlook.com (2603:10a6:208:c6::21) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-TrafficTypeDiagnostic: AM0PR04MB5089:EE_|AS4PR04MB9243:EE_ X-MS-Office365-Filtering-Correlation-Id: 4f798c88-08a7-48c0-6581-08db56870999 X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 2gAx4Og7fbZ0B341wksdrzU/LvlUI4VmxsevfZWCMgixkqHe65pZsy24GnaNP2C72TkQG8PYQ3IsR49tJy+l2IXP8ZoMOZRJJFmwDCugAtyiUNdRuKd3ZoksI02z1G1iD/Pyz8kMVMsLY55rcIOJzOALB5MrI3iNXrzFti9L/00y69zr6vIbswReKAh+8URm3uxBKDbX2B1xF5AZ7X0siqD/IT+WuC/qM4dRxzvjCUZAgMFwOOwZmjHIOxXob+HBaxH0YHqmFzqIB+CdSHmBKyx60OjvB/+EhfhhaQ1uvEHWhiaAOjvka3JByhOhJ/yOSZSY54zB9AUxDG+Boo0kKpp5WmldL9vI3iPggiqQtqPN1Zkii/7xVTHRQZjKDUPIPNRSVLE9uzkBqFiLELvBeqrLoWaZ3uMxDqZr5pm65Y1X/VHaHYMq5er9cBMuZoZu7NSiPggbAKMNqbqTTToAjdMBHU7uNxxOApmtUdIY1RlXAn8usHEHfctpWuULL1Yybq622ZTpzmcOwkDid7xXOhFzkoYM2M7ANfUKFKqQQVXVOerY8qNPKorEOMMmTHsT6zHoVuunKs2/BG9llq9QfNhC84yrVD2xMtGGjI2olGDgY52rUBSgsNJJ3QDiwWaT X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:AM0PR04MB5089.eurprd04.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230028)(4636009)(136003)(376002)(346002)(366004)(39860400002)(396003)(451199021)(6512007)(66476007)(66556008)(4326008)(66946007)(478600001)(316002)(52116002)(6486002)(2906002)(6666004)(8936002)(8676002)(5660300002)(26005)(1076003)(41300700001)(86362001)(36756003)(38100700002)(38350700002)(83380400001)(2616005)(186003)(6506007);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: /3e1X6twGA+D8WWJ6D4bWqc6SwFR/NgNtk5uoGI04F1RPE5RdgWgS5G7Cq9gBEhQU6rrwj5b46fZyUlwdPf6NlqKQcVxA7VvU7urSxI6g7vlMVYRjNSiiWowGg84qAFpB+che/nS/SmdtQeSAlMJQSELBwNzeIBikl1Vz5Q5uic1S0Qfvb6Fi36RdN1CHgOOVEd7ilPc2wI1wWXj9VardJHYcsKhPjoHjyvXQ8SoDmQgfSJJqYEYGsJAqhJMwFdjAo3VRqUF9WY2YB/DuUCj7z9lIy4jbGSKiO2+8qi7GnQ5uNFxqbQeNd6MOyFq4J0TPCrxATbNw3CpBgvUJ4LQZMqSNY4pFm8Yx4q9yhczU4d74JGKZlifAwfoAYDwlaoBv/RFL6dy2Oz2Ai7eBhO3QbbKafwJywb8ffZSfRS2RJ/6tQCXRybFiOixHyMop03+o4c9BfvOKb1ok/bRdec5wScgpRNndl8WLngB4Lw7JVN2eeMIDXs0tppMCUt9X8MIlAhsEYAHMs4FOjA6+TdvJrR2nPwPLKK6lmeGyfjujXIfbygeqNr4BF3IqB1FqeuxXPKzEnApLojM2NR3PpnsRItGuo/z7i03JPKdnS0PrR2QDH4yhmxVrGs0ksTx2rKKEIR+yHcMnwwFMgpFWHt1UPJ9VAbbLd1VVqKE+d7fszCOnYLpvNre8R1Y0LQFzBiBL/nutVN8nkxbMLyXAacSN/vt6QGSuZ1Uy4rTaze8SNwfjqYE5e4n+f5MaXMS58q3N4iEgstPxShdwQz0oLaxf95c78AjJxL4hI/9UilL5oRY/waLQ4HM0U0S77416+RGbPYuzRRyr0gWwi8MBRQySt41fkvdcqzco7cgWk+2xsB5Nch4sJT5D/KddYB/mtJVYtq3E/Ohh4GGCPyMwPeLZxtv52VcIMXY79C+xfJ7iYB364GbDpk87/nhzBW9eIIos3wjoOQGsV1jwktnbX5IuojHrLW1qN9HXLiNXE/+MSVndyhTcqpm6O0ciOO6tM9hWNiJNfTtiQ33qbaWG7vePdddhgOK96e/A8Ss2rGZVyaaGnERSj1Mnx041Gd3K//TKCv2vW3Bbn3oBivpgScjicag81DQuOD0bdlK8f75txNlUdW3ebjqHGJpQLuI1wmOulhLzqq9d8Gy8iv9/5QN882yagM67Qdwik8uAo3QCkOKaEdEK7lVmOY7O8OuIGGgudGo1Ij/C2FiHdkf2Lr3Td7/F4yrOvgkpZnubcKnpVzlT6aiQB+e1M1+wpwBMbtmHwaC5oOXYZ5TBRe6x+5FWYqgbrfTJ+Tgw7BUpxBbCpZUnnUbEMpYVHpVay0vdNaVCkYDjEje1OcPKhp4XTtWaS92d9ZXMJipmlW9YT2WyFmt4NebVVXs/3Mucq/pfnToqxETygIkDacZUjzsc8T7l+/9WnDm5g0u+RFpmv/5vVi7Qs0UyltaF1MCuU1uPev9cCWSxEO8Cak/Zl/yjJrl5G3AF6WbLrB2yKx6Z05YWrpf92LFbc6M4S7hClqBrVFX6De5GESwvUJykRf9MQ4hqSVgOMpcQXOZ+vZ9/VUwvKApez6IK044c6HOo6ySVdqT X-OriginatorOrg: nxp.com X-MS-Exchange-CrossTenant-Network-Message-Id: 4f798c88-08a7-48c0-6581-08db56870999 X-MS-Exchange-CrossTenant-AuthSource: AM0PR04MB5089.eurprd04.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 17 May 2023 03:30:18.6654 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 686ea1d3-bc2b-4c6f-a92c-d99c5c301635 X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 0HkL9oSnBKyOjYJX6d5s/UuLbVMDzBhzU537XSdYq/CbexFwsB6epwm6wdjA4UvI7d3DmxBnBuq8R0ZPjhPmTA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: AS4PR04MB9243 X-Spam-Status: No, score=-2.1 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H2,SPF_HELO_PASS,SPF_PASS,T_SCC_BODY_TEXT_LINE, URIBL_BLOCKED autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766111656484042183?= X-GMAIL-MSGID: =?utf-8?q?1766111656484042183?= pm_runtime_resume_and_get() may call sleep(). It cannot be used in svc_i3c_master_start_xfer_locked(), because it is in a spin lock. Move the pm runtime operations to svc_i3c_master_enqueue_xfer(). Signed-off-by: Clark Wang Fixes: 05be23ef78f7 ("i3c: master: svc: add runtime pm support") Reviewed-by: Miquel Raynal --- drivers/i3c/master/svc-i3c-master.c | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/drivers/i3c/master/svc-i3c-master.c b/drivers/i3c/master/svc-i3c-master.c index bca3a4352ad1..4edf33ed207d 100644 --- a/drivers/i3c/master/svc-i3c-master.c +++ b/drivers/i3c/master/svc-i3c-master.c @@ -1096,12 +1096,6 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) if (!xfer) return; - ret = pm_runtime_resume_and_get(master->dev); - if (ret < 0) { - dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__); - return; - } - svc_i3c_master_clear_merrwarn(master); svc_i3c_master_flush_fifo(master); @@ -1116,9 +1110,6 @@ static void svc_i3c_master_start_xfer_locked(struct svc_i3c_master *master) break; } - pm_runtime_mark_last_busy(master->dev); - pm_runtime_put_autosuspend(master->dev); - xfer->ret = ret; complete(&xfer->comp); @@ -1139,6 +1130,13 @@ static void svc_i3c_master_enqueue_xfer(struct svc_i3c_master *master, struct svc_i3c_xfer *xfer) { unsigned long flags; + int ret; + + ret = pm_runtime_resume_and_get(master->dev); + if (ret < 0) { + dev_err(master->dev, "<%s> Cannot get runtime PM.\n", __func__); + return; + } init_completion(&xfer->comp); spin_lock_irqsave(&master->xferqueue.lock, flags); @@ -1149,6 +1147,9 @@ static void svc_i3c_master_enqueue_xfer(struct svc_i3c_master *master, svc_i3c_master_start_xfer_locked(master); } spin_unlock_irqrestore(&master->xferqueue.lock, flags); + + pm_runtime_mark_last_busy(master->dev); + pm_runtime_put_autosuspend(master->dev); } static bool