Received: by 2002:a25:b794:0:0:0:0:0 with SMTP id n20csp4862576ybh; Tue, 6 Aug 2019 19:47:06 -0700 (PDT) X-Google-Smtp-Source: APXvYqw7hsR8osq4Baacp0vfnUsAztm1NqH1722xZCEM8PhGl3V6CAP4obu8q9pnvv6l++UlfOZR X-Received: by 2002:a17:902:f204:: with SMTP id gn4mr6141190plb.3.1565146026242; Tue, 06 Aug 2019 19:47:06 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565146026; cv=none; d=google.com; s=arc-20160816; b=hawjDygO428nGf5ODnnC5SK/gD39wwkE3FtJrjLssm64HbP5UYiXem8aFWCo1ZiynQ 7udB9aj/b86p+G2rpuzanL8sV7l6+NVUip7spKwuE1/Ae0Qh17ndjg/IrZZOkTx9mONi cCxz4OlXN88YkxLF6sj4vksTEWRTSbHRaydpo+f62WaX1922KyD008X1uURaappJ/ndf kawP+c/wvHYkk/c7F5Sdq8zw6hVYYBcWiGnLUJstGg/Eeg565gYUVeGAcRsqfQJtPUrV /2/WwBCutR1p0eGCCj5QVfN3uAGHiVvkwP8I1PKYzZzBy5kLY29TZA6Sst/zFHNH1E9j A91A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:to:message-id:date:subject:cc:from :dkim-signature; bh=PrH45PB9RsMA7pyDP1csKVYDAqtxvNcn8nWcn6FbNjc=; b=dLV7y/BzjR59Zs8qPhGjV04UMETKSR4rE6GbH7lB/X0xUgLsHO+9BHMPjXahhy6zW3 KHksL7vjJP/IlM6HYlWso658erETjuzRh4pR1Jls8rlPQJMd1oHlRerA5ZPUS8MRXzE6 8LZ9DhdLvQIFFHeI1PPPMJ+cVl5roSHBo3yUZPIDreog6iyXDEjZNL7QA30XMOUtZV1D 84uy8zJoaOUceR/TUTxi2ogUZbH3TyeibyA6uekwzqaRVsZ+nm40/BNUbcYqxaPF6HlK QQOw3JoEbfJeVdmc+HsK0C3oGxzm6S8skxynucHhdWVfpkJCzUQiW1lKihO7itYsqxGY NL0A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=siHGvn1B; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h10si49306509pfk.197.2019.08.06.19.46.50; Tue, 06 Aug 2019 19:47:06 -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; dkim=fail header.i=@gmail.com header.s=20161025 header.b=siHGvn1B; 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; dmarc=fail (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727653AbfHGCqR (ORCPT + 99 others); Tue, 6 Aug 2019 22:46:17 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:39401 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726542AbfHGCqQ (ORCPT ); Tue, 6 Aug 2019 22:46:16 -0400 Received: by mail-pf1-f195.google.com with SMTP id f17so38599198pfn.6; Tue, 06 Aug 2019 19:46:16 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=PrH45PB9RsMA7pyDP1csKVYDAqtxvNcn8nWcn6FbNjc=; b=siHGvn1Bj4sIEYw5q5Gg20BGgu8x4a1UDeEVboEey9CPp5bwN7qRSX9PdbaORdYhKH YkFcM8TpUuQwt6hsamQhz5DuOUHd74woX/sCdc4OzwKeHi1BwamkrTwX4FC3mMx+K6I9 GliEblk6tNZKXY+o7iNGHFMB3sd2XRWkiqmJ0SnmEyGAcqAvus0fi+m5oOCcpSOQ66N3 dDkKgbCtk9CMy9Fjaw9c5bPyAztNXN3LxHZMZBCJh267HKxdXSUsjyFxJocebohzrZuV Xh2L7rAAuVYsLieEQNwEDnk/pHbhPGilXJtGs8lQwOV8Bav46NWW9TJnRpsWxVrpnF0t 2xqg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=PrH45PB9RsMA7pyDP1csKVYDAqtxvNcn8nWcn6FbNjc=; b=EiKHvei5aAd4PhXThGlJZLcg3oR9jx4rl+7or2uE4dkNOLju7dI5JlGH0hINXoNXQP al+X9cxBMLDr2lSUUPHtcWB4zpyl/vM94XlP3aeoOPy2cEnUUasm4kAYwL4DmPM7X9a9 ogl1KMC+u7u6D0EeMfsYS9B7VtXiJkkbQvaMGIIf7pxM4cAH6GOlWXWI/75UQrxHZUQ2 EsLP24LinWjJelZOUVgmwu11pOF7E+SAeJEkXkdb+PLre7ELCEehv0bmghf2kTjz8EOh Ituf2s5IaTy7UGlmRJ5O234ncBMuuD7VumCRrVIbQghEtYAgZHMnq9u9R+J86lIE/RyF BpqQ== X-Gm-Message-State: APjAAAXfNT65/t1EgFEsU8kT4S9QWzyBvHS1bSTnIIqEURNcrHcuLIjj 4pS/4dXNHG4ylMBR1YUw4iY= X-Received: by 2002:a63:2026:: with SMTP id g38mr5668729pgg.172.1565145975883; Tue, 06 Aug 2019 19:46:15 -0700 (PDT) Received: from hfq-skylake.ipads-lab.se.sjtu.edu.cn ([202.120.40.82]) by smtp.googlemail.com with ESMTPSA id q1sm104267950pfg.84.2019.08.06.19.46.13 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 06 Aug 2019 19:46:14 -0700 (PDT) From: Fuqian Huang Cc: Jens Axboe , linux-ide@vger.kernel.org, linux-kernel@vger.kernel.org, Fuqian Huang Subject: [PATCH] libata-sff: use spin_lock_irqsave instead of spin_lock_irq in IRQ context. Date: Wed, 7 Aug 2019 10:45:55 +0800 Message-Id: <20190807024555.13770-1-huangfq.daxian@gmail.com> X-Mailer: git-send-email 2.11.0 To: unlisted-recipients:; (no To-header on input) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Function ata_sff_flush_pio_task use spin_lock_irq/spin_unlock_irq to protect shared data. spin_unlock_irq will enable interrupts. In the interrupt handler nv_swncq_interrupt (./drivers/ata/sata_nv.c), when ap->link.sactive is true, nv_swncq_host_interrupt was called. nv_swncq_hotplug is called when NV_SWNCQ_IRQ_HOTPLUG is set. Then it will follow this chain: nv_swncq_hotplug -> sata_scr_read (./dirvers/ata/libata-core.c) -> sata_pmp_scr_read (./drivers/ata/libata-pmp.c) -> sata_pmp_read -> ata_exec_internal -> ata_exec_internal_sg -> ata_sff_flush_pio_task Interrupts are enabled in interrupt handler. Use spin_lock_irqsave instead of spin_lock_irq to avoid this. Signed-off-by: Fuqian Huang --- drivers/ata/libata-sff.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/drivers/ata/libata-sff.c b/drivers/ata/libata-sff.c index 10aa27882142..d3143e7e6ec0 100644 --- a/drivers/ata/libata-sff.c +++ b/drivers/ata/libata-sff.c @@ -1241,6 +1241,7 @@ EXPORT_SYMBOL_GPL(ata_sff_queue_pio_task); void ata_sff_flush_pio_task(struct ata_port *ap) { + unsigned long flags; DPRINTK("ENTER\n"); cancel_delayed_work_sync(&ap->sff_pio_task); @@ -1253,9 +1254,9 @@ void ata_sff_flush_pio_task(struct ata_port *ap) * __ata_sff_port_intr() checks for HSM_ST_IDLE and before it calls * ata_sff_hsm_move() causing ata_sff_hsm_move() to BUG(). */ - spin_lock_irq(ap->lock); + spin_lock_irqsave(ap->lock, flags); ap->hsm_task_state = HSM_ST_IDLE; - spin_unlock_irq(ap->lock); + spin_unlock_irqrestore(ap->lock, flags); ap->sff_pio_task_link = NULL; -- 2.11.0