From patchwork Thu Sep 8 12:53:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Sreekanth Reddy X-Patchwork-Id: 604141 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 2CD1EC38145 for ; Thu, 8 Sep 2022 12:41:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S231928AbiIHMlw (ORCPT ); Thu, 8 Sep 2022 08:41:52 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:60906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S231927AbiIHMlf (ORCPT ); Thu, 8 Sep 2022 08:41:35 -0400 Received: from mail-pj1-x102a.google.com (mail-pj1-x102a.google.com [IPv6:2607:f8b0:4864:20::102a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AD337E5838 for ; Thu, 8 Sep 2022 05:41:27 -0700 (PDT) Received: by mail-pj1-x102a.google.com with SMTP id fv3so11535949pjb.0 for ; Thu, 08 Sep 2022 05:41:27 -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=b5vDrWo6iGBaLBDiG+7DhbGO2eN47CGSvmCRNshTjBs=; b=QyKaSFtoltNN7tFBToDWudYbilNX69fH8srHhpj7YP49b0ALLxhMYswBK+jusfORuK xTmKNMdU+WRC4rR7EgeO2LzviR8cS1QR1KzL2+KnRMCLabx5Z+svuNhLTRte4SG6rGZs WWJZzH4GaC4/y3DgygcUEwkKvZektr2vLkyTs= 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=b5vDrWo6iGBaLBDiG+7DhbGO2eN47CGSvmCRNshTjBs=; b=hSDLe3VvAEOLqUNelvd8XzGHV0XOt6oK5dG/jcjOFLP9biDaThyNxkTQItsfSAi+qR yMDsH4DMmVxGw5Z7MTzqFRyP8tmAGy81Nymg3LHL3/dEMViqSfauwnZMVvdQRjCfDnrC twG+dkUt9wjdzw0OeQjgvHsagRjvx61p6cuVzYzYUi8jFNvyJxIMRG3qIoQpM8hHYtdU vDRn/8ofaAYrHeYvhnxwfH4mqZvR0FnPHajOni6VuqABZzx+aLe66/FaK5hxZIImp+LU tuAKSk3MI8WQspbAFOwvQ1SSlOsI6UEHCdkm+DFLg7iiwzCvgty0KMbvE9YuMaIRl72J AvGw== X-Gm-Message-State: ACgBeo2OZUXBncBIuQIMPzpXfVA+YNMwhB/HodVKO+6iDDpD9ymxmVlD JgZtQMnEPNKV+0LdG0gXB3NbnJ1L29NPvsH+COWdI3qD1rraF+U5jrcChD22IIWMcIBrTWchxzN sne6G6a/qDCLF9xUDJlRmDbtl4zrfOXxeCV6ejbfNYeACOU2GxXe1s+D5STelOKkTnxUOJEqFbO MS59wILBCn X-Google-Smtp-Source: AA6agR7LJ/n2MY8g9+uWaqV21gBOj/tnexfRVS+0Ar0h7KPWWdddqude/e3WojIRmuWXaSvPnEnCbw== X-Received: by 2002:a17:90b:507:b0:1fd:9b50:d5de with SMTP id r7-20020a17090b050700b001fd9b50d5demr3956582pjz.178.1662640886762; Thu, 08 Sep 2022 05:41:26 -0700 (PDT) Received: from dhcp-10-123-20-36.dhcp.broadcom.net ([192.19.234.250]) by smtp.gmail.com with ESMTPSA id c17-20020a63ef51000000b0043395af24f6sm11106807pgk.25.2022.09.08.05.41.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 08 Sep 2022 05:41:26 -0700 (PDT) From: Sreekanth Reddy To: linux-scsi@vger.kernel.org Cc: martin.petersen@oracle.com, Sreekanth Reddy Subject: [PATCH 6/9] mpi3mr: Free enclosure objects during driver unload Date: Thu, 8 Sep 2022 18:23:29 +0530 Message-Id: <20220908125332.21110-7-sreekanth.reddy@broadcom.com> X-Mailer: git-send-email 2.27.0 In-Reply-To: <20220908125332.21110-1-sreekanth.reddy@broadcom.com> References: <20220908125332.21110-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 5447fda..1289bbe 100644 --- a/drivers/scsi/mpi3mr/mpi3mr_fw.c +++ b/drivers/scsi/mpi3mr/mpi3mr_fw.c @@ -4247,6 +4247,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, @@ -4894,6 +4896,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