Skip to content

Commit efa1fca

Browse files
damien-lemoalmartinkpetersen
authored andcommitted
scsi: pm8001: Remove PM8001_USE_MSIX
The pm8001 driver does not compile if PM8001_USE_MSIX is not defined in pm8001_sas.h because various fields and functions conditionally defined are used unconditionally without a "#ifdef PM8001_USE_MSIX" protection. This macro is rather useless anyway and not convenient as diabling MSI-X use requires recompiling the driver. Remove this macro and replace it with the bool module parameter "use_msix" which defaults to true. The use of MSI-X interrupts for an adapter is gated by this module parameter for adapters that actually support MSI-X. The "use_msix" boolean field is added to struct pm8001_hba_info and all code defined depending on PM8001_USE_MSIX is modified to rely on pm8001_hba_info->use_msix instead. Signed-off-by: Damien Le Moal <[email protected]> Link: https://lore.kernel.org/r/[email protected] Acked-by: Jack Wang <[email protected]> Signed-off-by: Martin K. Petersen <[email protected]>
1 parent d93e1ac commit efa1fca

File tree

4 files changed

+67
-55
lines changed

4 files changed

+67
-55
lines changed

drivers/scsi/pm8001/pm8001_hwi.c

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1188,13 +1188,14 @@ void pm8001_chip_iounmap(struct pm8001_hba_info *pm8001_ha)
11881188
static void
11891189
pm8001_chip_interrupt_enable(struct pm8001_hba_info *pm8001_ha, u8 vec)
11901190
{
1191-
#ifdef PM8001_USE_MSIX
1192-
pm8001_cw32(pm8001_ha, 0, MSIX_TABLE_BASE, MSIX_INTERRUPT_ENABLE);
1193-
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, 1);
1194-
#else
1195-
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_CLEAR_ALL);
1196-
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, ODCR_CLEAR_ALL);
1197-
#endif
1191+
if (pm8001_ha->use_msix) {
1192+
pm8001_cw32(pm8001_ha, 0, MSIX_TABLE_BASE,
1193+
MSIX_INTERRUPT_ENABLE);
1194+
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, 1);
1195+
} else {
1196+
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_CLEAR_ALL);
1197+
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, ODCR_CLEAR_ALL);
1198+
}
11981199
}
11991200

12001201
/**
@@ -1205,11 +1206,11 @@ pm8001_chip_interrupt_enable(struct pm8001_hba_info *pm8001_ha, u8 vec)
12051206
static void
12061207
pm8001_chip_interrupt_disable(struct pm8001_hba_info *pm8001_ha, u8 vec)
12071208
{
1208-
#ifdef PM8001_USE_MSIX
1209-
pm8001_cw32(pm8001_ha, 0, MSIX_TABLE_BASE, MSIX_INTERRUPT_DISABLE);
1210-
#else
1211-
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_MASK_ALL);
1212-
#endif
1209+
if (pm8001_ha->use_msix)
1210+
pm8001_cw32(pm8001_ha, 0, MSIX_TABLE_BASE,
1211+
MSIX_INTERRUPT_DISABLE);
1212+
else
1213+
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_MASK_ALL);
12131214
}
12141215

12151216
/**
@@ -4252,16 +4253,15 @@ static int pm8001_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha,
42524253

42534254
static u32 pm8001_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha)
42544255
{
4255-
#ifdef PM8001_USE_MSIX
4256-
return 1;
4257-
#else
42584256
u32 value;
42594257

4258+
if (pm8001_ha->use_msix)
4259+
return 1;
4260+
42604261
value = pm8001_cr32(pm8001_ha, 0, MSGU_ODR);
42614262
if (value)
42624263
return 1;
42634264
return 0;
4264-
#endif
42654265
}
42664266

42674267
/**

drivers/scsi/pm8001/pm8001_init.c

Lines changed: 28 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,10 @@ MODULE_PARM_DESC(link_rate, "Enable link rate.\n"
5656
" 4: Link rate 6.0G\n"
5757
" 8: Link rate 12.0G\n");
5858

59+
bool pm8001_use_msix = true;
60+
module_param_named(use_msix, pm8001_use_msix, bool, 0444);
61+
MODULE_PARM_DESC(zoned, "Use MSIX interrupts. Default: true");
62+
5963
static struct scsi_transport_template *pm8001_stt;
6064
static int pm8001_init_ccb_tag(struct pm8001_hba_info *);
6165

@@ -961,7 +965,6 @@ static int pm8001_configure_phy_settings(struct pm8001_hba_info *pm8001_ha)
961965
}
962966
}
963967

964-
#ifdef PM8001_USE_MSIX
965968
/**
966969
* pm8001_setup_msix - enable MSI-X interrupt
967970
* @pm8001_ha: our ha struct.
@@ -1043,7 +1046,6 @@ static u32 pm8001_request_msix(struct pm8001_hba_info *pm8001_ha)
10431046

10441047
return rc;
10451048
}
1046-
#endif
10471049

10481050
/**
10491051
* pm8001_request_irq - register interrupt
@@ -1052,25 +1054,32 @@ static u32 pm8001_request_msix(struct pm8001_hba_info *pm8001_ha)
10521054
static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
10531055
{
10541056
struct pci_dev *pdev = pm8001_ha->pdev;
1055-
#ifdef PM8001_USE_MSIX
10561057
int rc;
10571058

1058-
if (pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
1059+
if (pm8001_use_msix && pci_find_capability(pdev, PCI_CAP_ID_MSIX)) {
10591060
rc = pm8001_setup_msix(pm8001_ha);
10601061
if (rc) {
10611062
pm8001_dbg(pm8001_ha, FAIL,
10621063
"pm8001_setup_irq failed [ret: %d]\n", rc);
10631064
return rc;
10641065
}
10651066

1066-
if (pdev->msix_cap && pci_msi_enabled())
1067-
return pm8001_request_msix(pm8001_ha);
1067+
if (!pdev->msix_cap || !pci_msi_enabled())
1068+
goto use_intx;
1069+
1070+
rc = pm8001_request_msix(pm8001_ha);
1071+
if (rc)
1072+
return rc;
1073+
1074+
pm8001_ha->use_msix = true;
1075+
1076+
return 0;
10681077
}
10691078

1079+
use_intx:
1080+
/* Initialize the INT-X interrupt */
10701081
pm8001_dbg(pm8001_ha, INIT, "MSIX not supported!!!\n");
1071-
#endif
1072-
1073-
/* initialize the INT-X interrupt */
1082+
pm8001_ha->use_msix = false;
10741083
pm8001_ha->irq_vector[0].irq_id = 0;
10751084
pm8001_ha->irq_vector[0].drv_inst = pm8001_ha;
10761085

@@ -1081,20 +1090,22 @@ static u32 pm8001_request_irq(struct pm8001_hba_info *pm8001_ha)
10811090

10821091
static void pm8001_free_irq(struct pm8001_hba_info *pm8001_ha)
10831092
{
1084-
#ifdef PM8001_USE_MSIX
10851093
struct pci_dev *pdev = pm8001_ha->pdev;
10861094
int i;
10871095

1088-
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1089-
synchronize_irq(pci_irq_vector(pdev, i));
1096+
if (pm8001_ha->use_msix) {
1097+
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1098+
synchronize_irq(pci_irq_vector(pdev, i));
10901099

1091-
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1092-
free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]);
1100+
for (i = 0; i < pm8001_ha->number_of_intr; i++)
1101+
free_irq(pci_irq_vector(pdev, i), &pm8001_ha->irq_vector[i]);
10931102

1094-
pci_free_irq_vectors(pdev);
1095-
#else
1103+
pci_free_irq_vectors(pdev);
1104+
return;
1105+
}
1106+
1107+
/* INT-X */
10961108
free_irq(pm8001_ha->irq, pm8001_ha->sas);
1097-
#endif
10981109
}
10991110

11001111
/**

drivers/scsi/pm8001/pm8001_sas.h

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,9 @@ do { \
8383
pm8001_info(HBA, fmt, ##__VA_ARGS__); \
8484
} while (0)
8585

86+
extern bool pm8001_use_msix;
87+
8688
#define PM8001_USE_TASKLET
87-
#define PM8001_USE_MSIX
8889
#define PM8001_READ_VPD
8990

9091

@@ -520,11 +521,11 @@ struct pm8001_hba_info {
520521
struct pm8001_device *devices;
521522
struct pm8001_ccb_info *ccb_info;
522523
u32 ccb_count;
523-
#ifdef PM8001_USE_MSIX
524+
525+
bool use_msix;
524526
int number_of_intr;/*will be used in remove()*/
525527
char intr_drvname[PM8001_MAX_MSIX_VEC]
526528
[PM8001_NAME_LENGTH+1+3+1];
527-
#endif
528529
#ifdef PM8001_USE_TASKLET
529530
struct tasklet_struct tasklet[PM8001_MAX_MSIX_VEC];
530531
#endif

drivers/scsi/pm8001/pm80xx_hwi.c

Lines changed: 19 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1722,16 +1722,16 @@ static void pm80xx_hw_chip_rst(struct pm8001_hba_info *pm8001_ha)
17221722
static void
17231723
pm80xx_chip_interrupt_enable(struct pm8001_hba_info *pm8001_ha, u8 vec)
17241724
{
1725-
#ifdef PM8001_USE_MSIX
1725+
if (!pm8001_ha->use_msix) {
1726+
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_CLEAR_ALL);
1727+
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, ODCR_CLEAR_ALL);
1728+
return;
1729+
}
1730+
17261731
if (vec < 32)
17271732
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_CLR, 1U << vec);
17281733
else
1729-
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_CLR_U,
1730-
1U << (vec - 32));
1731-
#else
1732-
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, ODMR_CLEAR_ALL);
1733-
pm8001_cw32(pm8001_ha, 0, MSGU_ODCR, ODCR_CLEAR_ALL);
1734-
#endif
1734+
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_CLR_U, 1U << (vec - 32));
17351735
}
17361736

17371737
/**
@@ -1742,19 +1742,20 @@ pm80xx_chip_interrupt_enable(struct pm8001_hba_info *pm8001_ha, u8 vec)
17421742
static void
17431743
pm80xx_chip_interrupt_disable(struct pm8001_hba_info *pm8001_ha, u8 vec)
17441744
{
1745-
#ifdef PM8001_USE_MSIX
1745+
if (!pm8001_ha->use_msix) {
1746+
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_CLR, ODMR_MASK_ALL);
1747+
return;
1748+
}
1749+
17461750
if (vec == 0xFF) {
17471751
/* disable all vectors 0-31, 32-63 */
17481752
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, 0xFFFFFFFF);
17491753
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_U, 0xFFFFFFFF);
1750-
} else if (vec < 32)
1754+
} else if (vec < 32) {
17511755
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR, 1U << vec);
1752-
else
1753-
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_U,
1754-
1U << (vec - 32));
1755-
#else
1756-
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_CLR, ODMR_MASK_ALL);
1757-
#endif
1756+
} else {
1757+
pm8001_cw32(pm8001_ha, 0, MSGU_ODMR_U, 1U << (vec - 32));
1758+
}
17581759
}
17591760

17601761
/**
@@ -4781,16 +4782,15 @@ static int pm80xx_chip_phy_ctl_req(struct pm8001_hba_info *pm8001_ha,
47814782

47824783
static u32 pm80xx_chip_is_our_interrupt(struct pm8001_hba_info *pm8001_ha)
47834784
{
4784-
#ifdef PM8001_USE_MSIX
4785-
return 1;
4786-
#else
47874785
u32 value;
47884786

4787+
if (pm8001_ha->use_msix)
4788+
return 1;
4789+
47894790
value = pm8001_cr32(pm8001_ha, 0, MSGU_ODR);
47904791
if (value)
47914792
return 1;
47924793
return 0;
4793-
#endif
47944794
}
47954795

47964796
/**

0 commit comments

Comments
 (0)