Skip to content

Commit 2c71d33

Browse files
committed
Merge tag 'powerpc-4.17-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux
Pull powerpc fixes from Michael Ellerman: "Just three commits. The two cxl ones are not fixes per se, but they modify code that was added this cycle so that it will work with a recent firmware change. And then a fix for a recent commit that added sleeps in the NVRAM code, which needs to be more careful and not sleep if eg. we're called in the panic() path. Thanks to Nicholas Piggin, Philippe Bergheaud, Christophe Lombard" * tag 'powerpc-4.17-6' of git://git.kernel.org/pub/scm/linux/kernel/git/powerpc/linux: powerpc/powernv: Fix NVRAM sleep in invalid context when crashing cxl: Report the tunneled operations status cxl: Set the PBCQ Tunnel BAR register when enabling capi mode
2 parents d315482 + c1d2a31 commit 2c71d33

5 files changed

Lines changed: 43 additions & 2 deletions

File tree

‎Documentation/ABI/testing/sysfs-class-cxl‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,3 +244,11 @@ Description: read only
244244
Returns 1 if the psl timebase register is synchronized
245245
with the core timebase register, 0 otherwise.
246246
Users: https://github.com/ibm-capi/libcxl
247+
248+
What: /sys/class/cxl/<card>/tunneled_ops_supported
249+
Date: May 2018
250+
Contact: linuxppc-dev@lists.ozlabs.org
251+
Description: read only
252+
Returns 1 if tunneled operations are supported in capi mode,
253+
0 otherwise.
254+
Users: https://github.com/ibm-capi/libcxl

‎arch/powerpc/platforms/powernv/opal-nvram.c‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,10 @@ static ssize_t opal_nvram_read(char *buf, size_t count, loff_t *index)
4444
return count;
4545
}
4646

47+
/*
48+
* This can be called in the panic path with interrupts off, so use
49+
* mdelay in that case.
50+
*/
4751
static ssize_t opal_nvram_write(char *buf, size_t count, loff_t *index)
4852
{
4953
s64 rc = OPAL_BUSY;
@@ -58,10 +62,16 @@ static ssize_t opal_nvram_write(char *buf, size_t count, loff_t *index)
5862
while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
5963
rc = opal_write_nvram(__pa(buf), count, off);
6064
if (rc == OPAL_BUSY_EVENT) {
61-
msleep(OPAL_BUSY_DELAY_MS);
65+
if (in_interrupt() || irqs_disabled())
66+
mdelay(OPAL_BUSY_DELAY_MS);
67+
else
68+
msleep(OPAL_BUSY_DELAY_MS);
6269
opal_poll_events(NULL);
6370
} else if (rc == OPAL_BUSY) {
64-
msleep(OPAL_BUSY_DELAY_MS);
71+
if (in_interrupt() || irqs_disabled())
72+
mdelay(OPAL_BUSY_DELAY_MS);
73+
else
74+
msleep(OPAL_BUSY_DELAY_MS);
6575
}
6676
}
6777

‎drivers/misc/cxl/cxl.h‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -717,6 +717,7 @@ struct cxl {
717717
bool perst_select_user;
718718
bool perst_same_image;
719719
bool psl_timebase_synced;
720+
bool tunneled_ops_supported;
720721

721722
/*
722723
* number of contexts mapped on to this card. Possible values are:

‎drivers/misc/cxl/pci.c‎

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1742,6 +1742,15 @@ static int cxl_configure_adapter(struct cxl *adapter, struct pci_dev *dev)
17421742
/* Required for devices using CAPP DMA mode, harmless for others */
17431743
pci_set_master(dev);
17441744

1745+
adapter->tunneled_ops_supported = false;
1746+
1747+
if (cxl_is_power9()) {
1748+
if (pnv_pci_set_tunnel_bar(dev, 0x00020000E0000000ull, 1))
1749+
dev_info(&dev->dev, "Tunneled operations unsupported\n");
1750+
else
1751+
adapter->tunneled_ops_supported = true;
1752+
}
1753+
17451754
if ((rc = pnv_phb_to_cxl_mode(dev, adapter->native->sl_ops->capi_mode)))
17461755
goto err;
17471756

@@ -1768,6 +1777,9 @@ static void cxl_deconfigure_adapter(struct cxl *adapter)
17681777
{
17691778
struct pci_dev *pdev = to_pci_dev(adapter->dev.parent);
17701779

1780+
if (cxl_is_power9())
1781+
pnv_pci_set_tunnel_bar(pdev, 0x00020000E0000000ull, 0);
1782+
17711783
cxl_native_release_psl_err_irq(adapter);
17721784
cxl_unmap_adapter_regs(adapter);
17731785

‎drivers/misc/cxl/sysfs.c‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,15 @@ static ssize_t psl_timebase_synced_show(struct device *device,
7878
return scnprintf(buf, PAGE_SIZE, "%i\n", adapter->psl_timebase_synced);
7979
}
8080

81+
static ssize_t tunneled_ops_supported_show(struct device *device,
82+
struct device_attribute *attr,
83+
char *buf)
84+
{
85+
struct cxl *adapter = to_cxl_adapter(device);
86+
87+
return scnprintf(buf, PAGE_SIZE, "%i\n", adapter->tunneled_ops_supported);
88+
}
89+
8190
static ssize_t reset_adapter_store(struct device *device,
8291
struct device_attribute *attr,
8392
const char *buf, size_t count)
@@ -183,6 +192,7 @@ static struct device_attribute adapter_attrs[] = {
183192
__ATTR_RO(base_image),
184193
__ATTR_RO(image_loaded),
185194
__ATTR_RO(psl_timebase_synced),
195+
__ATTR_RO(tunneled_ops_supported),
186196
__ATTR_RW(load_image_on_perst),
187197
__ATTR_RW(perst_reloads_same_image),
188198
__ATTR(reset, S_IWUSR, NULL, reset_adapter_store),

0 commit comments

Comments
 (0)