Skip to content

Commit 3eb5ca8

Browse files
committed
Merge tag 'cxl-fixes-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl
Pull cxl fixes from Dan Williams: "A build regression fix, a device compatibility fix, and an original bug preventing creation of large (16 device) interleave sets: - Fix unit test build regression fallout from global "missing-prototypes" change - Fix compatibility with devices that do not support interrupts - Fix overflow when calculating the capacity of large interleave sets" * tag 'cxl-fixes-6.8-rc2' of git://git.kernel.org/pub/scm/linux/kernel/git/cxl/cxl: cxl/region:Fix overflow issue in alloc_hpa() cxl/pci: Skip irq features if MSI/MSI-X are not supported tools/testing/nvdimm: Disable "missing prototypes / declarations" warnings tools/testing/cxl: Disable "missing prototypes / declarations" warnings
2 parents 4854cf9 + d76779d commit 3eb5ca8

File tree

5 files changed

+23
-13
lines changed

5 files changed

+23
-13
lines changed

drivers/cxl/core/region.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
525525
struct cxl_root_decoder *cxlrd = to_cxl_root_decoder(cxlr->dev.parent);
526526
struct cxl_region_params *p = &cxlr->params;
527527
struct resource *res;
528-
u32 remainder = 0;
528+
u64 remainder = 0;
529529

530530
lockdep_assert_held_write(&cxl_region_rwsem);
531531

@@ -545,7 +545,7 @@ static int alloc_hpa(struct cxl_region *cxlr, resource_size_t size)
545545
(cxlr->mode == CXL_DECODER_PMEM && uuid_is_null(&p->uuid)))
546546
return -ENXIO;
547547

548-
div_u64_rem(size, SZ_256M * p->interleave_ways, &remainder);
548+
div64_u64_rem(size, (u64)SZ_256M * p->interleave_ways, &remainder);
549549
if (remainder)
550550
return -EINVAL;
551551

drivers/cxl/pci.c

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,7 @@ static int cxl_pci_mbox_send(struct cxl_memdev_state *mds,
382382
return rc;
383383
}
384384

385-
static int cxl_pci_setup_mailbox(struct cxl_memdev_state *mds)
385+
static int cxl_pci_setup_mailbox(struct cxl_memdev_state *mds, bool irq_avail)
386386
{
387387
struct cxl_dev_state *cxlds = &mds->cxlds;
388388
const int cap = readl(cxlds->regs.mbox + CXLDEV_MBOX_CAPS_OFFSET);
@@ -441,7 +441,7 @@ static int cxl_pci_setup_mailbox(struct cxl_memdev_state *mds)
441441
INIT_DELAYED_WORK(&mds->security.poll_dwork, cxl_mbox_sanitize_work);
442442

443443
/* background command interrupts are optional */
444-
if (!(cap & CXLDEV_MBOX_CAP_BG_CMD_IRQ))
444+
if (!(cap & CXLDEV_MBOX_CAP_BG_CMD_IRQ) || !irq_avail)
445445
return 0;
446446

447447
msgnum = FIELD_GET(CXLDEV_MBOX_CAP_IRQ_MSGNUM_MASK, cap);
@@ -588,7 +588,7 @@ static int cxl_mem_alloc_event_buf(struct cxl_memdev_state *mds)
588588
return devm_add_action_or_reset(mds->cxlds.dev, free_event_buf, buf);
589589
}
590590

591-
static int cxl_alloc_irq_vectors(struct pci_dev *pdev)
591+
static bool cxl_alloc_irq_vectors(struct pci_dev *pdev)
592592
{
593593
int nvecs;
594594

@@ -605,9 +605,9 @@ static int cxl_alloc_irq_vectors(struct pci_dev *pdev)
605605
PCI_IRQ_MSIX | PCI_IRQ_MSI);
606606
if (nvecs < 1) {
607607
dev_dbg(&pdev->dev, "Failed to alloc irq vectors: %d\n", nvecs);
608-
return -ENXIO;
608+
return false;
609609
}
610-
return 0;
610+
return true;
611611
}
612612

613613
static irqreturn_t cxl_event_thread(int irq, void *id)
@@ -743,7 +743,7 @@ static bool cxl_event_int_is_fw(u8 setting)
743743
}
744744

745745
static int cxl_event_config(struct pci_host_bridge *host_bridge,
746-
struct cxl_memdev_state *mds)
746+
struct cxl_memdev_state *mds, bool irq_avail)
747747
{
748748
struct cxl_event_interrupt_policy policy;
749749
int rc;
@@ -755,6 +755,11 @@ static int cxl_event_config(struct pci_host_bridge *host_bridge,
755755
if (!host_bridge->native_cxl_error)
756756
return 0;
757757

758+
if (!irq_avail) {
759+
dev_info(mds->cxlds.dev, "No interrupt support, disable event processing.\n");
760+
return 0;
761+
}
762+
758763
rc = cxl_mem_alloc_event_buf(mds);
759764
if (rc)
760765
return rc;
@@ -789,6 +794,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
789794
struct cxl_register_map map;
790795
struct cxl_memdev *cxlmd;
791796
int i, rc, pmu_count;
797+
bool irq_avail;
792798

793799
/*
794800
* Double check the anonymous union trickery in struct cxl_regs
@@ -846,11 +852,9 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
846852
else
847853
dev_warn(&pdev->dev, "Media not active (%d)\n", rc);
848854

849-
rc = cxl_alloc_irq_vectors(pdev);
850-
if (rc)
851-
return rc;
855+
irq_avail = cxl_alloc_irq_vectors(pdev);
852856

853-
rc = cxl_pci_setup_mailbox(mds);
857+
rc = cxl_pci_setup_mailbox(mds, irq_avail);
854858
if (rc)
855859
return rc;
856860

@@ -909,7 +913,7 @@ static int cxl_pci_probe(struct pci_dev *pdev, const struct pci_device_id *id)
909913
}
910914
}
911915

912-
rc = cxl_event_config(host_bridge, mds);
916+
rc = cxl_event_config(host_bridge, mds, irq_avail);
913917
if (rc)
914918
return rc;
915919

tools/testing/cxl/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,4 +65,6 @@ cxl_core-y += config_check.o
6565
cxl_core-y += cxl_core_test.o
6666
cxl_core-y += cxl_core_exports.o
6767

68+
KBUILD_CFLAGS := $(filter-out -Wmissing-prototypes -Wmissing-declarations, $(KBUILD_CFLAGS))
69+
6870
obj-m += test/

tools/testing/cxl/test/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,3 +8,5 @@ obj-m += cxl_mock_mem.o
88
cxl_test-y := cxl.o
99
cxl_mock-y := mock.o
1010
cxl_mock_mem-y := mem.o
11+
12+
KBUILD_CFLAGS := $(filter-out -Wmissing-prototypes -Wmissing-declarations, $(KBUILD_CFLAGS))

tools/testing/nvdimm/Kbuild

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -82,4 +82,6 @@ libnvdimm-$(CONFIG_NVDIMM_KEYS) += $(NVDIMM_SRC)/security.o
8282
libnvdimm-y += libnvdimm_test.o
8383
libnvdimm-y += config_check.o
8484

85+
KBUILD_CFLAGS := $(filter-out -Wmissing-prototypes -Wmissing-declarations, $(KBUILD_CFLAGS))
86+
8587
obj-m += test/

0 commit comments

Comments
 (0)