Received: by 2002:a05:6358:f14:b0:e5:3b68:ec04 with SMTP id b20csp2602372rwj; Mon, 19 Dec 2022 06:44:03 -0800 (PST) X-Google-Smtp-Source: AA0mqf4BiEFhoCYqcal4cDvAzk0WeQBX5PusTZz6VlgFCfEfoLNWAgP4Yiy3ntNTVVvH8k2PSfYA X-Received: by 2002:a17:902:a406:b0:18f:6412:cac7 with SMTP id p6-20020a170902a40600b0018f6412cac7mr33535722plq.31.1671461043559; Mon, 19 Dec 2022 06:44:03 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1671461043; cv=none; d=google.com; s=arc-20160816; b=ZdzIwTSqxcSruT0NsnnUwuGse6qUPJ3QLrp6pdLhIiyGFtA+ANG4YaTUpClrDToDFJ zOVRRwEpYqOa2CCE6fWOfTgEJi03rdPLCoMnAug6/usnpHw3QQk9buQEZIuY4bnWgJyZ W4HPgh0Q9L2WH3H0Y6ct2NCbxZZqQYnj0ILqodJ/cru40CUjlJ+qkXHyjmVivCLkd2Qe wfES5y6/fSFue1PpwKOpGaZ0EcWTE1nuFuT1To3+tBVHwGYuvplq/W/JRgsRc//Of913 kys/fl+gu+/OO0rh2Yh47lMeOuYcOw/x4i+x5w6PlC6/LUUxYxXmkB8gOMKJ872asvp+ 07dw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:in-reply-to:content-disposition:mime-version :references:message-id:subject:cc:to:from:date:dkim-signature; bh=4ml4OJSsnYdjz2on2dlIK+cF2l/IAgGUuzkZZxYV+MM=; b=NGRvRlmJWRHM63wUb2IV+j5K2h/L4w0kNbHdR74VchRQCyXCE1zCnwdNJCL1+5ti1e qcFatv/bO8DmlcLLxKHKiRhm/MkH3rus83p3dZKfjKnFg6wkCQrrBOZ+aGxAsbT/Ledb nYtatW2u/ZpQOfvx71mrEXaqlY7vq3pEGT+5HZ03kyp+Lw5lBs9LnVDUhjf7MY1d0YbX CeanxMGvNjVkCxCj2NmNVI8Ovstm6z+PEyY9fMKqUaBzK5S/PIXXfnbGeSUR6vIHprnN J242kFXxzW4ljDvKx197Lw9xdOSUA2yIBe1lWNhkPYX3PQxtVvaib8XKTYqwp64gu66t Rp9w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@kernel.org header.s=k20201202 header.b=kHe6ZJtx; 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=kernel.org Return-Path: Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id y13-20020a17090322cd00b0018685257c0csi12220000plg.121.2022.12.19.06.43.54; Mon, 19 Dec 2022 06:44:03 -0800 (PST) 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=@kernel.org header.s=k20201202 header.b=kHe6ZJtx; 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=kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231586AbiLSOfE (ORCPT + 71 others); Mon, 19 Dec 2022 09:35:04 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:39210 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232290AbiLSOex (ORCPT ); Mon, 19 Dec 2022 09:34:53 -0500 Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DD6CF21A for ; Mon, 19 Dec 2022 06:34:51 -0800 (PST) Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 79F1460FC6 for ; Mon, 19 Dec 2022 14:34:51 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id D02B0C433D2; Mon, 19 Dec 2022 14:34:50 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1671460490; bh=WvJqO+O9grYq3EdoFlvoFSVrzmjasbVzPIMXkFDko5s=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=kHe6ZJtxRtmtfLTJ5dVTtz4MVEHrFRTi560vMdS8UG+0T3/vmISvveOiFj0GChCdH /9lC+DhEhV2ckHUcx72Aw3/SO6eYtWQDU/h7NOdpmQsiNnl2+I6S0MckSSgSCG24M3 4c+wK/I20d+J9OFJNp5rlkH5SLEf/CGHhpnAI0V9GDPdxB0rN+hp2glAkfXn47vU/H Jznqxs2npEa/d0iFS+1LVNYblIj/UAQMY/lQhN/3M0eDo/YndakK3Na1UxH7WwoqqU 5tIlEdteMfRmlFm/j/NQzU/+US+Zj6F9joU/4FZMS4+xJn+g/r3edAWRXVUhfADZRh ECISyfxMnaIzQ== Received: from johan by xi.lan with local (Exim 4.94.2) (envelope-from ) id 1p7HEr-0000VP-MV; Mon, 19 Dec 2022 15:35:33 +0100 Date: Mon, 19 Dec 2022 15:35:33 +0100 From: Johan Hovold To: Mark-PK Tsai Cc: Marc Zyngier , Thomas Gleixner , Matthias Brugger , yj.chiang@mediatek.com, phil.chang@mediatek.com, linux-kernel@vger.kernel.org, linux-arm-kernel@lists.infradead.org, linux-mediatek@lists.infradead.org Subject: Re: [PATCH] irqdomain: Fix irqdomain->revmap race Message-ID: References: <20221219130620.21092-1-mark-pk.tsai@mediatek.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20221219130620.21092-1-mark-pk.tsai@mediatek.com> X-Spam-Status: No, score=-7.1 required=5.0 tests=BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,DKIM_VALID_AU,DKIM_VALID_EF,RCVD_IN_DNSWL_HI, SPF_HELO_NONE,SPF_PASS 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 On Mon, Dec 19, 2022 at 09:06:15PM +0800, Mark-PK Tsai wrote: > The irqdomain->revmap(_tree) of a shared irq can be race updated > as following, which result in an unexpected irq mapping: > > --------------------------------------------------------------- > (2 threads parse the same hwirq fwspec in the same time.) > > Thread A Thread B > irq_create_fwspec_mapping > irq_find_mapping Thread A: virq = 0, alloc a new irq_desc > irq_create_fwspec_mapping > irq_find_mapping Thread B: virq = 0, alloc a new irq_desc > irq_domain_alloc_irqs > irq_domain_insert_irq domain->revmap[hwirq] = irq_data(virq x) > irq_domain_alloc_irqs > irq_domain_insert_irq domain->revmap[hwirq] = irq_data(virq x + 1) > > virq = x virq = x + 1 > --------------------------------------------------------------- > > The virq x can't work because the revmap[hwirq] was > overridden by thread B. > > It seems both hierarchy and non-hierarchy irq domain have the same > problem because the code from irq_find_mapping to revmap update are > not protected by a same lock. > > Do you have any suggestion about how to fix it properly? This is being fixed here: https://lore.kernel.org/lkml/20221209140150.1453-1-johan+linaro@kernel.org/ Johan