From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.8 required=3.0 tests=BAYES_00, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 0832DC63777 for ; Mon, 30 Nov 2020 16:08:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AE51820665 for ; Mon, 30 Nov 2020 16:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1728570AbgK3QHz (ORCPT ); Mon, 30 Nov 2020 11:07:55 -0500 Received: from mx2.suse.de ([195.135.220.15]:42190 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727773AbgK3QHy (ORCPT ); Mon, 30 Nov 2020 11:07:54 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.221.27]) by mx2.suse.de (Postfix) with ESMTP id 11AD3AC8F; Mon, 30 Nov 2020 16:07:13 +0000 (UTC) Date: Mon, 30 Nov 2020 17:07:11 +0100 From: Daniel Wagner To: Sebastian Andrzej Siewior Cc: linux-scsi@vger.kernel.org, Finn Thain , GR-QLogic-Storage-Upstream@marvell.com, Hannes Reinecke , Jack Wang , John Garry , linux-m68k@lists.linux-m68k.org, Manish Rangankar , Michael Schmitz , MPT-FusionLinux.pdl@broadcom.com, Nilesh Javali , Sathya Prakash , Sreekanth Reddy , Suganath Prabu Subramani , Vikram Auradkar , Xiang Chen , Xiaofei Tan , "James E . J . Bottomley" , "Martin K . Petersen" , Thomas Gleixner , "Ahmed S . Darwish" Subject: Re: [PATCH 14/14] scsi: message: fusion: Remove in_interrupt() usage in mptsas_cleanup_fw_event_q(). Message-ID: <20201130160711.64tn56vt5qshsaim@beryllium.lan> References: <20201126132952.2287996-1-bigeasy@linutronix.de> <20201126132952.2287996-15-bigeasy@linutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20201126132952.2287996-15-bigeasy@linutronix.de> Precedence: bulk List-ID: X-Mailing-List: linux-m68k@vger.kernel.org On Thu, Nov 26, 2020 at 02:29:52PM +0100, Sebastian Andrzej Siewior wrote: > mptsas_cleanup_fw_event_q() uses in_interrupt() to determine if it is > safe to cancel a worker item. > > Aside of that in_interrupt() is deprecated as it does not provide what the > name suggests. It covers more than hard/soft interrupt servicing context > and is semantically ill defined. > > Looking closer there are a few problems with the current construct: > - It could be invoked from an interrupt handler / non-blocking context > because cancel_delayed_work() has no such restriction. Also, > mptsas_free_fw_event() has no such restriction. > > - The list is accessed unlocked. It may dequeue a valid work-item but at > the time of invoking cancel_delayed_work() the memory may be released > or reused because the worker has already run. > > mptsas_cleanup_fw_event_q() is invoked via mptsas_shutdown() which is > always invoked from preemtible context on device shutdown. > It is also invoked via mptsas_ioc_reset(, MPT_IOC_POST_RESET) which is a > MptResetHandlers callback. The only caller here are > mpt_SoftResetHandler(), mpt_HardResetHandler() and > mpt_Soft_Hard_ResetHandler(). mpt_diag_reset(), iterates over all reset handler... > All these functions have a `sleepFlag' ...and also uses the same flag. > argument and each caller uses caller uses `CAN_SLEEP' here and according > to current documentation: > | @sleepFlag: Indicates if sleep or schedule must be called > > So it is safe to sleep. > > Add mptsas_hotplug_event::users member. Initialize it to one by default > so mptsas_free_fw_event() will free the memory. > mptsas_cleanup_fw_event_q() will increment its value for items it > dequeues and then it may keep a pointer after dropping the lock. > Invoke cancel_delayed_work_sync() to cancel the work item and wait if > the worker is currently busy. Free the memory afterwards since it owns > the last reference to it. > > Signed-off-by: Sebastian Andrzej Siewior > Cc: Sathya Prakash > Cc: Sreekanth Reddy > Cc: Suganath Prabu Subramani > Cc: MPT-FusionLinux.pdl@broadcom.com Reviewed-by: Daniel Wagner