From patchwork Mon Sep 12 13:57:39 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 606091 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 60787C6FA86 for ; Mon, 12 Sep 2022 13:45:47 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S229924AbiILNpq (ORCPT ); Mon, 12 Sep 2022 09:45:46 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:36602 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229893AbiILNpn (ORCPT ); Mon, 12 Sep 2022 09:45:43 -0400 Received: from mail-pf1-x436.google.com (mail-pf1-x436.google.com [IPv6:2607:f8b0:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6E3BA1FCD8 for ; Mon, 12 Sep 2022 06:45:39 -0700 (PDT) Received: by mail-pf1-x436.google.com with SMTP id y127so8670783pfy.5 for ; Mon, 12 Sep 2022 06:45:39 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=broadcom.com; s=google; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:from:to:cc:subject:date; bh=1cz8cJddhv/UgFa7XsIYYwuNzFE3YN92ZTJq73Pl1Qc=; b=a5z+y1xMNN6XuV6W0isJc6VvM5gTW6uKg1ra7XVNTtEgfzOXH6JTj1scw5oHcSytL8 ALbnuQOUWt9qxZIwePVTQSfBiXd8/wHfnpatbUZ3iq2VGbJITSs7RZlFq08WMcHjP6oH gdBrztJ/T5uJlpBn5KxEP5BkQi+9YyUHpjf9I= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=mime-version:references:in-reply-to:message-id:date:subject:cc:to :from:x-gm-message-state:from:to:cc:subject:date; bh=1cz8cJddhv/UgFa7XsIYYwuNzFE3YN92ZTJq73Pl1Qc=; b=gFtecKTMEkQPmIJaotN5ZFu4ljTBZn1xEJvh+waWdusARXV3GFMsWCL4DXOqtBEPyG Ss/OIlMqDne1MEqJwgH6Wk/TNDleffuXmcDOTCOxYnphD/ijxpDeXp+0vRMebpm4V2// AnfjKY7jGRQ9e0EoBkUoHcTj80pCjBCVTeF+GTZsgXEH73iyHSMpfes/eFEQmQBZiWQV XU3QkCIZUdwMRAL59vn8beCn+oScJypwVuZj3p8eUnZ30eutZXHzv+beZj8Kf+3igfQ0 ek88N6IWpZEmTXIXmCgtnatD6O/MVQYxDkneYIcgu43Q4902YJbumZNt1rUheAYvgSnP Er9Q== X-Gm-Message-State: ACgBeo1E8agUIHwzMQWbeN/FRv5KpbuUjY+x0GXmAlL6Y9cnFgt6PzXO 5EyhMpL7fNq42YKux9x6KARl2fAHmVClzhxnpdY6XeR9iFnu6xI0mzb6CXs6pRvugv7QUZqdr5o g9olCDwJzrk6i0KSiOQ9DswDtXteFH80ShJsKqfSToHxMNR09ahgzNxcIQZLfwJx4zlTySlmivK bzZHZK19I9 X-Google-Smtp-Source: AA6agR7ARvU8ukwJ07nFXCRORLyMIXvymdWlZHpx+bXosYoW5viDdGYOvECmsSKE3hKLF81lAIu4qw== X-Received: by 2002:a63:8641:0:b0:434:c1cf:9546 with SMTP id x62-20020a638641000000b00434c1cf9546mr23312431pgd.109.1662990338381; Mon, 12 Sep 2022 06:45:38 -0700 (PDT) Received: from dhcp-10-123-20-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id u7-20020a170903124700b00176e8f85146sm6112900plh.185.2022.09.12.06.45.36 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 12 Sep 2022 06:45:37 -0700 (PDT) From: Sreekanth Reddy To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, Sreekanth Reddy Subject: [PATCH v2 6/9] mpi3mr: Free enclosure objects during driver unload Date: Mon, 12 Sep 2022 19:27:39 +0530 Message-Id: <20220912135742.11764-7-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220912135742.11764-1-sreekanth.reddy@broadcom.com> References: <20220912135742.11764-1-sreekanth.reddy@broadcom.com> MIME-Version: 1.0 Precedence: bulk List-ID: X-Mailing-List: linux-scsi@vger.kernel.org Free the enclosure device objects during driver unload and before rescanning the target devices during controller reset. Signed-off-by: Sreekanth Reddy --- drivers/scsi/mpi3mr/mpi3mr.h | 1 + drivers/scsi/mpi3mr/mpi3mr_fw.c | 4 ++++ drivers/scsi/mpi3mr/mpi3mr_os.c | 19 +++++++++++++++++++ 3 files changed, 24 insertions(+) diff --git a/drivers/scsi/mpi3mr/mpi3mr.h b/drivers/scsi/mpi3mr/mpi3mr.h index 0eb0647..883ed59 100644 --- a/drivers/scsi/mpi3mr/mpi3mr.h +++ b/drivers/scsi/mpi3mr/mpi3mr.h @@ -1392,4 +1392,5 @@ void mpi3mr_refresh_expanders(struct mpi3mr_ioc *mrioc); void mpi3mr_add_event_wait_for_device_refresh(struct mpi3mr_ioc *mrioc); void mpi3mr_flush_drv_cmds(struct mpi3mr_ioc *mrioc); void mpi3mr_flush_cmds_for_unrecovered_controller(struct mpi3mr_ioc *mrioc); +void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc); #endif /*MPI3MR_H_INCLUDED*/ diff --git a/drivers/scsi/mpi3mr/mpi3mr_fw.c b/drivers/scsi/mpi3mr/mpi3mr_fw.c index abdccff..e3df044 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -4250,6 +4250,8 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) u16 i; struct mpi3mr_intr_info *intr_info; + mpi3mr_free_enclosure_list(mrioc); + if (mrioc->sense_buf_pool) { if (mrioc->sense_buf) dma_pool_free(mrioc->sense_buf_pool, mrioc->sense_buf, @@ -4897,6 +4899,8 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc, mpi3mr_flush_host_io(mrioc); mpi3mr_cleanup_fwevt_list(mrioc); mpi3mr_invalidate_devhandles(mrioc); + mpi3mr_free_enclosure_list(mrioc); + if (mrioc->prepare_for_reset) { mrioc->prepare_for_reset = 0; mrioc->prepare_for_reset_timeout_counter = 0; diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c index a5b6402..bb276b5 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_os.c +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c @@ -1334,6 +1334,25 @@ out: mpi3mr_tgtdev_put(tgtdev); } +/** + * mpi3mr_free_enclosure_list - release enclosures + * @mrioc: Adapter instance reference + * + * Free memory allocated during encloure add. + * + * Return nothing. + */ +void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc) +{ + struct mpi3mr_enclosure_node *enclosure_dev, *enclosure_dev_next; + + list_for_each_entry_safe(enclosure_dev, + enclosure_dev_next, &mrioc->enclosure_list, list) { + list_del(&enclosure_dev->list); + kfree(enclosure_dev); + } +} + /** * mpi3mr_enclosure_find_by_handle - enclosure search by handle * @mrioc: Adapter instance reference