Re: Oops running iptables -F OUTPUT

2018-08-27 Thread Nicholas Piggin
On Mon, 27 Aug 2018 19:11:01 +0200
Andreas Schwab  wrote:

> I'm getting this Oops when running iptables -F OUTPUT:
> 
> [   91.139409] Unable to handle kernel paging request for data at address 
> 0xd001fff12f34
> [   91.139414] Faulting instruction address: 0xd16a5718
> [   91.139419] Oops: Kernel access of bad area, sig: 11 [#1]
> [   91.139426] BE SMP NR_CPUS=2 PowerMac
> [   91.139434] Modules linked in: iptable_filter ip_tables x_tables bpfilter 
> nfsd auth_rpcgss lockd grace nfs_acl sunrpc tun af_packet snd_aoa_codec_tas 
> snd_aoa_fabric_layout snd_aoa snd_aoa_i2sbus snd_aoa_soundbus snd_pcm_oss 
> snd_pcm snd_seq snd_timer snd_seq_device snd_mixer_oss snd sungem sr_mod 
> firewire_ohci cdrom sungem_phy soundcore firewire_core pata_macio crc_itu_t 
> sg hid_generic usbhid linear md_mod ohci_pci ohci_hcd ehci_pci ehci_hcd 
> usbcore usb_common dm_snapshot dm_bufio dm_mirror dm_region_hash dm_log 
> dm_mod sata_svw
> [   91.139522] CPU: 1 PID: 3620 Comm: iptables Not tainted 4.19.0-rc1 #1
> [   91.139526] NIP:  d16a5718 LR: d16a569c CTR: 
> c06f560c
> [   91.139531] REGS: c001fa577670 TRAP: 0300   Not tainted  (4.19.0-rc1)
> [   91.139534] MSR:  9200b032   CR: 
> 84002484  XER: 2000
> [   91.139553] DAR: d001fff12f34 DSISR: 4000 IRQMASK: 0 
> GPR00: d16a569c c001fa5778f0 d16b0400  
> GPR04: 0002  8001fa46418e c001fa0d05c8 
> GPR08: d16b0400 d00037f13000 0001ff3e7000 d16a6fb8 
> GPR12: c06f560c c780   
> GPR16: 11635010 3fffa1b7aa68   
> GPR20: 0003 10013918 116350c0 c0b88990 
> GPR24: c0b88ba4  d001fff12f34  
> GPR28: d16b8000 c001fa20f400 c001fa20f440  
> [   91.139627] NIP [d16a5718] .alloc_counters.isra.10+0xbc/0x140 
> [ip_tables]
> [   91.139634] LR [d16a569c] .alloc_counters.isra.10+0x40/0x140 
> [ip_tables]
> [   91.139638] Call Trace:
> [   91.139645] [c001fa5778f0] [d16a569c] 
> .alloc_counters.isra.10+0x40/0x140 [ip_tables] (unreliable)
> [   91.139655] [c001fa5779b0] [d16a5b54] 
> .do_ipt_get_ctl+0x110/0x2ec [ip_tables]
> [   91.139666] [c001fa577aa0] [c06233e0] .nf_getsockopt+0x68/0x88
> [   91.139674] [c001fa577b40] [c0631608] .ip_getsockopt+0xbc/0x128
> [   91.139682] [c001fa577bf0] [c065adf4] .raw_getsockopt+0x18/0x5c
> [   91.139690] [c001fa577c60] [c05b5f60] 
> .sock_common_getsockopt+0x2c/0x40
> [   91.139697] [c001fa577cd0] [c05b3394] 
> .__sys_getsockopt+0xa4/0xd0
> [   91.139704] [c001fa577d80] [c05b5ab0] 
> .__se_sys_socketcall+0x238/0x2b4
> [   91.139712] [c001fa577e30] [c000a31c] system_call+0x5c/0x70
> [   91.139716] Instruction dump:
> [   91.139721] 39290040 7d3d4a14 7fbe4840 409cff98 8138 2b890001 419d000c 
> 393e0060 
> [   91.139736] 4810 7d57c82a e93e0060 7d295214 <815a> 794807e1 
> 41e20010 7c210b78 
> [   91.139752] ---[ end trace f5d1d5431651845d ]---

This is due to 7290d58095 ("module: use relative references for
__ksymtab entries"). This part of kernel/module.c -

   /* Divert to percpu allocation if a percpu var. */
   if (sym[i].st_shndx == info->index.pcpu)
   secbase = (unsigned long)mod_percpu(mod);
   else
   secbase = info->sechdrs[sym[i].st_shndx].sh_addr;
   sym[i].st_value += secbase;

Causes the distance to the target to exceed 32-bits on powerpc, so
it doesn't fit in a rel32 reloc. Not sure how other archs cope.

Thanks,
Nick


Re: [PATCH] misc: Convert to using %pOFn instead of device_node.name

2018-08-27 Thread Andrew Donnellan

On 28/08/18 11:52, Rob Herring wrote:

In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Frederic Barrat 
Cc: Andrew Donnellan 
Cc: Arnd Bergmann 
Cc: Greg Kroah-Hartman 
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Rob Herring 


Acked-by: Andrew Donnellan 


--
Andrew Donnellan  OzLabs, ADL Canberra
andrew.donnel...@au1.ibm.com  IBM Australia Limited



[PATCH] ASoC: Convert to using %pOFn instead of device_node.name

2018-08-27 Thread Rob Herring
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Timur Tabi 
Cc: Nicolin Chen 
Cc: Xiubo Li 
Cc: Fabio Estevam 
Cc: Liam Girdwood 
Cc: Mark Brown 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: Carlo Caione 
Cc: Kevin Hilman 
Cc: Olivier Moysan 
Cc: Arnaud Pouliquen 
Cc: Maxime Coquelin 
Cc: Alexandre Torgue 
Cc: alsa-de...@alsa-project.org
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-amlo...@lists.infradead.org
Signed-off-by: Rob Herring 
---
 sound/soc/fsl/fsl_esai.c  | 2 +-
 sound/soc/fsl/fsl_utils.c | 4 ++--
 sound/soc/meson/axg-card.c| 2 +-
 sound/soc/stm/stm32_sai.c | 2 +-
 sound/soc/stm/stm32_sai_sub.c | 8 
 5 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/sound/soc/fsl/fsl_esai.c b/sound/soc/fsl/fsl_esai.c
index c1d1d06783e5..57b484768a58 100644
--- a/sound/soc/fsl/fsl_esai.c
+++ b/sound/soc/fsl/fsl_esai.c
@@ -807,7 +807,7 @@ static int fsl_esai_probe(struct platform_device *pdev)
return -ENOMEM;
 
esai_priv->pdev = pdev;
-   strncpy(esai_priv->name, np->name, sizeof(esai_priv->name) - 1);
+   snprintf(esai_priv->name, sizeof(esai_priv->name), "%pOFn", np);
 
/* Get the addresses and IRQ */
res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
diff --git a/sound/soc/fsl/fsl_utils.c b/sound/soc/fsl/fsl_utils.c
index 7f0fa4b52223..9981668ab590 100644
--- a/sound/soc/fsl/fsl_utils.c
+++ b/sound/soc/fsl/fsl_utils.c
@@ -57,8 +57,8 @@ int fsl_asoc_get_dma_channel(struct device_node *ssi_np,
of_node_put(dma_channel_np);
return ret;
}
-   snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%s",
-(unsigned long long) res.start, dma_channel_np->name);
+   snprintf((char *)dai->platform_name, DAI_NAME_SIZE, "%llx.%pOFn",
+(unsigned long long) res.start, dma_channel_np);
 
iprop = of_get_property(dma_channel_np, "cell-index", NULL);
if (!iprop) {
diff --git a/sound/soc/meson/axg-card.c b/sound/soc/meson/axg-card.c
index 2914ba0d965b..b76a5f4f1785 100644
--- a/sound/soc/meson/axg-card.c
+++ b/sound/soc/meson/axg-card.c
@@ -478,7 +478,7 @@ static int axg_card_set_be_link(struct snd_soc_card *card,
 
ret = axg_card_set_link_name(card, link, "be");
if (ret)
-   dev_err(card->dev, "error setting %s link name\n", np->name);
+   dev_err(card->dev, "error setting %pOFn link name\n", np);
 
return ret;
 }
diff --git a/sound/soc/stm/stm32_sai.c b/sound/soc/stm/stm32_sai.c
index f22654253c43..d597eba61992 100644
--- a/sound/soc/stm/stm32_sai.c
+++ b/sound/soc/stm/stm32_sai.c
@@ -104,7 +104,7 @@ static int stm32_sai_set_sync(struct stm32_sai_data 
*sai_client,
 
if (!pdev) {
dev_err(_client->pdev->dev,
-   "Device not found for node %s\n", np_provider->name);
+   "Device not found for node %pOFn\n", np_provider);
return -ENODEV;
}
 
diff --git a/sound/soc/stm/stm32_sai_sub.c b/sound/soc/stm/stm32_sai_sub.c
index 06fba9650ac4..cad8c7888292 100644
--- a/sound/soc/stm/stm32_sai_sub.c
+++ b/sound/soc/stm/stm32_sai_sub.c
@@ -1124,16 +1124,16 @@ static int stm32_sai_sub_parse_of(struct 
platform_device *pdev,
sai->sync = SAI_SYNC_NONE;
if (args.np) {
if (args.np == np) {
-   dev_err(>dev, "%s sync own reference\n",
-   np->name);
+   dev_err(>dev, "%pOFn sync own reference\n",
+   np);
of_node_put(args.np);
return -EINVAL;
}
 
sai->np_sync_provider  = of_get_parent(args.np);
if (!sai->np_sync_provider) {
-   dev_err(>dev, "%s parent node not found\n",
-   np->name);
+   dev_err(>dev, "%pOFn parent node not found\n",
+   np);
of_node_put(args.np);
return -ENODEV;
}
-- 
2.17.1



[PATCH] sound: Convert to using %pOFn instead of device_node.name

2018-08-27 Thread Rob Herring
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Johannes Berg 
Cc: Jaroslav Kysela 
Cc: Takashi Iwai 
Cc: linuxppc-dev@lists.ozlabs.org
Cc: alsa-de...@alsa-project.org
Signed-off-by: Rob Herring 
---
 sound/aoa/soundbus/i2sbus/core.c | 15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

diff --git a/sound/aoa/soundbus/i2sbus/core.c b/sound/aoa/soundbus/i2sbus/core.c
index 000b58522106..bf32e1c74748 100644
--- a/sound/aoa/soundbus/i2sbus/core.c
+++ b/sound/aoa/soundbus/i2sbus/core.c
@@ -157,18 +157,19 @@ static int i2sbus_add_dev(struct macio_dev *macio,
struct device_node *child = NULL, *sound = NULL;
struct resource *r;
int i, layout = 0, rlen, ok = force;
-   static const char *rnames[] = { "i2sbus: %s (control)",
-   "i2sbus: %s (tx)",
-   "i2sbus: %s (rx)" };
+   char node_name[6];
+   static const char *rnames[] = { "i2sbus: %pOFn (control)",
+   "i2sbus: %pOFn (tx)",
+   "i2sbus: %pOFn (rx)" };
static irq_handler_t ints[] = {
i2sbus_bus_intr,
i2sbus_tx_intr,
i2sbus_rx_intr
};
 
-   if (strlen(np->name) != 5)
+   if (snprintf(node_name, sizeof(node_name), "%pOFn", np) != 5)
return 0;
-   if (strncmp(np->name, "i2s-", 4))
+   if (strncmp(np, "i2s-", 4))
return 0;
 
dev = kzalloc(sizeof(struct i2sbus_dev), GFP_KERNEL);
@@ -228,13 +229,13 @@ static int i2sbus_add_dev(struct macio_dev *macio,
dev->sound.pcmid = -1;
dev->macio = macio;
dev->control = control;
-   dev->bus_number = np->name[4] - 'a';
+   dev->bus_number = node_name[4] - 'a';
INIT_LIST_HEAD(>sound.codec_list);
 
for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++) {
dev->interrupts[i] = -1;
snprintf(dev->rnames[i], sizeof(dev->rnames[i]),
-rnames[i], np->name);
+rnames[i], np);
}
for (i = aoa_resource_i2smmio; i <= aoa_resource_rxdbdma; i++) {
int irq = irq_of_parse_and_map(np, i);
-- 
2.17.1



[PATCH] tty: Convert to using %pOFn instead of device_node.name

2018-08-27 Thread Rob Herring
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Greg Kroah-Hartman 
Cc: Jiri Slaby 
Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: linux-ser...@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Rob Herring 
---
 drivers/tty/ehv_bytechan.c  | 12 ++--
 drivers/tty/serial/cpm_uart/cpm_uart_core.c |  8 
 drivers/tty/serial/pmac_zilog.c |  4 ++--
 3 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/tty/ehv_bytechan.c b/drivers/tty/ehv_bytechan.c
index eea4049b5dcc..769e0a5d1dfc 100644
--- a/drivers/tty/ehv_bytechan.c
+++ b/drivers/tty/ehv_bytechan.c
@@ -128,8 +128,8 @@ static int find_console_handle(void)
 */
iprop = of_get_property(np, "hv-handle", NULL);
if (!iprop) {
-   pr_err("ehv-bc: no 'hv-handle' property in %s node\n",
-  np->name);
+   pr_err("ehv-bc: no 'hv-handle' property in %pOFn node\n",
+  np);
return 0;
}
stdout_bc = be32_to_cpu(*iprop);
@@ -661,8 +661,8 @@ static int ehv_bc_tty_probe(struct platform_device *pdev)
 
iprop = of_get_property(np, "hv-handle", NULL);
if (!iprop) {
-   dev_err(>dev, "no 'hv-handle' property in %s node\n",
-   np->name);
+   dev_err(>dev, "no 'hv-handle' property in %pOFn node\n",
+   np);
return -ENODEV;
}
 
@@ -682,8 +682,8 @@ static int ehv_bc_tty_probe(struct platform_device *pdev)
bc->rx_irq = irq_of_parse_and_map(np, 0);
bc->tx_irq = irq_of_parse_and_map(np, 1);
if ((bc->rx_irq == NO_IRQ) || (bc->tx_irq == NO_IRQ)) {
-   dev_err(>dev, "no 'interrupts' property in %s node\n",
-   np->name);
+   dev_err(>dev, "no 'interrupts' property in %pOFn node\n",
+   np);
ret = -ENODEV;
goto error;
}
diff --git a/drivers/tty/serial/cpm_uart/cpm_uart_core.c 
b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
index 24a5f05e769b..ea7204d75022 100644
--- a/drivers/tty/serial/cpm_uart/cpm_uart_core.c
+++ b/drivers/tty/serial/cpm_uart/cpm_uart_core.c
@@ -1151,8 +1151,8 @@ static int cpm_uart_init_port(struct device_node *np,
if (!pinfo->clk) {
data = of_get_property(np, "fsl,cpm-brg", );
if (!data || len != 4) {
-   printk(KERN_ERR "CPM UART %s has no/invalid "
-   "fsl,cpm-brg property.\n", np->name);
+   printk(KERN_ERR "CPM UART %pOFn has no/invalid "
+   "fsl,cpm-brg property.\n", np);
return -EINVAL;
}
pinfo->brg = *data;
@@ -1160,8 +1160,8 @@ static int cpm_uart_init_port(struct device_node *np,
 
data = of_get_property(np, "fsl,cpm-command", );
if (!data || len != 4) {
-   printk(KERN_ERR "CPM UART %s has no/invalid "
-   "fsl,cpm-command property.\n", np->name);
+   printk(KERN_ERR "CPM UART %pOFn has no/invalid "
+   "fsl,cpm-command property.\n", np);
return -EINVAL;
}
pinfo->command = *data;
diff --git a/drivers/tty/serial/pmac_zilog.c b/drivers/tty/serial/pmac_zilog.c
index 3d21790d961e..a4ec22d1f214 100644
--- a/drivers/tty/serial/pmac_zilog.c
+++ b/drivers/tty/serial/pmac_zilog.c
@@ -1566,9 +1566,9 @@ static int pmz_attach(struct macio_dev *mdev, const 
struct of_device_id *match)
 * to work around bugs in ancient Apple device-trees
 */
if (macio_request_resources(uap->dev, "pmac_zilog"))
-   printk(KERN_WARNING "%s: Failed to request resource"
+   printk(KERN_WARNING "%pOFn: Failed to request resource"
   ", port still active\n",
-  uap->node->name);
+  uap->node);
else
uap->flags |= PMACZILOG_FLAG_RSRC_REQUESTED;
 
-- 
2.17.1



[PATCH] soc: Convert to using %pOFn instead of device_node.name

2018-08-27 Thread Rob Herring
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Qiang Zhao 
Cc: Li Yang 
Cc: Andy Gross 
Cc: David Brown 
Cc: Heiko Stuebner 
Cc: Thierry Reding 
Cc: Jonathan Hunter 
Cc: Santosh Shilimkar 
Cc: linuxppc-dev@lists.ozlabs.org
Cc: linux-arm-ker...@lists.infradead.org
Cc: linux-...@vger.kernel.org
Signed-off-by: Rob Herring 
---
 drivers/soc/dove/pmu.c|  8 +++---
 drivers/soc/fsl/qe/qe_tdm.c   |  4 +--
 drivers/soc/qcom/apr.c|  2 +-
 drivers/soc/rockchip/pm_domains.c | 44 +++
 drivers/soc/tegra/pmc.c   | 12 -
 drivers/soc/ti/knav_dma.c |  8 +++---
 drivers/soc/ti/knav_qmss_queue.c  |  8 +++---
 7 files changed, 43 insertions(+), 43 deletions(-)

diff --git a/drivers/soc/dove/pmu.c b/drivers/soc/dove/pmu.c
index 5abb08ffb74d..ffc5311c0ed8 100644
--- a/drivers/soc/dove/pmu.c
+++ b/drivers/soc/dove/pmu.c
@@ -383,7 +383,7 @@ int __init dove_init_pmu(void)
 
domains_node = of_get_child_by_name(np_pmu, "domains");
if (!domains_node) {
-   pr_err("%s: failed to find domains sub-node\n", np_pmu->name);
+   pr_err("%pOFn: failed to find domains sub-node\n", np_pmu);
return 0;
}
 
@@ -396,7 +396,7 @@ int __init dove_init_pmu(void)
pmu->pmc_base = of_iomap(pmu->of_node, 0);
pmu->pmu_base = of_iomap(pmu->of_node, 1);
if (!pmu->pmc_base || !pmu->pmu_base) {
-   pr_err("%s: failed to map PMU\n", np_pmu->name);
+   pr_err("%pOFn: failed to map PMU\n", np_pmu);
iounmap(pmu->pmu_base);
iounmap(pmu->pmc_base);
kfree(pmu);
@@ -414,7 +414,7 @@ int __init dove_init_pmu(void)
break;
 
domain->pmu = pmu;
-   domain->base.name = kstrdup(np->name, GFP_KERNEL);
+   domain->base.name = kasprintf(GFP_KERNEL, "%pOFn", np);
if (!domain->base.name) {
kfree(domain);
break;
@@ -444,7 +444,7 @@ int __init dove_init_pmu(void)
/* Loss of the interrupt controller is not a fatal error. */
parent_irq = irq_of_parse_and_map(pmu->of_node, 0);
if (!parent_irq) {
-   pr_err("%s: no interrupt specified\n", np_pmu->name);
+   pr_err("%pOFn: no interrupt specified\n", np_pmu);
} else {
ret = dove_init_pmu_irq(pmu, parent_irq);
if (ret)
diff --git a/drivers/soc/fsl/qe/qe_tdm.c b/drivers/soc/fsl/qe/qe_tdm.c
index f744c214f680..f78c34647ca2 100644
--- a/drivers/soc/fsl/qe/qe_tdm.c
+++ b/drivers/soc/fsl/qe/qe_tdm.c
@@ -131,7 +131,7 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm 
*utdm,
 
pdev = of_find_device_by_node(np2);
if (!pdev) {
-   pr_err("%s: failed to lookup pdev\n", np2->name);
+   pr_err("%pOFn: failed to lookup pdev\n", np2);
of_node_put(np2);
return -EINVAL;
}
@@ -153,7 +153,7 @@ int ucc_of_parse_tdm(struct device_node *np, struct ucc_tdm 
*utdm,
pdev = of_find_device_by_node(np2);
if (!pdev) {
ret = -EINVAL;
-   pr_err("%s: failed to lookup pdev\n", np2->name);
+   pr_err("%pOFn: failed to lookup pdev\n", np2);
of_node_put(np2);
goto err_miss_siram_property;
}
diff --git a/drivers/soc/qcom/apr.c b/drivers/soc/qcom/apr.c
index 57af8a537332..4bda793ba6ae 100644
--- a/drivers/soc/qcom/apr.c
+++ b/drivers/soc/qcom/apr.c
@@ -219,7 +219,7 @@ static int apr_add_device(struct device *dev, struct 
device_node *np,
adev->domain_id = id->domain_id;
adev->version = id->svc_version;
if (np)
-   strncpy(adev->name, np->name, APR_NAME_SIZE);
+   snprintf(adev->name, APR_NAME_SIZE, "%pOFn", np);
else
strncpy(adev->name, id->name, APR_NAME_SIZE);
 
diff --git a/drivers/soc/rockchip/pm_domains.c 
b/drivers/soc/rockchip/pm_domains.c
index 6dff8682155f..6f86a726bb45 100644
--- a/drivers/soc/rockchip/pm_domains.c
+++ b/drivers/soc/rockchip/pm_domains.c
@@ -392,21 +392,21 @@ static int rockchip_pm_add_one_domain(struct rockchip_pmu 
*pmu,
error = of_property_read_u32(node, "reg", );
if (error) {
dev_err(pmu->dev,
-   "%s: failed to retrieve domain id (reg): %d\n",
-   node->name, error);
+   "%pOFn: failed to retrieve domain id (reg): %d\n",
+   node, error);
return -EINVAL;
}
 
if (id >= pmu->info->num_domains) {
-   dev_err(pmu->dev, "%s: invalid domain id %d\n",
-   node->name, id);
+   dev_err(pmu->dev, "%pOFn: invalid domain id %d\n",
+   node, id);

[PATCH] misc: Convert to using %pOFn instead of device_node.name

2018-08-27 Thread Rob Herring
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Frederic Barrat 
Cc: Andrew Donnellan 
Cc: Arnd Bergmann 
Cc: Greg Kroah-Hartman 
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Rob Herring 
---
 drivers/misc/cxl/flash.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/misc/cxl/flash.c b/drivers/misc/cxl/flash.c
index 43917898fb9a..4d6836f19489 100644
--- a/drivers/misc/cxl/flash.c
+++ b/drivers/misc/cxl/flash.c
@@ -92,8 +92,8 @@ static int update_property(struct device_node *dn, const char 
*name,
 
val = (u32 *)new_prop->value;
rc = cxl_update_properties(dn, new_prop);
-   pr_devel("%s: update property (%s, length: %i, value: %#x)\n",
- dn->name, name, vd, be32_to_cpu(*val));
+   pr_devel("%pOFn: update property (%s, length: %i, value: %#x)\n",
+ dn, name, vd, be32_to_cpu(*val));
 
if (rc) {
kfree(new_prop->name);
-- 
2.17.1



[PATCH] macintosh: Convert to using %pOFn instead of device_node.name

2018-08-27 Thread Rob Herring
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Benjamin Herrenschmidt 
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Rob Herring 
---
 drivers/macintosh/macio_sysfs.c   | 8 +++-
 drivers/macintosh/windfarm_smu_controls.c | 4 ++--
 2 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/drivers/macintosh/macio_sysfs.c b/drivers/macintosh/macio_sysfs.c
index ca4fcffe454b..d2451e58acb9 100644
--- a/drivers/macintosh/macio_sysfs.c
+++ b/drivers/macintosh/macio_sysfs.c
@@ -58,7 +58,13 @@ static ssize_t devspec_show(struct device *dev,
 static DEVICE_ATTR_RO(modalias);
 static DEVICE_ATTR_RO(devspec);
 
-macio_config_of_attr (name, "%s\n");
+static ssize_t name_show(struct device *dev,
+struct device_attribute *attr, char *buf)
+{
+   return sprintf(buf, "%pOFn\n", dev->of_node);
+}
+static DEVICE_ATTR_RO(name);
+
 macio_config_of_attr (type, "%s\n");
 
 static struct attribute *macio_dev_attrs[] = {
diff --git a/drivers/macintosh/windfarm_smu_controls.c 
b/drivers/macintosh/windfarm_smu_controls.c
index d174c7437337..86d65462a61c 100644
--- a/drivers/macintosh/windfarm_smu_controls.c
+++ b/drivers/macintosh/windfarm_smu_controls.c
@@ -277,7 +277,7 @@ static int __init smu_controls_init(void)
fct = smu_fan_create(fan, 0);
if (fct == NULL) {
printk(KERN_WARNING "windfarm: Failed to create SMU "
-  "RPM fan %s\n", fan->name);
+  "RPM fan %pOFn\n", fan);
continue;
}
list_add(>link, _fans);
@@ -296,7 +296,7 @@ static int __init smu_controls_init(void)
fct = smu_fan_create(fan, 1);
if (fct == NULL) {
printk(KERN_WARNING "windfarm: Failed to create SMU "
-  "PWM fan %s\n", fan->name);
+  "PWM fan %pOFn\n", fan);
continue;
}
list_add(>link, _fans);
-- 
2.17.1



[PATCH] i2c: Convert to using %pOFn instead of device_node.name

2018-08-27 Thread Rob Herring
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Peter Rosin 
Cc: linux-...@vger.kernel.org
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Rob Herring 
---
 drivers/i2c/busses/i2c-powermac.c | 15 ---
 drivers/i2c/muxes/i2c-mux-gpmux.c |  4 ++--
 2 files changed, 10 insertions(+), 9 deletions(-)

diff --git a/drivers/i2c/busses/i2c-powermac.c 
b/drivers/i2c/busses/i2c-powermac.c
index f2a2067525ef..b706fd136ca5 100644
--- a/drivers/i2c/busses/i2c-powermac.c
+++ b/drivers/i2c/busses/i2c-powermac.c
@@ -390,7 +390,6 @@ static int i2c_powermac_probe(struct platform_device *dev)
struct pmac_i2c_bus *bus = dev_get_platdata(>dev);
struct device_node *parent = NULL;
struct i2c_adapter *adapter;
-   const char *basename;
int rc;
 
if (bus == NULL)
@@ -407,23 +406,25 @@ static int i2c_powermac_probe(struct platform_device *dev)
parent = of_get_parent(pmac_i2c_get_controller(bus));
if (parent == NULL)
return -EINVAL;
-   basename = parent->name;
+   snprintf(adapter->name, sizeof(adapter->name), "%pOFn %d", 
+parent,
+pmac_i2c_get_channel(bus));
+   of_node_put(parent);
break;
case pmac_i2c_bus_pmu:
-   basename = "pmu";
+   snprintf(adapter->name, sizeof(adapter->name), "pmu %d",
+pmac_i2c_get_channel(bus));
break;
case pmac_i2c_bus_smu:
/* This is not what we used to do but I'm fixing drivers at
 * the same time as this change
 */
-   basename = "smu";
+   snprintf(adapter->name, sizeof(adapter->name), "smu %d",
+pmac_i2c_get_channel(bus));
break;
default:
return -EINVAL;
}
-   snprintf(adapter->name, sizeof(adapter->name), "%s %d", basename,
-pmac_i2c_get_channel(bus));
-   of_node_put(parent);
 
platform_set_drvdata(dev, adapter);
adapter->algo = _powermac_algorithm;
diff --git a/drivers/i2c/muxes/i2c-mux-gpmux.c 
b/drivers/i2c/muxes/i2c-mux-gpmux.c
index 92cf5f48afe6..f60b670deff7 100644
--- a/drivers/i2c/muxes/i2c-mux-gpmux.c
+++ b/drivers/i2c/muxes/i2c-mux-gpmux.c
@@ -120,8 +120,8 @@ static int i2c_mux_probe(struct platform_device *pdev)
 
ret = of_property_read_u32(child, "reg", );
if (ret < 0) {
-   dev_err(dev, "no reg property for node '%s'\n",
-   child->name);
+   dev_err(dev, "no reg property for node '%pOFn'\n",
+   child);
goto err_children;
}
 
-- 
2.17.1



[PATCH] powerpc: Convert to using %pOFn instead of device_node.name

2018-08-27 Thread Rob Herring
In preparation to remove the node name pointer from struct device_node,
convert printf users to use the %pOFn format specifier.

Cc: Benjamin Herrenschmidt 
Cc: Paul Mackerras 
Cc: Michael Ellerman 
Cc: Arnd Bergmann 
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Rob Herring 
---
 arch/powerpc/platforms/44x/fsp2.c |  8 +++---
 arch/powerpc/platforms/cell/spu_manage.c  |  4 +--
 arch/powerpc/platforms/embedded6xx/wii.c  |  2 +-
 .../powerpc/platforms/powernv/opal-powercap.c |  3 +-
 .../platforms/powernv/opal-sensor-groups.c|  4 +--
 .../powerpc/platforms/powernv/opal-sysparam.c |  2 +-
 arch/powerpc/platforms/pseries/hotplug-cpu.c  | 28 +--
 arch/powerpc/platforms/pseries/ibmebus.c  |  2 +-
 arch/powerpc/platforms/pseries/vio.c  | 27 +-
 9 files changed, 40 insertions(+), 40 deletions(-)

diff --git a/arch/powerpc/platforms/44x/fsp2.c 
b/arch/powerpc/platforms/44x/fsp2.c
index 04f0c73a9b4f..7a507f775308 100644
--- a/arch/powerpc/platforms/44x/fsp2.c
+++ b/arch/powerpc/platforms/44x/fsp2.c
@@ -210,15 +210,15 @@ static void node_irq_request(const char *compat, 
irq_handler_t errirq_handler)
for_each_compatible_node(np, NULL, compat) {
irq = irq_of_parse_and_map(np, 0);
if (irq == NO_IRQ) {
-   pr_err("device tree node %s is missing a interrupt",
- np->name);
+   pr_err("device tree node %pOFn is missing a interrupt",
+ np);
return;
}
 
rc = request_irq(irq, errirq_handler, 0, np->name, np);
if (rc) {
-   pr_err("fsp_of_probe: request_irq failed: np=%s rc=%d",
- np->full_name, rc);
+   pr_err("fsp_of_probe: request_irq failed: np=%pOF 
rc=%d",
+ np, rc);
return;
}
}
diff --git a/arch/powerpc/platforms/cell/spu_manage.c 
b/arch/powerpc/platforms/cell/spu_manage.c
index 5c409c98cca8..71ebf7f1bd62 100644
--- a/arch/powerpc/platforms/cell/spu_manage.c
+++ b/arch/powerpc/platforms/cell/spu_manage.c
@@ -295,8 +295,8 @@ static int __init of_enumerate_spus(int (*fn)(void *data))
for_each_node_by_type(node, "spe") {
ret = fn(node);
if (ret) {
-   printk(KERN_WARNING "%s: Error initializing %s\n",
-   __func__, node->name);
+   printk(KERN_WARNING "%s: Error initializing %pOFn\n",
+   __func__, node);
of_node_put(node);
break;
}
diff --git a/arch/powerpc/platforms/embedded6xx/wii.c 
b/arch/powerpc/platforms/embedded6xx/wii.c
index 403523c061ba..ecf703ee3a76 100644
--- a/arch/powerpc/platforms/embedded6xx/wii.c
+++ b/arch/powerpc/platforms/embedded6xx/wii.c
@@ -112,7 +112,7 @@ static void __iomem *wii_ioremap_hw_regs(char *name, char 
*compatible)
}
error = of_address_to_resource(np, 0, );
if (error) {
-   pr_err("no valid reg found for %s\n", np->name);
+   pr_err("no valid reg found for %pOFn\n", np);
goto out_put;
}
 
diff --git a/arch/powerpc/platforms/powernv/opal-powercap.c 
b/arch/powerpc/platforms/powernv/opal-powercap.c
index badb29bde93f..d90ee4fc2c6a 100644
--- a/arch/powerpc/platforms/powernv/opal-powercap.c
+++ b/arch/powerpc/platforms/powernv/opal-powercap.c
@@ -199,7 +199,7 @@ void __init opal_powercap_init(void)
}
 
j = 0;
-   pcaps[i].pg.name = node->name;
+   pcaps[i].pg.name = kasprintf(GFP_KERNEL, "%pOFn", node);
if (has_min) {
powercap_add_attr(min, "powercap-min",
  [i].pattrs[j]);
@@ -237,6 +237,7 @@ void __init opal_powercap_init(void)
while (--i >= 0) {
kfree(pcaps[i].pattrs);
kfree(pcaps[i].pg.attrs);
+   kfree(pcaps[i].pg.name);
}
kobject_put(powercap_kobj);
 out_pcaps:
diff --git a/arch/powerpc/platforms/powernv/opal-sensor-groups.c 
b/arch/powerpc/platforms/powernv/opal-sensor-groups.c
index f7d04b6a2d7a..179609220e6f 100644
--- a/arch/powerpc/platforms/powernv/opal-sensor-groups.c
+++ b/arch/powerpc/platforms/powernv/opal-sensor-groups.c
@@ -214,9 +214,9 @@ void __init opal_sensor_groups_init(void)
}
 
if (!of_property_read_u32(node, "ibm,chip-id", ))
-   sprintf(sgs[i].name, "%s%d", node->name, chipid);
+   sprintf(sgs[i].name, "%pOFn%d", node, chipid);
else
-   sprintf(sgs[i].name, "%s", node->name);
+   sprintf(sgs[i].name, "%pOFn", node);
 
sgs[i].sg.name = 

Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread H. Peter Anvin
On 08/27/18 06:11, Peter Zijlstra wrote:
> On Mon, Aug 27, 2018 at 05:26:53AM -0700, H. Peter Anvin wrote:
> 
>> _THIS_IP_, however, is completely ill-defined, other than being an
>> address *somewhere* in the same global function (not even necessarily
>> the same function if the function is static!)  As my experiment show, in
>> many (nearly) cases gcc will hoist the address all the way to the top of
>> the function, at least for the current generic implementation.
> 
> It seems to have mostly worked so far... did anything change?
> 

Most likely because the major architectures contain a arch-specific
assembly implementation.  The generic implementation used in some places
is completely broken, as my experiments show.

>> For the case where _THIS_IP_ is passed to an out-of-line function in all
>> cases, it is extra pointless because all it does is increase the
>> footprint of every caller: _RET_IP_ is inherently passed to the function
>> anyway, and with tailcall protection it will uniquely identify a callsite.
> 
> So I think we can convert many of the lockdep _THIS_IP_ calls to
> _RET_IP_ on the other side, with a wee bit of care.
> 
> A little something like so perhaps...

I don't have time to look at this right now (I'm on sabbatical, and I'm
dealing with personal legal stuff right at the moment), but I think it
is the right direction.

-hpa


Re: FSL/NXP P5020: USB problems with the latest Git kernels

2018-08-27 Thread Scott Wood
On Mon, 2018-08-27 at 20:15 +0200, Christian Zigotzky wrote:
> Hello,
> 
> Our users tested the RC1 of kernel 4.19 on their P5020 boards today.
> Unfortunately the USB bug still exists. With mem values bigger than 4096M,
> the USB mouse and keyboard doesn’t work. With the bootarg mem=4096M, the USB
> devices work without any problems. Please compile the RC1 and test it on
> your P5020 board. There is a problem with the memory management since
> 22/08/18. 

I just tested 4.19-rc1 on a T4240 and got a similar problem with MMC.  MMC and
USB on these chips both have a 32-bit DMA limitation.  I'll look into it.

-Scott



[PATCH v9 1/5] powerpc/pseries: Define MCE error event section.

2018-08-27 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar 

On pseries, the machine check error details are part of RTAS extended
event log passed under Machine check exception section. This patch adds
the definition of rtas MCE event section and related helper
functions.

Signed-off-by: Mahesh Salgaonkar 
---
---
 arch/powerpc/include/asm/rtas.h  |8 +++
 arch/powerpc/platforms/pseries/ras.c |   95 ++
 2 files changed, 103 insertions(+)

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index 71e393c46a49..adefa6493d29 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -185,6 +185,13 @@ static inline uint8_t rtas_error_disposition(const struct 
rtas_error_log *elog)
return (elog->byte1 & 0x18) >> 3;
 }
 
+static inline
+void rtas_set_disposition_recovered(struct rtas_error_log *elog)
+{
+   elog->byte1 &= ~0x18;
+   elog->byte1 |= (RTAS_DISP_FULLY_RECOVERED << 3);
+}
+
 static inline uint8_t rtas_error_extended(const struct rtas_error_log *elog)
 {
return (elog->byte1 & 0x04) >> 2;
@@ -275,6 +282,7 @@ inline uint32_t rtas_ext_event_company_id(struct 
rtas_ext_event_log_v6 *ext_log)
 #define PSERIES_ELOG_SECT_ID_CALL_HOME (('C' << 8) | 'H')
 #define PSERIES_ELOG_SECT_ID_USER_DEF  (('U' << 8) | 'D')
 #define PSERIES_ELOG_SECT_ID_HOTPLUG   (('H' << 8) | 'P')
+#define PSERIES_ELOG_SECT_ID_MCE   (('M' << 8) | 'C')
 
 /* Vendor specific Platform Event Log Format, Version 6, section header */
 struct pseries_errorlog {
diff --git a/arch/powerpc/platforms/pseries/ras.c 
b/arch/powerpc/platforms/pseries/ras.c
index 851ce326874a..3500ad982706 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -50,6 +50,101 @@ static irqreturn_t ras_hotplug_interrupt(int irq, void 
*dev_id);
 static irqreturn_t ras_epow_interrupt(int irq, void *dev_id);
 static irqreturn_t ras_error_interrupt(int irq, void *dev_id);
 
+/* RTAS pseries MCE errorlog section. */
+struct pseries_mc_errorlog {
+   __be32  fru_id;
+   __be32  proc_id;
+   u8  error_type;
+   /*
+* sub_err_type (1 byte). Bit fields depends on error_type
+*
+*   MSB0
+*   |
+*   V
+*   01234567
+*   
+*
+* For error_type == MC_ERROR_TYPE_UE
+*   
+*   X  1: Permanent or Transient UE.
+*X 1: Effective address provided.
+* X1: Logical address provided.
+*  XX  2: Reserved.
+*XXX   3: Type of UE error.
+*
+* For error_type != MC_ERROR_TYPE_UE
+*   
+*   X  1: Effective address provided.
+*X 5: Reserved.
+* XX   2: Type of SLB/ERAT/TLB error.
+*/
+   u8  sub_err_type;
+   u8  reserved_1[6];
+   __be64  effective_address;
+   __be64  logical_address;
+} __packed;
+
+/* RTAS pseries MCE error types */
+#define MC_ERROR_TYPE_UE   0x00
+#define MC_ERROR_TYPE_SLB  0x01
+#define MC_ERROR_TYPE_ERAT 0x02
+#define MC_ERROR_TYPE_TLB  0x04
+#define MC_ERROR_TYPE_D_CACHE  0x05
+#define MC_ERROR_TYPE_I_CACHE  0x07
+
+/* RTAS pseries MCE error sub types */
+#define MC_ERROR_UE_INDETERMINATE  0
+#define MC_ERROR_UE_IFETCH 1
+#define MC_ERROR_UE_PAGE_TABLE_WALK_IFETCH 2
+#define MC_ERROR_UE_LOAD_STORE 3
+#define MC_ERROR_UE_PAGE_TABLE_WALK_LOAD_STORE 4
+
+#define MC_ERROR_SLB_PARITY0
+#define MC_ERROR_SLB_MULTIHIT  1
+#define MC_ERROR_SLB_INDETERMINATE 2
+
+#define MC_ERROR_ERAT_PARITY   1
+#define MC_ERROR_ERAT_MULTIHIT 2
+#define MC_ERROR_ERAT_INDETERMINATE3
+
+#define MC_ERROR_TLB_PARITY1
+#define MC_ERROR_TLB_MULTIHIT  2
+#define MC_ERROR_TLB_INDETERMINATE 3
+
+static inline u8 rtas_mc_error_sub_type(const struct pseries_mc_errorlog *mlog)
+{
+   switch (mlog->error_type) {
+   caseMC_ERROR_TYPE_UE:
+   return (mlog->sub_err_type & 0x07);
+   caseMC_ERROR_TYPE_SLB:
+   caseMC_ERROR_TYPE_ERAT:
+   caseMC_ERROR_TYPE_TLB:
+   return (mlog->sub_err_type & 0x03);
+   default:
+   return 0;
+   }
+}
+
+static
+inline u64 rtas_mc_get_effective_addr(const struct pseries_mc_errorlog *mlog)
+{
+   __be64 addr = 0;
+
+   switch (mlog->error_type) {
+   caseMC_ERROR_TYPE_UE:
+   if (mlog->sub_err_type & 0x40)
+   addr = mlog->effective_address;
+   break;
+   caseMC_ERROR_TYPE_SLB:
+   caseMC_ERROR_TYPE_ERAT:
+   caseMC_ERROR_TYPE_TLB:
+   if (mlog->sub_err_type & 0x80)
+   addr = mlog->effective_address;
+   default:
+   

[PATCH v9 5/5] powernv/pseries: consolidate code for mce early handling.

2018-08-27 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar 

Now that other platforms also implements real mode mce handler,
lets consolidate the code by sharing existing powernv machine check
early code. Rename machine_check_powernv_early to
machine_check_common_early and reuse the code.

Signed-off-by: Mahesh Salgaonkar 
---
 arch/powerpc/kernel/exceptions-64s.S |  155 ++
 1 file changed, 28 insertions(+), 127 deletions(-)

diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 43258faa8289..3ee227c27701 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -243,14 +243,13 @@ EXC_REAL_BEGIN(machine_check, 0x200, 0x100)
SET_SCRATCH0(r13)   /* save r13 */
EXCEPTION_PROLOG_0(PACA_EXMC)
 BEGIN_FTR_SECTION
-   b   machine_check_powernv_early
+   b   machine_check_common_early
 FTR_SECTION_ELSE
b   machine_check_pSeries_0
 ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
 EXC_REAL_END(machine_check, 0x200, 0x100)
 EXC_VIRT_NONE(0x4200, 0x100)
-TRAMP_REAL_BEGIN(machine_check_powernv_early)
-BEGIN_FTR_SECTION
+TRAMP_REAL_BEGIN(machine_check_common_early)
EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
/*
 * Register contents:
@@ -306,7 +305,9 @@ BEGIN_FTR_SECTION
/* Save r9 through r13 from EXMC save area to stack frame. */
EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
mfmsr   r11 /* get MSR value */
+BEGIN_FTR_SECTION
ori r11,r11,MSR_ME  /* turn on ME bit */
+END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
ori r11,r11,MSR_RI  /* turn on RI bit */
LOAD_HANDLER(r12, machine_check_handle_early)
 1: mtspr   SPRN_SRR0,r12
@@ -325,7 +326,6 @@ BEGIN_FTR_SECTION
andcr11,r11,r10 /* Turn off MSR_ME */
b   1b
b   .   /* prevent speculative execution */
-END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
 
 TRAMP_REAL_BEGIN(machine_check_pSeries)
.globl machine_check_fwnmi
@@ -333,7 +333,7 @@ machine_check_fwnmi:
SET_SCRATCH0(r13)   /* save r13 */
EXCEPTION_PROLOG_0(PACA_EXMC)
 BEGIN_FTR_SECTION
-   b   machine_check_pSeries_early
+   b   machine_check_common_early
 END_FTR_SECTION_IFCLR(CPU_FTR_HVMODE)
 machine_check_pSeries_0:
EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST_PR, 0x200)
@@ -346,103 +346,6 @@ machine_check_pSeries_0:
 
 TRAMP_KVM_SKIP(PACA_EXMC, 0x200)
 
-TRAMP_REAL_BEGIN(machine_check_pSeries_early)
-BEGIN_FTR_SECTION
-   EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
-   mr  r10,r1  /* Save r1 */
-   lhz r11,PACA_IN_MCE(r13)
-   cmpwi   r11,0   /* Are we in nested machine check */
-   bne 0f  /* Yes, we are. */
-   /* First machine check entry */
-   ld  r1,PACAMCEMERGSP(r13)   /* Use MC emergency stack */
-0: subir1,r1,INT_FRAME_SIZE/* alloc stack frame */
-   addir11,r11,1   /* increment paca->in_mce */
-   sth r11,PACA_IN_MCE(r13)
-   /* Limit nested MCE to level 4 to avoid stack overflow */
-   cmpwi   r11,MAX_MCE_DEPTH
-   bgt 1f  /* Check if we hit limit of 4 */
-   mfspr   r11,SPRN_SRR0   /* Save SRR0 */
-   mfspr   r12,SPRN_SRR1   /* Save SRR1 */
-   EXCEPTION_PROLOG_COMMON_1()
-   EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
-   EXCEPTION_PROLOG_COMMON_3(0x200)
-   addir3,r1,STACK_FRAME_OVERHEAD
-   BRANCH_LINK_TO_FAR(machine_check_early) /* Function call ABI */
-   ld  r12,_MSR(r1)
-   andi.   r11,r12,MSR_PR  /* See if coming from user. */
-   bne 2f  /* continue in V mode if we are. */
-
-   /*
-* At this point we are not sure about what context we come from.
-* We may be in the middle of switching stack. r1 may not be valid.
-* Hence stay on emergency stack, call machine_check_exception and
-* return from the interrupt.
-* But before that, check if this is an un-recoverable exception.
-* If yes, then stay on emergency stack and panic.
-*/
-   andi.   r11,r12,MSR_RI
-   beq 1f
-
-   /*
-* Check if we have successfully handled/recovered from error, if not
-* then stay on emergency stack and panic.
-*/
-   cmpdi   r3,0/* see if we handled MCE successfully */
-   beq 1f  /* if !handled then panic */
-
-   /* Stay on emergency stack and return from interrupt. */
-   LOAD_HANDLER(r10,mce_return)
-   mtspr   SPRN_SRR0,r10
-   ld  r10,PACAKMSR(r13)
-   mtspr   SPRN_SRR1,r10
-   RFI_TO_KERNEL
-   b   .
-
-1: LOAD_HANDLER(r10,unrecover_mce)
-   mtspr   SPRN_SRR0,r10
-   ld  r10,PACAKMSR(r13)
-   /*
-* We are going down. But there are chances 

[PATCH v9 4/5] powerpc/pseries: Dump the SLB contents on SLB MCE errors.

2018-08-27 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar 

If we get a machine check exceptions due to SLB errors then dump the
current SLB contents which will be very much helpful in debugging the
root cause of SLB errors. Introduce an exclusive buffer per cpu to hold
faulty SLB entries. In real mode mce handler saves the old SLB contents
into this buffer accessible through paca and print it out later in virtual
mode.

With this patch the console will log SLB contents like below on SLB MCE
errors:

[  507.297236] SLB contents of cpu 0x1
[  507.297237] Last SLB entry inserted at slot 16
[  507.297238] 00 c800 400ea1b217000500
[  507.297239]   1T  ESID=   c0  VSID=  ea1b217 LLP:100
[  507.297240] 01 d800 400d43642f000510
[  507.297242]   1T  ESID=   d0  VSID=  d43642f LLP:110
[  507.297243] 11 f800 400a86c85f000500
[  507.297244]   1T  ESID=   f0  VSID=  a86c85f LLP:100
[  507.297245] 12 7f000800 4008119624000d90
[  507.297246]   1T  ESID=   7f  VSID=  8119624 LLP:110
[  507.297247] 13 1800 00092885f5150d90
[  507.297247]  256M ESID=1  VSID=   92885f5150 LLP:110
[  507.297248] 14 01000800 4009e7cb5d90
[  507.297249]   1T  ESID=1  VSID=  9e7cb50 LLP:110
[  507.297250] 15 d800 400d43642f000510
[  507.297251]   1T  ESID=   d0  VSID=  d43642f LLP:110
[  507.297252] 16 d800 400d43642f000510
[  507.297253]   1T  ESID=   d0  VSID=  d43642f LLP:110
[  507.297253] --
[  507.297254] SLB cache ptr value = 3
[  507.297254] Valid SLB cache entries:
[  507.297255] 00 EA[0-35]=7f000
[  507.297256] 01 EA[0-35]=1
[  507.297257] 02 EA[0-35]= 1000
[  507.297257] Rest of SLB cache entries:
[  507.297258] 03 EA[0-35]=7f000
[  507.297258] 04 EA[0-35]=1
[  507.297259] 05 EA[0-35]= 1000
[  507.297260] 06 EA[0-35]=   12
[  507.297260] 07 EA[0-35]=7f000

Suggested-by: Aneesh Kumar K.V 
Suggested-by: Michael Ellerman 
Signed-off-by: Mahesh Salgaonkar 
Reviewed-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/book3s/64/mmu-hash.h |7 ++
 arch/powerpc/include/asm/paca.h   |6 ++
 arch/powerpc/mm/slb.c |   72 +
 arch/powerpc/platforms/pseries/ras.c  |   17 ++
 arch/powerpc/platforms/pseries/setup.c|   13 +
 5 files changed, 114 insertions(+), 1 deletion(-)

diff --git a/arch/powerpc/include/asm/book3s/64/mmu-hash.h 
b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
index afca8c11d996..925271d95122 100644
--- a/arch/powerpc/include/asm/book3s/64/mmu-hash.h
+++ b/arch/powerpc/include/asm/book3s/64/mmu-hash.h
@@ -485,11 +485,18 @@ static inline void hpte_init_pseries(void) { }
 
 extern void hpte_init_native(void);
 
+struct slb_entry {
+   u64 esid;
+   u64 vsid;
+};
+
 extern void slb_initialize(void);
 extern void slb_flush_and_rebolt(void);
 extern void slb_flush_all_realmode(void);
 extern void __slb_restore_bolted_realmode(void);
 extern void slb_restore_bolted_realmode(void);
+extern void slb_save_contents(struct slb_entry *slb_ptr);
+extern void slb_dump_contents(struct slb_entry *slb_ptr);
 
 extern void slb_vmalloc_update(void);
 extern void slb_set_size(u16 size);
diff --git a/arch/powerpc/include/asm/paca.h b/arch/powerpc/include/asm/paca.h
index 7f22929ce915..8767abb521c2 100644
--- a/arch/powerpc/include/asm/paca.h
+++ b/arch/powerpc/include/asm/paca.h
@@ -255,6 +255,12 @@ struct paca_struct {
 #ifdef CONFIG_PPC_PSERIES
u8 *mce_data_buf;   /* buffer to hold per cpu rtas errlog */
 #endif /* CONFIG_PPC_PSERIES */
+
+#ifdef CONFIG_PPC_BOOK3S_64
+   /* Capture SLB related old contents in MCE handler. */
+   struct slb_entry *mce_faulty_slbs;
+   u16 slb_save_cache_ptr;
+#endif /* CONFIG_PPC_BOOK3S_64 */
 } cacheline_aligned;
 
 extern void copy_mm_to_paca(struct mm_struct *mm);
diff --git a/arch/powerpc/mm/slb.c b/arch/powerpc/mm/slb.c
index 9f574e59d178..2619115a63f1 100644
--- a/arch/powerpc/mm/slb.c
+++ b/arch/powerpc/mm/slb.c
@@ -184,6 +184,78 @@ void slb_flush_and_rebolt(void)
get_paca()->slb_cache_ptr = 0;
 }
 
+void slb_save_contents(struct slb_entry *slb_ptr)
+{
+   int i;
+   unsigned long e, v;
+
+   /* Save slb_cache_ptr value. */
+   get_paca()->slb_save_cache_ptr = get_paca()->slb_cache_ptr;
+
+   if (!slb_ptr)
+   return;
+
+   for (i = 0; i < mmu_slb_size; i++) {
+   asm volatile("slbmfee  %0,%1" : "=r" (e) : "r" (i));
+   asm volatile("slbmfev  %0,%1" : "=r" (v) : "r" (i));
+   slb_ptr->esid = e;
+   slb_ptr->vsid = v;
+   slb_ptr++;
+   }
+}
+
+void slb_dump_contents(struct slb_entry *slb_ptr)
+{
+   int i, n;
+   unsigned long e, v;
+   unsigned long llp;
+
+   if (!slb_ptr)
+   return;
+
+   pr_err("SLB contents of cpu 0x%x\n", 

[PATCH v9 3/5] powerpc/pseries: Display machine check error details.

2018-08-27 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar 

Extract the MCE error details from RTAS extended log and display it to
console.

With this patch you should now see mce logs like below:

[  142.371818] Severe Machine check interrupt [Recovered]
[  142.371822]   NIP [dca301b8]: init_module+0x1b8/0x338 [bork_kernel]
[  142.371822]   Initiator: CPU
[  142.371823]   Error type: SLB [Multihit]
[  142.371824] Effective address: dca7

Signed-off-by: Mahesh Salgaonkar 
---
 arch/powerpc/include/asm/rtas.h  |5 +
 arch/powerpc/platforms/pseries/ras.c |  133 ++
 2 files changed, 138 insertions(+)

diff --git a/arch/powerpc/include/asm/rtas.h b/arch/powerpc/include/asm/rtas.h
index adefa6493d29..0183e9595acc 100644
--- a/arch/powerpc/include/asm/rtas.h
+++ b/arch/powerpc/include/asm/rtas.h
@@ -197,6 +197,11 @@ static inline uint8_t rtas_error_extended(const struct 
rtas_error_log *elog)
return (elog->byte1 & 0x04) >> 2;
 }
 
+static inline uint8_t rtas_error_initiator(const struct rtas_error_log *elog)
+{
+   return (elog->byte2 & 0xf0) >> 4;
+}
+
 #define rtas_error_type(x) ((x)->byte3)
 
 static inline
diff --git a/arch/powerpc/platforms/pseries/ras.c 
b/arch/powerpc/platforms/pseries/ras.c
index 4c6f2b523293..26268f324b46 100644
--- a/arch/powerpc/platforms/pseries/ras.c
+++ b/arch/powerpc/platforms/pseries/ras.c
@@ -523,6 +523,136 @@ int pSeries_system_reset_exception(struct pt_regs *regs)
return 0; /* need to perform reset */
 }
 
+#define VAL_TO_STRING(ar, val) \
+   (((val) < ARRAY_SIZE(ar)) ? ar[(val)] : "Unknown")
+
+static void pseries_print_mce_info(struct pt_regs *regs,
+  struct rtas_error_log *errp)
+{
+   const char *level, *sevstr;
+   struct pseries_errorlog *pseries_log;
+   struct pseries_mc_errorlog *mce_log;
+   u8 error_type, err_sub_type;
+   u64 addr;
+   u8 initiator = rtas_error_initiator(errp);
+   int disposition = rtas_error_disposition(errp);
+
+   static const char * const initiators[] = {
+   "Unknown",
+   "CPU",
+   "PCI",
+   "ISA",
+   "Memory",
+   "Power Mgmt",
+   };
+   static const char * const mc_err_types[] = {
+   "UE",
+   "SLB",
+   "ERAT",
+   "TLB",
+   "D-Cache",
+   "Unknown",
+   "I-Cache",
+   };
+   static const char * const mc_ue_types[] = {
+   "Indeterminate",
+   "Instruction fetch",
+   "Page table walk ifetch",
+   "Load/Store",
+   "Page table walk Load/Store",
+   };
+
+   /* SLB sub errors valid values are 0x0, 0x1, 0x2 */
+   static const char * const mc_slb_types[] = {
+   "Parity",
+   "Multihit",
+   "Indeterminate",
+   };
+
+   /* TLB and ERAT sub errors valid values are 0x1, 0x2, 0x3 */
+   static const char * const mc_soft_types[] = {
+   "Unknown",
+   "Parity",
+   "Multihit",
+   "Indeterminate",
+   };
+
+   if (!rtas_error_extended(errp)) {
+   pr_err("Machine check interrupt: Missing extended error log\n");
+   return;
+   }
+
+   pseries_log = get_pseries_errorlog(errp, PSERIES_ELOG_SECT_ID_MCE);
+   if (pseries_log == NULL)
+   return;
+
+   mce_log = (struct pseries_mc_errorlog *)pseries_log->data;
+
+   error_type = mce_log->error_type;
+   err_sub_type = rtas_mc_error_sub_type(mce_log);
+
+   switch (rtas_error_severity(errp)) {
+   case RTAS_SEVERITY_NO_ERROR:
+   level = KERN_INFO;
+   sevstr = "Harmless";
+   break;
+   case RTAS_SEVERITY_WARNING:
+   level = KERN_WARNING;
+   sevstr = "";
+   break;
+   case RTAS_SEVERITY_ERROR:
+   case RTAS_SEVERITY_ERROR_SYNC:
+   level = KERN_ERR;
+   sevstr = "Severe";
+   break;
+   case RTAS_SEVERITY_FATAL:
+   default:
+   level = KERN_ERR;
+   sevstr = "Fatal";
+   break;
+   }
+
+   printk("%s%s Machine check interrupt [%s]\n", level, sevstr,
+  disposition == RTAS_DISP_FULLY_RECOVERED ?
+  "Recovered" : "Not recovered");
+   if (user_mode(regs)) {
+   printk("%s  NIP: [%016lx] PID: %d Comm: %s\n", level,
+  regs->nip, current->pid, current->comm);
+   } else {
+   printk("%s  NIP [%016lx]: %pS\n", level, regs->nip,
+  (void *)regs->nip);
+   }
+   printk("%s  Initiator: %s\n", level,
+  VAL_TO_STRING(initiators, initiator));
+
+   switch (error_type) {
+   case MC_ERROR_TYPE_UE:
+   printk("%s  Error type: %s [%s]\n", level,
+  

[PATCH v9 2/5] powerpc/pseries: flush SLB contents on SLB MCE errors.

2018-08-27 Thread Mahesh J Salgaonkar
From: Mahesh Salgaonkar 

On pseries, as of today system crashes if we get a machine check
exceptions due to SLB errors. These are soft errors and can be fixed by
flushing the SLBs so the kernel can continue to function instead of
system crash. We do this in real mode before turning on MMU. Otherwise
we would run into nested machine checks. This patch now fetches the
rtas error log in real mode and flushes the SLBs on SLB/ERAT errors.

Signed-off-by: Mahesh Salgaonkar 
Signed-off-by: Michal Suchanek 
Reviewed-by: Nicholas Piggin 
---

Changes in V9:
- Move mce_exceptions counting to powernv's virtual mode handler.
- Recover from ERAT errors.
---
 arch/powerpc/include/asm/machdep.h   |1 
 arch/powerpc/include/asm/mce.h   |3 +
 arch/powerpc/kernel/exceptions-64s.S |  129 ++
 arch/powerpc/kernel/mce.c|9 +-
 arch/powerpc/kernel/mce_power.c  |2 
 arch/powerpc/platforms/powernv/opal.c|2 
 arch/powerpc/platforms/powernv/setup.c   |   11 +++
 arch/powerpc/platforms/pseries/pseries.h |1 
 arch/powerpc/platforms/pseries/ras.c |   60 ++
 arch/powerpc/platforms/pseries/setup.c   |1 
 10 files changed, 213 insertions(+), 6 deletions(-)

diff --git a/arch/powerpc/include/asm/machdep.h 
b/arch/powerpc/include/asm/machdep.h
index a47de82fb8e2..b4831f1338db 100644
--- a/arch/powerpc/include/asm/machdep.h
+++ b/arch/powerpc/include/asm/machdep.h
@@ -108,6 +108,7 @@ struct machdep_calls {
 
/* Early exception handlers called in realmode */
int (*hmi_exception_early)(struct pt_regs *regs);
+   long(*machine_check_early)(struct pt_regs *regs);
 
/* Called during machine check exception to retrive fixup address. */
bool(*mce_check_early_recovery)(struct pt_regs *regs);
diff --git a/arch/powerpc/include/asm/mce.h b/arch/powerpc/include/asm/mce.h
index 3a1226e9b465..78a1da95a394 100644
--- a/arch/powerpc/include/asm/mce.h
+++ b/arch/powerpc/include/asm/mce.h
@@ -210,4 +210,7 @@ extern void release_mce_event(void);
 extern void machine_check_queue_event(void);
 extern void machine_check_print_event_info(struct machine_check_event *evt,
   bool user_mode);
+#ifdef CONFIG_PPC_BOOK3S_64
+extern void flush_and_reload_slb(void);
+#endif /* CONFIG_PPC_BOOK3S_64 */
 #endif /* __ASM_PPC64_MCE_H__ */
diff --git a/arch/powerpc/kernel/exceptions-64s.S 
b/arch/powerpc/kernel/exceptions-64s.S
index 285c6465324a..43258faa8289 100644
--- a/arch/powerpc/kernel/exceptions-64s.S
+++ b/arch/powerpc/kernel/exceptions-64s.S
@@ -332,6 +332,9 @@ TRAMP_REAL_BEGIN(machine_check_pSeries)
 machine_check_fwnmi:
SET_SCRATCH0(r13)   /* save r13 */
EXCEPTION_PROLOG_0(PACA_EXMC)
+BEGIN_FTR_SECTION
+   b   machine_check_pSeries_early
+END_FTR_SECTION_IFCLR(CPU_FTR_HVMODE)
 machine_check_pSeries_0:
EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST_PR, 0x200)
/*
@@ -343,6 +346,103 @@ machine_check_pSeries_0:
 
 TRAMP_KVM_SKIP(PACA_EXMC, 0x200)
 
+TRAMP_REAL_BEGIN(machine_check_pSeries_early)
+BEGIN_FTR_SECTION
+   EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
+   mr  r10,r1  /* Save r1 */
+   lhz r11,PACA_IN_MCE(r13)
+   cmpwi   r11,0   /* Are we in nested machine check */
+   bne 0f  /* Yes, we are. */
+   /* First machine check entry */
+   ld  r1,PACAMCEMERGSP(r13)   /* Use MC emergency stack */
+0: subir1,r1,INT_FRAME_SIZE/* alloc stack frame */
+   addir11,r11,1   /* increment paca->in_mce */
+   sth r11,PACA_IN_MCE(r13)
+   /* Limit nested MCE to level 4 to avoid stack overflow */
+   cmpwi   r11,MAX_MCE_DEPTH
+   bgt 1f  /* Check if we hit limit of 4 */
+   mfspr   r11,SPRN_SRR0   /* Save SRR0 */
+   mfspr   r12,SPRN_SRR1   /* Save SRR1 */
+   EXCEPTION_PROLOG_COMMON_1()
+   EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
+   EXCEPTION_PROLOG_COMMON_3(0x200)
+   addir3,r1,STACK_FRAME_OVERHEAD
+   BRANCH_LINK_TO_FAR(machine_check_early) /* Function call ABI */
+   ld  r12,_MSR(r1)
+   andi.   r11,r12,MSR_PR  /* See if coming from user. */
+   bne 2f  /* continue in V mode if we are. */
+
+   /*
+* At this point we are not sure about what context we come from.
+* We may be in the middle of switching stack. r1 may not be valid.
+* Hence stay on emergency stack, call machine_check_exception and
+* return from the interrupt.
+* But before that, check if this is an un-recoverable exception.
+* If yes, then stay on emergency stack and panic.
+*/
+   andi.   r11,r12,MSR_RI
+   beq 1f
+
+   /*
+* Check if we have successfully handled/recovered from error, if not
+   

[PATCH v9 0/5] powerpc/pseries: Machine check handler improvements.

2018-08-27 Thread Mahesh J Salgaonkar
This patch series includes some improvement to Machine check handler
for pSeries. First 3 patches from v7 revision are already in powerpc next.
Posting rest of the patches with review comments. This patch series drops
the sysctl knob patch that was proposed in v7. The SLB recovery code now
uses flush_and_reload_slb() from mce_power.c.

Patch 1 defines MCE error event section.
Patch 2 implements a real mode mce handler and flushes the SLBs on SLB error.
Patch 3 display's the MCE error details on console.
Patch 4 saves and dumps the SLB contents on SLB MCE errors to improve the
debugability.
Patch 5 consolidates mce early real mode handling code.

Change in V9:
- Move mce_exceptions counting to powernv's virtual mode handler.
- Recover from ERAT errors.
- Minor changes to fix few warnings/checks from checkpatch.pl

Change in V8:
- Move mce error log structure definition to ras.c
- Use flush_and_reload_slb() from mce_power.c.
- Limit the slb saving to single level of mce recursion.
- Move mce_faulty_slbs and slb_save_cache_ptr under CONFIG_PPC_BOOK3S_64
  instead of CONFIG_PPC_PSERIES.
- Drop the sysctl knob patch.

Change in V7:
- Fold Michal's patch into patch 5
- Handle MSR_RI=0 and evil context case in MC handler in patch 5.
- Patch 7: Print slb cache ptr value and slb cache data.
- Move patch 8 to patch 9.
- Introduce patch 8 add sysctl knob for recovery action on recovered MCEs.

Change in V6:
- Introduce patch 8 to consolidate early real mode handling code.
- Address Nick's comment on erroneous hunk.

Change in V5:
- Use min_t instead of max_t.
- Fix an issue reported by kbuild test robot and address review comments.

Change in V4:
- Flush the SLBs in real mode mce handler to handle SLB errors for entry 0.
- Allocate buffers per cpu to hold rtas error log and old slb contents.
- Defer the logging of rtas error log to irq work queue.

Change in V3:
- Moved patch 5 to patch 2

Change in V2:
- patch 3: Display additional info (NIP and task info) in MCE error details.
- patch 5: Fix endain bug while restoring of r3 in MCE handler.


---

Mahesh Salgaonkar (5):
  powerpc/pseries: Define MCE error event section.
  powerpc/pseries: flush SLB contents on SLB MCE errors.
  powerpc/pseries: Display machine check error details.
  powerpc/pseries: Dump the SLB contents on SLB MCE errors.
  powernv/pseries: consolidate code for mce early handling.


 arch/powerpc/include/asm/book3s/64/mmu-hash.h |7 +
 arch/powerpc/include/asm/machdep.h|1 
 arch/powerpc/include/asm/mce.h|3 
 arch/powerpc/include/asm/paca.h   |6 
 arch/powerpc/include/asm/rtas.h   |   13 +
 arch/powerpc/kernel/exceptions-64s.S  |   42 +++
 arch/powerpc/kernel/mce.c |9 -
 arch/powerpc/kernel/mce_power.c   |2 
 arch/powerpc/mm/slb.c |   72 ++
 arch/powerpc/platforms/powernv/opal.c |2 
 arch/powerpc/platforms/powernv/setup.c|   11 +
 arch/powerpc/platforms/pseries/pseries.h  |1 
 arch/powerpc/platforms/pseries/ras.c  |  303 +
 arch/powerpc/platforms/pseries/setup.c|   14 +
 14 files changed, 474 insertions(+), 12 deletions(-)

--
-Mahesh



Re: [RFC PATCH 11/11] powerpc/svm: Increase SWIOTLB buffer size

2018-08-27 Thread Konrad Rzeszutek Wilk
On Fri, Aug 24, 2018 at 01:25:35PM -0300, Thiago Jung Bauermann wrote:
> From: Anshuman Khandual 
> 
> SWIOTLB buffer default size (64MB) is not enough for large sequential write
> operations which eventually leads to kernel crash like here.
> 
> virtio-pci :00:05.0: swiotlb buffer is full (sz: 327680 bytes)
> virtio-pci :00:05.0: DMA: Out of SW-IOMMU space for 327680 bytes
> Kernel panic - not syncing: DMA: Random memory could be DMA read
> CPU: 12 PID: 3985 Comm: mkfs.ext4 Not tainted 4.18.0-rc4+ #285
> Call Trace:
> [c007d2a27020] [c0cfdffc] dump_stack+0xb0/0xf4 (unreliable)
> [c007d2a27060] [c0112a98] panic+0x140/0x328
> [c007d2a270f0] [c01b4f88] swiotlb_full+0x108/0x130
> [c007d2a27180] [c01b5f6c] swiotlb_map_page+0x25c/0x2c0
> [c007d2a271e0] [c07bfaf8] vring_map_one_sg.isra.0+0x58/0x70
> [c007d2a27200] [c07c08dc] virtqueue_add_sgs+0x1bc/0x690
> [c007d2a272f0] [d42a1280] virtio_queue_rq+0x358/0x4a0 [virtio_blk]
> [c007d2a273d0] [c06b5d68] blk_mq_dispatch_rq_list+0x1f8/0x6d0
> ..
> 
> Increase the SWIOTLB size to 1GB on Ultravisor based secure guests.

Gosh, that is huge.

What about making the SWIOTLB be more dynamic? That is expand it's size
dynamically if it can?

> 
> Signed-off-by: Anshuman Khandual 
> Signed-off-by: Thiago Jung Bauermann 
> ---
>  arch/powerpc/Kconfig | 5 +
>  kernel/dma/swiotlb.c | 5 +
>  2 files changed, 10 insertions(+)
> 
> diff --git a/arch/powerpc/Kconfig b/arch/powerpc/Kconfig
> index 1466d1234723..fee7194ce9e4 100644
> --- a/arch/powerpc/Kconfig
> +++ b/arch/powerpc/Kconfig
> @@ -457,6 +457,11 @@ config PPC_SVM
>  
>If unsure, say "N".
>  
> +config SWIOTLB_DEFAULT_SIZE
> +   int "Size of Software I/O TLB buffer (in MiB)"
> +   default "1024"
> +   depends on PPC_SVM
> +
>  config PPC_TRANSACTIONAL_MEM
> bool "Transactional Memory support for POWERPC"
> depends on PPC_BOOK3S_64
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index 04b68d9dffac..32dc67422d8a 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
> @@ -146,8 +146,13 @@ void swiotlb_set_max_segment(unsigned int val)
>   max_segment = rounddown(val, PAGE_SIZE);
>  }
>  
> +#ifdef CONFIG_SWIOTLB_DEFAULT_SIZE
> +#define IO_TLB_DEFAULT_SIZE ((unsigned long) CONFIG_SWIOTLB_DEFAULT_SIZE << 
> 20)
> +#else
>  /* default to 64MB */
>  #define IO_TLB_DEFAULT_SIZE (64UL<<20)
> +#endif
> +
>  unsigned long swiotlb_size_or_default(void)
>  {
>   unsigned long size;
> 


FSL/NXP P5020: USB problems with the latest Git kernels

2018-08-27 Thread Christian Zigotzky
Hello,

Our users tested the RC1 of kernel 4.19 on their P5020 boards today. 
Unfortunately the USB bug still exists. With mem values bigger than 4096M, the 
USB mouse and keyboard doesn’t work. With the bootarg mem=4096M, the USB 
devices work without any problems. Please compile the RC1 and test it on your 
P5020 board. There is a problem with the memory management since 22/08/18. 

Thanks,
Christian

Sent from my iPhone

> On 25. Aug 2018, at 22:19, Christian Zigotzky  wrote:
> 
> Hello,
> 
> With the boot argument “mem=3500M” the USB devices work. Please compile the 
> latest Git kernel and test it on your P5020 board. There is a problem with 
> the memory management since 22/08/18. I can’t test because I don’t have a 
> P5020 board here and our users can’t compile kernels.
> 
> Thanks,
> Christian
> 
> Sent from my iPhone
> 
>> On 24. Aug 2018, at 20:11, Christian Zigotzky  wrote:
>> 
>> Hello,
>> 
>> There are USB problems with P5020 boards with the latest Git kernels.
>> 
>> Some users reported the following error messages:
>> 
>> skateman@X5000LNX:~$ grep -i -E 'usb.*error' /var/log/syslog
>> Aug 24 13:12:50 X5000LNX kernel: [ 6.552303] usb 1-1: device descriptor 
>> read/64, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 6.649376] usb 2-1: device descriptor 
>> read/64, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 6.794158] usb 1-1: device descriptor 
>> read/64, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 6.883156] usb 2-1: device descriptor 
>> read/64, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 7.139155] usb 1-1: device descriptor 
>> read/64, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 7.226156] usb 2-1: device descriptor 
>> read/64, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 7.363155] usb 1-1: device descriptor 
>> read/64, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 7.451156] usb 2-1: device descriptor 
>> read/64, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 8.521156] usb 1-1: device not accepting 
>> address 4, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 8.609156] usb 2-1: device not accepting 
>> address 4, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 9.057155] usb 1-1: device not accepting 
>> address 5, error -32
>> Aug 24 13:12:50 X5000LNX kernel: [ 9.145157] usb 2-1: device not accepting 
>> address 5, error -32
>> 
>> I don’t have a P5020 board here. That means I can’t bisect and test. 
>> Therefore I need your help. The problematic Git commit must be somewhere 
>> between 22/08/18 1:20 PM UTC and 23/08/18 10:49 AM UTC.
>> The Git kernel from 22/08/18 1:20 PM UTC works with USB devices.
>> Could you please compile a Git kernel and test it on your P5020 board?
>> 
>> Thanks,
>> Christian


Oops running iptables -F OUTPUT

2018-08-27 Thread Andreas Schwab
I'm getting this Oops when running iptables -F OUTPUT:

[   91.139409] Unable to handle kernel paging request for data at address 
0xd001fff12f34
[   91.139414] Faulting instruction address: 0xd16a5718
[   91.139419] Oops: Kernel access of bad area, sig: 11 [#1]
[   91.139426] BE SMP NR_CPUS=2 PowerMac
[   91.139434] Modules linked in: iptable_filter ip_tables x_tables bpfilter 
nfsd auth_rpcgss lockd grace nfs_acl sunrpc tun af_packet snd_aoa_codec_tas 
snd_aoa_fabric_layout snd_aoa snd_aoa_i2sbus snd_aoa_soundbus snd_pcm_oss 
snd_pcm snd_seq snd_timer snd_seq_device snd_mixer_oss snd sungem sr_mod 
firewire_ohci cdrom sungem_phy soundcore firewire_core pata_macio crc_itu_t sg 
hid_generic usbhid linear md_mod ohci_pci ohci_hcd ehci_pci ehci_hcd usbcore 
usb_common dm_snapshot dm_bufio dm_mirror dm_region_hash dm_log dm_mod sata_svw
[   91.139522] CPU: 1 PID: 3620 Comm: iptables Not tainted 4.19.0-rc1 #1
[   91.139526] NIP:  d16a5718 LR: d16a569c CTR: c06f560c
[   91.139531] REGS: c001fa577670 TRAP: 0300   Not tainted  (4.19.0-rc1)
[   91.139534] MSR:  9200b032   CR: 
84002484  XER: 2000
[   91.139553] DAR: d001fff12f34 DSISR: 4000 IRQMASK: 0 
GPR00: d16a569c c001fa5778f0 d16b0400  
GPR04: 0002  8001fa46418e c001fa0d05c8 
GPR08: d16b0400 d00037f13000 0001ff3e7000 d16a6fb8 
GPR12: c06f560c c780   
GPR16: 11635010 3fffa1b7aa68   
GPR20: 0003 10013918 116350c0 c0b88990 
GPR24: c0b88ba4  d001fff12f34  
GPR28: d16b8000 c001fa20f400 c001fa20f440  
[   91.139627] NIP [d16a5718] .alloc_counters.isra.10+0xbc/0x140 
[ip_tables]
[   91.139634] LR [d16a569c] .alloc_counters.isra.10+0x40/0x140 
[ip_tables]
[   91.139638] Call Trace:
[   91.139645] [c001fa5778f0] [d16a569c] 
.alloc_counters.isra.10+0x40/0x140 [ip_tables] (unreliable)
[   91.139655] [c001fa5779b0] [d16a5b54] 
.do_ipt_get_ctl+0x110/0x2ec [ip_tables]
[   91.139666] [c001fa577aa0] [c06233e0] .nf_getsockopt+0x68/0x88
[   91.139674] [c001fa577b40] [c0631608] .ip_getsockopt+0xbc/0x128
[   91.139682] [c001fa577bf0] [c065adf4] .raw_getsockopt+0x18/0x5c
[   91.139690] [c001fa577c60] [c05b5f60] 
.sock_common_getsockopt+0x2c/0x40
[   91.139697] [c001fa577cd0] [c05b3394] .__sys_getsockopt+0xa4/0xd0
[   91.139704] [c001fa577d80] [c05b5ab0] 
.__se_sys_socketcall+0x238/0x2b4
[   91.139712] [c001fa577e30] [c000a31c] system_call+0x5c/0x70
[   91.139716] Instruction dump:
[   91.139721] 39290040 7d3d4a14 7fbe4840 409cff98 8138 2b890001 419d000c 
393e0060 
[   91.139736] 4810 7d57c82a e93e0060 7d295214 <815a> 794807e1 41e20010 
7c210b78 
[   91.139752] ---[ end trace f5d1d5431651845d ]---


Andreas.

-- 
Andreas Schwab, sch...@linux-m68k.org
GPG Key fingerprint = 7578 EB47 D4E5 4D69 2510  2552 DF73 E780 A9DA AEC1
"And now for something completely different."


Re: [PATCH v2 3/3] drivers/block/z2ram: use ioremap_wt() instead of __ioremap(_PAGE_WRITETHRU)

2018-08-27 Thread Geert Uytterhoeven
On Mon, Aug 27, 2018 at 6:10 PM Christophe Leroy
 wrote:
> _PAGE_WRITETHRU is a target specific flag. Prefer generic functions.
>
> Signed-off-by: Christophe Leroy 

>From a Zorro bus point of view:
Acked-by: Geert Uytterhoeven 

> --- a/drivers/block/z2ram.c
> +++ b/drivers/block/z2ram.c
> @@ -190,8 +190,7 @@ static int z2_open(struct block_device *bdev, fmode_t 
> mode)
> vfree(vmalloc (size));
> }
>
> -   vaddr = (unsigned long) __ioremap (paddr, size,
> -  _PAGE_WRITETHRU);
> +   vaddr = (unsigned long)ioremap_wt(paddr, size);
>
>  #else
> vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size);

However, since the removal of APUS support, this file can no longer be
compiled on powerpc.

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


[PATCH v2 3/3] drivers/block/z2ram: use ioremap_wt() instead of __ioremap(_PAGE_WRITETHRU)

2018-08-27 Thread Christophe Leroy
_PAGE_WRITETHRU is a target specific flag. Prefer generic functions.

Signed-off-by: Christophe Leroy 
---
 v2: no change

 drivers/block/z2ram.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/block/z2ram.c b/drivers/block/z2ram.c
index d0c5bc4e0703..cfbd70520eeb 100644
--- a/drivers/block/z2ram.c
+++ b/drivers/block/z2ram.c
@@ -190,8 +190,7 @@ static int z2_open(struct block_device *bdev, fmode_t mode)
vfree(vmalloc (size));
}
 
-   vaddr = (unsigned long) __ioremap (paddr, size, 
-  _PAGE_WRITETHRU);
+   vaddr = (unsigned long)ioremap_wt(paddr, size);
 
 #else
vaddr = (unsigned long)z_remap_nocache_nonser(paddr, size);
-- 
2.13.3



[PATCH v2 2/3] drivers/video/fbdev: use ioremap_wt() instead of __ioremap(_PAGE_WRITETHRU)

2018-08-27 Thread Christophe Leroy
_PAGE_WRITETHRU is a target specific flag. Prefer generic functions.

Signed-off-by: Christophe Leroy 
---
 v2: removed unnecessary includes headers

 drivers/video/fbdev/controlfb.c  |  5 +
 drivers/video/fbdev/platinumfb.c |  5 +
 drivers/video/fbdev/valkyriefb.c | 12 ++--
 3 files changed, 8 insertions(+), 14 deletions(-)

diff --git a/drivers/video/fbdev/controlfb.c b/drivers/video/fbdev/controlfb.c
index 8d14b29aafea..9cb0ef7ac29e 100644
--- a/drivers/video/fbdev/controlfb.c
+++ b/drivers/video/fbdev/controlfb.c
@@ -48,9 +48,7 @@
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
 #include 
 
 #include "macmodes.h"
@@ -715,8 +713,7 @@ static int __init control_of_init(struct device_node *dp)
goto error_out;
}
/* map at most 8MB for the frame buffer */
-   p->frame_buffer = __ioremap(p->frame_buffer_phys, 0x80,
-   _PAGE_WRITETHRU);
+   p->frame_buffer = ioremap_wt(p->frame_buffer_phys, 0x80);
 
if (!p->control_regs_phys ||
!request_mem_region(p->control_regs_phys, p->control_regs_size,
diff --git a/drivers/video/fbdev/platinumfb.c b/drivers/video/fbdev/platinumfb.c
index 377d3399a3ad..bf6b7fb83cf4 100644
--- a/drivers/video/fbdev/platinumfb.c
+++ b/drivers/video/fbdev/platinumfb.c
@@ -32,9 +32,7 @@
 #include 
 #include 
 #include 
-#include 
 #include 
-#include 
 
 #include "macmodes.h"
 #include "platinumfb.h"
@@ -577,8 +575,7 @@ static int platinumfb_probe(struct platform_device* odev)
 
/* frame buffer - map only 4MB */
pinfo->frame_buffer_phys = pinfo->rsrc_fb.start;
-   pinfo->frame_buffer = __ioremap(pinfo->rsrc_fb.start, 0x40,
-   _PAGE_WRITETHRU);
+   pinfo->frame_buffer = ioremap_wt(pinfo->rsrc_fb.start, 0x40);
pinfo->base_frame_buffer = pinfo->frame_buffer;
 
/* registers */
diff --git a/drivers/video/fbdev/valkyriefb.c b/drivers/video/fbdev/valkyriefb.c
index 275fb98236d3..d51c3a8009cb 100644
--- a/drivers/video/fbdev/valkyriefb.c
+++ b/drivers/video/fbdev/valkyriefb.c
@@ -54,13 +54,11 @@
 #include 
 #include 
 #include 
-#include 
 #ifdef CONFIG_MAC
 #include 
 #else
 #include 
 #endif
-#include 
 
 #include "macmodes.h"
 #include "valkyriefb.h"
@@ -318,7 +316,7 @@ static void __init valkyrie_choose_mode(struct 
fb_info_valkyrie *p)
 int __init valkyriefb_init(void)
 {
struct fb_info_valkyrie *p;
-   unsigned long frame_buffer_phys, cmap_regs_phys, flags;
+   unsigned long frame_buffer_phys, cmap_regs_phys;
int err;
char *option = NULL;
 
@@ -337,7 +335,6 @@ int __init valkyriefb_init(void)
/* Hardcoded addresses... welcome to 68k Macintosh country :-) */
frame_buffer_phys = 0xf900;
cmap_regs_phys = 0x50f24000;
-   flags = IOMAP_NOCACHE_SER; /* IOMAP_WRITETHROUGH?? */
 #else /* ppc (!CONFIG_MAC) */
{
struct device_node *dp;
@@ -354,7 +351,6 @@ int __init valkyriefb_init(void)
 
frame_buffer_phys = r.start;
cmap_regs_phys = r.start + 0x304000;
-   flags = _PAGE_WRITETHRU;
}
 #endif /* ppc (!CONFIG_MAC) */
 
@@ -369,7 +365,11 @@ int __init valkyriefb_init(void)
}
p->total_vram = 0x10;
p->frame_buffer_phys = frame_buffer_phys;
-   p->frame_buffer = __ioremap(frame_buffer_phys, p->total_vram, flags);
+#ifdef CONFIG_MAC
+   p->frame_buffer = ioremap_nocache(frame_buffer_phys, p->total_vram);
+#else
+   p->frame_buffer = ioremap_wt(frame_buffer_phys, p->total_vram);
+#endif
p->cmap_regs_phys = cmap_regs_phys;
p->cmap_regs = ioremap(p->cmap_regs_phys, 0x1000);
p->valkyrie_regs_phys = cmap_regs_phys+0x6000;
-- 
2.13.3



[PATCH v2 1/3] powerpc/32: Add ioremap_wt()

2018-08-27 Thread Christophe Leroy
Other arches have ioremap_wt() to map IO areas write-through.
Implement it on PPC as well in order to avoid drivers using
__ioremap(_PAGE_WRITETHRU)

Signed-off-by: Christophe Leroy 
---
 v2: no change

 arch/powerpc/include/asm/io.h | 6 ++
 arch/powerpc/mm/pgtable_32.c  | 8 
 2 files changed, 14 insertions(+)

diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h
index e0331e754568..3380b5b22450 100644
--- a/arch/powerpc/include/asm/io.h
+++ b/arch/powerpc/include/asm/io.h
@@ -3,6 +3,9 @@
 #ifdef __KERNEL__
 
 #define ARCH_HAS_IOREMAP_WC
+#ifdef CONFIG_PPC32
+#define ARCH_HAS_IOREMAP_WT
+#endif
 
 /*
  * This program is free software; you can redistribute it and/or
@@ -746,6 +749,8 @@ static inline void iosync(void)
  *
  * * ioremap_wc enables write combining
  *
+ * * ioremap_wt enables write through
+ *
  * * iounmap undoes such a mapping and can be hooked
  *
  * * __ioremap_at (and the pending __iounmap_at) are low level functions to
@@ -767,6 +772,7 @@ extern void __iomem *ioremap(phys_addr_t address, unsigned 
long size);
 extern void __iomem *ioremap_prot(phys_addr_t address, unsigned long size,
  unsigned long flags);
 extern void __iomem *ioremap_wc(phys_addr_t address, unsigned long size);
+void __iomem *ioremap_wt(phys_addr_t address, unsigned long size);
 #define ioremap_nocache(addr, size)ioremap((addr), (size))
 #define ioremap_uc(addr, size) ioremap((addr), (size))
 #define ioremap_cache(addr, size) \
diff --git a/arch/powerpc/mm/pgtable_32.c b/arch/powerpc/mm/pgtable_32.c
index 120a49bfb9c6..528999738645 100644
--- a/arch/powerpc/mm/pgtable_32.c
+++ b/arch/powerpc/mm/pgtable_32.c
@@ -90,6 +90,14 @@ ioremap_wc(phys_addr_t addr, unsigned long size)
 EXPORT_SYMBOL(ioremap_wc);
 
 void __iomem *
+ioremap_wt(phys_addr_t addr, unsigned long size)
+{
+   return __ioremap_caller(addr, size, _PAGE_WRITETHRU,
+   __builtin_return_address(0));
+}
+EXPORT_SYMBOL(ioremap_wt);
+
+void __iomem *
 ioremap_prot(phys_addr_t addr, unsigned long size, unsigned long flags)
 {
/* writeable implies dirty for kernel addresses */
-- 
2.13.3



Re: [PATCH 05/20] swiotlb: allow the architecture to provide a get_required_mask hook

2018-08-27 Thread Konrad Rzeszutek Wilk
On Mon, Jul 30, 2018 at 06:38:09PM +0200, Christoph Hellwig wrote:
> For now this allows consolidating the powerpc code.  In the long run
> we should grow a generic implementation of dma_get_required_mask that
> returns the dma mask required to avoid bounce buffering.
> 
> Signed-off-by: Christoph Hellwig 
Reviewed-by: Konrad Rzeszutek Wilk 

Thank you!
> ---
>  kernel/dma/swiotlb.c | 4 
>  1 file changed, 4 insertions(+)
> 
> diff --git a/kernel/dma/swiotlb.c b/kernel/dma/swiotlb.c
> index 904541055792..1bb420244753 100644
> --- a/kernel/dma/swiotlb.c
> +++ b/kernel/dma/swiotlb.c
> @@ -1084,5 +1084,9 @@ const struct dma_map_ops swiotlb_dma_ops = {
>   .map_page   = swiotlb_map_page,
>   .unmap_page = swiotlb_unmap_page,
>   .dma_supported  = dma_direct_supported,
> +#ifdef swiotlb_get_required_mask
> + .get_required_mask  = swiotlb_get_required_mask,
> +#endif
> +
>  };
>  EXPORT_SYMBOL(swiotlb_dma_ops);
> -- 
> 2.18.0
> 


[PATCH v2] drivers/video/fbdev: use ioremap_wc() instead of __ioremap(_PAGE_NO_CACHE)

2018-08-27 Thread Christophe Leroy
_PAGE_NO_CACHE is a target specific flag. In addition, this flag
is misleading because one would think it requests a noncached page
whereas a noncached page is _PAGE_NO_CACHE | _PAGE_GUARDED

_PAGE_NO_CACHE alone means write combined noncached page, so lets
use ioremap_wc() instead.

Signed-off-by: Christophe Leroy 
---
 v2: removed unnecessary include and enhanced commit log follow Segher's comment

 drivers/video/fbdev/chipsfb.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/video/fbdev/chipsfb.c b/drivers/video/fbdev/chipsfb.c
index f103665cad43..40182ed85648 100644
--- a/drivers/video/fbdev/chipsfb.c
+++ b/drivers/video/fbdev/chipsfb.c
@@ -27,7 +27,6 @@
 #include 
 #include 
 #include 
-#include 
 
 #ifdef CONFIG_PMAC_BACKLIGHT
 #include 
@@ -401,7 +400,7 @@ static int chipsfb_pci_init(struct pci_dev *dp, const 
struct pci_device_id *ent)
 #endif /* CONFIG_PMAC_BACKLIGHT */
 
 #ifdef CONFIG_PPC
-   p->screen_base = __ioremap(addr, 0x20, _PAGE_NO_CACHE);
+   p->screen_base = ioremap_wc(addr, 0x20);
 #else
p->screen_base = ioremap(addr, 0x20);
 #endif
-- 
2.13.3



Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread Peter Zijlstra
On Mon, Aug 27, 2018 at 05:26:53AM -0700, H. Peter Anvin wrote:

> _THIS_IP_, however, is completely ill-defined, other than being an
> address *somewhere* in the same global function (not even necessarily
> the same function if the function is static!)  As my experiment show, in
> many (nearly) cases gcc will hoist the address all the way to the top of
> the function, at least for the current generic implementation.

It seems to have mostly worked so far... did anything change?

> For the case where _THIS_IP_ is passed to an out-of-line function in all
> cases, it is extra pointless because all it does is increase the
> footprint of every caller: _RET_IP_ is inherently passed to the function
> anyway, and with tailcall protection it will uniquely identify a callsite.

So I think we can convert many of the lockdep _THIS_IP_ calls to
_RET_IP_ on the other side, with a wee bit of care.

A little something like so perhaps...

---

 drivers/md/bcache/btree.c|  2 +-
 fs/jbd2/transaction.c|  6 +++---
 fs/super.c   |  4 ++--
 include/linux/fs.h   |  4 ++--
 include/linux/jbd2.h |  4 ++--
 include/linux/lockdep.h  | 21 ++---
 include/linux/percpu-rwsem.h | 22 ++
 include/linux/rcupdate.h |  8 
 include/linux/ww_mutex.h |  2 +-
 kernel/locking/lockdep.c | 14 --
 kernel/printk/printk.c   | 14 +++---
 kernel/sched/core.c  |  4 ++--
 lib/locking-selftest.c   | 32 
 13 files changed, 68 insertions(+), 69 deletions(-)

diff --git a/drivers/md/bcache/btree.c b/drivers/md/bcache/btree.c
index c19f7716df88..21ede9b317de 100644
--- a/drivers/md/bcache/btree.c
+++ b/drivers/md/bcache/btree.c
@@ -940,7 +940,7 @@ static struct btree *mca_alloc(struct cache_set *c, struct 
btree_op *op,
hlist_del_init_rcu(>hash);
hlist_add_head_rcu(>hash, mca_hash(c, k));
 
-   lock_set_subclass(>lock.dep_map, level + 1, _THIS_IP_);
+   lock_set_subclass(>lock.dep_map, level + 1);
b->parent   = (void *) ~0UL;
b->flags= 0;
b->written  = 0;
diff --git a/fs/jbd2/transaction.c b/fs/jbd2/transaction.c
index c0b66a7a795b..40aa71321f8a 100644
--- a/fs/jbd2/transaction.c
+++ b/fs/jbd2/transaction.c
@@ -382,7 +382,7 @@ static int start_this_handle(journal_t *journal, handle_t 
*handle,
read_unlock(>j_state_lock);
current->journal_info = handle;
 
-   rwsem_acquire_read(>j_trans_commit_map, 0, 0, _THIS_IP_);
+   rwsem_acquire_read(>j_trans_commit_map, 0, 0);
jbd2_journal_free_transaction(new_transaction);
/*
 * Ensure that no allocations done while the transaction is open are
@@ -677,7 +677,7 @@ int jbd2__journal_restart(handle_t *handle, int nblocks, 
gfp_t gfp_mask)
if (need_to_start)
jbd2_log_start_commit(journal, tid);
 
-   rwsem_release(>j_trans_commit_map, 1, _THIS_IP_);
+   rwsem_release(>j_trans_commit_map, 1);
handle->h_buffer_credits = nblocks;
/*
 * Restore the original nofs context because the journal restart
@@ -1771,7 +1771,7 @@ int jbd2_journal_stop(handle_t *handle)
wake_up(>j_wait_transaction_locked);
}
 
-   rwsem_release(>j_trans_commit_map, 1, _THIS_IP_);
+   rwsem_release(>j_trans_commit_map, 1);
 
if (wait_for_commit)
err = jbd2_log_wait_commit(journal, tid);
diff --git a/fs/super.c b/fs/super.c
index 50728d9c1a05..ec650a558f09 100644
--- a/fs/super.c
+++ b/fs/super.c
@@ -1431,7 +1431,7 @@ static void lockdep_sb_freeze_release(struct super_block 
*sb)
int level;
 
for (level = SB_FREEZE_LEVELS - 1; level >= 0; level--)
-   percpu_rwsem_release(sb->s_writers.rw_sem + level, 0, 
_THIS_IP_);
+   percpu_rwsem_release(sb->s_writers.rw_sem + level, 0);
 }
 
 /*
@@ -1442,7 +1442,7 @@ static void lockdep_sb_freeze_acquire(struct super_block 
*sb)
int level;
 
for (level = 0; level < SB_FREEZE_LEVELS; ++level)
-   percpu_rwsem_acquire(sb->s_writers.rw_sem + level, 0, 
_THIS_IP_);
+   percpu_rwsem_acquire(sb->s_writers.rw_sem + level, 0);
 }
 
 static void sb_freeze_unlock(struct super_block *sb)
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 1ec33fd0423f..2ba14e5362e4 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -1505,9 +1505,9 @@ void __sb_end_write(struct super_block *sb, int level);
 int __sb_start_write(struct super_block *sb, int level, bool wait);
 
 #define __sb_writers_acquired(sb, lev) \
-   percpu_rwsem_acquire(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_)
+   percpu_rwsem_acquire(&(sb)->s_writers.rw_sem[(lev)-1], 1)
 #define __sb_writers_release(sb, lev)  \
-   percpu_rwsem_release(&(sb)->s_writers.rw_sem[(lev)-1], 1, _THIS_IP_)
+   percpu_rwsem_release(&(sb)->s_writers.rw_sem[(lev)-1], 1)
 
 /**
  * 

Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread H. Peter Anvin
On 08/27/18 00:33, Peter Zijlstra wrote:
> 
> What problem are we trying to solve? _THIS_IP_ and _RET_IP_ work fine.
> We're 'good' at dealing with text addresses, we use them for call stacks
> and all sorts. Why does this need changing?
> 

_RET_IP_ works fine, with the following two caveats:

1. To get a unique IP for each call site, the function call needs to be
   tailcall protected (easily done by wrapping the function in an
  __always_inline function with the notailcall() function I described
  earlier.  Alternatively, a generic macro wrapper for the same thing:

  #define notailcall(x) ({ typeof(x) _x = (x); asm volatile("");  _x; })

2. To uniformly get the return IP, it needs to be defined as:

#define _RET_IP_((unsigned long) \
__builtin_extract_return_addr(__builtin_return_address(0)))

[sorry for the line wrapping]

Using the type unsigned long instead of void * seems kind of pointless
though.


_THIS_IP_, however, is completely ill-defined, other than being an
address *somewhere* in the same global function (not even necessarily
the same function if the function is static!)  As my experiment show, in
many (nearly) cases gcc will hoist the address all the way to the top of
the function, at least for the current generic implementation.

For the case where _THIS_IP_ is passed to an out-of-line function in all
cases, it is extra pointless because all it does is increase the
footprint of every caller: _RET_IP_ is inherently passed to the function
anyway, and with tailcall protection it will uniquely identify a callsite.

For the case where _THIS_IP_ is used inline, I believe the version I
described will at the very least avoid hoisting around volatile accesses
like READ_ONCE(). Surrounding the marked code with asm volatile("");
[which should be turned into a macro or inline, obviously] might be
necessary for it to make any kind of inherent sense.

The proposed "location identifier" does have a serious problem: with
inline functions you might very well have a bunch of duplicates pointing
into the inline function, so a single callsite isn't identifiable.

-hpa



Re: [PATCH v8 5/5] powernv/pseries: consolidate code for mce early handling.

2018-08-27 Thread Mahesh Jagannath Salgaonkar
On 08/23/2018 02:32 PM, Nicholas Piggin wrote:
> On Thu, 23 Aug 2018 14:13:13 +0530
> Mahesh Jagannath Salgaonkar  wrote:
> 
>> On 08/20/2018 05:04 PM, Nicholas Piggin wrote:
>>> On Sun, 19 Aug 2018 22:38:39 +0530
>>> Mahesh J Salgaonkar  wrote:
>>>   
 From: Mahesh Salgaonkar 

 Now that other platforms also implements real mode mce handler,
 lets consolidate the code by sharing existing powernv machine check
 early code. Rename machine_check_powernv_early to
 machine_check_common_early and reuse the code.

 Signed-off-by: Mahesh Salgaonkar 
 ---
  arch/powerpc/kernel/exceptions-64s.S |  155 
 ++
  1 file changed, 28 insertions(+), 127 deletions(-)

 diff --git a/arch/powerpc/kernel/exceptions-64s.S 
 b/arch/powerpc/kernel/exceptions-64s.S
 index 12f056179112..2f85a7baf026 100644
 --- a/arch/powerpc/kernel/exceptions-64s.S
 +++ b/arch/powerpc/kernel/exceptions-64s.S
 @@ -243,14 +243,13 @@ EXC_REAL_BEGIN(machine_check, 0x200, 0x100)
SET_SCRATCH0(r13)   /* save r13 */
EXCEPTION_PROLOG_0(PACA_EXMC)
  BEGIN_FTR_SECTION
 -  b   machine_check_powernv_early
 +  b   machine_check_common_early
  FTR_SECTION_ELSE
b   machine_check_pSeries_0
  ALT_FTR_SECTION_END_IFSET(CPU_FTR_HVMODE)
  EXC_REAL_END(machine_check, 0x200, 0x100)
  EXC_VIRT_NONE(0x4200, 0x100)
 -TRAMP_REAL_BEGIN(machine_check_powernv_early)
 -BEGIN_FTR_SECTION
 +TRAMP_REAL_BEGIN(machine_check_common_early)
EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
/*
 * Register contents:
 @@ -306,7 +305,9 @@ BEGIN_FTR_SECTION
/* Save r9 through r13 from EXMC save area to stack frame. */
EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
mfmsr   r11 /* get MSR value */
 +BEGIN_FTR_SECTION
ori r11,r11,MSR_ME  /* turn on ME bit */
 +END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
ori r11,r11,MSR_RI  /* turn on RI bit */
LOAD_HANDLER(r12, machine_check_handle_early)
  1:mtspr   SPRN_SRR0,r12
 @@ -325,7 +326,6 @@ BEGIN_FTR_SECTION
andcr11,r11,r10 /* Turn off MSR_ME */
b   1b
b   .   /* prevent speculative execution */
 -END_FTR_SECTION_IFSET(CPU_FTR_HVMODE)
  
  TRAMP_REAL_BEGIN(machine_check_pSeries)
.globl machine_check_fwnmi
 @@ -333,7 +333,7 @@ machine_check_fwnmi:
SET_SCRATCH0(r13)   /* save r13 */
EXCEPTION_PROLOG_0(PACA_EXMC)
  BEGIN_FTR_SECTION
 -  b   machine_check_pSeries_early
 +  b   machine_check_common_early
  END_FTR_SECTION_IFCLR(CPU_FTR_HVMODE)
  machine_check_pSeries_0:
EXCEPTION_PROLOG_1(PACA_EXMC, KVMTEST_PR, 0x200)
 @@ -346,103 +346,6 @@ machine_check_pSeries_0:
  
  TRAMP_KVM_SKIP(PACA_EXMC, 0x200)
  
 -TRAMP_REAL_BEGIN(machine_check_pSeries_early)
 -BEGIN_FTR_SECTION
 -  EXCEPTION_PROLOG_1(PACA_EXMC, NOTEST, 0x200)
 -  mr  r10,r1  /* Save r1 */
 -  lhz r11,PACA_IN_MCE(r13)
 -  cmpwi   r11,0   /* Are we in nested machine check */
 -  bne 0f  /* Yes, we are. */
 -  /* First machine check entry */
 -  ld  r1,PACAMCEMERGSP(r13)   /* Use MC emergency stack */
 -0:subir1,r1,INT_FRAME_SIZE/* alloc stack frame */
 -  addir11,r11,1   /* increment paca->in_mce */
 -  sth r11,PACA_IN_MCE(r13)
 -  /* Limit nested MCE to level 4 to avoid stack overflow */
 -  cmpwi   r11,MAX_MCE_DEPTH
 -  bgt 1f  /* Check if we hit limit of 4 */
 -  mfspr   r11,SPRN_SRR0   /* Save SRR0 */
 -  mfspr   r12,SPRN_SRR1   /* Save SRR1 */
 -  EXCEPTION_PROLOG_COMMON_1()
 -  EXCEPTION_PROLOG_COMMON_2(PACA_EXMC)
 -  EXCEPTION_PROLOG_COMMON_3(0x200)
 -  addir3,r1,STACK_FRAME_OVERHEAD
 -  BRANCH_LINK_TO_FAR(machine_check_early) /* Function call ABI */
 -  ld  r12,_MSR(r1)
 -  andi.   r11,r12,MSR_PR  /* See if coming from user. */
 -  bne 2f  /* continue in V mode if we are. */
 -
 -  /*
 -   * At this point we are not sure about what context we come from.
 -   * We may be in the middle of swithing stack. r1 may not be valid.
 -   * Hence stay on emergency stack, call machine_check_exception and
 -   * return from the interrupt.
 -   * But before that, check if this is an un-recoverable exception.
 -   * If yes, then stay on emergency stack and panic.
 -   */
 -  andi.   r11,r12,MSR_RI
 -  beq 1f
 -
 -  /*
 -   * Check if we have successfully handled/recovered from error, if not
 -   * then stay on emergency stack and panic.
 -   */
 -  cmpdi   r3,0/* see if we 

Re: Build regressions/improvements in v4.19-rc1

2018-08-27 Thread Geert Uytterhoeven
On Mon, Aug 27, 2018 at 11:50 AM Geert Uytterhoeven
 wrote:
> Below is the list of build error/warning regressions/improvements in
> v4.19-rc1[1] compared to v4.18[2].
>
> Summarized:
>   - build errors: +5/-3
>   - build warnings: +14732/-179
>
> Note that there may be false regressions, as some logs are incomplete.
> Still, they're build errors/warnings.
>
> Happy fixing! ;-)
>
> Thanks to the linux-next team for providing the build service.
>
> [1] 
> http://kisskb.ellerman.id.au/kisskb/branch/linus/head/5b394b2ddf0347bef56e50c69a58773c94343ff3/
>  (all 240 configs)
> [2] 
> http://kisskb.ellerman.id.au/kisskb/branch/linus/head/94710cac0ef4ee177a63b5227664b38c95bbf703/
>  (239 out of 240 configs)
>
>
> *** ERRORS ***
>
> 5 error regressions:
>   + /kisskb/src/arch/nds32/include/asm/elf.h: error: expected '}' before ';' 
> token:  => 126:29

nds32-allmodconfig, nds32-allyesconfig

>   + error: arch/sparc/kernel/.tmp_head_32.o: relocation truncated to fit: 
> R_SPARC_WDISP22 against `.init.text':  => (.head.text+0x5100), 
> (.head.text+0x5040)
>   + error: arch/sparc/kernel/.tmp_head_32.o: relocation truncated to fit: 
> R_SPARC_WDISP22 against symbol `leon_smp_cpu_startup' defined in .text 
> section in arch/sparc/kernel/trampoline_32.o:  => (.init.text+0xa4)
>   + error: arch/sparc/kernel/process_32.o: relocation truncated to fit: 
> R_SPARC_WDISP22 against `.text':  => (.fixup+0x4), (.fixup+0xc)
>   + error: arch/sparc/kernel/signal_32.o: relocation truncated to fit: 
> R_SPARC_WDISP22 against `.text':  => (.fixup+0x0), (.fixup+0x8), 
> (.fixup+0x10), (.fixup+0x18), (.fixup+0x20)

sparc64/sparc-allmodconfig

> *** WARNINGS ***
>
> [Deleted 14564 lines about "warning: -ffunction-sections disabled; it makes 
> profiling impossible [enabled by default]" on powerpc-all{mod,yes}config*]

Parisc finally managed to get rid of these, and now powerpc got them :-(

Gr{oetje,eeting}s,

Geert

-- 
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- ge...@linux-m68k.org

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say "programmer" or something like that.
-- Linus Torvalds


Re: [PATCH 2/2] powerpc/64s/radix: Explicitly flush ERAT with local LPID invalidation

2018-08-27 Thread Nicholas Piggin
On Mon, 27 Aug 2018 18:16:05 +1000
Benjamin Herrenschmidt  wrote:

> On Mon, 2018-08-27 at 13:03 +1000, Nicholas Piggin wrote:
> > Local radix TLB flush operations that operate on congruence classes
> > have explicit ERAT flushes for POWER9. The process scoped LPID flush
> > did not have a flush, so add it.  
> 
> Paul, is that an actual bug ? I think the ERAT is flushed on LPID
> changes...

FWIW I'd like to add the following patch after these fixes. While I
have your attention...

[PATCH] powerpc/64s/radix: keep kernel ERAT over local process/guest
 invalidates

Signed-off-by: Nicholas Piggin 
---
 arch/powerpc/include/asm/ppc-opcode.h | 10 +-
 arch/powerpc/mm/tlb-radix.c   |  6 +++---
 2 files changed, 12 insertions(+), 4 deletions(-)

diff --git a/arch/powerpc/include/asm/ppc-opcode.h 
b/arch/powerpc/include/asm/ppc-opcode.h
index 665af14850e4..5fe617ab680a 100644
--- a/arch/powerpc/include/asm/ppc-opcode.h
+++ b/arch/powerpc/include/asm/ppc-opcode.h
@@ -568,7 +568,15 @@
 
 #define PPC_SLBIA(IH)  stringify_in_c(.long PPC_INST_SLBIA | \
   ((IH & 0x7) << 21))
-#define PPC_INVALIDATE_ERATPPC_SLBIA(7)
+
+/*
+ * These may only be used by ARCH_300.
+ * GUEST/USER invalidates should only be used by radix mode, on HPT they also
+ * invalidate SLBs so the SLBIA instruction should be used directly.
+ */
+#define PPC_INVALIDATE_ERATPPC_SLBIA(7)
+#define PPC_INVALIDATE_GUEST_ERAT  PPC_SLBIA(6)
+#define PPC_INVALIDATE_USER_ERAT   PPC_SLBIA(3)
 
 #define VCMPEQUD_RC(vrt, vra, vrb) stringify_in_c(.long PPC_INST_VCMPEQUD 
| \
  ___PPC_RT(vrt) | ___PPC_RA(vra) | \
diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
index 4e798f33c530..6887e4b2568b 100644
--- a/arch/powerpc/mm/tlb-radix.c
+++ b/arch/powerpc/mm/tlb-radix.c
@@ -262,7 +262,7 @@ static inline void _tlbiel_pid(unsigned long pid, unsigned 
long ric)
__tlbiel_pid(pid, set, RIC_FLUSH_TLB);
 
asm volatile("ptesync": : :"memory");
-   asm volatile(PPC_INVALIDATE_ERAT "; isync" : : :"memory");
+   asm volatile(PPC_INVALIDATE_USER_ERAT "; isync" : : :"memory");
 }
 
 static inline void _tlbie_pid(unsigned long pid, unsigned long ric)
@@ -314,7 +314,7 @@ static inline void _tlbiel_lpid(unsigned long lpid, 
unsigned long ric)
__tlbiel_lpid(lpid, set, RIC_FLUSH_TLB);
 
asm volatile("ptesync": : :"memory");
-   asm volatile(PPC_INVALIDATE_ERAT "; isync" : : :"memory");
+   asm volatile(PPC_INVALIDATE_GUEST_ERAT "; isync" : : :"memory");
 }
 
 static inline void _tlbie_lpid(unsigned long lpid, unsigned long ric)
@@ -366,7 +366,7 @@ static inline void _tlbiel_lpid_guest(unsigned long lpid, 
unsigned long ric)
__tlbiel_lpid_guest(lpid, set, RIC_FLUSH_TLB);
 
asm volatile("ptesync": : :"memory");
-   asm volatile(PPC_INVALIDATE_ERAT : : :"memory");
+   asm volatile(PPC_INVALIDATE_GUEST_ERAT : : :"memory");
 }
 
 
-- 


Re: [PATCH 2/2] powerpc/64s/radix: Explicitly flush ERAT with local LPID invalidation

2018-08-27 Thread Nicholas Piggin
On Mon, 27 Aug 2018 18:16:05 +1000
Benjamin Herrenschmidt  wrote:

> On Mon, 2018-08-27 at 13:03 +1000, Nicholas Piggin wrote:
> > Local radix TLB flush operations that operate on congruence classes
> > have explicit ERAT flushes for POWER9. The process scoped LPID flush
> > did not have a flush, so add it.  
> 
> Paul, is that an actual bug ? I think the ERAT is flushed on LPID
> changes...

We also have a PPC_INVALIDATE_ERAT in tlbiel_lpid. I'd like to add some
comments for these things because I'm not entirely clear on them myself.

The P9 UM says, "Additionally, mtpidr and mtlpidr instructions perform
an implicit slbia with IH = x‘3’."

Although slbia IH=3 does not appear to invalidate LPID!=0 && PID==0
entries (guest OS mappigs).

The UM also says that tlbiels will clear the involved ERATs, but this
might not match hardware?

Thanks,
Nick

> 
> > Signed-off-by: Nicholas Piggin 
> > ---
> >  arch/powerpc/mm/tlb-radix.c | 1 +
> >  1 file changed, 1 insertion(+)
> > 
> > diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
> > index fef3e1eb3a19..4e798f33c530 100644
> > --- a/arch/powerpc/mm/tlb-radix.c
> > +++ b/arch/powerpc/mm/tlb-radix.c
> > @@ -366,6 +366,7 @@ static inline void _tlbiel_lpid_guest(unsigned long 
> > lpid, unsigned long ric)
> > __tlbiel_lpid_guest(lpid, set, RIC_FLUSH_TLB);
> >  
> > asm volatile("ptesync": : :"memory");
> > +   asm volatile(PPC_INVALIDATE_ERAT : : :"memory");
> >  }
> >  
> >
> 



[PATCH] powerpc: wire up memtest

2018-08-27 Thread Christophe Leroy
Add call to early_memtest() so that kernel compiled with
CONFIG_MEMTEST really perform memtest at startup when requested
via 'memtest' boot parameter.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/kernel/setup-common.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/arch/powerpc/kernel/setup-common.c 
b/arch/powerpc/kernel/setup-common.c
index 93fa0c99681e..904b728eb20d 100644
--- a/arch/powerpc/kernel/setup-common.c
+++ b/arch/powerpc/kernel/setup-common.c
@@ -33,6 +33,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -917,6 +918,8 @@ void __init setup_arch(char **cmdline_p)
/* Parse memory topology */
mem_topology_setup();
 
+   early_memtest(min_low_pfn << PAGE_SHIFT, max_low_pfn << PAGE_SHIFT);
+
/*
 * Release secondary cpus out of their spinloops at 0x60 now that
 * we can map physical -> logical CPU ids.
-- 
2.13.3



Re: [PATCH 16/20] powerpc/dma: use dma_direct_{alloc,free}

2018-08-27 Thread Scott Wood
On Thu, 2018-08-09 at 10:52 +1000, Benjamin Herrenschmidt wrote:
> On Mon, 2018-07-30 at 18:38 +0200, Christoph Hellwig wrote:
> > These do the same functionality as the existing helpers, but do it
> > simpler, and also allow the (optional) use of CMA.
> > 
> > Note that the swiotlb code now calls into the dma_direct code directly,
> > given that it doesn't work with noncoherent caches at all, and isn't
> > called
> > when we have an iommu either, so the iommu special case in
> > dma_nommu_alloc_coherent isn't required for swiotlb.
> 
> I am not convinced that this will produce the same results due to
> the way the zone picking works.
> 
> As for the interaction with swiotlb, we'll need the FSL guys to have
> a look. Scott, do you remember what this is about ?

dma_direct_alloc() has similar (though not identical[1]) zone picking, so I
think it will work.  Needs testing though, and I no longer have a book3e
machine with a PCIe card in it.

The odd thing about this platform (fsl book3e) is the 31-bit[2] limitation on
PCI.  We currently use ZONE_DMA32 for this, rather than ZONE_DMA, at Ben's
request[3].  dma_direct_alloc() regards ZONE_DMA32 as being fixed at 32-bits,
but it doesn't really matter as long as limit_zone_pfn() still works, and the
allocation is made below 2 GiB.  If we were to switch to ZONE_DMA, and have
both 31-bit and 32-bit zones, then dma_direct_alloc() would have a problem
knowing when to use the 31-bit zone since it's based on a non-power-of-2 limit
that isn't reflected in the dma mask.

-Scott

[1] The logic in dma_direct_alloc() seems wrong -- the zone should need to fit
in the mask, not the other way around.  If ARCH_ZONE_DMA_BITS is 24, then
0x007f should be a failure rather than GFP_DMA, 0x7fff should be
GFP_DMA rather than GFP_DMA32, and 0x3 should be GFP_DMA32 rather than
an unrestricted allocation (in each case assuming that the end of RAM is
beyond the mask).

[2] The actual limit is closer to 4 GiB, but not quite due to special windows.
 swiotlb still uses the real limit when deciding whether to bounce, so the dma
mask is still 32 bits.

[3] https://lists.ozlabs.org/pipermail/linuxppc-dev/2012-July/099593.html



Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread Peter Zijlstra
On Sun, Aug 26, 2018 at 07:52:59PM -0700, Nick Desaulniers wrote:
> On Sun, Aug 26, 2018 at 1:25 PM Linus Torvalds

> > Instead, maybe we could encourage something like
> >
> >   struct kernel_loc { const char *file; const char *fn; int line; };
> >
> >   #define __GEN_LOC__(n) \
> > ({ static const struct kernel_loc n = { \
> > __FILE__, __FUNCTION__, __LINE__  \
> >};  })
> >
> >   #define _THIS_LOC_ __GEN_LOC__(__UNIQUE_ID(loc))
> >
> > which is a hell of a lot nicer to use, and actually allows gcc to
> > optimize things (try it: if you pass a _THIS_LOC_ off to an inline
> > function, and that inline function uses the name and line number, gcc
> > will pick them up directly, without the extra structure dereference.
> >
> > Wouldn't it be much nicer to pass these kinds of "location pointer"
> > around, rather than the nasty _THIS_IP_ thing?
> >
> > Certainly lockdep looks like it could easily take that "const struct
> > kernel_loc *" instead of "unsigned long ip". Makes it easy to print
> > out the lockdep info.

> This is extremely reasonable.  I can follow up with the lockdep folks
> to see if they really need _THIS_IP_ to solve their problem, or if
> there's a simpler solution that can solve their needs.  Sometimes
> taking a step back and asking for clarity around the big picture
> allows simpler solutions to shake out.

What problem are we trying to solve? _THIS_IP_ and _RET_IP_ work fine.
We're 'good' at dealing with text addresses, we use them for call stacks
and all sorts. Why does this need changing?


[PATCH] powerpc/sysdev/ipic: check primary_ipic NULL pointer before using it

2018-08-27 Thread Christophe Leroy
ipic_get_mcp_status() is used by targets implementing NMI
watchdog in target specific machine check handler in order
to known whether a machine check results from a watchdog
NMI reset.

In case of very early machine check, primary_ipic pointer
might not have been set yet, so ipic_get_mcp_status() needs
to check it for nullity before using it.

Signed-off-by: Christophe Leroy 
---
 arch/powerpc/sysdev/ipic.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/powerpc/sysdev/ipic.c b/arch/powerpc/sysdev/ipic.c
index 535cf1f6941c..6300123ce965 100644
--- a/arch/powerpc/sysdev/ipic.c
+++ b/arch/powerpc/sysdev/ipic.c
@@ -846,7 +846,7 @@ void ipic_disable_mcp(enum ipic_mcp_irq mcp_irq)
 
 u32 ipic_get_mcp_status(void)
 {
-   return ipic_read(primary_ipic->regs, IPIC_SERSR);
+   return primary_ipic ? ipic_read(primary_ipic->regs, IPIC_SERSR) : 0;
 }
 
 void ipic_clear_mcp_status(u32 mask)
-- 
2.13.3



Re: [PATCH 2/2] powerpc/64s/radix: Explicitly flush ERAT with local LPID invalidation

2018-08-27 Thread Benjamin Herrenschmidt
On Mon, 2018-08-27 at 13:03 +1000, Nicholas Piggin wrote:
> Local radix TLB flush operations that operate on congruence classes
> have explicit ERAT flushes for POWER9. The process scoped LPID flush
> did not have a flush, so add it.

Paul, is that an actual bug ? I think the ERAT is flushed on LPID
changes...

> Signed-off-by: Nicholas Piggin 
> ---
>  arch/powerpc/mm/tlb-radix.c | 1 +
>  1 file changed, 1 insertion(+)
> 
> diff --git a/arch/powerpc/mm/tlb-radix.c b/arch/powerpc/mm/tlb-radix.c
> index fef3e1eb3a19..4e798f33c530 100644
> --- a/arch/powerpc/mm/tlb-radix.c
> +++ b/arch/powerpc/mm/tlb-radix.c
> @@ -366,6 +366,7 @@ static inline void _tlbiel_lpid_guest(unsigned long lpid, 
> unsigned long ric)
>   __tlbiel_lpid_guest(lpid, set, RIC_FLUSH_TLB);
>  
>   asm volatile("ptesync": : :"memory");
> + asm volatile(PPC_INVALIDATE_ERAT : : :"memory");
>  }
>  
>  



11 minute NTP hw clock update racy?

2018-08-27 Thread Joakim Tjernlund
We see corrupt HW clock time every now and then(really hard to reproduce)
Our RTC is a DS1388 on an I2C bus.

Looking at ntp_notify_cmos_timer() and it's delayed work queue impl. I wonder
if there could be a race here w.r.t reboot ?

Could the 11 minute update kick in just as the system is about to reset
the CPU?

I am on 4.14.51, ppc32 and using the ppc_md.restart() hook which will
reset the CPU immediately.

Question, is safe to call ntp_notify_cmos_timer() when the work queue is already
armed(like do_adjtimex() does) ? 

 Jocke


Re: [PATCH] treewide: remove current_text_addr

2018-08-27 Thread Nicholas Piggin
[ Trimmed the cc list because my SMTP didn't accept that many
addresses. ]

On Sun, 26 Aug 2018 13:25:14 -0700
Linus Torvalds  wrote:

> On Sun, Aug 26, 2018 at 12:32 PM H. Peter Anvin  wrote:
> >
> > Here is a full-blown (user space) test program demonstrating the whole
> > technique and how to use it.  
> 
> So while I agree that some _THIS_IP_ users might be better off being
> converted to __builtin_return_address(0) at the caller, I also think
> that the whole "notailcall" thing shows why that can easily be more
> problematic than just our currnet _THIS_IP_ solution.
> 
> Honestly, I'd suggest:
> 
>  - just do the current_text_addr() to _THIS_IP_ conversion
> 
>  - keep _THIS_IP_ and make it be the generic one, and screw the whole
> "some architectures might implement is better" issue. Nobody cares.
> 
>  - try to convince people to move away from the "we want the kernel
> instruction pointer for the call" model entirely, and consider this a
> "legacy" issue.
> 
> The whole instruction pointer is a nasty thing. We should discourage
> it and not make complex infrastructure for it.
> 
> Instead, maybe we could encourage something like
> 
>   struct kernel_loc { const char *file; const char *fn; int line; };
> 
>   #define __GEN_LOC__(n) \
> ({ static const struct kernel_loc n = { \
> __FILE__, __FUNCTION__, __LINE__  \
>};  })
> 
>   #define _THIS_LOC_ __GEN_LOC__(__UNIQUE_ID(loc))
> 
> which is a hell of a lot nicer to use, and actually allows gcc to
> optimize things (try it: if you pass a _THIS_LOC_ off to an inline
> function, and that inline function uses the name and line number, gcc
> will pick them up directly, without the extra structure dereference.
> 
> Wouldn't it be much nicer to pass these kinds of "location pointer"
> around, rather than the nasty _THIS_IP_ thing?

Seems nice. Do you even need this unique ID thing? AFAIKS the name
would never really be useful.

It could perhaps go into a cold data section too, I assume the common
case is that you do not access it. Although gcc will end up putting
the file and function names into regular rodata.

Possibly we could add a printk specifier for it, pass it through to
existing BUG, etc macros that want exactly this, etc. Makes a lot of
sense.

Thanks,
Nick