Skip to content

Commit 78bc671

Browse files
bvanasschemartinkpetersen
authored andcommitted
scsi: ufs: core: Make DMA mask configuration more flexible
Replace UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS with ufs_hba_variant_ops::set_dma_mask. Update the Renesas driver accordingly. This patch enables supporting other configurations than 32-bit or 64-bit DMA addresses, e.g. 36-bit DMA addresses. Signed-off-by: Bart Van Assche <[email protected]> Link: https://lore.kernel.org/r/[email protected] Reviewed-by: Avri Altman <[email protected]> Reviewed-by: Peter Wang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent 6c1143b commit 78bc671

File tree

3 files changed

+13
-9
lines changed

3 files changed

+13
-9
lines changed

drivers/ufs/core/ufshcd.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2401,8 +2401,6 @@ static inline int ufshcd_hba_capabilities(struct ufs_hba *hba)
24012401
int err;
24022402

24032403
hba->capabilities = ufshcd_readl(hba, REG_CONTROLLER_CAPABILITIES);
2404-
if (hba->quirks & UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS)
2405-
hba->capabilities &= ~MASK_64_ADDRESSING_SUPPORT;
24062404

24072405
/* nutrs and nutmrs are 0 based values */
24082406
hba->nutrs = (hba->capabilities & MASK_TRANSFER_REQUESTS_SLOTS_SDB) + 1;
@@ -10315,6 +10313,8 @@ EXPORT_SYMBOL_GPL(ufshcd_dealloc_host);
1031510313
*/
1031610314
static int ufshcd_set_dma_mask(struct ufs_hba *hba)
1031710315
{
10316+
if (hba->vops && hba->vops->set_dma_mask)
10317+
return hba->vops->set_dma_mask(hba);
1031810318
if (hba->capabilities & MASK_64_ADDRESSING_SUPPORT) {
1031910319
if (!dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(64)))
1032010320
return 0;

drivers/ufs/host/ufs-renesas.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
#include <linux/clk.h>
99
#include <linux/delay.h>
10+
#include <linux/dma-mapping.h>
1011
#include <linux/err.h>
1112
#include <linux/iopoll.h>
1213
#include <linux/kernel.h>
@@ -364,14 +365,20 @@ static int ufs_renesas_init(struct ufs_hba *hba)
364365
return -ENOMEM;
365366
ufshcd_set_variant(hba, priv);
366367

367-
hba->quirks |= UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS | UFSHCD_QUIRK_HIBERN_FASTAUTO;
368+
hba->quirks |= UFSHCD_QUIRK_HIBERN_FASTAUTO;
368369

369370
return 0;
370371
}
371372

373+
static int ufs_renesas_set_dma_mask(struct ufs_hba *hba)
374+
{
375+
return dma_set_mask_and_coherent(hba->dev, DMA_BIT_MASK(32));
376+
}
377+
372378
static const struct ufs_hba_variant_ops ufs_renesas_vops = {
373379
.name = "renesas",
374380
.init = ufs_renesas_init,
381+
.set_dma_mask = ufs_renesas_set_dma_mask,
375382
.setup_clocks = ufs_renesas_setup_clocks,
376383
.hce_enable_notify = ufs_renesas_hce_enable_notify,
377384
.dbg_register_dump = ufs_renesas_dbg_register_dump,

include/ufs/ufshcd.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -299,6 +299,8 @@ struct ufs_pwr_mode_info {
299299
* @max_num_rtt: maximum RTT supported by the host
300300
* @init: called when the driver is initialized
301301
* @exit: called to cleanup everything done in init
302+
* @set_dma_mask: For setting another DMA mask than indicated by the 64AS
303+
* capability bit.
302304
* @get_ufs_hci_version: called to get UFS HCI version
303305
* @clk_scale_notify: notifies that clks are scaled up/down
304306
* @setup_clocks: called before touching any of the controller registers
@@ -341,6 +343,7 @@ struct ufs_hba_variant_ops {
341343
int (*init)(struct ufs_hba *);
342344
void (*exit)(struct ufs_hba *);
343345
u32 (*get_ufs_hci_version)(struct ufs_hba *);
346+
int (*set_dma_mask)(struct ufs_hba *);
344347
int (*clk_scale_notify)(struct ufs_hba *, bool,
345348
enum ufs_notify_change_status);
346349
int (*setup_clocks)(struct ufs_hba *, bool,
@@ -623,12 +626,6 @@ enum ufshcd_quirks {
623626
*/
624627
UFSHCD_QUIRK_SKIP_PH_CONFIGURATION = 1 << 16,
625628

626-
/*
627-
* This quirk needs to be enabled if the host controller has
628-
* 64-bit addressing supported capability but it doesn't work.
629-
*/
630-
UFSHCD_QUIRK_BROKEN_64BIT_ADDRESS = 1 << 17,
631-
632629
/*
633630
* This quirk needs to be enabled if the host controller has
634631
* auto-hibernate capability but it's FASTAUTO only.

0 commit comments

Comments
 (0)