Received: by 2002:a05:6a10:6d10:0:0:0:0 with SMTP id gq16csp896186pxb; Fri, 22 Apr 2022 13:42:18 -0700 (PDT) X-Google-Smtp-Source: ABdhPJym+NWzGakXDYroRE+V618lx1EqP1KSiu69dOnXnF5rr2Q/Dp6BdjGonDttUIwbtH9eha/R X-Received: by 2002:a17:903:11c9:b0:154:be2d:eb9 with SMTP id q9-20020a17090311c900b00154be2d0eb9mr6387064plh.91.1650660138055; Fri, 22 Apr 2022 13:42:18 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1650660138; cv=none; d=google.com; s=arc-20160816; b=VxJr148fk9ZTM/xnLLP1VKwETPlYodvT7QY/Xjpj27Tt4kFYY7dKTJi/q2nCjhgiWy ZJhh4ZEklYFWcyPDKnYSrXGJAxzSJAhdLgUePtuEuZLvlvTHa0RPwVrMoz/SqflwR5pB q/4Vu5px0GfvX3cXV6idmzLoisztsTYhKZqDKSbM6dyNT4fGIltl6fQGp5QrBLpy50vb rrC5C9iui1dFYt0GgoZHbxJxUOIx3X2l0uGjAIWfiVefN7z7dG6R9sFE60+ZKYDVzhoa KZb/LufhwsYKeKRkInZof8zjl+R+BU1zZ1aApGhwvaRiWQwF+VeSxYgywtVDNhLdbwkT mPjA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=2BbdN1kr5sGoIGX1dtNP33lYM00rauT2fciX5GfBZWk=; b=cDsn02oFR6uNapisx4vjhgGXGa/hTQzW694iYCxvqoqc0Cjp+CLeFkCeKUIpCEIcrt DhtyHm3NsSNAutHgdN53WMPK9CF99Ofkj0R5PsGetHIVlYQM6jx9v5oBAE0JHVmOoU5T N0uxUNdUxA1fFx0mgvaKoktpFwqUSpwWjuPuD1KV4SA3iM3jpDpPrOZwrQIU9AtvDSQD ICUMeNpFdN5SIYAx8PzFdAEZVGnJwx6+sy7ESs0FTJqIMkC/muAt3F6Cd52K6QxwcV1y vuUASSRo2COVpxsM4zoxcZFgvu9GcsNRnsKdSHYMDO8K1cgJkQ6gNr34EVaJfx8ooAqt LIUA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qPaGt8W1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net. [2620:137:e000::1:18]) by mx.google.com with ESMTPS id oa14-20020a17090b1bce00b001d28b845edcsi9717399pjb.59.2022.04.22.13.42.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 22 Apr 2022 13:42:18 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) client-ip=2620:137:e000::1:18; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20210112 header.b=qPaGt8W1; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by lindbergh.monkeyblade.net (Postfix) with ESMTP id D6C9D2B97C9; Fri, 22 Apr 2022 12:28:22 -0700 (PDT) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1379325AbiDTOI4 (ORCPT + 99 others); Wed, 20 Apr 2022 10:08:56 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55116 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1379319AbiDTOIt (ORCPT ); Wed, 20 Apr 2022 10:08:49 -0400 Received: from mail-pj1-x1034.google.com (mail-pj1-x1034.google.com [IPv6:2607:f8b0:4864:20::1034]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 29F19433A9 for ; Wed, 20 Apr 2022 07:06:03 -0700 (PDT) Received: by mail-pj1-x1034.google.com with SMTP id s14-20020a17090a880e00b001caaf6d3dd1so5049077pjn.3 for ; Wed, 20 Apr 2022 07:06:03 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=2BbdN1kr5sGoIGX1dtNP33lYM00rauT2fciX5GfBZWk=; b=qPaGt8W1SqBUdOv9jbIxxS6ZyJAG8y3H45tHU2B/Rku9YW/MdoizmUnnz/k3hzJuFL PwKCyUmQuU00oINndtdwHZGGA9NeIIp4Ja7sCeCsbVIxJx/6vqgyB2Wm5sUvQsUWqYur 5XrzKb6MyXbu3tr/UpAj6JhAP06wKMWV63FSUCkG9AMYgMGPXfTHQ5PHuZqReyCIoQCa eqlk9W1RBcZV6naDaBUkwHO/hpuNEy2xvG02iPOa9acTWBJb1tned1CLlL2IYSmTyaej 2CPr3alR9H1u8xODMebyeOSV5SuwemSA5rHLqGmq1RboRqULztcVquB/DVby9RpXMCBU Vl+g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=2BbdN1kr5sGoIGX1dtNP33lYM00rauT2fciX5GfBZWk=; b=mGs3wqf1/TKQl5EC7hNRTj7GnsB8PfRrkko54boblKRZEZAYGkuFj3ia0Nf2dlr5N1 AUm+N4MAq2AGPaSBMt9xPpWD7eUWkKvdkCAfGML5v76PJzG0ktFCkvEzHeYTUAaENuhh I889ZZpi4V9d/E1K/pDY/Q0Ow9PtB9vFbPLnzAIkpuUzE1arPiSiS/tPfWocjKIsgHyU YTkKlemDnUyGya4WEU5rigFtT3DMO6g8kaCCSQkeKH5YlwLdunlvfw8VQULWCpa3cxGh LCf+jz0fT+2b1aw6sXJ8MRiu8O0sN8EASb4P56Neap9b6Mh3pbk4cV5cFgpvMOy2TQXq GHwg== X-Gm-Message-State: AOAM533pIHv3KxjOyLink1ii9JLEj0F8QOmfsAhnbo0xB0arJlRvZ7ot y1LEMA7IqNLxfDP33+sG9zlkjb3PfQ== X-Received: by 2002:a17:90b:350e:b0:1d2:b6e2:1000 with SMTP id ls14-20020a17090b350e00b001d2b6e21000mr4702893pjb.199.1650463562517; Wed, 20 Apr 2022 07:06:02 -0700 (PDT) Received: from piliu.users.ipa.redhat.com ([209.132.188.80]) by smtp.gmail.com with ESMTPSA id br10-20020a056a00440a00b0050a777cd10csm10959178pfb.91.2022.04.20.07.06.00 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 20 Apr 2022 07:06:02 -0700 (PDT) From: Pingfan Liu To: linux-kernel@vger.kernel.org Cc: Pingfan Liu , Thomas Gleixner , "Rafael J. Wysocki" Subject: [PATCH 6/9] pm/irq: make for_each_irq_desc() safe of irq_desc release Date: Wed, 20 Apr 2022 22:05:18 +0800 Message-Id: <20220420140521.45361-7-kernelfans@gmail.com> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20220420140521.45361-1-kernelfans@gmail.com> References: <20220420140521.45361-1-kernelfans@gmail.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Spam-Status: No, score=-1.7 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,MAILING_LIST_MULTI,RDNS_NONE, SPF_HELO_NONE autolearn=no 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 The invloved context is no a RCU read section. Furthermore there may be more than one task at this point. Hence it demands a measure to prevent irq_desc from freeing. Use irq_lock_sparse to serve the protection purpose. Signed-off-by: Pingfan Liu Cc: Thomas Gleixner Cc: "Rafael J. Wysocki" To: linux-kernel@vger.kernel.org --- kernel/irq/pm.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/kernel/irq/pm.c b/kernel/irq/pm.c index ca71123a6130..4b67a4c7de3c 100644 --- a/kernel/irq/pm.c +++ b/kernel/irq/pm.c @@ -133,6 +133,7 @@ void suspend_device_irqs(void) struct irq_desc *desc; int irq; + irq_lock_sparse(); for_each_irq_desc(irq, desc) { unsigned long flags; bool sync; @@ -146,6 +147,7 @@ void suspend_device_irqs(void) if (sync) synchronize_irq(irq); } + irq_unlock_sparse(); } EXPORT_SYMBOL_GPL(suspend_device_irqs); @@ -186,6 +188,7 @@ static void resume_irqs(bool want_early) struct irq_desc *desc; int irq; + /* The early resume stage is free of irq_desc release */ for_each_irq_desc(irq, desc) { unsigned long flags; bool is_early = desc->action && -- 2.31.1