* Re: [PATCH RFC] powerpc/kernel: Don't check for dev->dma_mask in fsl_set_dma_mask
From: Christophe LEROY @ 2018-09-03 7:04 UTC (permalink / raw)
To: Darren Stevens, linuxppc-dev, Christian Zigotzky,
Julian Margetson, Scott Wood
In-Reply-To: <4c7f98c86ad.343ea8c1@auth.smtp.1and1.co.uk>
Hi,
Your patch should be sent as part of the message text and not as an
attached file.
By sending as an attached file, patchwork doesn't handle it properly
(all compilation tests fail) https://patchwork.ozlabs.org/patch/965082/
For reference, see
https://www.kernel.org/doc/html/latest/process/submitting-patches.html#no-mime-no-links-no-compression-no-attachments-just-plain-text
Christophe
Le 02/09/2018 à 13:30, Darren Stevens a écrit :
> To enable use of dma to all ram on a corenet generic system, we add the
> function fsl_pci_dma_set_mask, and link it into the ppc.md structure.
>
> But this function checks for the presence of dev->dma_mask and dma_ops
> at entry, and fails if one or other are missing. Powerpc's dma_set_mask
> (which it is called from) doesn't check this until after it has set the
> dma_mask for pci devs, this difference shows up on a Cyrus (AmigaOne X5000)
> - a soundblaster live pci card, will works properly if memory is limited
> to <4G, but fail on probe with the following message if the memory is >=4G
>
> [ 4.646531] snd_emu10k1 1000:04:04.0: architecture does not support PCI
> busmaster DMA with mask 0x7fffffff
>
> Remove the dev->mask tests to make the routines behave similarly.
>
> Signed-off-by: Darren Stevens <darren@stevens-zone.net>
>
> ---
>
> This fix looks wrong to me, although it works. The test needs to be removed,
> moving it to the end of the function doesn't work either. This needs someone
> with more knowledge of what's going on to take a look.
>
^ permalink raw reply
* [PATCH v2] powerpc/powernv: Make possible for user to force a full ipl cec reboot
From: Vaibhav Jain @ 2018-09-03 10:26 UTC (permalink / raw)
To: Benjamin Herrenschmidt, Michael Ellerman, Stewart Smith
Cc: Vaibhav Jain, linuxppc-dev, Andrew Donnellan, Vasant Hegde,
Michael Neuling, Nicholas Piggin, Oliver O'Halloran
Ever since fast reboot is enabled by default in opal,
opal_cec_reboot() will use fast-reset instead of full IPL to perform
system reboot. This leaves the user with no direct way to force a full
IPL reboot except changing an nvram setting that persistently disables
fast-reset for all subsequent reboots.
This patch provides a more direct way for the user to force a one-shot
full IPL reboot by passing the command line argument 'full' to the
reboot command. So the user will be able to tweak the reboot behavior
via:
$ sudo reboot full # Force a full ipl reboot skipping fast-reset
or
$ sudo reboot # default reboot path (usually fast-reset)
The reboot command passes the un-parsed command argument to the kernel
via the 'Reboot' syscall which is then passed on to the arch function
pnv_restart(). The patch updates pnv_restart() to handle this cmd-arg
and issues opal_cec_reboot2 with OPAL_REBOOT_FULL_IPL to force a full
IPL reset.
Signed-off-by: Vaibhav Jain <vaibhav@linux.ibm.com>
---
Change-log:
v2 -> Updated the code to handle case when opal_cec_reboot2() is
not supported by opal. [Andrew]
-> Force a call to opal_cec_reboot() is opal_cec_reboot2()
fails or the action verb 'cmd' is not recognized.
---
arch/powerpc/include/asm/opal-api.h | 1 +
arch/powerpc/platforms/powernv/setup.c | 17 ++++++++++++++++-
2 files changed, 17 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h
index 8365353330b4..870fb7b239ea 100644
--- a/arch/powerpc/include/asm/opal-api.h
+++ b/arch/powerpc/include/asm/opal-api.h
@@ -1050,6 +1050,7 @@ enum OpalSysCooling {
enum {
OPAL_REBOOT_NORMAL = 0,
OPAL_REBOOT_PLATFORM_ERROR = 1,
+ OPAL_REBOOT_FULL_IPL = 2,
};
/* Argument to OPAL_PCI_TCE_KILL */
diff --git a/arch/powerpc/platforms/powernv/setup.c b/arch/powerpc/platforms/powernv/setup.c
index adddde023622..650484e0940b 100644
--- a/arch/powerpc/platforms/powernv/setup.c
+++ b/arch/powerpc/platforms/powernv/setup.c
@@ -224,7 +224,22 @@ static void __noreturn pnv_restart(char *cmd)
pnv_prepare_going_down();
while (rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT) {
- rc = opal_cec_reboot();
+ /* See if we need to do a full IPL reboot */
+ if (cmd && strcmp(cmd, "full") == 0)
+ rc = opal_cec_reboot2(OPAL_REBOOT_FULL_IPL, NULL);
+ else
+ rc = OPAL_UNSUPPORTED;
+
+ if (!(rc == OPAL_BUSY || rc == OPAL_BUSY_EVENT)) {
+ if (cmd) {
+ pr_warn("Couldn't do a '%s' reboot. Err=%ld\n",
+ cmd, rc);
+ /* reset cmd to force a cec_reboot now */
+ cmd = NULL;
+ }
+ rc = opal_cec_reboot();
+ }
+
if (rc == OPAL_BUSY_EVENT)
opal_poll_events(NULL);
else
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 1/3] dmaengine: fsldma: move spin_lock_bh to spin_lock in tasklet
From: Vinod @ 2018-09-03 10:55 UTC (permalink / raw)
To: Barry Song
Cc: leoyang.li, zw, dan.j.williams, linuxppc-dev, dmaengine,
linux-kernel
In-Reply-To: <1534510826-7603-1-git-send-email-21cnbao@gmail.com>
On 17-08-18, 06:00, Barry Song wrote:
> as you are already in a tasklet, it is unnecessary to call spin_lock_bh.
Applied all, thanks
You may want to check you send-mail options, they patches were all over
my inbox and npot threaded
--
~Vinod
^ permalink raw reply
* [PATCH v3 2/6] net/wan/fsl_ucc_hdlc: allow PARITY_CRC16_PR0_CCITT parity
From: David Gounaris @ 2018-09-03 12:47 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, joakim.tjernlund; +Cc: David Gounaris
In-Reply-To: <20180903124730.1551-1-david.gounaris@infinera.com>
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 1 +
1 file changed, 1 insertion(+)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 485764c537d9..5619e2c2e02d 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -781,6 +781,7 @@ static int ucc_hdlc_attach(struct net_device *dev, unsigned short encoding,
if (parity != PARITY_NONE &&
parity != PARITY_CRC32_PR1_CCITT &&
+ parity != PARITY_CRC16_PR0_CCITT &&
parity != PARITY_CRC16_PR1_CCITT)
return -EINVAL;
--
2.13.6
^ permalink raw reply related
* [PATCH v3 4/6] net/wan/fsl_ucc_hdlc: hmask
From: David Gounaris @ 2018-09-03 12:47 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, joakim.tjernlund; +Cc: David Gounaris
In-Reply-To: <20180903124730.1551-1-david.gounaris@infinera.com>
Ability to set hmask in the device-tree,
which can be used to change address
filtering of packets.
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt | 6 ++++++
drivers/net/wan/fsl_ucc_hdlc.c | 5 ++++-
drivers/net/wan/fsl_ucc_hdlc.h | 1 +
3 files changed, 11 insertions(+), 1 deletion(-)
diff --git a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt
index 03c741602c6d..6d2dd8a31482 100644
--- a/Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt
+++ b/Documentation/devicetree/bindings/soc/fsl/cpm_qe/network.txt
@@ -98,6 +98,12 @@ The property below is dependent on fsl,tdm-interface:
usage: optional for tdm interface
value type: <empty>
Definition : Internal loopback connecting on TDM layer.
+- fsl,hmask
+ usage: optional
+ Value type: <u16>
+ Definition: HDLC address recognition. Set to zero to disable
+ address filtering of packets:
+ fsl,hmask = /bits/ 16 <0x0000>;
Example for tdm interface:
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 2aaa5e1959a9..3dacafb219c6 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -263,7 +263,7 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
iowrite16be(MAX_FRAME_LENGTH, &priv->ucc_pram->mflr);
iowrite16be(DEFAULT_RFTHR, &priv->ucc_pram->rfthr);
iowrite16be(DEFAULT_RFTHR, &priv->ucc_pram->rfcnt);
- iowrite16be(DEFAULT_ADDR_MASK, &priv->ucc_pram->hmask);
+ iowrite16be(priv->hmask, &priv->ucc_pram->hmask);
iowrite16be(DEFAULT_HDLC_ADDR, &priv->ucc_pram->haddr1);
iowrite16be(DEFAULT_HDLC_ADDR, &priv->ucc_pram->haddr2);
iowrite16be(DEFAULT_HDLC_ADDR, &priv->ucc_pram->haddr3);
@@ -1097,6 +1097,9 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
goto free_utdm;
}
+ if (of_property_read_u16(np, "fsl,hmask", &uhdlc_priv->hmask))
+ uhdlc_priv->hmask = DEFAULT_ADDR_MASK;
+
ret = uhdlc_init(uhdlc_priv);
if (ret) {
dev_err(&pdev->dev, "Failed to init uhdlc\n");
diff --git a/drivers/net/wan/fsl_ucc_hdlc.h b/drivers/net/wan/fsl_ucc_hdlc.h
index c21134c1f180..b99fa2f1cd99 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.h
+++ b/drivers/net/wan/fsl_ucc_hdlc.h
@@ -106,6 +106,7 @@ struct ucc_hdlc_private {
unsigned short encoding;
unsigned short parity;
+ unsigned short hmask;
u32 clocking;
spinlock_t lock; /* lock for Tx BD and Tx buffer */
#ifdef CONFIG_PM
--
2.13.6
^ permalink raw reply related
* [PATCH v3 3/6] net/wan/fsl_ucc_hdlc: Adding ARPHRD_ETHER
From: David Gounaris @ 2018-09-03 12:47 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, joakim.tjernlund; +Cc: David Gounaris
In-Reply-To: <20180903124730.1551-1-david.gounaris@infinera.com>
This patch is to avoid discarding ethernet
packets when using HDLC_ETH protocol.
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 5619e2c2e02d..2aaa5e1959a9 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -376,6 +376,10 @@ static netdev_tx_t ucc_hdlc_tx(struct sk_buff *skb, struct net_device *dev)
dev->stats.tx_bytes += skb->len;
break;
+ case ARPHRD_ETHER:
+ dev->stats.tx_bytes += skb->len;
+ break;
+
default:
dev->stats.tx_dropped++;
dev_kfree_skb(skb);
@@ -513,6 +517,7 @@ static int hdlc_rx_done(struct ucc_hdlc_private *priv, int rx_work_limit)
break;
case ARPHRD_PPP:
+ case ARPHRD_ETHER:
length -= HDLC_CRC_SIZE;
skb = dev_alloc_skb(length);
--
2.13.6
^ permalink raw reply related
* [PATCH v3 0/6] Ethernet over hdlc
From: David Gounaris @ 2018-09-03 12:47 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, joakim.tjernlund; +Cc: David Gounaris
In-Reply-To: <20180828110921.2542-2-david.gounaris@infinera.com>
Here is what has been changed in v3 after the review comments from v2.
v3-0001: corrected style problems
v3-0002: corrected style problems
v3-0003: corrected style problems
v3-0004: corrected style problems
v3-0005: corrected style problems
v3-0006: corrected style problems
Sorry for that, I did not know about scripts/checkpatch.pl.
David Gounaris (6):
net/wan/fsl_ucc_hdlc: allow ucc index up to 7
net/wan/fsl_ucc_hdlc: allow PARITY_CRC16_PR0_CCITT parity
net/wan/fsl_ucc_hdlc: Adding ARPHRD_ETHER
net/wan/fsl_ucc_hdlc: hmask
net/wan/fsl_ucc_hdlc: GUMR for non tsa mode
net/wan/fsl_ucc_hdlc: tx timeout handler
.../devicetree/bindings/soc/fsl/cpm_qe/network.txt | 6 +++++
drivers/net/wan/fsl_ucc_hdlc.c | 26 ++++++++++++++++++++--
drivers/net/wan/fsl_ucc_hdlc.h | 1 +
3 files changed, 31 insertions(+), 2 deletions(-)
--
2.13.6
^ permalink raw reply
* [PATCH v3 1/6] net/wan/fsl_ucc_hdlc: allow ucc index up to 7
From: David Gounaris @ 2018-09-03 12:47 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, joakim.tjernlund; +Cc: David Gounaris
In-Reply-To: <20180903124730.1551-1-david.gounaris@infinera.com>
There is a need to allow higher indexes to be
able to support MPC83xx platforms. (UCC1-UCC8)
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 33df76405b86..485764c537d9 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1016,7 +1016,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
}
ucc_num = val - 1;
- if ((ucc_num > 3) || (ucc_num < 0)) {
+ if (ucc_num > (UCC_MAX_NUM - 1) || ucc_num < 0) {
dev_err(&pdev->dev, ": Invalid UCC num\n");
return -EINVAL;
}
--
2.13.6
^ permalink raw reply related
* [PATCH v3 6/6] net/wan/fsl_ucc_hdlc: tx timeout handler
From: David Gounaris @ 2018-09-03 12:47 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, joakim.tjernlund; +Cc: David Gounaris
In-Reply-To: <20180903124730.1551-1-david.gounaris@infinera.com>
Added tx timeout handler. This helps
when troubleshooting.
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 7 +++++++
1 file changed, 7 insertions(+)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 999d93fa54f7..124fea454ac4 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -1000,11 +1000,17 @@ static const struct dev_pm_ops uhdlc_pm_ops = {
#define HDLC_PM_OPS NULL
#endif
+static void uhdlc_tx_timeout(struct net_device *ndev)
+{
+ netdev_err(ndev, "%s\n", __func__);
+}
+
static const struct net_device_ops uhdlc_ops = {
.ndo_open = uhdlc_open,
.ndo_stop = uhdlc_close,
.ndo_start_xmit = hdlc_start_xmit,
.ndo_do_ioctl = uhdlc_ioctl,
+ .ndo_tx_timeout = uhdlc_tx_timeout,
};
static int ucc_hdlc_probe(struct platform_device *pdev)
@@ -1123,6 +1129,7 @@ static int ucc_hdlc_probe(struct platform_device *pdev)
hdlc = dev_to_hdlc(dev);
dev->tx_queue_len = 16;
dev->netdev_ops = &uhdlc_ops;
+ dev->watchdog_timeo = 2 * HZ;
hdlc->attach = ucc_hdlc_attach;
hdlc->xmit = ucc_hdlc_tx;
netif_napi_add(dev, &uhdlc_priv->napi, ucc_hdlc_poll, 32);
--
2.13.6
^ permalink raw reply related
* [PATCH v3 5/6] net/wan/fsl_ucc_hdlc: GUMR for non tsa mode
From: David Gounaris @ 2018-09-03 12:47 UTC (permalink / raw)
To: qiang.zhao, netdev, linuxppc-dev, joakim.tjernlund; +Cc: David Gounaris
In-Reply-To: <20180903124730.1551-1-david.gounaris@infinera.com>
The following bits in the GUMR is changed for non
tsa mode: CDS, CTSP and CTSS are set to zero.
When set, there is no tx interrupts from the controller.
Signed-off-by: David Gounaris <david.gounaris@infinera.com>
---
drivers/net/wan/fsl_ucc_hdlc.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/drivers/net/wan/fsl_ucc_hdlc.c b/drivers/net/wan/fsl_ucc_hdlc.c
index 3dacafb219c6..999d93fa54f7 100644
--- a/drivers/net/wan/fsl_ucc_hdlc.c
+++ b/drivers/net/wan/fsl_ucc_hdlc.c
@@ -97,6 +97,12 @@ static int uhdlc_init(struct ucc_hdlc_private *priv)
if (priv->tsa) {
uf_info->tsa = 1;
uf_info->ctsp = 1;
+ uf_info->cds = 1;
+ uf_info->ctss = 1;
+ } else {
+ uf_info->cds = 0;
+ uf_info->ctsp = 0;
+ uf_info->ctss = 0;
}
/* This sets HPM register in CMXUCR register which configures a
--
2.13.6
^ permalink raw reply related
* Re: [PATCH v7 1/4] gpiolib: Pass bitmaps, not integer arrays, to get/set array
From: Geert Uytterhoeven @ 2018-09-03 14:24 UTC (permalink / raw)
To: Matthew Wilcox
Cc: Janusz Krzysztofik, Linus Walleij, Jonathan Corbet,
Miguel Ojeda Sandonis, peter.korsgaard, Peter Rosin, Ulf Hansson,
Andrew Lunn, Florian Fainelli, David S. Miller, Dominik Brodowski,
Greg KH, Kishon Vijay Abraham I, Lars-Peter Clausen,
Michael Hennerich, Jonathan Cameron, Hartmut Knaack,
Peter Meerwald, Jiri Slaby, Willy Tarreau,
open list:DOCUMENTATION, Linux I2C, Linux MMC List, netdev,
linux-iio, driverdevel, open list:SERIAL DRIVERS,
open list:GPIO SUBSYSTEM, Linux Kernel Mailing List,
sebastien.bourdelin, Lukas Wunner, Rojhalat Ibrahim, Russell King,
ext Tony Lindgren, Yegor Yefremov, Uwe Kleine-König,
linuxppc-dev
In-Reply-To: <20180903043129.GA17856@bombadil.infradead.org>
On Mon, Sep 3, 2018 at 6:31 AM Matthew Wilcox <willy@infradead.org> wrote:
> > +++ b/drivers/auxdisplay/hd44780.c
> > @@ -62,17 +62,12 @@ static void hd44780_strobe_gpio(struct hd44780 *hd)
> > /* write to an LCD panel register in 8 bit GPIO mode */
> > static void hd44780_write_gpio8(struct hd44780 *hd, u8 val, unsigned int rs)
> > {
> > - int values[10]; /* for DATA[0-7], RS, RW */
> > - unsigned int i, n;
> > -
> > - for (i = 0; i < 8; i++)
> > - values[PIN_DATA0 + i] = !!(val & BIT(i));
> > - values[PIN_CTRL_RS] = rs;
> > - n = 9;
> > - if (hd->pins[PIN_CTRL_RW]) {
> > - values[PIN_CTRL_RW] = 0;
> > - n++;
> > - }
> > + DECLARE_BITMAP(values, 10); /* for DATA[0-7], RS, RW */
> > + unsigned int n;
> > +
> > + *values = val;
> > + __assign_bit(8, values, rs);
> > + n = hd->pins[PIN_CTRL_RW] ? 10 : 9;
>
> Doesn't this assume little endian bitmaps? Has anyone tested this on
> big-endian machines?
include/linux/bitops.h:
static __always_inline void __assign_bit(long nr, volatile unsigned long *addr,
bool value)
{
if (value)
__set_bit(nr, addr);
else
__clear_bit(nr, addr);
}
include/asm-generic/bitops/non-atomic.h:
static inline void __set_bit(int nr, volatile unsigned long *addr)
{
unsigned long mask = BIT_MASK(nr);
unsigned long *p = ((unsigned long *)addr) + BIT_WORD(nr);
*p |= mask;
}
include/linux/bits.h:
#define BIT_MASK(nr) (1UL << ((nr) % BITS_PER_LONG))
Looks like native endianness to me.
Gr{oetje,eeting}s,
Geert
--
Geert Uytterhoeven -- There's lots of Linux beyond ia32 -- geert@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
^ permalink raw reply
* [PATCH 0/6] powerpc sstep: Extend instruction emulation support
From: Sandipan Das @ 2018-09-03 15:19 UTC (permalink / raw)
To: mpe; +Cc: linuxppc-dev, paulus, anton, naveen.n.rao, ravi.bangoria
This series adds emulation support for some additional ISA 3.0
instructions, most of which are now generated by a recent compiler
(e.g. gcc-8.x) when building the kernel with CONFIG_POWER9_CPU = y.
PrasannaKumar Muralidharan (1):
powerpc sstep: Add modsw, moduw instruction emulation
Sandipan Das (5):
powerpc sstep: Add maddhd, maddhdu, maddld instruction emulation
powerpc sstep: Add darn instruction emulation
powerpc sstep: Add cnttzw, cnttzd instruction emulation
powerpc sstep: Add extswsli instruction emulation
powerpc sstep: Add modsd, modud instruction emulation
arch/powerpc/lib/sstep.c | 111 ++++++++++++++++++++++++++++++++++++++++++++++-
1 file changed, 109 insertions(+), 2 deletions(-)
--
2.14.4
^ permalink raw reply
* [PATCH 1/6] powerpc sstep: Add maddhd, maddhdu, maddld instruction emulation
From: Sandipan Das @ 2018-09-03 15:19 UTC (permalink / raw)
To: mpe; +Cc: linuxppc-dev, paulus, anton, naveen.n.rao, ravi.bangoria
In-Reply-To: <cover.1535609090.git.sandipan@linux.ibm.com>
This adds emulation support for the following integer instructions:
* Multiply-Add High Doubleword (maddhd)
* Multiply-Add High Doubleword Unsigned (maddhdu)
* Multiply-Add Low Doubleword (maddld)
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
---
arch/powerpc/lib/sstep.c | 35 ++++++++++++++++++++++++++++++++++-
1 file changed, 34 insertions(+), 1 deletion(-)
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index d81568f783e5..b40ec18515bd 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1169,7 +1169,7 @@ static nokprobe_inline int trap_compare(long v1, long v2)
int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
unsigned int instr)
{
- unsigned int opcode, ra, rb, rd, spr, u;
+ unsigned int opcode, ra, rb, rc, rd, spr, u;
unsigned long int imm;
unsigned long int val, val2;
unsigned int mb, me, sh;
@@ -1292,6 +1292,7 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
rd = (instr >> 21) & 0x1f;
ra = (instr >> 16) & 0x1f;
rb = (instr >> 11) & 0x1f;
+ rc = (instr >> 6) & 0x1f;
switch (opcode) {
#ifdef __powerpc64__
@@ -1305,6 +1306,38 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
goto trap;
return 1;
+#ifdef __powerpc64__
+ case 4:
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+
+ switch (instr & 0x3f) {
+ case 48: /* maddhd */
+ asm("maddhd %0,%1,%2,%3" : "=r" (op->val) :
+ "r" (regs->gpr[ra]), "r" (regs->gpr[rb]),
+ "r" (regs->gpr[rc]));
+ goto compute_done;
+
+ case 49: /* maddhdu */
+ asm("maddhdu %0,%1,%2,%3" : "=r" (op->val) :
+ "r" (regs->gpr[ra]), "r" (regs->gpr[rb]),
+ "r" (regs->gpr[rc]));
+ goto compute_done;
+
+ case 51: /* maddld */
+ asm("maddld %0,%1,%2,%3" : "=r" (op->val) :
+ "r" (regs->gpr[ra]), "r" (regs->gpr[rb]),
+ "r" (regs->gpr[rc]));
+ goto compute_done;
+ }
+
+ /*
+ * There are other instructions from ISA 3.0 with the same
+ * primary opcode which do not have emulation support yet.
+ */
+ return -1;
+#endif
+
case 7: /* mulli */
op->val = regs->gpr[ra] * (short) instr;
goto compute_done;
--
2.14.4
^ permalink raw reply related
* [PATCH 2/6] powerpc sstep: Add darn instruction emulation
From: Sandipan Das @ 2018-09-03 15:19 UTC (permalink / raw)
To: mpe; +Cc: linuxppc-dev, paulus, anton, naveen.n.rao, ravi.bangoria
In-Reply-To: <cover.1535609090.git.sandipan@linux.ibm.com>
This adds emulation support for the following integer instructions:
* Deliver A Random Number (darn)
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
---
arch/powerpc/lib/sstep.c | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index b40ec18515bd..18ac0a26c4fc 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1728,6 +1728,25 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
(int) regs->gpr[rb];
goto arith_done;
+ case 755: /* darn */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ switch (ra & 0x3) {
+ case 0:
+ asm("darn %0,0" : "=r" (op->val));
+ goto compute_done;
+
+ case 1:
+ asm("darn %0,1" : "=r" (op->val));
+ goto compute_done;
+
+ case 2:
+ asm("darn %0,2" : "=r" (op->val));
+ goto compute_done;
+ }
+
+ return -1;
+
/*
* Logical instructions
--
2.14.4
^ permalink raw reply related
* [PATCH 4/6] powerpc sstep: Add extswsli instruction emulation
From: Sandipan Das @ 2018-09-03 15:19 UTC (permalink / raw)
To: mpe; +Cc: linuxppc-dev, paulus, anton, naveen.n.rao, ravi.bangoria
In-Reply-To: <cover.1535609090.git.sandipan@linux.ibm.com>
This adds emulation support for the following integer instructions:
* Extend-Sign Word and Shift Left Immediate (extswsli[.])
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
---
arch/powerpc/lib/sstep.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index d57cb4e28621..828677df47b2 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1932,6 +1932,20 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
op->xerval &= ~XER_CA;
set_ca32(op, op->xerval & XER_CA);
goto logical_done;
+
+ case 890: /* extswsli with sh_5 = 0 */
+ case 891: /* extswsli with sh_5 = 1 */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ op->type = COMPUTE + SETREG;
+ sh = rb | ((instr & 2) << 4);
+ val = (signed int) regs->gpr[rd];
+ if (sh)
+ op->val = ROTATE(val, sh) & MASK64(0, 63 - sh);
+ else
+ op->val = val;
+ goto logical_done;
+
#endif /* __powerpc64__ */
/*
--
2.14.4
^ permalink raw reply related
* [PATCH 3/6] powerpc sstep: Add cnttzw, cnttzd instruction emulation
From: Sandipan Das @ 2018-09-03 15:19 UTC (permalink / raw)
To: mpe; +Cc: linuxppc-dev, paulus, anton, naveen.n.rao, ravi.bangoria
In-Reply-To: <cover.1535609090.git.sandipan@linux.ibm.com>
This adds emulation support for the following integer instructions:
* Count Trailing Zeros Word (cnttzw[.])
* Count Trailing Zeros Doubleword (cnttzd[.])
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
---
arch/powerpc/lib/sstep.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 18ac0a26c4fc..d57cb4e28621 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1816,6 +1816,20 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
case 506: /* popcntd */
do_popcnt(regs, op, regs->gpr[rd], 64);
goto logical_done_nocc;
+#endif
+ case 538: /* cnttzw */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ val = (unsigned int) regs->gpr[rd];
+ op->val = ( val ? __builtin_ctz(val) : 32 );
+ goto logical_done;
+#ifdef __powerpc64__
+ case 570: /* cnttzd */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ val = regs->gpr[rd];
+ op->val = ( val ? __builtin_ctzl(val) : 64 );
+ goto logical_done;
#endif
case 922: /* extsh */
op->val = (signed short) regs->gpr[rd];
--
2.14.4
^ permalink raw reply related
* [PATCH 5/6] powerpc sstep: Add modsw, moduw instruction emulation
From: Sandipan Das @ 2018-09-03 15:19 UTC (permalink / raw)
To: mpe
Cc: linuxppc-dev, paulus, anton, naveen.n.rao, ravi.bangoria,
PrasannaKumar Muralidharan
In-Reply-To: <cover.1535609090.git.sandipan@linux.ibm.com>
From: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
This adds emulation support for the following integer instructions:
* Modulo Signed Word (modsw)
* Modulo Unsigned Word (moduw)
Signed-off-by: PrasannaKumar Muralidharan <prasannatsmkumar@gmail.com>
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
---
arch/powerpc/lib/sstep.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index 828677df47b2..ddc2de28e00a 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1708,6 +1708,13 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
case 266: /* add */
op->val = regs->gpr[ra] + regs->gpr[rb];
goto arith_done;
+
+ case 267: /* moduw */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ op->val = (unsigned int) regs->gpr[ra] %
+ (unsigned int) regs->gpr[rb];
+ goto compute_done;
#ifdef __powerpc64__
case 457: /* divdu */
op->val = regs->gpr[ra] / regs->gpr[rb];
@@ -1747,6 +1754,13 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
return -1;
+ case 779: /* modsw */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ op->val = (int) regs->gpr[ra] %
+ (int) regs->gpr[rb];
+ goto compute_done;
+
/*
* Logical instructions
--
2.14.4
^ permalink raw reply related
* [PATCH 6/6] powerpc sstep: Add modsd, modud instruction emulation
From: Sandipan Das @ 2018-09-03 15:19 UTC (permalink / raw)
To: mpe; +Cc: linuxppc-dev, paulus, anton, naveen.n.rao, ravi.bangoria
In-Reply-To: <cover.1535609090.git.sandipan@linux.ibm.com>
This adds emulation support for the following integer instructions:
* Modulo Signed Doubleword (modsd)
* Modulo Unsigned Doubleword (modud)
Signed-off-by: Sandipan Das <sandipan@linux.ibm.com>
---
arch/powerpc/lib/sstep.c | 17 +++++++++++++++--
1 file changed, 15 insertions(+), 2 deletions(-)
diff --git a/arch/powerpc/lib/sstep.c b/arch/powerpc/lib/sstep.c
index ddc2de28e00a..b3b508d175fb 100644
--- a/arch/powerpc/lib/sstep.c
+++ b/arch/powerpc/lib/sstep.c
@@ -1704,7 +1704,13 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
(int) regs->gpr[rb];
goto arith_done;
-
+#ifdef __powerpc64__
+ case 265: /* modud */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ op->val = regs->gpr[ra] % regs->gpr[rb];
+ goto compute_done;
+#endif
case 266: /* add */
op->val = regs->gpr[ra] + regs->gpr[rb];
goto arith_done;
@@ -1753,7 +1759,14 @@ int analyse_instr(struct instruction_op *op, const struct pt_regs *regs,
}
return -1;
-
+#ifdef __powerpc64__
+ case 777: /* modsd */
+ if (!cpu_has_feature(CPU_FTR_ARCH_300))
+ return -1;
+ op->val = (long int) regs->gpr[ra] %
+ (long int) regs->gpr[rb];
+ goto compute_done;
+#endif
case 779: /* modsw */
if (!cpu_has_feature(CPU_FTR_ARCH_300))
return -1;
--
2.14.4
^ permalink raw reply related
* [RFC PATCH 3/3] powerpc/mm/iommu: Allow migration of cma allocated pages during mm_iommu_get
From: Aneesh Kumar K.V @ 2018-09-03 16:37 UTC (permalink / raw)
To: npiggin, benh, paulus, mpe, David Gibson, Alexey Kardashevskiy
Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180903163733.27965-1-aneesh.kumar@linux.ibm.com>
Current code doesn't do page migration if the page allocated is a compound page.
With HugeTLB migration support, we can end up allocating hugetlb pages from
CMA region. Also THP pages can be allocated from CMA region. This patch updates
the code to handle compound pages correctly.
This add a new helper get_user_pages_cma_migrate. It does one get_user_pages
with right count, instead of doing one get_user_pages per page. That avoids
reading page table multiple times. The helper could possibly used by other
subystem if we have more users.
The patch also convert the hpas member of mm_iommu_table_group_mem_t to a union.
We use the same storage location to store pointers to struct page. We cannot
update alll the code path use struct page *, because we access hpas in real mode
and we can't do that struct page * to pfn conversion in real mode.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/mmu_context_iommu.c | 195 ++++++++++++++++++----------
1 file changed, 123 insertions(+), 72 deletions(-)
diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c
index f472965f7638..597b88a0abce 100644
--- a/arch/powerpc/mm/mmu_context_iommu.c
+++ b/arch/powerpc/mm/mmu_context_iommu.c
@@ -20,6 +20,7 @@
#include <linux/swap.h>
#include <asm/mmu_context.h>
#include <asm/pte-walk.h>
+#include <linux/mm_inline.h>
static DEFINE_MUTEX(mem_list_mutex);
@@ -30,8 +31,18 @@ struct mm_iommu_table_group_mem_t {
atomic64_t mapped;
unsigned int pageshift;
u64 ua; /* userspace address */
- u64 entries; /* number of entries in hpas[] */
- u64 *hpas; /* vmalloc'ed */
+ u64 entries; /* number of entries in hpages[] */
+ /*
+ * in mm_iommu_get we temporarily use this to store
+ * struct page address.
+ *
+ * We need to convert ua to hpa in real mode. Make it
+ * simpler by storing physicall address.
+ */
+ union {
+ struct page **hpages; /* vmalloc'ed */
+ phys_addr_t *hpas;
+ };
};
static long mm_iommu_adjust_locked_vm(struct mm_struct *mm,
@@ -75,62 +86,112 @@ bool mm_iommu_preregistered(struct mm_struct *mm)
EXPORT_SYMBOL_GPL(mm_iommu_preregistered);
/*
- * Taken from alloc_migrate_target with changes to remove CMA allocations
+ * Taken from alloc_migrate_target/alloc_migrate_huge_page with changes to remove
+ * CMA allocations
+ * Is this the right allocator for hugetlb?
*/
struct page *new_iommu_non_cma_page(struct page *page, unsigned long private)
{
- gfp_t gfp_mask = GFP_USER;
- struct page *new_page;
+ /* is this the right nid? */
+ int nid = numa_mem_id();
+ gfp_t gfp_mask = GFP_HIGHUSER;
- if (PageCompound(page))
- return NULL;
+ if (PageHuge(page)) {
- if (PageHighMem(page))
- gfp_mask |= __GFP_HIGHMEM;
+ struct hstate *h = page_hstate(page);
+ /*
+ * We don't want to dequeue from the pool because pool pages will
+ * mostly be from the CMA region.
+ */
+ return alloc_migrate_huge_page(h, gfp_mask, nid, NULL);
- /*
- * We don't want the allocation to force an OOM if possibe
- */
- new_page = alloc_page(gfp_mask | __GFP_NORETRY | __GFP_NOWARN);
- return new_page;
+ } else if (PageTransHuge(page)) {
+ struct page *thp;
+ gfp_t thp_gfpmask = GFP_TRANSHUGE & ~__GFP_MOVABLE;
+
+ thp = __alloc_pages_node(nid, thp_gfpmask, HPAGE_PMD_ORDER);
+ if (!thp)
+ return NULL;
+ prep_transhuge_page(thp);
+ return thp;
+ }
+ return __alloc_pages_node(nid, gfp_mask, 0);
}
-static int mm_iommu_move_page_from_cma(struct page *page)
+int get_user_pages_cma_migrate(unsigned long start, int nr_pages, int write,
+ struct page **pages)
{
- int ret = 0;
- LIST_HEAD(cma_migrate_pages);
-
- /* Ignore huge pages for now */
- if (PageCompound(page))
- return -EBUSY;
-
- lru_add_drain();
- ret = isolate_lru_page(page);
- if (ret)
+ int i, ret;
+ bool drain_allow = true;
+ bool migrate_allow = true;
+ LIST_HEAD(cma_page_list);
+
+get_user_again:
+ ret = get_user_pages_fast(start, nr_pages, write, pages);
+ if (ret <= 0)
return ret;
- list_add(&page->lru, &cma_migrate_pages);
- put_page(page); /* Drop the gup reference */
-
- ret = migrate_pages(&cma_migrate_pages, new_iommu_non_cma_page,
- NULL, 0, MIGRATE_SYNC, MR_CONTIG_RANGE);
- if (ret) {
- if (!list_empty(&cma_migrate_pages))
- putback_movable_pages(&cma_migrate_pages);
+ for (i = 0; i < ret; ++i) {
+ /*
+ * If we get a page from the CMA zone, since we are going to
+ * be pinning these entries, we might as well move them out
+ * of the CMA zone if possible.
+ */
+ if (is_migrate_cma_page(pages[i]) && migrate_allow) {
+ if (PageHuge(pages[i]))
+ isolate_huge_page(pages[i], &cma_page_list);
+ else {
+ struct page *head = compound_head(pages[i]);
+
+ if (!PageLRU(head) && drain_allow) {
+ lru_add_drain_all();
+ drain_allow = false;
+ }
+
+ if (!isolate_lru_page(head)) {
+ list_add_tail(&head->lru, &cma_page_list);
+ mod_node_page_state(page_pgdat(head),
+ NR_ISOLATED_ANON +
+ page_is_file_cache(head),
+ hpage_nr_pages(head));
+ }
+ }
+ }
}
-
- return 0;
+ if (!list_empty(&cma_page_list)) {
+ /*
+ * drop the above get_user_pages reference.
+ */
+ for (i = 0; i < ret; ++i)
+ put_page(pages[i]);
+
+ if (migrate_pages(&cma_page_list, new_iommu_non_cma_page,
+ NULL, 0, MIGRATE_SYNC, MR_CONTIG_RANGE)) {
+ /*
+ * some of the pages failed migration. Do get_user_pages
+ * without migration.
+ */
+ migrate_allow = false;
+
+ if (!list_empty(&cma_page_list))
+ putback_movable_pages(&cma_page_list);
+ }
+ /*
+ * We did migrate all the pages, Try to get the page references again
+ * migrating any new CMA pages which we failed to isolate earlier.
+ */
+ drain_allow = true;
+ goto get_user_again;
+ }
+ return ret;
}
long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries,
struct mm_iommu_table_group_mem_t **pmem)
{
struct mm_iommu_table_group_mem_t *mem;
- long i, j, ret = 0, locked_entries = 0;
+ long i, ret = 0, locked_entries = 0;
unsigned int pageshift;
- unsigned long flags;
- unsigned long cur_ua;
- struct page *page = NULL;
mutex_lock(&mem_list_mutex);
@@ -177,47 +238,37 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries,
goto unlock_exit;
}
+ ret = get_user_pages_cma_migrate(ua, entries, 1, mem->hpages);
+ if (ret != entries) {
+ /* free the reference taken */
+ for (i = 0; i < ret; i++)
+ put_page(mem->hpages[i]);
+
+ vfree(mem->hpas);
+ kfree(mem);
+ ret = -EFAULT;
+ goto unlock_exit;
+ } else
+ ret = 0;
+
+ pageshift = PAGE_SHIFT;
for (i = 0; i < entries; ++i) {
- cur_ua = ua + (i << PAGE_SHIFT);
- if (1 != get_user_pages_fast(cur_ua,
- 1/* pages */, 1/* iswrite */, &page)) {
- ret = -EFAULT;
- for (j = 0; j < i; ++j)
- put_page(pfn_to_page(mem->hpas[j] >>
- PAGE_SHIFT));
- vfree(mem->hpas);
- kfree(mem);
- goto unlock_exit;
- }
+ struct page *page = mem->hpages[i];
/*
- * If we get a page from the CMA zone, since we are going to
- * be pinning these entries, we might as well move them out
- * of the CMA zone if possible. NOTE: faulting in + migration
- * can be expensive. Batching can be considered later
+ * Allow to use larger than 64k IOMMU pages. Only do that
+ * if we are backed by hugetlb.
*/
- if (is_migrate_cma_page(page)) {
- if (mm_iommu_move_page_from_cma(page))
- goto populate;
- if (1 != get_user_pages_fast(cur_ua,
- 1/* pages */, 1/* iswrite */,
- &page)) {
- ret = -EFAULT;
- for (j = 0; j < i; ++j)
- put_page(pfn_to_page(mem->hpas[j] >>
- PAGE_SHIFT));
- vfree(mem->hpas);
- kfree(mem);
- goto unlock_exit;
- }
- }
-populate:
- pageshift = PAGE_SHIFT;
- if (mem->pageshift > PAGE_SHIFT && PageHuge(page)) {
+ if ((mem->pageshift > PAGE_SHIFT) && PageHuge(page)) {
struct page *head = compound_head(page);
pageshift = compound_order(head) + PAGE_SHIFT;
}
mem->pageshift = min(mem->pageshift, pageshift);
+ /*
+ * We don't need struct page reference any more, switch
+ * physicall address.
+ */
mem->hpas[i] = page_to_pfn(page) << PAGE_SHIFT;
+
}
atomic64_set(&mem->mapped, 1);
--
2.17.1
^ permalink raw reply related
* [RFC PATCH 1/3] mm: Export alloc_migrate_huge_page
From: Aneesh Kumar K.V @ 2018-09-03 16:37 UTC (permalink / raw)
To: npiggin, benh, paulus, mpe, David Gibson, Alexey Kardashevskiy
Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180903163733.27965-1-aneesh.kumar@linux.ibm.com>
We want to use this to support customized huge page migration.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
include/linux/hugetlb.h | 2 ++
mm/hugetlb.c | 4 ++--
2 files changed, 4 insertions(+), 2 deletions(-)
diff --git a/include/linux/hugetlb.h b/include/linux/hugetlb.h
index c39d9170a8a0..98c9c6dc308c 100644
--- a/include/linux/hugetlb.h
+++ b/include/linux/hugetlb.h
@@ -357,6 +357,8 @@ struct page *alloc_huge_page_nodemask(struct hstate *h, int preferred_nid,
nodemask_t *nmask);
struct page *alloc_huge_page_vma(struct hstate *h, struct vm_area_struct *vma,
unsigned long address);
+struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask,
+ int nid, nodemask_t *nmask);
int huge_add_to_page_cache(struct page *page, struct address_space *mapping,
pgoff_t idx);
diff --git a/mm/hugetlb.c b/mm/hugetlb.c
index 47566bb0b4b1..88881b3f8628 100644
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -1586,8 +1586,8 @@ static struct page *alloc_surplus_huge_page(struct hstate *h, gfp_t gfp_mask,
return page;
}
-static struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask,
- int nid, nodemask_t *nmask)
+struct page *alloc_migrate_huge_page(struct hstate *h, gfp_t gfp_mask,
+ int nid, nodemask_t *nmask)
{
struct page *page;
--
2.17.1
^ permalink raw reply related
* [RFC PATCH 2/3] powerpc/mm/iommu: Allow large IOMMU page size only for hugetlb backing
From: Aneesh Kumar K.V @ 2018-09-03 16:37 UTC (permalink / raw)
To: npiggin, benh, paulus, mpe, David Gibson, Alexey Kardashevskiy
Cc: linuxppc-dev, Aneesh Kumar K.V
In-Reply-To: <20180903163733.27965-1-aneesh.kumar@linux.ibm.com>
THP pages can get split during different code paths. An incremented reference
count do imply we will not split the compound page. But the pmd entry can be
converted to level 4 pte entries. Keep the code simpler by allowing large
IOMMU page size only if the guest ram is backed by hugetlb pages.
Signed-off-by: Aneesh Kumar K.V <aneesh.kumar@linux.ibm.com>
---
arch/powerpc/mm/mmu_context_iommu.c | 16 ++--------------
1 file changed, 2 insertions(+), 14 deletions(-)
diff --git a/arch/powerpc/mm/mmu_context_iommu.c b/arch/powerpc/mm/mmu_context_iommu.c
index c9ee9e23845f..f472965f7638 100644
--- a/arch/powerpc/mm/mmu_context_iommu.c
+++ b/arch/powerpc/mm/mmu_context_iommu.c
@@ -212,21 +212,9 @@ long mm_iommu_get(struct mm_struct *mm, unsigned long ua, unsigned long entries,
}
populate:
pageshift = PAGE_SHIFT;
- if (mem->pageshift > PAGE_SHIFT && PageCompound(page)) {
- pte_t *pte;
+ if (mem->pageshift > PAGE_SHIFT && PageHuge(page)) {
struct page *head = compound_head(page);
- unsigned int compshift = compound_order(head);
- unsigned int pteshift;
-
- local_irq_save(flags); /* disables as well */
- pte = find_linux_pte(mm->pgd, cur_ua, NULL, &pteshift);
-
- /* Double check it is still the same pinned page */
- if (pte && pte_page(*pte) == head &&
- pteshift == compshift + PAGE_SHIFT)
- pageshift = max_t(unsigned int, pteshift,
- PAGE_SHIFT);
- local_irq_restore(flags);
+ pageshift = compound_order(head) + PAGE_SHIFT;
}
mem->pageshift = min(mem->pageshift, pageshift);
mem->hpas[i] = page_to_pfn(page) << PAGE_SHIFT;
--
2.17.1
^ permalink raw reply related
* Re: [PATCH 7/9] PCI: hotplug: Drop hotplug_slot_info
From: Sebastian Ott @ 2018-09-03 17:52 UTC (permalink / raw)
To: Lukas Wunner
Cc: Bjorn Helgaas, linux-pci, Sinan Kaya, Mika Westerberg,
Rafael J. Wysocki, Len Brown, Scott Murray,
Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Gavin Shan, Gerald Schaefer, Corentin Chary, Darren Hart,
Andy Shevchenko, Greg Kroah-Hartman, linux-acpi, linux-s390,
platform-driver-x86, acpi4asus-user, linuxppc-dev
In-Reply-To: <a364bcc959e01f2ebab27cefc5b87ff01633275c.1534686485.git.lukas@wunner.de>
On Sun, 19 Aug 2018, Lukas Wunner wrote:
> Ever since the PCI hotplug core was introduced in 2002, drivers had to
> allocate and register a struct hotplug_slot_info for every slot:
> https://git.kernel.org/tglx/history/c/a8a2069f432c
>
> Apparently the idea was that drivers furnish the hotplug core with an
> up-to-date card presence status, power status, latch status and
> attention indicator status as well as notify the hotplug core of changes
> thereof. However only 4 out of 12 hotplug drivers bother to notify the
> hotplug core with pci_hp_change_slot_info() and the hotplug core never
> made any use of the information: There is just a single macro in
> pci_hotplug_core.c, GET_STATUS(), which uses the hotplug_slot_info if
> the driver lacks the corresponding callback in hotplug_slot_ops. The
> macro is called when the user reads the attribute via sysfs.
>
> Now, if the callback isn't defined, the attribute isn't exposed in sysfs
> in the first place (see e.g. has_power_file()). There are only two
> situations when the hotplug_slot_info would actually be accessed:
>
> * If the driver defines ->enable_slot or ->disable_slot but not
> ->get_power_status.
>
> * If the driver defines ->set_attention_status but not
> ->get_attention_status.
>
> There is no driver doing the former and just a single driver doing the
> latter, namely pnv_php.c. Amend it with a ->get_attention_status
> callback. With that, the hotplug_slot_info becomes completely unused by
> the PCI hotplug core. But a few drivers use it internally as a cache:
>
> cpcihp uses it to cache the latch_status and adapter_status.
> cpqhp uses it to cache the adapter_status.
> pnv_php and rpaphp use it to cache the attention_status.
> shpchp uses it to cache all four values.
>
> Amend these drivers to cache the information in their private slot
> struct. shpchp's slot struct already contains members to cache the
> power_status and adapter_status, so additional members are only needed
> for the other two values. In the case of cpqphp, the cached value is
> only accessed in a single place, so instead of caching it, read the
> current value from the hardware.
>
> Caution: acpiphp, cpci, cpqhp, shpchp, asus-wmi and eeepc-laptop
> populate the hotplug_slot_info with initial values on probe. That code
> is herewith removed. There is a theoretical chance that the code has
> side effects without which the driver fails to function, e.g. if the
> ACPI method to read the adapter status needs to be executed at least
> once on probe. That seems unlikely to me, still maintainers should
> review the changes carefully for this possibility.
>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Scott Murray <scott@spiteful.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Gavin Shan <gwshan@linux.vnet.ibm.com>
> Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
> Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> Cc: Corentin Chary <corentin.chary@gmail.com>
> Cc: Darren Hart <dvhart@infradead.org>
> Cc: Andy Shevchenko <andy@infradead.org>
for s390_pci_hpc.c:
Acked-by: Sebastian Ott <sebott@linux.ibm.com>
^ permalink raw reply
* [RFC PATCH 0/3] Add support for compound page migration in mm_iommu_get
From: Aneesh Kumar K.V @ 2018-09-03 16:37 UTC (permalink / raw)
To: npiggin, benh, paulus, mpe, David Gibson, Alexey Kardashevskiy
Cc: linuxppc-dev, Aneesh Kumar K.V
This patch series add support for migrating compound pages if we find them in the
CMA area before taking long term page reference for VFIO.
Testing:
* TODO: test with hugetlb backed guest ram.
* Testing done with a code change as below
- if (is_migrate_cma_page(pages[i]) && migrate_allow) {
+ if (migrate_allow) {
...
+ migrate_allow = false;
Aneesh Kumar K.V (3):
mm: Export alloc_migrate_huge_page
powerpc/mm/iommu: Allow large IOMMU page size only for hugetlb backing
powerpc/mm/iommu: Allow migration of cma allocated pages during
mm_iommu_get
arch/powerpc/mm/mmu_context_iommu.c | 209 +++++++++++++++++-----------
include/linux/hugetlb.h | 2 +
mm/hugetlb.c | 4 +-
3 files changed, 128 insertions(+), 87 deletions(-)
--
2.17.1
^ permalink raw reply
* Re: [PATCH 8/9] PCI: hotplug: Embed hotplug_slot
From: Sebastian Ott @ 2018-09-03 17:54 UTC (permalink / raw)
To: Lukas Wunner
Cc: Bjorn Helgaas, linux-pci, Sinan Kaya, Mika Westerberg,
Rafael J. Wysocki, Len Brown, Scott Murray,
Benjamin Herrenschmidt, Paul Mackerras, Michael Ellerman,
Gavin Shan, Sebastian Ott, Gerald Schaefer, Corentin Chary,
Darren Hart, Andy Shevchenko, Greg Kroah-Hartman, linux-acpi,
linux-s390, platform-driver-x86, acpi4asus-user, linuxppc-dev
In-Reply-To: <9918fbca94bcfc03d1560b191d138d3e6664cc86.1534686485.git.lukas@wunner.de>
On Sun, 19 Aug 2018, Lukas Wunner wrote:
> When the PCI hotplug core and its first user, cpqphp, were introduced in
> February 2002 with historic commit a8a2069f432c, cpqphp allocated a slot
> struct for its internal use plus a hotplug_slot struct to be registered
> with the hotplug core and linked the two with pointers:
> https://git.kernel.org/tglx/history/c/a8a2069f432c
>
> Nowadays, the predominant pattern in the tree is to embed ("subclass")
> such structures in one another and cast to the containing struct with
> container_of(). But it wasn't until July 2002 that container_of() was
> introduced with historic commit ec4f214232cf:
> https://git.kernel.org/tglx/history/c/ec4f214232cf
>
> pnv_php, introduced in 2016, did the right thing and embedded struct
> hotplug_slot in its internal struct pnv_php_slot, but all other drivers
> cargo-culted cpqphp's design and linked separate structs with pointers.
>
> Embedding structs is preferrable to linking them with pointers because
> it requires fewer allocations, thereby reducing overhead and simplifying
> error paths. Casting an embedded struct to the containing struct
> becomes a cheap subtraction rather than a dereference. And having fewer
> pointers reduces the risk of them pointing nowhere either accidentally
> or due to an attack.
>
> Convert all drivers to embed struct hotplug_slot in their internal slot
> struct. The "private" pointer in struct hotplug_slot thereby becomes
> unused, so drop it.
>
> Signed-off-by: Lukas Wunner <lukas@wunner.de>
> Cc: Rafael J. Wysocki <rjw@rjwysocki.net>
> Cc: Len Brown <lenb@kernel.org>
> Cc: Scott Murray <scott@spiteful.org>
> Cc: Benjamin Herrenschmidt <benh@kernel.crashing.org>
> Cc: Paul Mackerras <paulus@samba.org>
> Cc: Michael Ellerman <mpe@ellerman.id.au>
> Cc: Gavin Shan <gwshan@linux.vnet.ibm.com>
> Cc: Sebastian Ott <sebott@linux.vnet.ibm.com>
> Cc: Gerald Schaefer <gerald.schaefer@de.ibm.com>
> Cc: Corentin Chary <corentin.chary@gmail.com>
> Cc: Darren Hart <dvhart@infradead.org>
> Cc: Andy Shevchenko <andy@infradead.org>
for s390_pci_hpc.c:
Acked-by: Sebastian Ott <sebott@linux.ibm.com>
^ permalink raw reply
* [PATCH 4.4 14/80] usb/phy: fix PPC64 build errors in phy-fsl-usb.c
From: Greg Kroah-Hartman @ 2018-09-03 16:48 UTC (permalink / raw)
To: linux-kernel
Cc: Greg Kroah-Hartman, stable, Randy Dunlap, Felipe Balbi, linux-usb,
Michael Ellerman, linuxppc-dev, Felipe Balbi, Sasha Levin
In-Reply-To: <20180903164934.171677301@linuxfoundation.org>
4.4-stable review patch. If anyone has any objections, please let me know.
------------------
From: Randy Dunlap <rdunlap@infradead.org>
[ Upstream commit a39ba90a1cc7010edb0a7132e1b67f3d80b994e9 ]
Fix build errors when built for PPC64:
These variables are only used on PPC32 so they don't need to be
initialized for PPC64.
../drivers/usb/phy/phy-fsl-usb.c: In function 'usb_otg_start':
../drivers/usb/phy/phy-fsl-usb.c:865:3: error: '_fsl_readl' undeclared (first use in this function); did you mean 'fsl_readl'?
_fsl_readl = _fsl_readl_be;
../drivers/usb/phy/phy-fsl-usb.c:865:16: error: '_fsl_readl_be' undeclared (first use in this function); did you mean 'fsl_readl'?
_fsl_readl = _fsl_readl_be;
../drivers/usb/phy/phy-fsl-usb.c:866:3: error: '_fsl_writel' undeclared (first use in this function); did you mean 'fsl_writel'?
_fsl_writel = _fsl_writel_be;
../drivers/usb/phy/phy-fsl-usb.c:866:17: error: '_fsl_writel_be' undeclared (first use in this function); did you mean 'fsl_writel'?
_fsl_writel = _fsl_writel_be;
../drivers/usb/phy/phy-fsl-usb.c:868:16: error: '_fsl_readl_le' undeclared (first use in this function); did you mean 'fsl_readl'?
_fsl_readl = _fsl_readl_le;
../drivers/usb/phy/phy-fsl-usb.c:869:17: error: '_fsl_writel_le' undeclared (first use in this function); did you mean 'fsl_writel'?
_fsl_writel = _fsl_writel_le;
and the sysfs "show" function return type should be ssize_t, not int:
../drivers/usb/phy/phy-fsl-usb.c:1042:49: error: initialization of 'ssize_t (*)(struct device *, struct device_attribute *, char *)' {aka 'long int (*)(struct device *, struct device_attribute *, char *)'} from incompatible pointer type 'int (*)(struct device *, struct device_attribute *, char *)' [-Werror=incompatible-pointer-types]
static DEVICE_ATTR(fsl_usb2_otg_state, S_IRUGO, show_fsl_usb2_otg_state, NULL);
Signed-off-by: Randy Dunlap <rdunlap@infradead.org>
Cc: Felipe Balbi <balbi@kernel.org>
Cc: linux-usb@vger.kernel.org
Cc: Michael Ellerman <mpe@ellerman.id.au>
Cc: linuxppc-dev@lists.ozlabs.org
Signed-off-by: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Sasha Levin <alexander.levin@microsoft.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
---
drivers/usb/phy/phy-fsl-usb.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
--- a/drivers/usb/phy/phy-fsl-usb.c
+++ b/drivers/usb/phy/phy-fsl-usb.c
@@ -879,6 +879,7 @@ int usb_otg_start(struct platform_device
if (pdata->init && pdata->init(pdev) != 0)
return -EINVAL;
+#ifdef CONFIG_PPC32
if (pdata->big_endian_mmio) {
_fsl_readl = _fsl_readl_be;
_fsl_writel = _fsl_writel_be;
@@ -886,6 +887,7 @@ int usb_otg_start(struct platform_device
_fsl_readl = _fsl_readl_le;
_fsl_writel = _fsl_writel_le;
}
+#endif
/* request irq */
p_otg->irq = platform_get_irq(pdev, 0);
@@ -976,7 +978,7 @@ int usb_otg_start(struct platform_device
/*
* state file in sysfs
*/
-static int show_fsl_usb2_otg_state(struct device *dev,
+static ssize_t show_fsl_usb2_otg_state(struct device *dev,
struct device_attribute *attr, char *buf)
{
struct otg_fsm *fsm = &fsl_otg_dev->fsm;
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox