Return-Path: Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1752096AbdFNOaB (ORCPT ); Wed, 14 Jun 2017 10:30:01 -0400 Received: from esa5.hgst.iphmx.com ([216.71.153.144]:39667 "EHLO esa5.hgst.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751688AbdFNO37 (ORCPT ); Wed, 14 Jun 2017 10:29:59 -0400 X-IronPort-AV: E=Sophos;i="5.39,340,1493654400"; d="scan'208";a="25280316" From: Bart Van Assche To: "linux-scsi@vger.kernel.org" , "linux-kernel@vger.kernel.org" , "sreekanth.reddy@broadcom.com" CC: "hch@infradead.org" , "jejb@kernel.org" , "martin.petersen@oracle.com" Subject: Re: mpt3sas: driver got task abort request just after it's .shutdown() function is invoked Thread-Topic: mpt3sas: driver got task abort request just after it's .shutdown() function is invoked Thread-Index: AQHS5Nqik0dXyM5K6EiUzymywFR0JqIka6qA Date: Wed, 14 Jun 2017 14:29:55 +0000 Message-ID: <1497450593.3896.2.camel@wdc.com> References: In-Reply-To: Accept-Language: en-US Content-Language: en-US X-MS-Has-Attach: X-MS-TNEF-Correlator: authentication-results: vger.kernel.org; dkim=none (message not signed) header.d=none;vger.kernel.org; dmarc=none action=none header.from=wdc.com; x-originating-ip: [76.102.111.178] x-ms-publictraffictype: Email x-microsoft-exchange-diagnostics: 1;CY1PR0401MB1536;7:fmzkXyu07uwpydr3Xh/MiFbv7hpS7zaP0E3LySNRysnu/gyAmAIDtTT1NdASNO/4KK700SHuD0UxMrIVzirp5Cu6TBdsXFVYEqZcbOtARlZEC9ZfBWoQiSQgGyFPUYppsIUTK8y/oAnqmeCKYB0uGUVyWm+GQSIwKaKM4mMgN7DBMF3aeCwHd7x9DohEVBOftEMgEfipfLNS+JeE7PhcaT+eO271Ua+RGwdsH2fikVppChVPhF43zHViB+qHF8Vq+h9Idi0O1e/v9HFwRWAlL7awAssbGxbh5L9IyJA5/Y1Jo/Kv9B2kzMfSTlsCSn1ie5OoHVYZHYInNURBIrC+Eg==;20:e8uugvVe2x1Iy1+YzEUlW+G25ToJUFLJvFiaLS7THNS0kOKkeHvFBMiSmIvHAuqJVPSHZj9Yfs1ZHaDisVANIVBzCD0bflonqFlu+1/vNXp/sFl+FqeJfMy0GktWbZJSUBc6rWJG9QBbpG9pNurmcyZ2Syq5NX1YT9wf8sQ1khU= x-ms-traffictypediagnostic: CY1PR0401MB1536: x-ms-office365-filtering-correlation-id: bef8a9cd-6bae-4631-b235-08d4b331d441 x-ms-office365-filtering-ht: Tenant x-microsoft-antispam: UriScan:;BCL:0;PCL:0;RULEID:(22001)(2017030254075)(48565401081)(201703131423075)(201703031133081);SRVR:CY1PR0401MB1536; wdcipoutbound: EOP-TRUE x-microsoft-antispam-prvs: x-exchange-antispam-report-test: UriScan:(17755550239193); x-exchange-antispam-report-cfa-test: BCL:0;PCL:0;RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(601004)(2401047)(8121501046)(5005006)(10201501046)(3002001)(100000703101)(100105400095)(93006095)(93001095)(6055026)(6041248)(20161123555025)(20161123562025)(20161123560025)(20161123564025)(20161123558100)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(6072148)(100000704101)(100105200095)(100000705101)(100105500095);SRVR:CY1PR0401MB1536;BCL:0;PCL:0;RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095);SRVR:CY1PR0401MB1536; x-forefront-prvs: 033857D0BD x-forefront-antispam-report: SFV:NSPM;SFS:(10019020)(6009001)(39850400002)(39450400003)(39840400002)(39410400002)(39400400002)(39860400002)(377424004)(24454002)(2201001)(86362001)(8936002)(6116002)(3280700002)(5890100001)(305945005)(2501003)(8676002)(81166006)(7736002)(2906002)(2950100002)(4326008)(102836003)(3846002)(3660700001)(25786009)(2900100001)(103116003)(72206003)(478600001)(77096006)(6246003)(53936002)(6506006)(33646002)(122556002)(6512007)(189998001)(6486002)(14454004)(54906002)(99286003)(66066001)(36756003)(38730400002)(6436002)(5660300001)(50986999)(54356999)(76176999)(229853002)(142923001)(32563001);DIR:OUT;SFP:1102;SCL:1;SRVR:CY1PR0401MB1536;H:CY1PR0401MB1536.namprd04.prod.outlook.com;FPR:;SPF:None;MLV:sfv;LANG:en; spamdiagnosticoutput: 1:99 spamdiagnosticmetadata: NSPM Content-Type: text/plain; charset="utf-8" Content-ID: MIME-Version: 1.0 X-OriginatorOrg: wdc.com X-MS-Exchange-CrossTenant-originalarrivaltime: 14 Jun 2017 14:29:56.0015 (UTC) X-MS-Exchange-CrossTenant-fromentityheader: Hosted X-MS-Exchange-CrossTenant-id: b61c8803-16f3-4c35-9b17-6f65f441df86 X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0401MB1536 Sender: linux-kernel-owner@vger.kernel.org List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Content-Transfer-Encoding: 8bit X-MIME-Autoconverted: from base64 to 8bit by mail.home.local id v5EEUipW015994 Content-Length: 1553 Lines: 33 On Wed, 2017-06-14 at 12:20 +0530, Sreekanth Reddy wrote: > I am using 4.9 kernel and I am observing NULL pointer deference type > kernel panic in the below scenario, > > * Hotplug (i.e. hot add) the HBA (with a set of drives attached to it) > to the system just few seconds before issuing "poweroff" command. > > * Observed that during drives discovery process; for some of the > drives "MODE SENSE" command got timed out. > > * And as "poweroff" command issued, so kernel as called driver's > shutdown() callback function and driver has cleaned up all the HBA > resources (such as IRQ's, memory pools etc). > > * But as the "MODE SENSE" command got timed out, so SCSI EH thread has > invoked driver's .eh_abort_handler() callback function, but by this > time driver has already cleaned up the resources and so it leads to > kernel panic when it trying to access one of these resources. > > I was assuming that kernel should not call driver's shutdown() > callback function until all the outstanding IOs count reaches to zero > (i.e. kernel should call the driver's shutdown() functions only after > clearing up all the outstanding IOs). Please correct me if I am wrong, > and please suggest better way to handle these types of issues. Hello Sreekanth, The SCSI core is not aware of PCIe (hot-)removal and hence cannot help in this case. I think SCSI LLDs are responsible when .shutdown() is called for 1) waiting until any ongoing scsi_scan_target() call has finished and 2) calling scsi_remove_host() from inside pci_driver.shutdown(). Bart.