Received: by 2002:a25:d7c1:0:0:0:0:0 with SMTP id o184csp3768442ybg; Mon, 28 Oct 2019 19:07:33 -0700 (PDT) X-Google-Smtp-Source: APXvYqwyv58g//DqmCjuE8bOcDf6MG5x71Ct+R1LZhPv/1/b0Kxt+3jV5fAKh0yZZLoIbXJfBWC/ X-Received: by 2002:a17:906:5807:: with SMTP id m7mr949404ejq.58.1572314853637; Mon, 28 Oct 2019 19:07:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1572314853; cv=none; d=google.com; s=arc-20160816; b=RveWf4Pu2gJoF+GkNKkgW1bsyqco4mOfZ4z8iUcsUgVYpHZelNj/d9br0F/CSNkwUt JzCsSC4z2Dc4BMG0NoojwBEax0pdWRv1HJvEg5s8qqL6E66g2oU6p8mb92KRZ32rITHr 8ItiLQQiJ/LNLLpgGvlZDNTHk7pDkvbDMsnvvWFIHxrLS31XWi/X1M5rOBSPT09fG9Qy EGWm4wg2KhpeO9pY8bLbxXlmZihPwZQHvBFsSPkHbk6mpf7YDTg/AKQ81cig4taOMiiT gw8H7gCKKPD/9j+Sb9NueLB1MpfPcdS2n1YsFjQvBZYu9fZ9ks8SdEIrObLLCMD4qaBH 5XrQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:message-id:date:subject:cc :to:from; bh=iWdvI3EMczEFNvHttf/HtP3wkiIZP/Z8Rvj0zcL0K4M=; b=qlZeKGXJCKuqsQ4N64YLc0q5J0rKa8yzv67y9GfDw4R1oNOO1T+CH7waLxz6O6yy+9 7Cf6vNEC9aT/gv0P1elB4Liu6DRC9k/44GEtoUSP5vXR1wsrYu8RljwTQxtxkPtIuRn1 YeQQ0ocePosIcGB3jRK1wv4yyfusUDW4w8HpM3YGobJWx4AvdV0+7P/j9SiUPEn8txhM rxYiuTyiiQ/cBLZiXmUhnJ9uabHVMoRri0ajtFoytSz70Wy3ZpMHX7YI5yODK/Oc6MaY yhLNVafLEhXUYLW50o5hcuQEv7AtbT0hGzDpySvopMLxEP3UwXvJzH6tA4WaW4EbNJlH bkAw== 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 s6si9426364edi.154.2019.10.28.19.07.10; Mon, 28 Oct 2019 19:07:33 -0700 (PDT) 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 S1728381AbfJ1N3x (ORCPT + 99 others); Mon, 28 Oct 2019 09:29:53 -0400 Received: from szxga07-in.huawei.com ([45.249.212.35]:60228 "EHLO huawei.com" rhost-flags-OK-OK-OK-FAIL) by vger.kernel.org with ESMTP id S1726691AbfJ1N3x (ORCPT ); Mon, 28 Oct 2019 09:29:53 -0400 Received: from DGGEMS408-HUB.china.huawei.com (unknown [172.30.72.60]) by Forcepoint Email with ESMTP id 3E0FFF9A41F616FE4F0C; Mon, 28 Oct 2019 21:29:49 +0800 (CST) Received: from HGHY4Z004218071.china.huawei.com (10.133.224.57) by DGGEMS408-HUB.china.huawei.com (10.3.19.208) with Microsoft SMTP Server id 14.3.439.0; Mon, 28 Oct 2019 21:29:41 +0800 From: Xiang Zheng To: CC: , , , , , , , , , , , Subject: [PATCH] pci: lock the pci_cfg_wait queue for the consistency of data Date: Mon, 28 Oct 2019 17:18:09 +0800 Message-ID: <20191028091809.35212-1-zhengxiang9@huawei.com> X-Mailer: git-send-email 2.15.1.windows.2 MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.133.224.57] X-CFilter-Loop: Reflected Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Commit "7ea7e98fd8d0" suggests that the "pci_lock" is sufficient, and all the callers of pci_wait_cfg() are wrapped with the "pci_lock". However, since the commit "cdcb33f98244" merged, the accesses to the pci_cfg_wait queue are not safe anymore. A "pci_lock" is insufficient and we need to hold an additional queue lock while read/write the wait queue. So let's use the add_wait_queue()/remove_wait_queue() instead of __add_wait_queue()/__remove_wait_queue(). Signed-off-by: Xiang Zheng Cc: Heyi Guo Cc: Biaoxiang Ye Cc: Xiongfeng Wang --- drivers/pci/access.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/pci/access.c b/drivers/pci/access.c index 2fccb5762c76..247bf36e0047 100644 --- a/drivers/pci/access.c +++ b/drivers/pci/access.c @@ -207,14 +207,14 @@ static noinline void pci_wait_cfg(struct pci_dev *dev) { DECLARE_WAITQUEUE(wait, current); - __add_wait_queue(&pci_cfg_wait, &wait); + add_wait_queue(&pci_cfg_wait, &wait); do { set_current_state(TASK_UNINTERRUPTIBLE); raw_spin_unlock_irq(&pci_lock); schedule(); raw_spin_lock_irq(&pci_lock); } while (dev->block_cfg_access); - __remove_wait_queue(&pci_cfg_wait, &wait); + remove_wait_queue(&pci_cfg_wait, &wait); } /* Returns 0 on success, negative values indicate error. */ -- 2.19.1