From: Hannes Reinecke <hare@suse.de>
To: John Garry <john.garry@huawei.com>,
jejb@linux.ibm.com, martin.petersen@oracle.com,
jinpu.wang@cloud.ionos.com, damien.lemoal@wdc.com
Cc: linux-scsi@vger.kernel.org, linux-kernel@vger.kernel.org,
linuxarm@huawei.com, ipylypiv@google.com, changyuanl@google.com,
hch@lst.de, yanaijie@huawei.com
Subject: Re: [PATCH v2 4/6] scsi: pm8001: Use sas_task_find_rq() for tagging
Date: Tue, 4 Oct 2022 07:53:10 +0200 [thread overview]
Message-ID: <fdbb5c5f-05d9-93fa-83d4-2f0129221641@suse.de> (raw)
In-Reply-To: <1664528184-162714-5-git-send-email-john.garry@huawei.com>
On 9/30/22 10:56, John Garry wrote:
> The request associated with a scsi command coming from the block layer
> has a unique tag, so use that when possible for getting a CCB.
>
> Unfortunately we don't support reserved commands in the SCSI midlayer yet,
> so in the interim continue to manage those tags internally (along with
> tags for private commands).
>
> Signed-off-by: John Garry <john.garry@huawei.com>
> ---
> drivers/scsi/pm8001/pm8001_init.c | 12 ++++--------
> drivers/scsi/pm8001/pm8001_sas.c | 16 ++++++++++++----
> drivers/scsi/pm8001/pm8001_sas.h | 11 ++++++++---
> drivers/scsi/pm8001/pm80xx_hwi.c | 17 +++--------------
> 4 files changed, 27 insertions(+), 29 deletions(-)
>
> diff --git a/drivers/scsi/pm8001/pm8001_init.c b/drivers/scsi/pm8001/pm8001_init.c
> index 0edc9857a8bd..abb884ddcaf9 100644
> --- a/drivers/scsi/pm8001/pm8001_init.c
> +++ b/drivers/scsi/pm8001/pm8001_init.c
> @@ -196,7 +196,7 @@ static void pm8001_free(struct pm8001_hba_info *pm8001_ha)
> }
> PM8001_CHIP_DISP->chip_iounmap(pm8001_ha);
> flush_workqueue(pm8001_wq);
> - bitmap_free(pm8001_ha->tags);
> + bitmap_free(pm8001_ha->rsvd_tags);
> kfree(pm8001_ha);
> }
>
> @@ -1208,18 +1208,15 @@ static int pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha)
> struct Scsi_Host *shost = pm8001_ha->shost;
> struct device *dev = pm8001_ha->dev;
> u32 max_out_io, ccb_count;
> - u32 can_queue;
> int i;
>
> max_out_io = pm8001_ha->main_cfg_tbl.pm80xx_tbl.max_out_io;
> ccb_count = min_t(int, PM8001_MAX_CCB, max_out_io);
>
> - /* Update to the scsi host*/
> - can_queue = ccb_count - PM8001_RESERVE_SLOT;
> - shost->can_queue = can_queue;
> + shost->can_queue = ccb_count - PM8001_RESERVE_SLOT;
>
> - pm8001_ha->tags = bitmap_zalloc(ccb_count, GFP_KERNEL);
> - if (!pm8001_ha->tags)
> + pm8001_ha->rsvd_tags = bitmap_zalloc(PM8001_RESERVE_SLOT, GFP_KERNEL);
> + if (!pm8001_ha->rsvd_tags)
> goto err_out;
>
> /* Memory region for ccb_info*/
> @@ -1244,7 +1241,6 @@ static int pm8001_init_ccb_tag(struct pm8001_hba_info *pm8001_ha)
> pm8001_ha->ccb_info[i].task = NULL;
> pm8001_ha->ccb_info[i].ccb_tag = PM8001_INVALID_TAG;
> pm8001_ha->ccb_info[i].device = NULL;
> - ++pm8001_ha->tags_num;
> }
>
> return 0;
> diff --git a/drivers/scsi/pm8001/pm8001_sas.c b/drivers/scsi/pm8001/pm8001_sas.c
> index 066dfa9f4683..d60bc311a4e9 100644
> --- a/drivers/scsi/pm8001/pm8001_sas.c
> +++ b/drivers/scsi/pm8001/pm8001_sas.c
> @@ -65,9 +65,14 @@ static int pm8001_find_tag(struct sas_task *task, u32 *tag)
> */
> void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
> {
> - void *bitmap = pm8001_ha->tags;
> + void *bitmap = pm8001_ha->rsvd_tags;
> unsigned long flags;
>
> + if (tag < pm8001_ha->shost->can_queue)
> + return;
> +
> + tag -= pm8001_ha->shost->can_queue;
> +
> spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags);
> __clear_bit(tag, bitmap);
> spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
> @@ -80,18 +85,21 @@ void pm8001_tag_free(struct pm8001_hba_info *pm8001_ha, u32 tag)
> */
> int pm8001_tag_alloc(struct pm8001_hba_info *pm8001_ha, u32 *tag_out)
> {
> - void *bitmap = pm8001_ha->tags;
> + void *bitmap = pm8001_ha->rsvd_tags;
> unsigned long flags;
> unsigned int tag;
>
> spin_lock_irqsave(&pm8001_ha->bitmap_lock, flags);
> - tag = find_first_zero_bit(bitmap, pm8001_ha->tags_num);
> - if (tag >= pm8001_ha->tags_num) {
> + tag = find_first_zero_bit(bitmap, PM8001_RESERVE_SLOT);
> + if (tag >= PM8001_RESERVE_SLOT) {
> spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
> return -SAS_QUEUE_FULL;
> }
> __set_bit(tag, bitmap);
> spin_unlock_irqrestore(&pm8001_ha->bitmap_lock, flags);
> +
> + /* reserved tags are in the upper region of the tagset */
> + tag += pm8001_ha->shost->can_queue;
> *tag_out = tag;
> return 0;
> }
Can you move the reserved tags to the _lower_ region of the tagset?
That way the tag allocation scheme matches with what the block-layer
does, and the eventual conversion to reserved tags becomes easier.
Cheers,
Hannes
--
Dr. Hannes Reinecke Kernel Storage Architect
hare@suse.de +49 911 74053 688
SUSE Software Solutions GmbH, Maxfeldstr. 5, 90409 Nürnberg
HRB 36809 (AG Nürnberg), Geschäftsführer: Ivo Totev, Andrew
Myers, Andrew McDonald, Martje Boudien Moerman
next prev parent reply other threads:[~2022-10-04 5:53 UTC|newest]
Thread overview: 21+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-09-30 8:56 [PATCH v2 0/6] scsi: libsas: Use request tag in more drivers John Garry
2022-09-30 8:56 ` [PATCH v2 1/6] scsi: libsas: Add sas_task_find_rq() John Garry
2022-09-30 9:15 ` Jinpu Wang
2022-09-30 9:22 ` Jason Yan
2022-10-04 5:48 ` Hannes Reinecke
2022-09-30 8:56 ` [PATCH v2 2/6] scsi: hisi_sas: Use sas_task_find_rq() John Garry
2022-10-04 5:49 ` Hannes Reinecke
2022-09-30 8:56 ` [PATCH v2 3/6] scsi: pm8001: Remove pm8001_tag_init() John Garry
2022-09-30 9:15 ` Jinpu Wang
2022-10-04 5:50 ` Hannes Reinecke
2022-09-30 8:56 ` [PATCH v2 4/6] scsi: pm8001: Use sas_task_find_rq() for tagging John Garry
2022-09-30 9:17 ` Jinpu Wang
2022-09-30 10:20 ` John Garry
2022-09-30 11:05 ` John Garry
2022-10-04 4:51 ` Jinpu Wang
2022-10-04 5:53 ` Hannes Reinecke [this message]
2022-10-04 7:37 ` John Garry
2022-09-30 8:56 ` [PATCH v2 5/6] scsi: mvsas: Delete mvs_tag_init() John Garry
2022-10-04 5:53 ` Hannes Reinecke
2022-09-30 8:56 ` [PATCH v2 6/6] scsi: mvsas: Use sas_task_find_rq() for tagging John Garry
2022-10-04 5:55 ` Hannes Reinecke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=fdbb5c5f-05d9-93fa-83d4-2f0129221641@suse.de \
--to=hare@suse.de \
--cc=changyuanl@google.com \
--cc=damien.lemoal@wdc.com \
--cc=hch@lst.de \
--cc=ipylypiv@google.com \
--cc=jejb@linux.ibm.com \
--cc=jinpu.wang@cloud.ionos.com \
--cc=john.garry@huawei.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-scsi@vger.kernel.org \
--cc=linuxarm@huawei.com \
--cc=martin.petersen@oracle.com \
--cc=yanaijie@huawei.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).