* [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id
@ 2023-12-29 4:03 Guixin Liu
2023-12-31 17:58 ` Lee Duncan
` (5 more replies)
0 siblings, 6 replies; 8+ messages in thread
From: Guixin Liu @ 2023-12-29 4:03 UTC (permalink / raw)
To: sathya.prakash, kashyap.desai, sumit.saxena, sreekanth.reddy,
jejb, martin.petersen
Cc: mpi3mr-linuxdrv.pdl, linux-scsi
To ensure that the same id is not obtained during concurrent
execution of the probe, an ida is used to manage the mrioc's
id.
Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
---
Changes from v1 to v2:
- change id from int to u8, and use ida_alloc_range instead of ida_alloc.
drivers/scsi/mpi3mr/mpi3mr_os.c | 12 ++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)
diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
index 040031eb0c12..36c4ab679094 100644
--- a/drivers/scsi/mpi3mr/mpi3mr_os.c
+++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
@@ -8,11 +8,12 @@
*/
#include "mpi3mr.h"
+#include <linux/idr.h>
/* global driver scop variables */
LIST_HEAD(mrioc_list);
DEFINE_SPINLOCK(mrioc_list_lock);
-static int mrioc_ids;
+static DEFINE_IDA(mrioc_ida);
static int warn_non_secure_ctlr;
atomic64_t event_counter;
@@ -5060,7 +5061,10 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
}
mrioc = shost_priv(shost);
- mrioc->id = mrioc_ids++;
+ retval = ida_alloc_range(&mrioc_ida, 1, U8_MAX, GFP_KERNEL);
+ if (retval < 0)
+ goto id_alloc_failed;
+ mrioc->id = (u8)retval;
sprintf(mrioc->driver_name, "%s", MPI3MR_DRIVER_NAME);
sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id);
INIT_LIST_HEAD(&mrioc->list);
@@ -5207,9 +5211,11 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
resource_alloc_failed:
destroy_workqueue(mrioc->fwevt_worker_thread);
fwevtthread_failed:
+ ida_free(&mrioc_ida, mrioc->id);
spin_lock(&mrioc_list_lock);
list_del(&mrioc->list);
spin_unlock(&mrioc_list_lock);
+id_alloc_failed:
scsi_host_put(shost);
shost_failed:
return retval;
@@ -5295,6 +5301,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
mrioc->sas_hba.num_phys = 0;
}
+ ida_free(&mrioc_ida, mrioc->id);
spin_lock(&mrioc_list_lock);
list_del(&mrioc->list);
spin_unlock(&mrioc_list_lock);
@@ -5502,6 +5509,7 @@ static void __exit mpi3mr_exit(void)
&driver_attr_event_counter);
pci_unregister_driver(&mpi3mr_pci_driver);
sas_release_transport(mpi3mr_transport_template);
+ ida_destroy(&mrioc_ida);
}
module_init(mpi3mr_init);
--
2.43.0
^ permalink raw reply related [flat|nested] 8+ messages in thread
* Re: [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id
2023-12-29 4:03 [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id Guixin Liu
@ 2023-12-31 17:58 ` Lee Duncan
2024-01-03 2:24 ` Guixin Liu
` (4 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Lee Duncan @ 2023-12-31 17:58 UTC (permalink / raw)
To: Guixin Liu
Cc: sathya.prakash, kashyap.desai, sumit.saxena, sreekanth.reddy,
jejb, martin.petersen, mpi3mr-linuxdrv.pdl, linux-scsi
Reviewed-by: Lee Duncan <lduncan@suse.com>
On Thu, Dec 28, 2023 at 8:03 PM Guixin Liu <kanie@linux.alibaba.com> wrote:
>
> To ensure that the same id is not obtained during concurrent
> execution of the probe, an ida is used to manage the mrioc's
> id.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
> Changes from v1 to v2:
> - change id from int to u8, and use ida_alloc_range instead of ida_alloc.
>
> drivers/scsi/mpi3mr/mpi3mr_os.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index 040031eb0c12..36c4ab679094 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -8,11 +8,12 @@
> */
>
> #include "mpi3mr.h"
> +#include <linux/idr.h>
>
> /* global driver scop variables */
> LIST_HEAD(mrioc_list);
> DEFINE_SPINLOCK(mrioc_list_lock);
> -static int mrioc_ids;
> +static DEFINE_IDA(mrioc_ida);
> static int warn_non_secure_ctlr;
> atomic64_t event_counter;
>
> @@ -5060,7 +5061,10 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> }
>
> mrioc = shost_priv(shost);
> - mrioc->id = mrioc_ids++;
> + retval = ida_alloc_range(&mrioc_ida, 1, U8_MAX, GFP_KERNEL);
> + if (retval < 0)
> + goto id_alloc_failed;
> + mrioc->id = (u8)retval;
> sprintf(mrioc->driver_name, "%s", MPI3MR_DRIVER_NAME);
> sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id);
> INIT_LIST_HEAD(&mrioc->list);
> @@ -5207,9 +5211,11 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> resource_alloc_failed:
> destroy_workqueue(mrioc->fwevt_worker_thread);
> fwevtthread_failed:
> + ida_free(&mrioc_ida, mrioc->id);
> spin_lock(&mrioc_list_lock);
> list_del(&mrioc->list);
> spin_unlock(&mrioc_list_lock);
> +id_alloc_failed:
> scsi_host_put(shost);
> shost_failed:
> return retval;
> @@ -5295,6 +5301,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
> mrioc->sas_hba.num_phys = 0;
> }
>
> + ida_free(&mrioc_ida, mrioc->id);
> spin_lock(&mrioc_list_lock);
> list_del(&mrioc->list);
> spin_unlock(&mrioc_list_lock);
> @@ -5502,6 +5509,7 @@ static void __exit mpi3mr_exit(void)
> &driver_attr_event_counter);
> pci_unregister_driver(&mpi3mr_pci_driver);
> sas_release_transport(mpi3mr_transport_template);
> + ida_destroy(&mrioc_ida);
> }
>
> module_init(mpi3mr_init);
> --
> 2.43.0
>
>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id
2023-12-29 4:03 [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id Guixin Liu
2023-12-31 17:58 ` Lee Duncan
@ 2024-01-03 2:24 ` Guixin Liu
2024-01-08 1:59 ` Guixin Liu
2024-01-19 7:44 ` Guixin Liu
` (3 subsequent siblings)
5 siblings, 1 reply; 8+ messages in thread
From: Guixin Liu @ 2024-01-03 2:24 UTC (permalink / raw)
To: sathya.prakash, kashyap.desai, sumit.saxena, sreekanth.reddy,
jejb, martin.petersen
Cc: mpi3mr-linuxdrv.pdl, linux-scsi
gentle ping..
best regards,
Guixin Liu
在 2023/12/29 12:03, Guixin Liu 写道:
> To ensure that the same id is not obtained during concurrent
> execution of the probe, an ida is used to manage the mrioc's
> id.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
> Changes from v1 to v2:
> - change id from int to u8, and use ida_alloc_range instead of ida_alloc.
>
> drivers/scsi/mpi3mr/mpi3mr_os.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index 040031eb0c12..36c4ab679094 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -8,11 +8,12 @@
> */
>
> #include "mpi3mr.h"
> +#include <linux/idr.h>
>
> /* global driver scop variables */
> LIST_HEAD(mrioc_list);
> DEFINE_SPINLOCK(mrioc_list_lock);
> -static int mrioc_ids;
> +static DEFINE_IDA(mrioc_ida);
> static int warn_non_secure_ctlr;
> atomic64_t event_counter;
>
> @@ -5060,7 +5061,10 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> }
>
> mrioc = shost_priv(shost);
> - mrioc->id = mrioc_ids++;
> + retval = ida_alloc_range(&mrioc_ida, 1, U8_MAX, GFP_KERNEL);
> + if (retval < 0)
> + goto id_alloc_failed;
> + mrioc->id = (u8)retval;
> sprintf(mrioc->driver_name, "%s", MPI3MR_DRIVER_NAME);
> sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id);
> INIT_LIST_HEAD(&mrioc->list);
> @@ -5207,9 +5211,11 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> resource_alloc_failed:
> destroy_workqueue(mrioc->fwevt_worker_thread);
> fwevtthread_failed:
> + ida_free(&mrioc_ida, mrioc->id);
> spin_lock(&mrioc_list_lock);
> list_del(&mrioc->list);
> spin_unlock(&mrioc_list_lock);
> +id_alloc_failed:
> scsi_host_put(shost);
> shost_failed:
> return retval;
> @@ -5295,6 +5301,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
> mrioc->sas_hba.num_phys = 0;
> }
>
> + ida_free(&mrioc_ida, mrioc->id);
> spin_lock(&mrioc_list_lock);
> list_del(&mrioc->list);
> spin_unlock(&mrioc_list_lock);
> @@ -5502,6 +5509,7 @@ static void __exit mpi3mr_exit(void)
> &driver_attr_event_counter);
> pci_unregister_driver(&mpi3mr_pci_driver);
> sas_release_transport(mpi3mr_transport_template);
> + ida_destroy(&mrioc_ida);
> }
>
> module_init(mpi3mr_init);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id
2024-01-03 2:24 ` Guixin Liu
@ 2024-01-08 1:59 ` Guixin Liu
0 siblings, 0 replies; 8+ messages in thread
From: Guixin Liu @ 2024-01-08 1:59 UTC (permalink / raw)
To: sathya.prakash, kashyap.desai, sumit.saxena, sreekanth.reddy,
jejb, martin.petersen
Cc: mpi3mr-linuxdrv.pdl, linux-scsi
friendly ping..
best regards,
Guixin Liu
在 2024/1/3 10:24, Guixin Liu 写道:
> gentle ping..
>
> best regards,
>
> Guixin Liu
>
> 在 2023/12/29 12:03, Guixin Liu 写道:
>> To ensure that the same id is not obtained during concurrent
>> execution of the probe, an ida is used to manage the mrioc's
>> id.
>>
>> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
>> ---
>> Changes from v1 to v2:
>> - change id from int to u8, and use ida_alloc_range instead of
>> ida_alloc.
>>
>> drivers/scsi/mpi3mr/mpi3mr_os.c | 12 ++++++++++--
>> 1 file changed, 10 insertions(+), 2 deletions(-)
>>
>> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c
>> b/drivers/scsi/mpi3mr/mpi3mr_os.c
>> index 040031eb0c12..36c4ab679094 100644
>> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
>> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
>> @@ -8,11 +8,12 @@
>> */
>> #include "mpi3mr.h"
>> +#include <linux/idr.h>
>> /* global driver scop variables */
>> LIST_HEAD(mrioc_list);
>> DEFINE_SPINLOCK(mrioc_list_lock);
>> -static int mrioc_ids;
>> +static DEFINE_IDA(mrioc_ida);
>> static int warn_non_secure_ctlr;
>> atomic64_t event_counter;
>> @@ -5060,7 +5061,10 @@ mpi3mr_probe(struct pci_dev *pdev, const
>> struct pci_device_id *id)
>> }
>> mrioc = shost_priv(shost);
>> - mrioc->id = mrioc_ids++;
>> + retval = ida_alloc_range(&mrioc_ida, 1, U8_MAX, GFP_KERNEL);
>> + if (retval < 0)
>> + goto id_alloc_failed;
>> + mrioc->id = (u8)retval;
>> sprintf(mrioc->driver_name, "%s", MPI3MR_DRIVER_NAME);
>> sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id);
>> INIT_LIST_HEAD(&mrioc->list);
>> @@ -5207,9 +5211,11 @@ mpi3mr_probe(struct pci_dev *pdev, const
>> struct pci_device_id *id)
>> resource_alloc_failed:
>> destroy_workqueue(mrioc->fwevt_worker_thread);
>> fwevtthread_failed:
>> + ida_free(&mrioc_ida, mrioc->id);
>> spin_lock(&mrioc_list_lock);
>> list_del(&mrioc->list);
>> spin_unlock(&mrioc_list_lock);
>> +id_alloc_failed:
>> scsi_host_put(shost);
>> shost_failed:
>> return retval;
>> @@ -5295,6 +5301,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
>> mrioc->sas_hba.num_phys = 0;
>> }
>> + ida_free(&mrioc_ida, mrioc->id);
>> spin_lock(&mrioc_list_lock);
>> list_del(&mrioc->list);
>> spin_unlock(&mrioc_list_lock);
>> @@ -5502,6 +5509,7 @@ static void __exit mpi3mr_exit(void)
>> &driver_attr_event_counter);
>> pci_unregister_driver(&mpi3mr_pci_driver);
>> sas_release_transport(mpi3mr_transport_template);
>> + ida_destroy(&mrioc_ida);
>> }
>> module_init(mpi3mr_init);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id
2023-12-29 4:03 [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id Guixin Liu
2023-12-31 17:58 ` Lee Duncan
2024-01-03 2:24 ` Guixin Liu
@ 2024-01-19 7:44 ` Guixin Liu
2024-01-19 10:05 ` Martin Wilck
` (2 subsequent siblings)
5 siblings, 0 replies; 8+ messages in thread
From: Guixin Liu @ 2024-01-19 7:44 UTC (permalink / raw)
To: sathya.prakash, kashyap.desai, sumit.saxena, sreekanth.reddy,
jejb, martin.petersen
Cc: mpi3mr-linuxdrv.pdl, linux-scsi
Hi guys,
Friendly ping...
My patch has been sent to the community for three weeks now,
Could someone please review this patch?
Best regards,
Guixin Liu
在 2023/12/29 12:03, Guixin Liu 写道:
> To ensure that the same id is not obtained during concurrent
> execution of the probe, an ida is used to manage the mrioc's
> id.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
> Changes from v1 to v2:
> - change id from int to u8, and use ida_alloc_range instead of ida_alloc.
>
> drivers/scsi/mpi3mr/mpi3mr_os.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
> diff --git a/drivers/scsi/mpi3mr/mpi3mr_os.c b/drivers/scsi/mpi3mr/mpi3mr_os.c
> index 040031eb0c12..36c4ab679094 100644
> --- a/drivers/scsi/mpi3mr/mpi3mr_os.c
> +++ b/drivers/scsi/mpi3mr/mpi3mr_os.c
> @@ -8,11 +8,12 @@
> */
>
> #include "mpi3mr.h"
> +#include <linux/idr.h>
>
> /* global driver scop variables */
> LIST_HEAD(mrioc_list);
> DEFINE_SPINLOCK(mrioc_list_lock);
> -static int mrioc_ids;
> +static DEFINE_IDA(mrioc_ida);
> static int warn_non_secure_ctlr;
> atomic64_t event_counter;
>
> @@ -5060,7 +5061,10 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> }
>
> mrioc = shost_priv(shost);
> - mrioc->id = mrioc_ids++;
> + retval = ida_alloc_range(&mrioc_ida, 1, U8_MAX, GFP_KERNEL);
> + if (retval < 0)
> + goto id_alloc_failed;
> + mrioc->id = (u8)retval;
> sprintf(mrioc->driver_name, "%s", MPI3MR_DRIVER_NAME);
> sprintf(mrioc->name, "%s%d", mrioc->driver_name, mrioc->id);
> INIT_LIST_HEAD(&mrioc->list);
> @@ -5207,9 +5211,11 @@ mpi3mr_probe(struct pci_dev *pdev, const struct pci_device_id *id)
> resource_alloc_failed:
> destroy_workqueue(mrioc->fwevt_worker_thread);
> fwevtthread_failed:
> + ida_free(&mrioc_ida, mrioc->id);
> spin_lock(&mrioc_list_lock);
> list_del(&mrioc->list);
> spin_unlock(&mrioc_list_lock);
> +id_alloc_failed:
> scsi_host_put(shost);
> shost_failed:
> return retval;
> @@ -5295,6 +5301,7 @@ static void mpi3mr_remove(struct pci_dev *pdev)
> mrioc->sas_hba.num_phys = 0;
> }
>
> + ida_free(&mrioc_ida, mrioc->id);
> spin_lock(&mrioc_list_lock);
> list_del(&mrioc->list);
> spin_unlock(&mrioc_list_lock);
> @@ -5502,6 +5509,7 @@ static void __exit mpi3mr_exit(void)
> &driver_attr_event_counter);
> pci_unregister_driver(&mpi3mr_pci_driver);
> sas_release_transport(mpi3mr_transport_template);
> + ida_destroy(&mrioc_ida);
> }
>
> module_init(mpi3mr_init);
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id
2023-12-29 4:03 [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id Guixin Liu
` (2 preceding siblings ...)
2024-01-19 7:44 ` Guixin Liu
@ 2024-01-19 10:05 ` Martin Wilck
2024-01-24 2:46 ` Martin K. Petersen
2024-01-30 2:27 ` Martin K. Petersen
5 siblings, 0 replies; 8+ messages in thread
From: Martin Wilck @ 2024-01-19 10:05 UTC (permalink / raw)
To: Guixin Liu, sathya.prakash, kashyap.desai, sumit.saxena,
sreekanth.reddy, jejb, martin.petersen
Cc: mpi3mr-linuxdrv.pdl, linux-scsi
On Fri, 2023-12-29 at 12:03 +0800, Guixin Liu wrote:
> To ensure that the same id is not obtained during concurrent
> execution of the probe, an ida is used to manage the mrioc's
> id.
>
> Signed-off-by: Guixin Liu <kanie@linux.alibaba.com>
> ---
> Changes from v1 to v2:
> - change id from int to u8, and use ida_alloc_range instead of
> ida_alloc.
>
> drivers/scsi/mpi3mr/mpi3mr_os.c | 12 ++++++++++--
> 1 file changed, 10 insertions(+), 2 deletions(-)
>
Reviewed-by: Martin Wilck <mwilck@suse.com>
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id
2023-12-29 4:03 [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id Guixin Liu
` (3 preceding siblings ...)
2024-01-19 10:05 ` Martin Wilck
@ 2024-01-24 2:46 ` Martin K. Petersen
2024-01-30 2:27 ` Martin K. Petersen
5 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2024-01-24 2:46 UTC (permalink / raw)
To: Guixin Liu
Cc: sathya.prakash, kashyap.desai, sumit.saxena, sreekanth.reddy,
jejb, martin.petersen, mpi3mr-linuxdrv.pdl, linux-scsi
Guixin,
> To ensure that the same id is not obtained during concurrent execution
> of the probe, an ida is used to manage the mrioc's id.
Applied to 6.9/scsi-staging, thanks!
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id
2023-12-29 4:03 [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id Guixin Liu
` (4 preceding siblings ...)
2024-01-24 2:46 ` Martin K. Petersen
@ 2024-01-30 2:27 ` Martin K. Petersen
5 siblings, 0 replies; 8+ messages in thread
From: Martin K. Petersen @ 2024-01-30 2:27 UTC (permalink / raw)
To: sathya.prakash, kashyap.desai, sumit.saxena, sreekanth.reddy,
jejb, Guixin Liu
Cc: Martin K . Petersen, mpi3mr-linuxdrv.pdl, linux-scsi
On Fri, 29 Dec 2023 12:03:31 +0800, Guixin Liu wrote:
> To ensure that the same id is not obtained during concurrent
> execution of the probe, an ida is used to manage the mrioc's
> id.
>
>
Applied to 6.9/scsi-queue, thanks!
[1/1] scsi: mpi3mr: use ida to manage mrioc's id
https://git.kernel.org/mkp/scsi/c/29b75184f721
--
Martin K. Petersen Oracle Linux Engineering
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-01-30 2:27 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-12-29 4:03 [PATCH V2] scsi: mpi3mr: use ida to manage mrioc's id Guixin Liu
2023-12-31 17:58 ` Lee Duncan
2024-01-03 2:24 ` Guixin Liu
2024-01-08 1:59 ` Guixin Liu
2024-01-19 7:44 ` Guixin Liu
2024-01-19 10:05 ` Martin Wilck
2024-01-24 2:46 ` Martin K. Petersen
2024-01-30 2:27 ` Martin K. Petersen
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).