Message ID | 20240910-topic-ufs-enhancements-v1-4-3ee0bffacc64@linaro.org |
---|---|
State | Superseded |
Headers | show |
Series | ufs: enhancements to support Qualcomm UFS controllers | expand |
On 10/09/24 14:50, Neil Armstrong wrote: > Now we have proper flush and invalidate helpers, we can use them > directly to operate on the scsi_cmd data. > > Likewise, we do not need to flush then invalidate, just flush _or_ > invalidate depending on the data direction. > > Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> > --- > drivers/ufs/ufs.c | 14 ++++---------- > 1 file changed, 4 insertions(+), 10 deletions(-) > > diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c > index 5845fd694d3..d99dcdef7d0 100644 > --- a/drivers/ufs/ufs.c > +++ b/drivers/ufs/ufs.c > @@ -1468,7 +1468,6 @@ static void prepare_prdt_table(struct ufs_hba *hba, struct scsi_cmd *pccb) > { > struct utp_transfer_req_desc *req_desc = hba->utrdl; > struct ufshcd_sg_entry *prd_table = hba->ucd_prdt_ptr; > - uintptr_t aaddr = (uintptr_t)(pccb->pdata) & ~(ARCH_DMA_MINALIGN - 1); > ulong datalen = pccb->datalen; > int table_length; > u8 *buf; > @@ -1480,15 +1479,6 @@ static void prepare_prdt_table(struct ufs_hba *hba, struct scsi_cmd *pccb) > return; > } > > - if (pccb->dma_dir == DMA_TO_DEVICE) { /* Write to device */ > - flush_dcache_range(aaddr, > - ALIGN((uintptr_t)pccb->pdata + datalen, ARCH_DMA_MINALIGN)); > - } > - > - /* In any case, invalidate cache to avoid stale data in it. */ > - invalidate_dcache_range(aaddr, > - ALIGN((uintptr_t)pccb->pdata + datalen, ARCH_DMA_MINALIGN)); > - > table_length = DIV_ROUND_UP(pccb->datalen, MAX_PRDT_ENTRY); > buf = pccb->pdata; > i = table_length; > @@ -1517,8 +1507,12 @@ static int ufs_scsi_exec(struct udevice *scsi_dev, struct scsi_cmd *pccb) > ufshcd_prepare_utp_scsi_cmd_upiu(hba, pccb, upiu_flags); > prepare_prdt_table(hba, pccb); > > + ufshcd_cache_flush(pccb->pdata, pccb->datalen); > + > ufshcd_send_command(hba, TASK_TAG); > > + ufshcd_cache_invalidate(pccb->pdata, pccb->datalen); > + > ocs = ufshcd_get_tr_ocs(hba); > switch (ocs) { > case OCS_SUCCESS: > Reviewed-by: Neha Malcom Francis <n-francis@ti.com>
diff --git a/drivers/ufs/ufs.c b/drivers/ufs/ufs.c index 5845fd694d3..d99dcdef7d0 100644 --- a/drivers/ufs/ufs.c +++ b/drivers/ufs/ufs.c @@ -1468,7 +1468,6 @@ static void prepare_prdt_table(struct ufs_hba *hba, struct scsi_cmd *pccb) { struct utp_transfer_req_desc *req_desc = hba->utrdl; struct ufshcd_sg_entry *prd_table = hba->ucd_prdt_ptr; - uintptr_t aaddr = (uintptr_t)(pccb->pdata) & ~(ARCH_DMA_MINALIGN - 1); ulong datalen = pccb->datalen; int table_length; u8 *buf; @@ -1480,15 +1479,6 @@ static void prepare_prdt_table(struct ufs_hba *hba, struct scsi_cmd *pccb) return; } - if (pccb->dma_dir == DMA_TO_DEVICE) { /* Write to device */ - flush_dcache_range(aaddr, - ALIGN((uintptr_t)pccb->pdata + datalen, ARCH_DMA_MINALIGN)); - } - - /* In any case, invalidate cache to avoid stale data in it. */ - invalidate_dcache_range(aaddr, - ALIGN((uintptr_t)pccb->pdata + datalen, ARCH_DMA_MINALIGN)); - table_length = DIV_ROUND_UP(pccb->datalen, MAX_PRDT_ENTRY); buf = pccb->pdata; i = table_length; @@ -1517,8 +1507,12 @@ static int ufs_scsi_exec(struct udevice *scsi_dev, struct scsi_cmd *pccb) ufshcd_prepare_utp_scsi_cmd_upiu(hba, pccb, upiu_flags); prepare_prdt_table(hba, pccb); + ufshcd_cache_flush(pccb->pdata, pccb->datalen); + ufshcd_send_command(hba, TASK_TAG); + ufshcd_cache_invalidate(pccb->pdata, pccb->datalen); + ocs = ufshcd_get_tr_ocs(hba); switch (ocs) { case OCS_SUCCESS:
Now we have proper flush and invalidate helpers, we can use them directly to operate on the scsi_cmd data. Likewise, we do not need to flush then invalidate, just flush _or_ invalidate depending on the data direction. Signed-off-by: Neil Armstrong <neil.armstrong@linaro.org> --- drivers/ufs/ufs.c | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-)