Skip to content

Commit 5af28da

Browse files
minipli-ossSasha Levin
authored andcommitted
scsi: lpfc: Properly set WC for DPP mapping
[ Upstream commit bffda93 ] Using set_memory_wc() to enable write-combining for the DPP portion of the MMIO mapping is wrong as set_memory_*() is meant to operate on RAM only, not MMIO mappings. In fact, as used currently triggers a BUG_ON() with enabled CONFIG_DEBUG_VIRTUAL. Simply map the DPP region separately and in addition to the already existing mappings, avoiding any possible negative side effects for these. Fixes: 1351e69 ("scsi: lpfc: Add push-to-adapter support to sli4") Signed-off-by: Mathias Krause <minipli@grsecurity.net> Signed-off-by: Justin Tee <justin.tee@broadcom.com> Reviewed-by: Mathias Krause <minipli@grsecurity.net> Link: https://patch.msgid.link/20260212192327.141104-1-justintee8345@gmail.com Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com> Signed-off-by: Sasha Levin <sashal@kernel.org>
1 parent f611791 commit 5af28da

File tree

3 files changed

+35
-6
lines changed

3 files changed

+35
-6
lines changed

drivers/scsi/lpfc/lpfc_init.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12034,6 +12034,8 @@ lpfc_sli4_pci_mem_unset(struct lpfc_hba *phba)
1203412034
iounmap(phba->sli4_hba.conf_regs_memmap_p);
1203512035
if (phba->sli4_hba.dpp_regs_memmap_p)
1203612036
iounmap(phba->sli4_hba.dpp_regs_memmap_p);
12037+
if (phba->sli4_hba.dpp_regs_memmap_wc_p)
12038+
iounmap(phba->sli4_hba.dpp_regs_memmap_wc_p);
1203712039
break;
1203812040
case LPFC_SLI_INTF_IF_TYPE_1:
1203912041
break;

drivers/scsi/lpfc/lpfc_sli.c

Lines changed: 30 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -15981,6 +15981,32 @@ lpfc_dual_chute_pci_bar_map(struct lpfc_hba *phba, uint16_t pci_barset)
1598115981
return NULL;
1598215982
}
1598315983

15984+
static __maybe_unused void __iomem *
15985+
lpfc_dpp_wc_map(struct lpfc_hba *phba, uint8_t dpp_barset)
15986+
{
15987+
15988+
/* DPP region is supposed to cover 64-bit BAR2 */
15989+
if (dpp_barset != WQ_PCI_BAR_4_AND_5) {
15990+
lpfc_log_msg(phba, KERN_WARNING, LOG_INIT,
15991+
"3273 dpp_barset x%x != WQ_PCI_BAR_4_AND_5\n",
15992+
dpp_barset);
15993+
return NULL;
15994+
}
15995+
15996+
if (!phba->sli4_hba.dpp_regs_memmap_wc_p) {
15997+
void __iomem *dpp_map;
15998+
15999+
dpp_map = ioremap_wc(phba->pci_bar2_map,
16000+
pci_resource_len(phba->pcidev,
16001+
PCI_64BIT_BAR4));
16002+
16003+
if (dpp_map)
16004+
phba->sli4_hba.dpp_regs_memmap_wc_p = dpp_map;
16005+
}
16006+
16007+
return phba->sli4_hba.dpp_regs_memmap_wc_p;
16008+
}
16009+
1598416010
/**
1598516011
* lpfc_modify_hba_eq_delay - Modify Delay Multiplier on EQs
1598616012
* @phba: HBA structure that EQs are on.
@@ -16944,9 +16970,6 @@ lpfc_wq_create(struct lpfc_hba *phba, struct lpfc_queue *wq,
1694416970
uint8_t dpp_barset;
1694516971
uint32_t dpp_offset;
1694616972
uint8_t wq_create_version;
16947-
#ifdef CONFIG_X86
16948-
unsigned long pg_addr;
16949-
#endif
1695016973

1695116974
/* sanity check on queue memory */
1695216975
if (!wq || !cq)
@@ -17132,14 +17155,15 @@ lpfc_wq_create(struct lpfc_hba *phba, struct lpfc_queue *wq,
1713217155

1713317156
#ifdef CONFIG_X86
1713417157
/* Enable combined writes for DPP aperture */
17135-
pg_addr = (unsigned long)(wq->dpp_regaddr) & PAGE_MASK;
17136-
rc = set_memory_wc(pg_addr, 1);
17137-
if (rc) {
17158+
bar_memmap_p = lpfc_dpp_wc_map(phba, dpp_barset);
17159+
if (!bar_memmap_p) {
1713817160
lpfc_printf_log(phba, KERN_ERR, LOG_INIT,
1713917161
"3272 Cannot setup Combined "
1714017162
"Write on WQ[%d] - disable DPP\n",
1714117163
wq->queue_id);
1714217164
phba->cfg_enable_dpp = 0;
17165+
} else {
17166+
wq->dpp_regaddr = bar_memmap_p + dpp_offset;
1714317167
}
1714417168
#else
1714517169
phba->cfg_enable_dpp = 0;

drivers/scsi/lpfc/lpfc_sli4.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -785,6 +785,9 @@ struct lpfc_sli4_hba {
785785
void __iomem *dpp_regs_memmap_p; /* Kernel memory mapped address for
786786
* dpp registers
787787
*/
788+
void __iomem *dpp_regs_memmap_wc_p;/* Kernel memory mapped address for
789+
* dpp registers with write combining
790+
*/
788791
union {
789792
struct {
790793
/* IF Type 0, BAR 0 PCI cfg space reg mem map */

0 commit comments

Comments
 (0)