Skip to contentSkip to conversation

idmaengine: make FSL_EDMA and INTEL_IDMA64 depends on HAS_IOMEM

PATCH In review Sasha Levin 3 participants 8 messages Aug 22, 2023 – Aug 23, 2023

Subsystems (5)
lore
Share & tools
lore

Sasha Levin

author maintainer
#0 lore raw

PATCH 1/6 idmaengine: make FSL_EDMA and INTEL_IDMA64 depends on HAS_IOMEM

From: Baoquan He <[email protected]>

[ Upstream commit b1e213a9e31c20206f111ec664afcf31cbfe0dbb ]

On s390 systems (aka mainframes), it has classic channel devices for networking and permanent storage that are currently even more common than PCI devices. Hence it could have a fully functional s390 kernel with CONFIG_PCI=n, then the relevant iomem mapping functions [including ioremap(), devm_ioremap(), etc.] are not available.

Here let FSL_EDMA and INTEL_IDMA64 depend on HAS_IOMEM so that it won't be built to cause below compiling error if PCI is unset.

--------
ERROR: modpost: "devm_platform_ioremap_resource" [drivers/dma/fsl-edma.ko] undefined!
ERROR: modpost: "devm_platform_ioremap_resource" [drivers/dma/idma64.ko] undefined!
--------

---
 drivers/dma/Kconfig | 2 ++
 1 file changed, 2 insertions(+)
drivers/dma/Kconfig +2 -0
index 95344ae49e532..e1beddcc8c84a 100644
@@ -202,6 +202,7 @@ config FSL_DMA
 config FSL_EDMA
 	tristate "Freescale eDMA engine support"
 	depends on OF
+	depends on HAS_IOMEM
 	select DMA_ENGINE
 	select DMA_VIRTUAL_CHANNELS
 	help
@@ -271,6 +272,7 @@ config IMX_SDMA
 
 config INTEL_IDMA64
 	tristate "Intel integrated DMA 64-bit support"
+	depends on HAS_IOMEM
 	select DMA_ENGINE
 	select DMA_VIRTUAL_CHANNELS
 	help
Signature · 1 line
2.40.1
author maintainer
#1 lore raw

PATCH 2/6 scsi: lpfc: Remove reftag check in DIF paths

From: Justin Tee <[email protected]>

[ Upstream commit 8eebf0e84f0614cebc7347f7bbccba4056d77d42 ]

When preparing protection DIF I/O for DMA, the driver obtains reference tags from scsi_prot_ref_tag(). Previously, there was a wrong assumption that an all 0xffffffff value meant error and thus the driver failed the I/O. This patch removes the evaluation code and accepts whatever the upper layer returns.

---
 drivers/scsi/lpfc/lpfc_scsi.c | 20 +++-----------------
 1 file changed, 3 insertions(+), 17 deletions(-)
drivers/scsi/lpfc/lpfc_scsi.c +3 -17
index edae98a35fc3b..4813adec0301d 100644
@@ -117,8 +117,6 @@ lpfc_sli4_set_rsp_sgl_last(struct lpfc_hba *phba,
 	}
 }
 
-#define LPFC_INVALID_REFTAG ((u32)-1)
-
 /**
  * lpfc_update_stats - Update statistical data for the command completion
  * @vport: The virtual port on which this call is executing.
@@ -1042,8 +1040,6 @@ lpfc_bg_err_inject(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 
 	sgpe = scsi_prot_sglist(sc);
 	lba = scsi_prot_ref_tag(sc);
-	if (lba == LPFC_INVALID_REFTAG)
-		return 0;
 
 	/* First check if we need to match the LBA */
 	if (phba->lpfc_injerr_lba != LPFC_INJERR_LBA_OFF) {
@@ -1624,8 +1620,6 @@ lpfc_bg_setup_bpl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 
 	/* extract some info from the scsi command for pde*/
 	reftag = scsi_prot_ref_tag(sc);
-	if (reftag == LPFC_INVALID_REFTAG)
-		goto out;
 
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
 	rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
@@ -1787,8 +1781,6 @@ lpfc_bg_setup_bpl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 	/* extract some info from the scsi command */
 	blksize = scsi_prot_interval(sc);
 	reftag = scsi_prot_ref_tag(sc);
-	if (reftag == LPFC_INVALID_REFTAG)
-		goto out;
 
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
 	rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
@@ -2018,8 +2010,6 @@ lpfc_bg_setup_sgl(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 
 	/* extract some info from the scsi command for pde*/
 	reftag = scsi_prot_ref_tag(sc);
-	if (reftag == LPFC_INVALID_REFTAG)
-		goto out;
 
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
 	rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
@@ -2219,8 +2209,6 @@ lpfc_bg_setup_sgl_prot(struct lpfc_hba *phba, struct scsi_cmnd *sc,
 	/* extract some info from the scsi command */
 	blksize = scsi_prot_interval(sc);
 	reftag = scsi_prot_ref_tag(sc);
-	if (reftag == LPFC_INVALID_REFTAG)
-		goto out;
 
 #ifdef CONFIG_SCSI_LPFC_DEBUG_FS
 	rc = lpfc_bg_err_inject(phba, sc, &reftag, NULL, 1);
@@ -2812,8 +2800,6 @@ lpfc_calc_bg_err(struct lpfc_hba *phba, struct lpfc_io_buf *lpfc_cmd)
 
 		src = (struct scsi_dif_tuple *)sg_virt(sgpe);
 		start_ref_tag = scsi_prot_ref_tag(cmd);
-		if (start_ref_tag == LPFC_INVALID_REFTAG)
-			goto out;
 		start_app_tag = src->app_tag;
 		len = sgpe->length;
 		while (src && protsegcnt) {
@@ -3660,11 +3646,11 @@ lpfc_bg_scsi_prep_dma_buf_s4(struct lpfc_hba *phba,
 			     scsi_cmnd->sc_data_direction);
 
 	lpfc_printf_log(phba, KERN_ERR, LOG_TRACE_EVENT,
-			"9084 Cannot setup S/G List for HBA"
-			"IO segs %d/%d SGL %d SCSI %d: %d %d\n",
+			"9084 Cannot setup S/G List for HBA "
+			"IO segs %d/%d SGL %d SCSI %d: %d %d %d\n",
 			lpfc_cmd->seg_cnt, lpfc_cmd->prot_seg_cnt,
 			phba->cfg_total_seg_cnt, phba->cfg_sg_seg_cnt,
-			prot_group_type, num_sge);
+			prot_group_type, num_sge, ret);
 
 	lpfc_cmd->seg_cnt = 0;
 	lpfc_cmd->prot_seg_cnt = 0;
Signature · 1 line
2.40.1
author maintainer
#2 lore raw

PATCH 3/6 scsi: qedi: Fix potential deadlock on &qedi_percpu->p_work_lock

In reply to Sasha Levin

From: Chengfeng Ye <[email protected]>

[ Upstream commit dd64f80587190265ca8a0f4be6c64c2fda6d3ac2 ]

As &qedi_percpu->p_work_lock is acquired by hard IRQ qedi_msix_handler(), other acquisitions of the same lock under process context should disable IRQ, otherwise deadlock could happen if the IRQ preempts the execution while the lock is held in process context on the same CPU.

qedi_cpu_offline() is one such function which acquires the lock in process context.

[Deadlock Scenario]
qedi_cpu_offline()

    ->spin_lock(&p->p_work_lock)
        <irq>
        ->qedi_msix_handler()
        ->edi_process_completions()
        ->spin_lock_irqsave(&p->p_work_lock, flags); (deadlock here)

This flaw was found by an experimental static analysis tool I am developing for IRQ-related deadlocks.

The tentative patch fix the potential deadlock by spin_lock_irqsave() under process context.

---
 drivers/scsi/qedi/qedi_main.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)
drivers/scsi/qedi/qedi_main.c +3 -2
index d2fe8ae97abc9..b36edbef5b82f 100644
@@ -1979,8 +1979,9 @@ static int qedi_cpu_offline(unsigned int cpu)
 	struct qedi_percpu_s *p = this_cpu_ptr(&qedi_percpu);
 	struct qedi_work *work, *tmp;
 	struct task_struct *thread;
+	unsigned long flags;
 
-	spin_lock_bh(&p->p_work_lock);
+	spin_lock_irqsave(&p->p_work_lock, flags);
 	thread = p->iothread;
 	p->iothread = NULL;
 
@@ -1991,7 +1992,7 @@ static int qedi_cpu_offline(unsigned int cpu)
 			kfree(work);
 	}
 
-	spin_unlock_bh(&p->p_work_lock);
+	spin_unlock_irqrestore(&p->p_work_lock, flags);
 	if (thread)
 		kthread_stop(thread);
 	return 0;
Signature · 1 line
2.40.1
author maintainer
#3 lore raw

PATCH 4/6 net: hns3: restore user pause configure when disable autoneg

In reply to Sasha Levin

From: Jian Shen <[email protected]>

[ Upstream commit 15159ec0c831b565820c2de05114ea1b4cf07681 ]

Restore the mac pause state to user configuration when autoneg is disabled

---
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c | 5 ++++-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c   | 2 +-
 drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h   | 1 +
 3 files changed, 6 insertions(+), 2 deletions(-)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_main.c +4 -1
index 847ebb31d4701..1d424b1ee6cd3 100644
@@ -10993,9 +10993,12 @@ int hclge_cfg_flowctrl(struct hclge_dev *hdev)
 	u32 rx_pause, tx_pause;
 	u8 flowctl;
 
-	if (!phydev->link || !phydev->autoneg)
+	if (!phydev->link)
 		return 0;
 
+	if (!phydev->autoneg)
+		return hclge_mac_pause_setup_hw(hdev);
+
 	local_advertising = linkmode_adv_to_lcl_adv_t(phydev->advertising);
 
 	if (phydev->pause)
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.c +1 -1
index e7cb6a81e5b67..f5fe5e437bcd1 100644
@@ -1429,7 +1429,7 @@ static int hclge_bp_setup_hw(struct hclge_dev *hdev, u8 tc)
 	return 0;
 }
 
-static int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
+int hclge_mac_pause_setup_hw(struct hclge_dev *hdev)
 {
 	bool tx_en, rx_en;
 
drivers/net/ethernet/hisilicon/hns3/hns3pf/hclge_tm.h +1 -0
index 2c5256d7f9962..e1f2feaba5454 100644
@@ -233,6 +233,7 @@ int hclge_pfc_pause_en_cfg(struct hclge_dev *hdev, u8 tx_rx_bitmap,
 			   u8 pfc_bitmap);
 int hclge_mac_pause_en_cfg(struct hclge_dev *hdev, bool tx, bool rx);
 int hclge_pause_addr_cfg(struct hclge_dev *hdev, const u8 *mac_addr);
+int hclge_mac_pause_setup_hw(struct hclge_dev *hdev);
 void hclge_pfc_rx_stats_get(struct hclge_dev *hdev, u64 *stats);
 void hclge_pfc_tx_stats_get(struct hclge_dev *hdev, u64 *stats);
 int hclge_tm_qs_shaper_cfg(struct hclge_vport *vport, int max_tx_rate);
Signature · 1 line
2.40.1
author maintainer
#4 lore raw

PATCH 5/6 drm/amdgpu: Match against exact bootloader status

In reply to Sasha Levin

From: Lijo Lazar <[email protected]>

[ Upstream commit d3de41ee5febe5c2d9989fe9810bce2bb54a3a8e ]

On PSP v13.x ASICs, boot loader will set only the MSB to 1 and clear the least significant bits for any command submission. Hence match against the exact register value, otherwise a register value of all 0xFFs also could falsely indicate that boot loader is ready. Also, from PSP v13.0.6 and newer, bits[7:0] will be used to indicate command error status.

---
 drivers/gpu/drm/amd/amdgpu/psp_v13_0.c | 15 ++++++++-------
 1 file changed, 8 insertions(+), 7 deletions(-)
drivers/gpu/drm/amd/amdgpu/psp_v13_0.c +8 -7
index 47a500f64db20..bcf356df1ef33 100644
@@ -101,14 +101,15 @@ static int psp_v13_0_wait_for_bootloader(struct psp_context *psp)
 	int ret;
 	int retry_loop;
 
+	/* Wait for bootloader to signify that it is ready having bit 31 of
+	 * C2PMSG_35 set to 1. All other bits are expected to be cleared.
+	 * If there is an error in processing command, bits[7:0] will be set.
+	 * This is applicable for PSP v13.0.6 and newer.
+	 */
 	for (retry_loop = 0; retry_loop < 10; retry_loop++) {
-		/* Wait for bootloader to signify that is
-		    ready having bit 31 of C2PMSG_35 set to 1 */
-		ret = psp_wait_for(psp,
-				   SOC15_REG_OFFSET(MP0, 0, regMP0_SMN_C2PMSG_35),
-				   0x80000000,
-				   0x80000000,
-				   false);
+		ret = psp_wait_for(
+			psp, SOC15_REG_OFFSET(MP0, 0, regMP0_SMN_C2PMSG_35),
+			0x80000000, 0xffffffff, false);
 
 		if (ret == 0)
 			return 0;
Signature · 1 line
2.40.1
author maintainer
#5 lore raw

PATCH 6/6 drm/amdkfd: ignore crat by default

In reply to Sasha Levin

From: Alex Deucher <[email protected]>

[ Upstream commit a6dea2d64ff92851e68cd4e20a35f6534286e016 ]

We are dropping the IOMMUv2 path, so no need to enable this. It's often buggy on consumer platforms anyway.

---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0 -4
index e574aa32a111d..46dfd9baeb013 100644
@@ -1523,11 +1523,7 @@ static bool kfd_ignore_crat(void)
 	if (ignore_crat)
 		return true;
 
-#ifndef KFD_SUPPORT_IOMMU_V2
 	ret = true;
-#else
-	ret = false;
-#endif
 
 	return ret;
 }
Signature · 1 line
2.40.1
#6 lore raw

RE: [PATCH AUTOSEL 5.15 6/6] drm/amdkfd: ignore crat by default

[Public]

Quoted 11 lines

-----Original Message-----
From: Sasha Levin <[email protected]>
Sent: Tuesday, August 22, 2023 7:37 AM
To: [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Kuehling, Felix <[email protected]>; Koenig, Christian <[email protected]>; Mike Lothian <[email protected]>; Sasha Levin <[email protected]>; Pan, Xinhui <[email protected]>; [email protected]; [email protected]; amd- [email protected]; [email protected]
Subject: [PATCH AUTOSEL 5.15 6/6] drm/amdkfd: ignore crat by default

Quoted 6 lines

From: Alex Deucher <[email protected]>

[ Upstream commit a6dea2d64ff92851e68cd4e20a35f6534286e016 ]

We are dropping the IOMMUv2 path, so no need to enable this. It's often buggy on consumer platforms anyway.

This is not needed for stable.

Alex

Quoted 29 lines
---
 drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 4 ----
 1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0 -5
index e574aa32a111d..46dfd9baeb013 100644
@@ -1523,11 +1523,7 @@ static bool kfd_ignore_crat(void)
      if (ignore_crat)
              return true;
 
-#ifndef KFD_SUPPORT_IOMMU_V2
      ret = true;
-#else
-     ret = false;
-#endif
 
      return ret;
 }
--

2.40.1

#7 lore raw

Re: [PATCH AUTOSEL 5.15 6/6] drm/amdkfd: ignore crat by default

Quoted 13 lines · Alexander

[Public]

Quoted 11 lines

-----Original Message-----
From: Sasha Levin <[email protected]>
Sent: Tuesday, August 22, 2023 7:37 AM
To: [email protected]; [email protected]
Cc: Deucher, Alexander <[email protected]>; Kuehling, Felix <[email protected]>; Koenig, Christian <[email protected]>; Mike Lothian <[email protected]>; Sasha Levin <[email protected]>; Pan, Xinhui <[email protected]>; [email protected]; [email protected]; amd- [email protected]; [email protected]
Subject: [PATCH AUTOSEL 5.15 6/6] drm/amdkfd: ignore crat by default

Quoted 7 lines
Quoted 6 lines

From: Alex Deucher <[email protected]>

[ Upstream commit a6dea2d64ff92851e68cd4e20a35f6534286e016 ]

We are dropping the IOMMUv2 path, so no need to enable this. It's often buggy on consumer platforms anyway.

This is not needed for stable.

I agree. I was about to comment in the 5.10 patch as well.

Regards,
  Felix

Quoted 31 lines

Alex

Quoted 28 lines
---
  drivers/gpu/drm/amd/amdkfd/kfd_crat.c | 4 ----
  1 file changed, 4 deletions(-)
drivers/gpu/drm/amd/amdkfd/kfd_crat.c +0 -5
index e574aa32a111d..46dfd9baeb013 100644
@@ -1523,11 +1523,7 @@ static bool kfd_ignore_crat(void)
       if (ignore_crat)
               return true;
 
-#ifndef KFD_SUPPORT_IOMMU_V2
       ret = true;
-#else
-     ret = false;
-#endif
 
       return ret;
  }
--

2.40.1