Commit 130fc180 authored by Sreekanth Reddy's avatar Sreekanth Reddy Committed by Martin K. Petersen

scsi: mpi3mr: Free enclosure objects during driver unload

Free the enclosure device objects during driver unload and before
rescanning the target devices during controller reset.

Link: https://lore.kernel.org/r/20220912135742.11764-7-sreekanth.reddy@broadcom.comSigned-off-by: default avatarSreekanth Reddy <sreekanth.reddy@broadcom.com>
Signed-off-by: default avatarMartin K. Petersen <martin.petersen@oracle.com>
parent bad2f28d
...@@ -1392,4 +1392,5 @@ void mpi3mr_refresh_expanders(struct mpi3mr_ioc *mrioc); ...@@ -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_add_event_wait_for_device_refresh(struct mpi3mr_ioc *mrioc);
void mpi3mr_flush_drv_cmds(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_flush_cmds_for_unrecovered_controller(struct mpi3mr_ioc *mrioc);
void mpi3mr_free_enclosure_list(struct mpi3mr_ioc *mrioc);
#endif /*MPI3MR_H_INCLUDED*/ #endif /*MPI3MR_H_INCLUDED*/
...@@ -4250,6 +4250,8 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc) ...@@ -4250,6 +4250,8 @@ void mpi3mr_free_mem(struct mpi3mr_ioc *mrioc)
u16 i; u16 i;
struct mpi3mr_intr_info *intr_info; struct mpi3mr_intr_info *intr_info;
mpi3mr_free_enclosure_list(mrioc);
if (mrioc->sense_buf_pool) { if (mrioc->sense_buf_pool) {
if (mrioc->sense_buf) if (mrioc->sense_buf)
dma_pool_free(mrioc->sense_buf_pool, 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, ...@@ -4897,6 +4899,8 @@ int mpi3mr_soft_reset_handler(struct mpi3mr_ioc *mrioc,
mpi3mr_flush_host_io(mrioc); mpi3mr_flush_host_io(mrioc);
mpi3mr_cleanup_fwevt_list(mrioc); mpi3mr_cleanup_fwevt_list(mrioc);
mpi3mr_invalidate_devhandles(mrioc); mpi3mr_invalidate_devhandles(mrioc);
mpi3mr_free_enclosure_list(mrioc);
if (mrioc->prepare_for_reset) { if (mrioc->prepare_for_reset) {
mrioc->prepare_for_reset = 0; mrioc->prepare_for_reset = 0;
mrioc->prepare_for_reset_timeout_counter = 0; mrioc->prepare_for_reset_timeout_counter = 0;
......
...@@ -1334,6 +1334,25 @@ static void mpi3mr_devinfochg_evt_bh(struct mpi3mr_ioc *mrioc, ...@@ -1334,6 +1334,25 @@ static void mpi3mr_devinfochg_evt_bh(struct mpi3mr_ioc *mrioc,
mpi3mr_tgtdev_put(tgtdev); 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 * mpi3mr_enclosure_find_by_handle - enclosure search by handle
* @mrioc: Adapter instance reference * @mrioc: Adapter instance reference
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment