scsi: ufs: core: Allocate the SCSI host earlier
Call ufshcd_add_scsi_host() before any UPIU commands are sent to the UFS device. This patch prepares for letting ufshcd_add_scsi_host() allocate memory for both SCSI and UPIU commands. Signed-off-by: Bart Van Assche <bvanassche@acm.org> Link: https://patch.msgid.link/20251031204029.2883185-19-bvanassche@acm.org Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
This commit is contained in:
committed by
Martin K. Petersen
parent
e8ea985a83
commit
f46b9a595f
@@ -10605,6 +10605,9 @@ static int ufshcd_add_scsi_host(struct ufs_hba *hba)
|
|||||||
{
|
{
|
||||||
int err;
|
int err;
|
||||||
|
|
||||||
|
WARN_ON_ONCE(!hba->host->can_queue);
|
||||||
|
WARN_ON_ONCE(!hba->host->cmd_per_lun);
|
||||||
|
|
||||||
if (is_mcq_supported(hba)) {
|
if (is_mcq_supported(hba)) {
|
||||||
ufshcd_mcq_enable(hba);
|
ufshcd_mcq_enable(hba);
|
||||||
err = ufshcd_alloc_mcq(hba);
|
err = ufshcd_alloc_mcq(hba);
|
||||||
@@ -10765,7 +10768,11 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
|
|||||||
ufshcd_host_memory_configure(hba);
|
ufshcd_host_memory_configure(hba);
|
||||||
|
|
||||||
host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED;
|
host->can_queue = hba->nutrs - UFSHCD_NUM_RESERVED;
|
||||||
host->cmd_per_lun = hba->nutrs - UFSHCD_NUM_RESERVED;
|
/*
|
||||||
|
* Set the queue depth for WLUNs. ufs_get_device_desc() will increase
|
||||||
|
* host->cmd_per_lun to a larger value.
|
||||||
|
*/
|
||||||
|
host->cmd_per_lun = 1;
|
||||||
host->max_id = UFSHCD_MAX_ID;
|
host->max_id = UFSHCD_MAX_ID;
|
||||||
host->max_lun = UFS_MAX_LUNS;
|
host->max_lun = UFS_MAX_LUNS;
|
||||||
host->max_channel = UFSHCD_MAX_CHANNEL;
|
host->max_channel = UFSHCD_MAX_CHANNEL;
|
||||||
@@ -10857,6 +10864,10 @@ int ufshcd_init(struct ufs_hba *hba, void __iomem *mmio_base, unsigned int irq)
|
|||||||
FIELD_PREP(UFSHCI_AHIBERN8_SCALE_MASK, 3);
|
FIELD_PREP(UFSHCI_AHIBERN8_SCALE_MASK, 3);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
err = ufshcd_add_scsi_host(hba);
|
||||||
|
if (err)
|
||||||
|
goto out_disable;
|
||||||
|
|
||||||
/* Hold auto suspend until async scan completes */
|
/* Hold auto suspend until async scan completes */
|
||||||
pm_runtime_get_sync(dev);
|
pm_runtime_get_sync(dev);
|
||||||
|
|
||||||
@@ -10907,10 +10918,6 @@ initialized:
|
|||||||
if (err)
|
if (err)
|
||||||
goto out_disable;
|
goto out_disable;
|
||||||
|
|
||||||
err = ufshcd_add_scsi_host(hba);
|
|
||||||
if (err)
|
|
||||||
goto out_disable;
|
|
||||||
|
|
||||||
async_schedule(ufshcd_async_scan, hba);
|
async_schedule(ufshcd_async_scan, hba);
|
||||||
ufs_sysfs_add_nodes(hba->dev);
|
ufs_sysfs_add_nodes(hba->dev);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user