Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp2054913ybv; Fri, 14 Feb 2020 10:34:11 -0800 (PST) X-Google-Smtp-Source: APXvYqzAaemvY/xJJZS7zwUGYIUyJTTdpjKbki4jjlDqkVjSW6OHd4JpJL95YMSEL3DoyzJsEzzA X-Received: by 2002:a9d:7:: with SMTP id 7mr3243586ota.26.1581705251706; Fri, 14 Feb 2020 10:34:11 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1581705251; cv=none; d=google.com; s=arc-20160816; b=xBJ4EBM8giQAgd81whWWybW8wA4Uqj5qAsxbHaj2uD9gCxFZ4w/zGqOz72RQxH9UM9 1viRCv9zGHVeXQCDUFuvcvPPdB7mJNF76zbbUjvnPu4c912z2V9Ew8YeEzflwlZSLNMd widcj3QVn+AN87UKb7NogjXj2QrARlQSiSp4mge7JjMKMq7C6vJ3rGCvw+vbwAb4uGz/ aXJ+ad8Z9YdkAgdM8SUnTbGjBSSChsHcM39WI81fpkIjt9dIkJfTPXfhHOKmi7mTcC36 6dH3F0BLycDit5D5t/pCCuMHXSydb8JBKs+wSnMjGWo/CQpl9uCNxqLWx5Eh/5d4czbg lgWQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding :content-language:in-reply-to:mime-version:user-agent:date :message-id:references:cc:to:subject:from; bh=g4JIqAZmiKVOtnv4mybFlnG5vZVADez4ioRONBkYdzM=; b=tZGHEgV9cKyxkyWngojvssiqT0Pk+gR8a2SIlesMvberwYNifwHGmDTR8vDI5+Bi2C 1GyYQjI41p+o8czxVjbIxjciLL5jpCc3h7NS98Ia9qL2yaoKssBZSHtsoJl0kCulnEkZ 2oYuD99YB35JPfsrAK28UmH43XyBFB6qfVUKz3r45rSej6EBIrrIRg9T0igVSXG7vJgq ImXE1ydVM85pmCaHHtTqU0Ykp2ihA3Ye3ugtUahD2EG2qL7AX3j+j9fcuJsig59TN4sD rZItKF+4GmVUlLr6X9TFMyEIHBmy8ARzVZ12ZbxyEEX/dKEDHrik/cIjZ8BkgWx4OOQa okog== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id u14si3491863otg.10.2020.02.14.10.33.59; Fri, 14 Feb 2020 10:34:11 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729747AbgBNSc5 (ORCPT + 99 others); Fri, 14 Feb 2020 13:32:57 -0500 Received: from foss.arm.com ([217.140.110.172]:43566 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729448AbgBNSc4 (ORCPT ); Fri, 14 Feb 2020 13:32:56 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.121.207.14]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id 380E5328; Fri, 14 Feb 2020 10:32:56 -0800 (PST) Received: from [10.1.196.105] (eglon.cambridge.arm.com [10.1.196.105]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id B6F033F68E; Fri, 14 Feb 2020 10:32:55 -0800 (PST) From: James Morse Subject: Re: [V2 1/3] firmware: arm_sdei: fix possible deadlock To: luanshi Cc: linux-arm-kernel@lists.infradead.org, linux-kernel@vger.kernel.org References: <1579145331-78633-1-git-send-email-zhangliguang@linux.alibaba.com> Message-ID: <2a86cb1b-f8e7-a106-68f2-42e7350a12d2@arm.com> Date: Fri, 14 Feb 2020 18:32:54 +0000 User-Agent: Mozilla/5.0 (X11; Linux aarch64; rv:60.0) Gecko/20100101 Thunderbird/60.9.0 MIME-Version: 1.0 In-Reply-To: <1579145331-78633-1-git-send-email-zhangliguang@linux.alibaba.com> Content-Type: text/plain; charset=utf-8 Content-Language: en-GB Content-Transfer-Encoding: 7bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Luanshi, On 16/01/2020 03:28, luanshi wrote: > We call sdei_reregister_event() with sdei_list_lock held but > _sdei_event_register() and sdei_event_destroy() also acquires > sdei_list_lock thus creating A-A deadlock. > > Fixes: da351827240e ("firmware: arm_sdei: Add support for CPU and system > power states") > (Nit: stray whitespace in the fixes tag, the backport tools may choke on this) (Please include 'PATCH' in the [] section of the subject when posting, its part of the 'canonical patch format', and my scripts for pulling a series of the list depend on it!) > --- Thanks for picking up my suggestion, ... it was what I think should have been done in the first place to avoid this bug. Looking at your patch, we'd need to take the per-event lock around the reads of reregister and reenable in sdei_cpuhp_up() too, and sdei_reregister_shared(), ... and this quickly becomes much noisier than a patch for stable should be. (Sorry, I should have tried it before suggesting it!) I've picked up your first version, but instead of duplicating the contents of the function, I've added '_llocked' wrappers to account for that lock already being held. This isn't great as we have _locked too, but lockdep should keep us honest. Because I started with your patch, git has kept you as author. This ended up as patch 2, because it was also necessary to move those reregister updates into their callers to fix hibernate. I'll posted what I have next week, sorry for the hiatus. Thanks, James