Re: [PATCH] x86/mm: Rewrite sme_populate_pgd() in a more sensible way

2017-12-04 Thread Tom Lendacky

On 12/4/2017 8:57 AM, Kirill A. Shutemov wrote:

On Mon, Dec 04, 2017 at 08:19:11AM -0600, Tom Lendacky wrote:

On 12/4/2017 5:23 AM, Kirill A. Shutemov wrote:

sme_populate_pgd() open-codes a lot of things that are not needed to be
open-coded.

Let's rewrite it in a more stream-lined way.

This would also buy us boot-time switching between support between
paging modes, when rest of the pieces will be upstream.


Hi Kirill,

Unfortunately, some of these can't be changed.  The use of p4d_offset(),
pud_offset(), etc., use non-identity mapped virtual addresses which cause
failures at this point of the boot process.


Wat? Virtual address is virtual address. p?d_offset() doesn't care about
what mapping you're using.


Yes it does.  For example, pmd_offset() issues a pud_page_addr() call,
which does a __va() returning a non-identity mapped address (0x88...). 
 Only identity mapped virtual addresses have been setup at this point, so

the use of that virtual address panics the kernel.

Thanks,
Tom




Also, calls such as __p4d(), __pud(), etc., are part of the paravirt
support and can't be used yet, either.


Yeah, I missed this. native_make_p?d() has to be used instead.


I can take a closer look at some of the others (p*d_none() and
p*d_large()) which make use of the native_ macros, but my worry would be
that these get changed in the future to the non-native calls and then
boot failures occur.


If you want to avoid paravirt altogher for whole compilation unit, one
more option would be to put #undef CONFIG_PARAVIRT before all includes.
That's hack, but it works. We already use this in arch/x86/boot/compressed
code.



[PATCH 4.4 09/27] mm, thp: Do not make page table dirty unconditionally in touch_p[mu]d()

2017-12-04 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Kirill A. Shutemov 

commit a8f97366452ed491d13cf1e44241bc0b5740b1f0 upstream.

Currently, we unconditionally make page table dirty in touch_pmd().
It may result in false-positive can_follow_write_pmd().

We may avoid the situation, if we would only make the page table entry
dirty if caller asks for write access -- FOLL_WRITE.

The patch also changes touch_pud() in the same way.

Signed-off-by: Kirill A. Shutemov 
Cc: Michal Hocko 
Cc: Hugh Dickins 
Signed-off-by: Linus Torvalds 
[Salvatore Bonaccorso: backport for 3.16:
 - Adjust context
 - Drop specific part for PUD-sized transparent hugepages. Support
   for PUD-sized transparent hugepages was added in v4.11-rc1
]
Signed-off-by: Ben Hutchings 
Signed-off-by: Greg Kroah-Hartman 
---
 mm/huge_memory.c |   14 --
 1 file changed, 4 insertions(+), 10 deletions(-)

--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -1304,17 +1304,11 @@ struct page *follow_trans_huge_pmd(struc
VM_BUG_ON_PAGE(!PageHead(page), page);
if (flags & FOLL_TOUCH) {
pmd_t _pmd;
-   /*
-* We should set the dirty bit only for FOLL_WRITE but
-* for now the dirty bit in the pmd is meaningless.
-* And if the dirty bit will become meaningful and
-* we'll only set it with FOLL_WRITE, an atomic
-* set_bit will be required on the pmd to set the
-* young bit, instead of the current set_pmd_at.
-*/
-   _pmd = pmd_mkyoung(pmd_mkdirty(*pmd));
+   _pmd = pmd_mkyoung(*pmd);
+   if (flags & FOLL_WRITE)
+   _pmd = pmd_mkdirty(_pmd);
if (pmdp_set_access_flags(vma, addr & HPAGE_PMD_MASK,
- pmd, _pmd,  1))
+ pmd, _pmd, flags & FOLL_WRITE))
update_mmu_cache_pmd(vma, addr, pmd);
}
if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) {




[PATCH 4.4 25/27] nfsd: Make init_open_stateid() a bit more whole

2017-12-04 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Oleg Drokin 

commit 8c7245abda877d4689b3371db8ae2a4400d7d9ce upstream.

Move the state selection logic inside from the caller,
always making it return correct stp to use.

Signed-off-by: J . Bruce Fields 
Signed-off-by: Oleg Drokin 
Signed-off-by: J. Bruce Fields 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/nfsd/nfs4state.c |   27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3420,13 +3420,14 @@ alloc_init_open_stateowner(unsigned int
 }
 
 static struct nfs4_ol_stateid *
-init_open_stateid(struct nfs4_ol_stateid *stp, struct nfs4_file *fp,
-   struct nfsd4_open *open)
+init_open_stateid(struct nfs4_file *fp, struct nfsd4_open *open)
 {
 
struct nfs4_openowner *oo = open->op_openowner;
struct nfs4_ol_stateid *retstp = NULL;
+   struct nfs4_ol_stateid *stp;
 
+   stp = open->op_stp;
/* We are moving these outside of the spinlocks to avoid the warnings */
mutex_init(&stp->st_mutex);
mutex_lock(&stp->st_mutex);
@@ -3437,6 +3438,8 @@ init_open_stateid(struct nfs4_ol_stateid
retstp = nfsd4_find_existing_open(fp, open);
if (retstp)
goto out_unlock;
+
+   open->op_stp = NULL;
atomic_inc(&stp->st_stid.sc_count);
stp->st_stid.sc_type = NFS4_OPEN_STID;
INIT_LIST_HEAD(&stp->st_locks);
@@ -3454,10 +3457,11 @@ out_unlock:
spin_unlock(&oo->oo_owner.so_client->cl_lock);
if (retstp) {
mutex_lock(&retstp->st_mutex);
-   /* Not that we need to, just for neatness */
+   /* To keep mutex tracking happy */
mutex_unlock(&stp->st_mutex);
+   stp = retstp;
}
-   return retstp;
+   return stp;
 }
 
 /*
@@ -4260,7 +4264,6 @@ nfsd4_process_open2(struct svc_rqst *rqs
struct nfs4_client *cl = open->op_openowner->oo_owner.so_client;
struct nfs4_file *fp = NULL;
struct nfs4_ol_stateid *stp = NULL;
-   struct nfs4_ol_stateid *swapstp = NULL;
struct nfs4_delegation *dp = NULL;
__be32 status;
 
@@ -4297,16 +4300,10 @@ nfsd4_process_open2(struct svc_rqst *rqs
goto out;
}
} else {
-   stp = open->op_stp;
-   open->op_stp = NULL;
-   /*
-* init_open_stateid() either returns a locked stateid
-* it found, or initializes and locks the new one we passed in
-*/
-   swapstp = init_open_stateid(stp, fp, open);
-   if (swapstp) {
-   nfs4_put_stid(&stp->st_stid);
-   stp = swapstp;
+   /* stp is returned locked. */
+   stp = init_open_stateid(fp, open);
+   /* See if we lost the race to some other thread */
+   if (stp->st_access_bmap != 0) {
status = nfs4_upgrade_open(rqstp, fp, current_fh,
stp, open);
if (status) {




[PATCH 4.4 17/27] bcache: Fix building error on MIPS

2017-12-04 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Huacai Chen 

commit cf33c1ee5254c6a430bc1538232b49c3ea13e613 upstream.

This patch try to fix the building error on MIPS. The reason is MIPS
has already defined the PTR macro, which conflicts with the PTR macro
in include/uapi/linux/bcache.h.

[fixed by mlyle: corrected a line-length issue]

Signed-off-by: Huacai Chen 
Reviewed-by: Michael Lyle 
Signed-off-by: Michael Lyle 
Signed-off-by: Jens Axboe 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/md/bcache/alloc.c   |2 +-
 drivers/md/bcache/extents.c |2 +-
 drivers/md/bcache/journal.c |2 +-
 include/uapi/linux/bcache.h |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -479,7 +479,7 @@ int __bch_bucket_alloc_set(struct cache_
if (b == -1)
goto err;
 
-   k->ptr[i] = PTR(ca->buckets[b].gen,
+   k->ptr[i] = MAKE_PTR(ca->buckets[b].gen,
bucket_to_sector(c, b),
ca->sb.nr_this_dev);
 
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -584,7 +584,7 @@ static bool bch_extent_merge(struct btre
return false;
 
for (i = 0; i < KEY_PTRS(l); i++)
-   if (l->ptr[i] + PTR(0, KEY_SIZE(l), 0) != r->ptr[i] ||
+   if (l->ptr[i] + MAKE_PTR(0, KEY_SIZE(l), 0) != r->ptr[i] ||
PTR_BUCKET_NR(b->c, l, i) != PTR_BUCKET_NR(b->c, r, i))
return false;
 
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -508,7 +508,7 @@ static void journal_reclaim(struct cache
continue;
 
ja->cur_idx = next;
-   k->ptr[n++] = PTR(0,
+   k->ptr[n++] = MAKE_PTR(0,
  bucket_to_sector(c, ca->sb.d[ja->cur_idx]),
  ca->sb.nr_this_dev);
}
--- a/include/uapi/linux/bcache.h
+++ b/include/uapi/linux/bcache.h
@@ -90,7 +90,7 @@ PTR_FIELD(PTR_GEN,0,  8)
 
 #define PTR_CHECK_DEV  ((1 << PTR_DEV_BITS) - 1)
 
-#define PTR(gen, offset, dev)  \
+#define MAKE_PTR(gen, offset, dev) \
__u64) dev) << 51) | ((__u64) offset) << 8 | gen)
 
 /* Bkey utility code */




[PATCH 4.4 20/27] drm/panel: simple: Add missing panel_simple_unprepare() calls

2017-12-04 Thread Greg Kroah-Hartman
4.4-stable review patch.  If anyone has any objections, please let me know.

--

From: Jonathan Liu 

commit f3621a8eb59a913612c8e6e37d81f16b649f8b6c upstream.

During panel removal or system shutdown panel_simple_disable() is called
which disables the panel backlight but the panel is still powered due to
missing calls to panel_simple_unprepare().

Fixes: d02fd93e2cd8 ("drm/panel: simple - Disable panel on shutdown")
Signed-off-by: Jonathan Liu 
Signed-off-by: Thierry Reding 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20170807115545.27747-1-net...@gmail.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/panel/panel-simple.c |2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -352,6 +352,7 @@ static int panel_simple_remove(struct de
drm_panel_remove(&panel->base);
 
panel_simple_disable(&panel->base);
+   panel_simple_unprepare(&panel->base);
 
if (panel->ddc)
put_device(&panel->ddc->dev);
@@ -367,6 +368,7 @@ static void panel_simple_shutdown(struct
struct panel_simple *panel = dev_get_drvdata(dev);
 
panel_simple_disable(&panel->base);
+   panel_simple_unprepare(&panel->base);
 }
 
 static const struct drm_display_mode ampire_am800480r3tmqwa1h_mode = {




[PATCH 4.9 25/38] hwmon: (jc42) optionally try to disable the SMBUS timeout

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Rosin 

commit 68615eb01f82256c19e41967bfb3eef902f77033 upstream.

With a nxp,se97 chip on an atmel sama5d31 board, the I2C adapter driver
is not always capable of avoiding the 25-35 ms timeout as specified by
the SMBUS protocol. This may cause silent corruption of the last bit of
any transfer, e.g. a one is read instead of a zero if the sensor chip
times out. This also affects the eeprom half of the nxp-se97 chip, where
this silent corruption was originally noticed. Other I2C adapters probably
suffer similar issues, e.g. bit-banging comes to mind as risky...

The SMBUS register in the nxp chip is not a standard Jedec register, but
it is not special to the nxp chips either, at least the atmel chips
have the same mechanism. Therefore, do not special case this on the
manufacturer, it is opt-in via the device property anyway.

Signed-off-by: Peter Rosin 
Acked-by: Rob Herring 
Signed-off-by: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 Documentation/devicetree/bindings/hwmon/jc42.txt |4 
 drivers/hwmon/jc42.c |   21 +
 2 files changed, 25 insertions(+)

--- a/Documentation/devicetree/bindings/hwmon/jc42.txt
+++ b/Documentation/devicetree/bindings/hwmon/jc42.txt
@@ -34,6 +34,10 @@ Required properties:
 
 - reg: I2C address
 
+Optional properties:
+- smbus-timeout-disable: When set, the smbus timeout function will be disabled.
+This is not supported on all chips.
+
 Example:
 
 temp-sensor@1a {
--- a/drivers/hwmon/jc42.c
+++ b/drivers/hwmon/jc42.c
@@ -22,6 +22,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -45,6 +46,7 @@ static const unsigned short normal_i2c[]
 #define JC42_REG_TEMP  0x05
 #define JC42_REG_MANID 0x06
 #define JC42_REG_DEVICEID  0x07
+#define JC42_REG_SMBUS 0x22 /* NXP and Atmel, possibly others? */
 
 /* Status bits in temperature register */
 #define JC42_ALARM_CRIT_BIT15
@@ -73,6 +75,9 @@ static const unsigned short normal_i2c[]
 #define ONS_MANID  0x1b09  /* ON Semiconductor */
 #define STM_MANID  0x104a  /* ST Microelectronics */
 
+/* SMBUS register */
+#define SMBUS_STMOUT   BIT(7)  /* SMBus time-out, active low */
+
 /* Supported chips */
 
 /* Analog Devices */
@@ -476,6 +481,22 @@ static int jc42_probe(struct i2c_client
 
data->extended = !!(cap & JC42_CAP_RANGE);
 
+   if (device_property_read_bool(dev, "smbus-timeout-disable")) {
+   int smbus;
+
+   /*
+* Not all chips support this register, but from a
+* quick read of various datasheets no chip appears
+* incompatible with the below attempt to disable
+* the timeout. And the whole thing is opt-in...
+*/
+   smbus = i2c_smbus_read_word_swapped(client, JC42_REG_SMBUS);
+   if (smbus < 0)
+   return smbus;
+   i2c_smbus_write_word_swapped(client, JC42_REG_SMBUS,
+smbus | SMBUS_STMOUT);
+   }
+
config = i2c_smbus_read_word_swapped(client, JC42_REG_CONFIG);
if (config < 0)
return config;




[PATCH 4.9 22/38] eeprom: at24: check at24_read/write arguments

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Heiner Kallweit 

commit d9bcd462daf34aebb8de9ad7f76de0198bb5a0f0 upstream.

So far we completely rely on the caller to provide valid arguments.
To be on the safe side perform an own sanity check.

Signed-off-by: Heiner Kallweit 
Signed-off-by: Bartosz Golaszewski 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/misc/eeprom/at24.c |6 ++
 1 file changed, 6 insertions(+)

--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -507,6 +507,9 @@ static int at24_read(void *priv, unsigne
if (unlikely(!count))
return count;
 
+   if (off + count > at24->chip.byte_len)
+   return -EINVAL;
+
/*
 * Read data from chip, protecting against concurrent updates
 * from this host, but not from other I2C masters.
@@ -539,6 +542,9 @@ static int at24_write(void *priv, unsign
if (unlikely(!count))
return -EINVAL;
 
+   if (off + count > at24->chip.byte_len)
+   return -EINVAL;
+
/*
 * Write data to chip, protecting against concurrent updates
 * from this host, but not from other I2C masters.




[PATCH 4.9 19/38] mmc: core: prepend 0x to OCR entry in sysfs

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Bastian Stender 

commit c892b0d81705c566f575e489efc3c50762db1bde upstream.

The sysfs entry "ocr" was missing the 0x prefix to identify it as hex
formatted.

Fixes: 5fb06af7a33b ("mmc: core: Extend sysfs with OCR register")
Signed-off-by: Bastian Stender 
[Ulf: Amended change to also cover SD-cards]
Signed-off-by: Ulf Hansson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/mmc/core/mmc.c |2 +-
 drivers/mmc/core/sd.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -752,7 +752,7 @@ MMC_DEV_ATTR(enhanced_area_offset, "%llu
 MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
 MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult);
 MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors);
-MMC_DEV_ATTR(ocr, "%08x\n", card->ocr);
+MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr);
 
 static ssize_t mmc_fwrev_show(struct device *dev,
  struct device_attribute *attr,
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -683,7 +683,7 @@ MMC_DEV_ATTR(manfid, "0x%06x\n", card->c
 MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
 MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
 MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
-MMC_DEV_ATTR(ocr, "%08x\n", card->ocr);
+MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr);
 
 
 static ssize_t mmc_dsr_show(struct device *dev,




[PATCH 4.9 12/38] ARM: OMAP2+: Fix WL1283 Bluetooth Baud Rate

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Adam Ford 

commit a3ac350793d90d1da631c8b9352387974ed5 upstream.

Commit 485fa1261f78 ("ARM: OMAP2+: LogicPD Torpedo + Wireless: Add Bluetooth")
set the wrong baud rate for the UART. The Baud rate was 300,000 and it should
be 3,000,000 for WL1283.

Signed-off-by: Adam Ford 
Signed-off-by: Tony Lindgren 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/arm/mach-omap2/pdata-quirks.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arm/mach-omap2/pdata-quirks.c
+++ b/arch/arm/mach-omap2/pdata-quirks.c
@@ -162,7 +162,7 @@ static struct ti_st_plat_data wilink7_pd
.nshutdown_gpio = 162,
.dev_name = "/dev/ttyO1",
.flow_cntrl = 1,
-   .baud_rate = 30,
+   .baud_rate = 300,
 };
 
 static struct platform_device wl128x_device = {




[PATCH 4.9 18/38] mmc: core: Do not leave the block driver in a suspended state

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Adrian Hunter 

commit ebe7dd45cf49e3b49cacbaace17f9f878f21fbea upstream.

The block driver must be resumed if the mmc bus fails to suspend the card.

Signed-off-by: Adrian Hunter 
Reviewed-by: Linus Walleij 
Signed-off-by: Ulf Hansson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/mmc/core/bus.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -155,6 +155,9 @@ static int mmc_bus_suspend(struct device
return ret;
 
ret = host->bus_ops->suspend(host);
+   if (ret)
+   pm_generic_resume(dev);
+
return ret;
 }
 




[PATCH 4.9 16/38] KVM: lapic: Split out x2apic ldr calculation

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Dr. David Alan Gilbert 

commit e872fa94662d0644057c7c80b3071bdb9249e5ab upstream.

Split out the ldr calculation from kvm_apic_set_x2apic_id
since we're about to reuse it in the following patch.

Signed-off-by: Dr. David Alan Gilbert 
Signed-off-by: Paolo Bonzini 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/x86/kvm/lapic.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- a/arch/x86/kvm/lapic.c
+++ b/arch/x86/kvm/lapic.c
@@ -246,9 +246,14 @@ static inline void kvm_apic_set_ldr(stru
recalculate_apic_map(apic->vcpu->kvm);
 }
 
+static inline u32 kvm_apic_calc_x2apic_ldr(u32 id)
+{
+   return ((id >> 4) << 16) | (1 << (id & 0xf));
+}
+
 static inline void kvm_apic_set_x2apic_id(struct kvm_lapic *apic, u32 id)
 {
-   u32 ldr = ((id >> 4) << 16) | (1 << (id & 0xf));
+   u32 ldr = kvm_apic_calc_x2apic_ldr(id);
 
kvm_lapic_set_reg(apic, APIC_ID, id);
kvm_lapic_set_reg(apic, APIC_LDR, ldr);




[PATCH 4.9 02/38] ARM: dts: omap3: logicpd-torpedo-37xx-devkit: Fix MMC1 cd-gpio

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Adam Ford 

commit b7ace5ed8867ca54503727988adec6b20af54eeb upstream.

Fixes commit 687c27676151 ("ARM: dts: Add minimal support for LogicPD
Torpedo DM3730 devkit")

This patch corrects an issue where the cd-gpios was improperly setup
using IRQ_TYPE_LEVEL_LOW instead of GPIO_ACTIVE_LOW.

Signed-off-by: Adam Ford 
Signed-off-by: Tony Lindgren 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
+++ b/arch/arm/boot/dts/logicpd-torpedo-37xx-devkit.dts
@@ -192,7 +192,7 @@
interrupts-extended = <&intc 83 &omap3_pmx_core 0x11a>;
pinctrl-names = "default";
pinctrl-0 = <&mmc1_pins &mmc1_cd>;
-   cd-gpios = <&gpio4 31 IRQ_TYPE_LEVEL_LOW>;  /* gpio127 */
+   cd-gpios = <&gpio4 31 GPIO_ACTIVE_LOW>; /* gpio127 */
vmmc-supply = <&vmmc1>;
bus-width = <4>;
cap-power-off-card;




[PATCH 4.9 03/38] mm, thp: Do not make page table dirty unconditionally in touch_p[mu]d()

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Kirill A. Shutemov 

commit a8f97366452ed491d13cf1e44241bc0b5740b1f0 upstream.

Currently, we unconditionally make page table dirty in touch_pmd().
It may result in false-positive can_follow_write_pmd().

We may avoid the situation, if we would only make the page table entry
dirty if caller asks for write access -- FOLL_WRITE.

The patch also changes touch_pud() in the same way.

Signed-off-by: Kirill A. Shutemov 
Cc: Michal Hocko 
Cc: Hugh Dickins 
Signed-off-by: Linus Torvalds 
[Salvatore Bonaccorso: backport for 4.9:
 - Adjust context
 - Drop specific part for PUD-sized transparent hugepages. Support
   for PUD-sized transparent hugepages was added in v4.11-rc1
]
Signed-off-by: Ben Hutchings 
Signed-off-by: Greg Kroah-Hartman 
---
 mm/huge_memory.c |   19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

--- a/mm/huge_memory.c
+++ b/mm/huge_memory.c
@@ -745,20 +745,15 @@ int vmf_insert_pfn_pmd(struct vm_area_st
 EXPORT_SYMBOL_GPL(vmf_insert_pfn_pmd);
 
 static void touch_pmd(struct vm_area_struct *vma, unsigned long addr,
-   pmd_t *pmd)
+   pmd_t *pmd, int flags)
 {
pmd_t _pmd;
 
-   /*
-* We should set the dirty bit only for FOLL_WRITE but for now
-* the dirty bit in the pmd is meaningless.  And if the dirty
-* bit will become meaningful and we'll only set it with
-* FOLL_WRITE, an atomic set_bit will be required on the pmd to
-* set the young bit, instead of the current set_pmd_at.
-*/
-   _pmd = pmd_mkyoung(pmd_mkdirty(*pmd));
+   _pmd = pmd_mkyoung(*pmd);
+   if (flags & FOLL_WRITE)
+   _pmd = pmd_mkdirty(_pmd);
if (pmdp_set_access_flags(vma, addr & HPAGE_PMD_MASK,
-   pmd, _pmd,  1))
+   pmd, _pmd, flags & FOLL_WRITE))
update_mmu_cache_pmd(vma, addr, pmd);
 }
 
@@ -787,7 +782,7 @@ struct page *follow_devmap_pmd(struct vm
return NULL;
 
if (flags & FOLL_TOUCH)
-   touch_pmd(vma, addr, pmd);
+   touch_pmd(vma, addr, pmd, flags);
 
/*
 * device mapped pages can only be returned if the
@@ -1158,7 +1153,7 @@ struct page *follow_trans_huge_pmd(struc
page = pmd_page(*pmd);
VM_BUG_ON_PAGE(!PageHead(page) && !is_zone_device_page(page), page);
if (flags & FOLL_TOUCH)
-   touch_pmd(vma, addr, pmd);
+   touch_pmd(vma, addr, pmd, flags);
if ((flags & FOLL_MLOCK) && (vma->vm_flags & VM_LOCKED)) {
/*
 * We don't mlock() pte-mapped THPs. This way we can avoid




[PATCH 4.9 30/38] drm/radeon: fix atombios on big endian

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Roman Kapl 

commit 4f626a4ac8f57ddabf06d03870adab91e463217f upstream.

The function for byteswapping the data send to/from atombios was buggy for
num_bytes not divisible by four. The function must be aware of the fact
that after byte-swapping the u32 units, valid bytes might end up after the
num_bytes boundary.

This patch was tested on kernel 3.12 and allowed us to sucesfully use
DisplayPort on and Radeon SI card. Namely it fixed the link training and
EDID readout.

The function is patched both in radeon and amd drivers, since the functions
and the fixes are identical.

Signed-off-by: Roman Kapl 
Signed-off-by: Alex Deucher 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c |   38 ---
 drivers/gpu/drm/radeon/atombios_dp.c |   38 ---
 2 files changed, 36 insertions(+), 40 deletions(-)

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -1788,34 +1788,32 @@ void amdgpu_atombios_scratch_regs_restor
WREG32(mmBIOS_SCRATCH_0 + i, adev->bios_scratch[i]);
 }
 
-/* Atom needs data in little endian format
- * so swap as appropriate when copying data to
- * or from atom. Note that atom operates on
- * dw units.
+/* Atom needs data in little endian format so swap as appropriate when copying
+ * data to or from atom. Note that atom operates on dw units.
+ *
+ * Use to_le=true when sending data to atom and provide at least
+ * ALIGN(num_bytes,4) bytes in the dst buffer.
+ *
+ * Use to_le=false when receiving data from atom and provide ALIGN(num_bytes,4)
+ * byes in the src buffer.
  */
 void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
 {
 #ifdef __BIG_ENDIAN
-   u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
-   u32 *dst32, *src32;
+   u32 src_tmp[5], dst_tmp[5];
int i;
+   u8 align_num_bytes = ALIGN(num_bytes, 4);
 
-   memcpy(src_tmp, src, num_bytes);
-   src32 = (u32 *)src_tmp;
-   dst32 = (u32 *)dst_tmp;
if (to_le) {
-   for (i = 0; i < ((num_bytes + 3) / 4); i++)
-   dst32[i] = cpu_to_le32(src32[i]);
-   memcpy(dst, dst_tmp, num_bytes);
+   memcpy(src_tmp, src, num_bytes);
+   for (i = 0; i < align_num_bytes / 4; i++)
+   dst_tmp[i] = cpu_to_le32(src_tmp[i]);
+   memcpy(dst, dst_tmp, align_num_bytes);
} else {
-   u8 dws = num_bytes & ~3;
-   for (i = 0; i < ((num_bytes + 3) / 4); i++)
-   dst32[i] = le32_to_cpu(src32[i]);
-   memcpy(dst, dst_tmp, dws);
-   if (num_bytes % 4) {
-   for (i = 0; i < (num_bytes % 4); i++)
-   dst[dws+i] = dst_tmp[dws+i];
-   }
+   memcpy(src_tmp, src, align_num_bytes);
+   for (i = 0; i < align_num_bytes / 4; i++)
+   dst_tmp[i] = le32_to_cpu(src_tmp[i]);
+   memcpy(dst, dst_tmp, num_bytes);
}
 #else
memcpy(dst, src, num_bytes);
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -45,34 +45,32 @@ static char *pre_emph_names[] = {
 
 /* radeon AUX functions */
 
-/* Atom needs data in little endian format
- * so swap as appropriate when copying data to
- * or from atom. Note that atom operates on
- * dw units.
+/* Atom needs data in little endian format so swap as appropriate when copying
+ * data to or from atom. Note that atom operates on dw units.
+ *
+ * Use to_le=true when sending data to atom and provide at least
+ * ALIGN(num_bytes,4) bytes in the dst buffer.
+ *
+ * Use to_le=false when receiving data from atom and provide ALIGN(num_bytes,4)
+ * byes in the src buffer.
  */
 void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
 {
 #ifdef __BIG_ENDIAN
-   u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
-   u32 *dst32, *src32;
+   u32 src_tmp[5], dst_tmp[5];
int i;
+   u8 align_num_bytes = ALIGN(num_bytes, 4);
 
-   memcpy(src_tmp, src, num_bytes);
-   src32 = (u32 *)src_tmp;
-   dst32 = (u32 *)dst_tmp;
if (to_le) {
-   for (i = 0; i < ((num_bytes + 3) / 4); i++)
-   dst32[i] = cpu_to_le32(src32[i]);
-   memcpy(dst, dst_tmp, num_bytes);
+   memcpy(src_tmp, src, num_bytes);
+   for (i = 0; i < align_num_bytes / 4; i++)
+   dst_tmp[i] = cpu_to_le32(src_tmp[i]);
+   memcpy(dst, dst_tmp, align_num_bytes);
} else {
-   u8 dws = num_bytes & ~3;
-   for (i = 0; i < ((num_bytes + 3) / 4); i++)
-   dst32[i] = le32_to_cpu(src32[i]);
-   memcpy(dst, dst_tmp, dws);
-

[PATCH 4.9 05/38] mm, hugetlbfs: introduce ->split() to vm_operations_struct

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Dan Williams 

commit 31383c6865a578834dd953d9dbc88e6b19fe3997 upstream.

Patch series "device-dax: fix unaligned munmap handling"

When device-dax is operating in huge-page mode we want it to behave like
hugetlbfs and fail attempts to split vmas into unaligned ranges.  It
would be messy to teach the munmap path about device-dax alignment
constraints in the same (hstate) way that hugetlbfs communicates this
constraint.  Instead, these patches introduce a new ->split() vm
operation.

This patch (of 2):

The device-dax interface has similar constraints as hugetlbfs in that it
requires the munmap path to unmap in huge page aligned units.  Rather
than add more custom vma handling code in __split_vma() introduce a new
vm operation to perform this vma specific check.

Link: 
http://lkml.kernel.org/r/151130418135.4029.6783191281930729710.st...@dwillia2-desk3.amr.corp.intel.com
Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap")
Signed-off-by: Dan Williams 
Cc: Jeff Moyer 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 include/linux/mm.h |1 +
 mm/hugetlb.c   |8 
 mm/mmap.c  |8 +---
 3 files changed, 14 insertions(+), 3 deletions(-)

--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -347,6 +347,7 @@ struct fault_env {
 struct vm_operations_struct {
void (*open)(struct vm_area_struct * area);
void (*close)(struct vm_area_struct * area);
+   int (*split)(struct vm_area_struct * area, unsigned long addr);
int (*mremap)(struct vm_area_struct * area);
int (*fault)(struct vm_area_struct *vma, struct vm_fault *vmf);
int (*pmd_fault)(struct vm_area_struct *, unsigned long address,
--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -3135,6 +3135,13 @@ static void hugetlb_vm_op_close(struct v
}
 }
 
+static int hugetlb_vm_op_split(struct vm_area_struct *vma, unsigned long addr)
+{
+   if (addr & ~(huge_page_mask(hstate_vma(vma
+   return -EINVAL;
+   return 0;
+}
+
 /*
  * We cannot handle pagefaults against hugetlb pages at all.  They cause
  * handle_mm_fault() to try to instantiate regular-sized pages in the
@@ -3151,6 +3158,7 @@ const struct vm_operations_struct hugetl
.fault = hugetlb_vm_op_fault,
.open = hugetlb_vm_op_open,
.close = hugetlb_vm_op_close,
+   .split = hugetlb_vm_op_split,
 };
 
 static pte_t make_huge_pte(struct vm_area_struct *vma, struct page *page,
--- a/mm/mmap.c
+++ b/mm/mmap.c
@@ -2538,9 +2538,11 @@ static int __split_vma(struct mm_struct
struct vm_area_struct *new;
int err;
 
-   if (is_vm_hugetlb_page(vma) && (addr &
-   ~(huge_page_mask(hstate_vma(vma)
-   return -EINVAL;
+   if (vma->vm_ops && vma->vm_ops->split) {
+   err = vma->vm_ops->split(vma, addr);
+   if (err)
+   return err;
+   }
 
new = kmem_cache_alloc(vm_area_cachep, GFP_KERNEL);
if (!new)




[PATCH 4.9 07/38] btrfs: clear space cache inode generation always

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Josef Bacik 

commit 8e138e0d92c6c9d3d481674fb14e3439b495be37 upstream.

We discovered a box that had double allocations, and suspected the space
cache may be to blame.  While auditing the write out path I noticed that
if we've already setup the space cache we will just carry on.  This
means that any error we hit after cache_save_setup before we go to
actually write the cache out we won't reset the inode generation, so
whatever was already written will be considered correct, except it'll be
stale.  Fix this by _always_ resetting the generation on the block group
inode, this way we only ever have valid or invalid cache.

With this patch I was no longer able to reproduce cache corruption with
dm-log-writes and my bpf error injection tool.

Signed-off-by: Josef Bacik 
Signed-off-by: David Sterba 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/btrfs/extent-tree.c |   14 +++---
 1 file changed, 7 insertions(+), 7 deletions(-)

--- a/fs/btrfs/extent-tree.c
+++ b/fs/btrfs/extent-tree.c
@@ -3397,13 +3397,6 @@ again:
goto again;
}
 
-   /* We've already setup this transaction, go ahead and exit */
-   if (block_group->cache_generation == trans->transid &&
-   i_size_read(inode)) {
-   dcs = BTRFS_DC_SETUP;
-   goto out_put;
-   }
-
/*
 * We want to set the generation to 0, that way if anything goes wrong
 * from here on out we know not to trust this cache when we load up next
@@ -3427,6 +3420,13 @@ again:
}
WARN_ON(ret);
 
+   /* We've already setup this transaction, go ahead and exit */
+   if (block_group->cache_generation == trans->transid &&
+   i_size_read(inode)) {
+   dcs = BTRFS_DC_SETUP;
+   goto out_put;
+   }
+
if (i_size_read(inode) > 0) {
ret = btrfs_check_trunc_cache_free_space(root,
&root->fs_info->global_block_rsv);




[PATCH 4.9 09/38] nfsd: Fix another OPEN stateid race

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

From: Trond Myklebust 

commit d8a1a000555ecd1b824ac1ed6df8fe364df0 upstream.

If nfsd4_process_open2() is initialising a new stateid, and yet the
call to nfs4_get_vfs_file() fails for some reason, then we must
declare the stateid closed, and unhash it before dropping the mutex.

Right now, we unhash the stateid after dropping the mutex, and without
changing the stateid type, meaning that another OPEN could theoretically
look it up and attempt to use it.

Reported-by: Andrew W Elble 
Signed-off-by: Trond Myklebust 
Signed-off-by: J. Bruce Fields 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/nfsd/nfs4state.c |   28 +---
 1 file changed, 13 insertions(+), 15 deletions(-)

--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4453,6 +4453,7 @@ nfsd4_process_open2(struct svc_rqst *rqs
struct nfs4_ol_stateid *stp = NULL;
struct nfs4_delegation *dp = NULL;
__be32 status;
+   bool new_stp = false;
 
/*
 * Lookup file; if found, lookup stateid and check open request,
@@ -4472,11 +4473,19 @@ nfsd4_process_open2(struct svc_rqst *rqs
goto out;
}
 
+   if (!stp) {
+   stp = init_open_stateid(fp, open);
+   if (!open->op_stp)
+   new_stp = true;
+   }
+
/*
 * OPEN the file, or upgrade an existing OPEN.
 * If truncate fails, the OPEN fails.
+*
+* stp is already locked.
 */
-   if (stp) {
+   if (!new_stp) {
/* Stateid was found, this is an OPEN upgrade */
status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open);
if (status) {
@@ -4484,22 +4493,11 @@ nfsd4_process_open2(struct svc_rqst *rqs
goto out;
}
} else {
-   /* stp is returned locked. */
-   stp = init_open_stateid(fp, open);
-   /* See if we lost the race to some other thread */
-   if (stp->st_access_bmap != 0) {
-   status = nfs4_upgrade_open(rqstp, fp, current_fh,
-   stp, open);
-   if (status) {
-   mutex_unlock(&stp->st_mutex);
-   goto out;
-   }
-   goto upgrade_out;
-   }
status = nfs4_get_vfs_file(rqstp, fp, current_fh, stp, open);
if (status) {
-   mutex_unlock(&stp->st_mutex);
+   stp->st_stid.sc_type = NFS4_CLOSED_STID;
release_open_stateid(stp);
+   mutex_unlock(&stp->st_mutex);
goto out;
}
 
@@ -4508,7 +4506,7 @@ nfsd4_process_open2(struct svc_rqst *rqs
if (stp->st_clnt_odstate == open->op_odstate)
open->op_odstate = NULL;
}
-upgrade_out:
+
nfs4_inc_and_copy_stateid(&open->op_stateid, &stp->st_stid);
mutex_unlock(&stp->st_mutex);
 




[PATCH 4.9 35/38] Revert "x86/entry/64: Add missing irqflags tracing to native_load_gs_index()"

2017-12-04 Thread Greg Kroah-Hartman
4.9-stable review patch.  If anyone has any objections, please let me know.

--

This reverts commit 0d794d0d018f23fb09c50f6ae26868bd6ae343d6 which is
commit 0d794d0d018f23fb09c50f6ae26868bd6ae343d6 upstream.

Andy writes:

I think the thing to do is to revert the patch from -stable.
The bug it fixes is very minor, and the regression is that it
made a pre-existing bug in some nearly-undebuggable core resume
code much easier to hit.  I don't feel comfortable with a
backport of the latter fix until it has a good long soak in
Linus' tree.

Reported-by: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Dave Hansen 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/x86/entry/entry_64.S | 10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/x86/entry/entry_64.S b/arch/x86/entry/entry_64.S
index be9df513141e..e7b0e7ff4c58 100644
--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -54,19 +54,15 @@ ENTRY(native_usergs_sysret64)
 ENDPROC(native_usergs_sysret64)
 #endif /* CONFIG_PARAVIRT */
 
-.macro TRACE_IRQS_FLAGS flags:req
+.macro TRACE_IRQS_IRETQ
 #ifdef CONFIG_TRACE_IRQFLAGS
-   bt  $9, \flags  /* interrupts off? */
+   bt  $9, EFLAGS(%rsp)/* interrupts off? */
jnc 1f
TRACE_IRQS_ON
 1:
 #endif
 .endm
 
-.macro TRACE_IRQS_IRETQ
-   TRACE_IRQS_FLAGS EFLAGS(%rsp)
-.endm
-
 /*
  * When dynamic function tracer is enabled it will add a breakpoint
  * to all locations that it is about to modify, sync CPUs, update
@@ -872,13 +868,11 @@ idtentry simd_coprocessor_error   
do_simd_coprocessor_error   has_error_code=0
 ENTRY(native_load_gs_index)
pushfq
DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
-   TRACE_IRQS_OFF
SWAPGS
 .Lgs_change:
movl%edi, %gs
 2: ALTERNATIVE "", "mfence", X86_BUG_SWAPGS_FENCE
SWAPGS
-   TRACE_IRQS_FLAGS (%rsp)
popfq
ret
 END(native_load_gs_index)
-- 
2.15.1





[PATCH 4.14 10/95] mm: fail get_vaddr_frames() for filesystem-dax mappings

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Dan Williams 

commit b7f0554a56f21fb3e636a627450a9add030889be upstream.

Until there is a solution to the dma-to-dax vs truncate problem it is
not safe to allow V4L2, Exynos, and other frame vector users to create
long standing / irrevocable memory registrations against filesytem-dax
vmas.

[dan.j.willi...@intel.com: add comment for vma_is_fsdax() check in 
get_vaddr_frames(), per Jan]
  Link: 
http://lkml.kernel.org/r/151197874035.26211.4061781453123083667.st...@dwillia2-desk3.amr.corp.intel.com
Link: 
http://lkml.kernel.org/r/151068939985.7446.15684639617389154187.st...@dwillia2-desk3.amr.corp.intel.com
Fixes: 3565fce3a659 ("mm, x86: get_user_pages() for dax mappings")
Signed-off-by: Dan Williams 
Reviewed-by: Jan Kara 
Cc: Inki Dae 
Cc: Seung-Woo Kim 
Cc: Joonyoung Shim 
Cc: Kyungmin Park 
Cc: Mauro Carvalho Chehab 
Cc: Mel Gorman 
Cc: Vlastimil Babka 
Cc: Christoph Hellwig 
Cc: Doug Ledford 
Cc: Hal Rosenstock 
Cc: Jason Gunthorpe 
Cc: Jeff Moyer 
Cc: Ross Zwisler 
Cc: Sean Hefty 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 mm/frame_vector.c |   12 
 1 file changed, 12 insertions(+)

--- a/mm/frame_vector.c
+++ b/mm/frame_vector.c
@@ -53,6 +53,18 @@ int get_vaddr_frames(unsigned long start
ret = -EFAULT;
goto out;
}
+
+   /*
+* While get_vaddr_frames() could be used for transient (kernel
+* controlled lifetime) pinning of memory pages all current
+* users establish long term (userspace controlled lifetime)
+* page pinning. Treat get_vaddr_frames() like
+* get_user_pages_longterm() and disallow it for filesystem-dax
+* mappings.
+*/
+   if (vma_is_fsdax(vma))
+   return -EOPNOTSUPP;
+
if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) {
vec->got_ref = true;
vec->is_pfns = false;




[PATCH 4.14 13/95] exec: avoid RLIMIT_STACK races with prlimit()

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Kees Cook 

commit 04e35f4495dd560db30c25efca4eecae8ec8c375 upstream.

While the defense-in-depth RLIMIT_STACK limit on setuid processes was
protected against races from other threads calling setrlimit(), I missed
protecting it against races from external processes calling prlimit().
This adds locking around the change and makes sure that rlim_max is set
too.

Link: http://lkml.kernel.org/r/20171127193457.GA11348@beast
Fixes: 64701dee4178e ("exec: Use sane stack rlimit under secureexec")
Signed-off-by: Kees Cook 
Reported-by: Ben Hutchings 
Reported-by: Brad Spengler 
Acked-by: Serge Hallyn 
Cc: James Morris 
Cc: Andy Lutomirski 
Cc: Oleg Nesterov 
Cc: Jiri Slaby 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/exec.c |7 ++-
 1 file changed, 6 insertions(+), 1 deletion(-)

--- a/fs/exec.c
+++ b/fs/exec.c
@@ -1340,10 +1340,15 @@ void setup_new_exec(struct linux_binprm
 * avoid bad behavior from the prior rlimits. This has to
 * happen before arch_pick_mmap_layout(), which examines
 * RLIMIT_STACK, but after the point of no return to avoid
-* needing to clean up the change on failure.
+* races from other threads changing the limits. This also
+* must be protected from races with prlimit() calls.
 */
+   task_lock(current->group_leader);
if (current->signal->rlim[RLIMIT_STACK].rlim_cur > _STK_LIM)
current->signal->rlim[RLIMIT_STACK].rlim_cur = _STK_LIM;
+   if (current->signal->rlim[RLIMIT_STACK].rlim_max > _STK_LIM)
+   current->signal->rlim[RLIMIT_STACK].rlim_max = _STK_LIM;
+   task_unlock(current->group_leader);
}
 
arch_pick_mmap_layout(current->mm);




[PATCH 4.14 19/95] autofs: revert "autofs: fix AT_NO_AUTOMOUNT not being honored"

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Ian Kent 

commit 5d38f049cee1e1c4a7ac55aa79d37d01ddcc3860 upstream.

Commit 42f461482178 ("autofs: fix AT_NO_AUTOMOUNT not being honored")
allowed the fstatat(2) system call to properly honor the AT_NO_AUTOMOUNT
flag but introduced a semantic change.

In order to honor AT_NO_AUTOMOUNT a semantic change was made to the
negative dentry case for stat family system calls in follow_automount().

This changed the unconditional triggering of an automount in this case
to no longer be done and an error returned instead.

This has caused more problems than I expected so reverting the change is
needed.

In a discussion with Neil Brown it was concluded that the automount(8)
daemon can implement this change without kernel modifications.  So that
will be done instead and the autofs module documentation updated with a
description of the problem and what needs to be done by module users for
this specific case.

Link: 
http://lkml.kernel.org/r/151174730120.6162.3848002191530283984.st...@pluto.themaw.net
Fixes: 42f4614821 ("autofs: fix AT_NO_AUTOMOUNT not being honored")
Signed-off-by: Ian Kent 
Cc: Neil Brown 
Cc: Al Viro 
Cc: David Howells 
Cc: Colin Walters 
Cc: Ondrej Holy 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/namei.c |   15 +++
 include/linux/fs.h |3 ++-
 2 files changed, 5 insertions(+), 13 deletions(-)

--- a/fs/namei.c
+++ b/fs/namei.c
@@ -1129,18 +1129,9 @@ static int follow_automount(struct path
 * of the daemon to instantiate them before they can be used.
 */
if (!(nd->flags & (LOOKUP_PARENT | LOOKUP_DIRECTORY |
-  LOOKUP_OPEN | LOOKUP_CREATE |
-  LOOKUP_AUTOMOUNT))) {
-   /* Positive dentry that isn't meant to trigger an
-* automount, EISDIR will allow it to be used,
-* otherwise there's no mount here "now" so return
-* ENOENT.
-*/
-   if (path->dentry->d_inode)
-   return -EISDIR;
-   else
-   return -ENOENT;
-   }
+  LOOKUP_OPEN | LOOKUP_CREATE | LOOKUP_AUTOMOUNT)) &&
+   path->dentry->d_inode)
+   return -EISDIR;
 
if (path->dentry->d_sb->s_user_ns != &init_user_ns)
return -EACCES;
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3069,7 +3069,8 @@ static inline int vfs_lstat(const char _
 static inline int vfs_fstatat(int dfd, const char __user *filename,
  struct kstat *stat, int flags)
 {
-   return vfs_statx(dfd, filename, flags, stat, STATX_BASIC_STATS);
+   return vfs_statx(dfd, filename, flags | AT_NO_AUTOMOUNT,
+stat, STATX_BASIC_STATS);
 }
 static inline int vfs_fstat(int fd, struct kstat *stat)
 {




[PATCH 4.14 24/95] nfsd: fix panic in posix_unblock_lock called from nfs4_laundromat

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Naofumi Honda 

commit 64ebe12494fd5d193f014ce38e1fd83cc57883c8 upstream.

>From kernel 4.9, my two nfsv4 servers sometimes suffer from
"panic: unable to handle kernel page request"
in posix_unblock_lock() called from nfs4_laundromat().

These panics diseappear if we revert the commit "nfsd: add a LRU list
for blocked locks".

The cause appears to be a typo in nfs4_laundromat(), which is also
present in nfs4_state_shutdown_net().

Fixes: 7919d0a27f1e "nfsd: add a LRU list for blocked locks"
Cc: jlay...@redhat.com
Reveiwed-by: Jeff Layton 
Signed-off-by: J. Bruce Fields 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/nfsd/nfs4state.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -4732,7 +4732,7 @@ nfs4_laundromat(struct nfsd_net *nn)
spin_unlock(&nn->blocked_locks_lock);
 
while (!list_empty(&reaplist)) {
-   nbl = list_first_entry(&nn->blocked_locks_lru,
+   nbl = list_first_entry(&reaplist,
struct nfsd4_blocked_lock, nbl_lru);
list_del_init(&nbl->nbl_lru);
posix_unblock_lock(&nbl->nbl_lock);
@@ -7152,7 +7152,7 @@ nfs4_state_shutdown_net(struct net *net)
spin_unlock(&nn->blocked_locks_lock);
 
while (!list_empty(&reaplist)) {
-   nbl = list_first_entry(&nn->blocked_locks_lru,
+   nbl = list_first_entry(&reaplist,
struct nfsd4_blocked_lock, nbl_lru);
list_del_init(&nbl->nbl_lru);
posix_unblock_lock(&nbl->nbl_lock);




[PATCH 4.14 05/95] mm/cma: fix alloc_contig_range ret code/potential leak

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Mike Kravetz 

commit 63cd448908b5eb51d84c52f02b31b9b4ccd1cb5a upstream.

If the call __alloc_contig_migrate_range() in alloc_contig_range returns
-EBUSY, processing continues so that test_pages_isolated() is called
where there is a tracepoint to identify the busy pages.  However, it is
possible for busy pages to become available between the calls to these
two routines.  In this case, the range of pages may be allocated.
Unfortunately, the original return code (ret == -EBUSY) is still set and
returned to the caller.  Therefore, the caller believes the pages were
not allocated and they are leaked.

Update the comment to indicate that allocation is still possible even if
__alloc_contig_migrate_range returns -EBUSY.  Also, clear return code in
this case so that it is not accidentally used or returned to caller.

Link: http://lkml.kernel.org/r/20171122185214.25285-1-mike.krav...@oracle.com
Fixes: 8ef5849fa8a2 ("mm/cma: always check which page caused allocation 
failure")
Signed-off-by: Mike Kravetz 
Acked-by: Vlastimil Babka 
Acked-by: Michal Hocko 
Acked-by: Johannes Weiner 
Acked-by: Joonsoo Kim 
Cc: Michal Nazarewicz 
Cc: Laura Abbott 
Cc: Michal Hocko 
Cc: Mel Gorman 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 mm/page_alloc.c |9 -
 1 file changed, 8 insertions(+), 1 deletion(-)

--- a/mm/page_alloc.c
+++ b/mm/page_alloc.c
@@ -7587,11 +7587,18 @@ int alloc_contig_range(unsigned long sta
 
/*
 * In case of -EBUSY, we'd like to know which page causes problem.
-* So, just fall through. We will check it in test_pages_isolated().
+* So, just fall through. test_pages_isolated() has a tracepoint
+* which will report the busy page.
+*
+* It is possible that busy pages could become available before
+* the call to test_pages_isolated, and the range will actually be
+* allocated.  So, if we fall through be sure to clear ret so that
+* -EBUSY is not accidentally used or returned to caller.
 */
ret = __alloc_contig_migrate_range(&cc, start, end);
if (ret && ret != -EBUSY)
goto done;
+   ret =0;
 
/*
 * Pages from [start, end) are within a MAX_ORDER_NR_PAGES




[PATCH 4.14 18/95] autofs: revert "autofs: take more care to not update last_used on path walk"

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Ian Kent 

commit 43694d4bf843ddd34519e8e9de983deefeada699 upstream.

While commit 092a53452bb7 ("autofs: take more care to not update
last_used on path walk") helped (partially) resolve a problem where
automounts were not expiring due to aggressive accesses from user space
it has a side effect for very large environments.

This change helps with the expire problem by making the expire more
aggressive but, for very large environments, that means more mount
requests from clients.  When there are a lot of clients that can mean
fairly significant server load increases.

It turns out I put the last_used in this position to solve this very
problem and failed to update my own thinking of the autofs expire
policy.  So the patch being reverted introduces a regression which
should be fixed.

Link: 
http://lkml.kernel.org/r/151174729420.6162.1832622523537052460.st...@pluto.themaw.net
Fixes: 092a53452b ("autofs: take more care to not update last_used on path 
walk")
Signed-off-by: Ian Kent 
Reviewed-by: NeilBrown 
Cc: Al Viro 
Cc: Colin Walters 
Cc: David Howells 
Cc: Ondrej Holy 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/autofs4/root.c |   17 ++---
 1 file changed, 6 insertions(+), 11 deletions(-)

--- a/fs/autofs4/root.c
+++ b/fs/autofs4/root.c
@@ -281,8 +281,8 @@ static int autofs4_mount_wait(const stru
pr_debug("waiting for mount name=%pd\n", path->dentry);
status = autofs4_wait(sbi, path, NFY_MOUNT);
pr_debug("mount wait done status=%d\n", status);
-   ino->last_used = jiffies;
}
+   ino->last_used = jiffies;
return status;
 }
 
@@ -321,21 +321,16 @@ static struct dentry *autofs4_mountpoint
 */
if (autofs_type_indirect(sbi->type) && d_unhashed(dentry)) {
struct dentry *parent = dentry->d_parent;
+   struct autofs_info *ino;
struct dentry *new;
 
new = d_lookup(parent, &dentry->d_name);
if (!new)
return NULL;
-   if (new == dentry)
-   dput(new);
-   else {
-   struct autofs_info *ino;
-
-   ino = autofs4_dentry_ino(new);
-   ino->last_used = jiffies;
-   dput(path->dentry);
-   path->dentry = new;
-   }
+   ino = autofs4_dentry_ino(new);
+   ino->last_used = jiffies;
+   dput(path->dentry);
+   path->dentry = new;
}
return path->dentry;
 }




[PATCH 4.14 08/95] device-dax: implement ->split() to catch invalid munmap attempts

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Dan Williams 

commit 9702cffdbf2129516db679e4467db81e1cd287da upstream.

Similar to how device-dax enforces that the 'address', 'offset', and
'len' parameters to mmap() be aligned to the device's fundamental
alignment, the same constraints apply to munmap().  Implement ->split()
to fail munmap calls that violate the alignment constraint.

Otherwise, we later fail VM_BUG_ON checks in the unmap_page_range() path
with crash signatures of the form:

vma 8800b60c8a88 start 7f88c000 end 7f88c0e0
next   (null) prev   (null) mm 8800b61150c0
prot 8027 anon_vma   (null) vm_ops a0091240
pgoff 0 file 8800b638ef80 private_data   (null)
flags: 
0x38fb(read|write|shared|mayread|maywrite|mayexec|mayshare|softdirty|mixedmap|hugepage)
[ cut here ]
kernel BUG at mm/huge_memory.c:2014!
[..]
RIP: 0010:__split_huge_pud+0x12a/0x180
[..]
Call Trace:
 unmap_page_range+0x245/0xa40
 ? __vma_adjust+0x301/0x990
 unmap_vmas+0x4c/0xa0
 unmap_region+0xae/0x120
 ? __vma_rb_erase+0x11a/0x230
 do_munmap+0x276/0x410
 vm_munmap+0x6a/0xa0
 SyS_munmap+0x1d/0x30

Link: 
http://lkml.kernel.org/r/151130418681.4029.7118245855057952010.st...@dwillia2-desk3.amr.corp.intel.com
Fixes: dee410792419 ("/dev/dax, core: file operations and dax-mmap")
Signed-off-by: Dan Williams 
Reported-by: Jeff Moyer 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/dax/device.c |   12 
 1 file changed, 12 insertions(+)

--- a/drivers/dax/device.c
+++ b/drivers/dax/device.c
@@ -427,9 +427,21 @@ static int dev_dax_fault(struct vm_fault
return dev_dax_huge_fault(vmf, PE_SIZE_PTE);
 }
 
+static int dev_dax_split(struct vm_area_struct *vma, unsigned long addr)
+{
+   struct file *filp = vma->vm_file;
+   struct dev_dax *dev_dax = filp->private_data;
+   struct dax_region *dax_region = dev_dax->region;
+
+   if (!IS_ALIGNED(addr, dax_region->align))
+   return -EINVAL;
+   return 0;
+}
+
 static const struct vm_operations_struct dax_vm_ops = {
.fault = dev_dax_fault,
.huge_fault = dev_dax_huge_fault,
+   .split = dev_dax_split,
 };
 
 static int dax_mmap(struct file *filp, struct vm_area_struct *vma)




[PATCH 4.14 26/95] crypto: af_alg - remove locking in async callback

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Stephan Mueller 

commit 7d2c3f54e6f646887d019faa45f35d6fe9fe82ce upstream.

The code paths protected by the socket-lock do not use or modify the
socket in a non-atomic fashion. The actions pertaining the socket do not
even need to be handled as an atomic operation. Thus, the socket-lock
can be safely ignored.

This fixes a bug regarding scheduling in atomic as the callback function
may be invoked in interrupt context.

In addition, the sock_hold is moved before the AIO encrypt/decrypt
operation to ensure that the socket is always present. This avoids a
tiny race window where the socket is unprotected and yet used by the AIO
operation.

Finally, the release of resources for a crypto operation is moved into a
common function of af_alg_free_resources.

Fixes: e870456d8e7c8 ("crypto: algif_skcipher - overhaul memory management")
Fixes: d887c52d6ae43 ("crypto: algif_aead - overhaul memory management")
Reported-by: Romain Izard 
Signed-off-by: Stephan Mueller 
Tested-by: Romain Izard 
Signed-off-by: Herbert Xu 
Signed-off-by: Greg Kroah-Hartman 

---
 crypto/af_alg.c |   21 ++---
 crypto/algif_aead.c |   23 ---
 crypto/algif_skcipher.c |   23 ---
 include/crypto/if_alg.h |1 +
 4 files changed, 39 insertions(+), 29 deletions(-)

--- a/crypto/af_alg.c
+++ b/crypto/af_alg.c
@@ -1048,6 +1048,18 @@ unlock:
 EXPORT_SYMBOL_GPL(af_alg_sendpage);
 
 /**
+ * af_alg_free_resources - release resources required for crypto request
+ */
+void af_alg_free_resources(struct af_alg_async_req *areq)
+{
+   struct sock *sk = areq->sk;
+
+   af_alg_free_areq_sgls(areq);
+   sock_kfree_s(sk, areq, areq->areqlen);
+}
+EXPORT_SYMBOL_GPL(af_alg_free_resources);
+
+/**
  * af_alg_async_cb - AIO callback handler
  *
  * This handler cleans up the struct af_alg_async_req upon completion of the
@@ -1063,18 +1075,13 @@ void af_alg_async_cb(struct crypto_async
struct kiocb *iocb = areq->iocb;
unsigned int resultlen;
 
-   lock_sock(sk);
-
/* Buffer size written by crypto operation. */
resultlen = areq->outlen;
 
-   af_alg_free_areq_sgls(areq);
-   sock_kfree_s(sk, areq, areq->areqlen);
-   __sock_put(sk);
+   af_alg_free_resources(areq);
+   sock_put(sk);
 
iocb->ki_complete(iocb, err ? err : resultlen, 0);
-
-   release_sock(sk);
 }
 EXPORT_SYMBOL_GPL(af_alg_async_cb);
 
--- a/crypto/algif_aead.c
+++ b/crypto/algif_aead.c
@@ -283,12 +283,23 @@ static int _aead_recvmsg(struct socket *
 
if (msg->msg_iocb && !is_sync_kiocb(msg->msg_iocb)) {
/* AIO operation */
+   sock_hold(sk);
areq->iocb = msg->msg_iocb;
aead_request_set_callback(&areq->cra_u.aead_req,
  CRYPTO_TFM_REQ_MAY_BACKLOG,
  af_alg_async_cb, areq);
err = ctx->enc ? crypto_aead_encrypt(&areq->cra_u.aead_req) :
 crypto_aead_decrypt(&areq->cra_u.aead_req);
+
+   /* AIO operation in progress */
+   if (err == -EINPROGRESS || err == -EBUSY) {
+   /* Remember output size that will be generated. */
+   areq->outlen = outlen;
+
+   return -EIOCBQUEUED;
+   }
+
+   sock_put(sk);
} else {
/* Synchronous operation */
aead_request_set_callback(&areq->cra_u.aead_req,
@@ -300,19 +311,9 @@ static int _aead_recvmsg(struct socket *
 &ctx->completion);
}
 
-   /* AIO operation in progress */
-   if (err == -EINPROGRESS) {
-   sock_hold(sk);
-
-   /* Remember output size that will be generated. */
-   areq->outlen = outlen;
-
-   return -EIOCBQUEUED;
-   }
 
 free:
-   af_alg_free_areq_sgls(areq);
-   sock_kfree_s(sk, areq, areq->areqlen);
+   af_alg_free_resources(areq);
 
return err ? err : outlen;
 }
--- a/crypto/algif_skcipher.c
+++ b/crypto/algif_skcipher.c
@@ -117,6 +117,7 @@ static int _skcipher_recvmsg(struct sock
 
if (msg->msg_iocb && !is_sync_kiocb(msg->msg_iocb)) {
/* AIO operation */
+   sock_hold(sk);
areq->iocb = msg->msg_iocb;
skcipher_request_set_callback(&areq->cra_u.skcipher_req,
  CRYPTO_TFM_REQ_MAY_SLEEP,
@@ -124,6 +125,16 @@ static int _skcipher_recvmsg(struct sock
err = ctx->enc ?
crypto_skcipher_encrypt(&areq->cra_u.skcipher_req) :
crypto_skcipher_decrypt(&areq->cra_u.skcipher_req);
+
+   /* AIO operation in progress */
+   if (err == -EINPROGRESS || err == -

[PATCH 4.14 22/95] nfsd: Fix stateid races between OPEN and CLOSE

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Trond Myklebust 

commit 15ca08d3299682dc49bad73251677b2c5017ef08 upstream.

Open file stateids can linger on the nfs4_file list of stateids even
after they have been closed. In order to avoid reusing such a
stateid, and confusing the client, we need to recheck the
nfs4_stid's type after taking the mutex.
Otherwise, we risk reusing an old stateid that was already closed,
which will confuse clients that expect new stateids to conform to
RFC7530 Sections 9.1.4.2 and 16.2.5 or RFC5661 Sections 8.2.2 and 18.2.4.

Signed-off-by: Trond Myklebust 
Signed-off-by: J. Bruce Fields 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/nfsd/nfs4state.c |   67 +---
 1 file changed, 59 insertions(+), 8 deletions(-)

--- a/fs/nfsd/nfs4state.c
+++ b/fs/nfsd/nfs4state.c
@@ -3512,7 +3512,9 @@ nfsd4_find_existing_open(struct nfs4_fil
/* ignore lock owners */
if (local->st_stateowner->so_is_open_owner == 0)
continue;
-   if (local->st_stateowner == &oo->oo_owner) {
+   if (local->st_stateowner != &oo->oo_owner)
+   continue;
+   if (local->st_stid.sc_type == NFS4_OPEN_STID) {
ret = local;
atomic_inc(&ret->st_stid.sc_count);
break;
@@ -3521,6 +3523,52 @@ nfsd4_find_existing_open(struct nfs4_fil
return ret;
 }
 
+static __be32
+nfsd4_verify_open_stid(struct nfs4_stid *s)
+{
+   __be32 ret = nfs_ok;
+
+   switch (s->sc_type) {
+   default:
+   break;
+   case NFS4_CLOSED_STID:
+   case NFS4_CLOSED_DELEG_STID:
+   ret = nfserr_bad_stateid;
+   break;
+   case NFS4_REVOKED_DELEG_STID:
+   ret = nfserr_deleg_revoked;
+   }
+   return ret;
+}
+
+/* Lock the stateid st_mutex, and deal with races with CLOSE */
+static __be32
+nfsd4_lock_ol_stateid(struct nfs4_ol_stateid *stp)
+{
+   __be32 ret;
+
+   mutex_lock(&stp->st_mutex);
+   ret = nfsd4_verify_open_stid(&stp->st_stid);
+   if (ret != nfs_ok)
+   mutex_unlock(&stp->st_mutex);
+   return ret;
+}
+
+static struct nfs4_ol_stateid *
+nfsd4_find_and_lock_existing_open(struct nfs4_file *fp, struct nfsd4_open 
*open)
+{
+   struct nfs4_ol_stateid *stp;
+   for (;;) {
+   spin_lock(&fp->fi_lock);
+   stp = nfsd4_find_existing_open(fp, open);
+   spin_unlock(&fp->fi_lock);
+   if (!stp || nfsd4_lock_ol_stateid(stp) == nfs_ok)
+   break;
+   nfs4_put_stid(&stp->st_stid);
+   }
+   return stp;
+}
+
 static struct nfs4_openowner *
 alloc_init_open_stateowner(unsigned int strhashval, struct nfsd4_open *open,
   struct nfsd4_compound_state *cstate)
@@ -3565,6 +3613,7 @@ init_open_stateid(struct nfs4_file *fp,
mutex_init(&stp->st_mutex);
mutex_lock(&stp->st_mutex);
 
+retry:
spin_lock(&oo->oo_owner.so_client->cl_lock);
spin_lock(&fp->fi_lock);
 
@@ -3589,7 +3638,11 @@ out_unlock:
spin_unlock(&fp->fi_lock);
spin_unlock(&oo->oo_owner.so_client->cl_lock);
if (retstp) {
-   mutex_lock(&retstp->st_mutex);
+   /* Handle races with CLOSE */
+   if (nfsd4_lock_ol_stateid(retstp) != nfs_ok) {
+   nfs4_put_stid(&retstp->st_stid);
+   goto retry;
+   }
/* To keep mutex tracking happy */
mutex_unlock(&stp->st_mutex);
stp = retstp;
@@ -4410,9 +4463,7 @@ nfsd4_process_open2(struct svc_rqst *rqs
status = nfs4_check_deleg(cl, open, &dp);
if (status)
goto out;
-   spin_lock(&fp->fi_lock);
-   stp = nfsd4_find_existing_open(fp, open);
-   spin_unlock(&fp->fi_lock);
+   stp = nfsd4_find_and_lock_existing_open(fp, open);
} else {
open->op_file = NULL;
status = nfserr_bad_stateid;
@@ -4426,7 +4477,6 @@ nfsd4_process_open2(struct svc_rqst *rqs
 */
if (stp) {
/* Stateid was found, this is an OPEN upgrade */
-   mutex_lock(&stp->st_mutex);
status = nfs4_upgrade_open(rqstp, fp, current_fh, stp, open);
if (status) {
mutex_unlock(&stp->st_mutex);
@@ -5317,7 +5367,6 @@ static void nfsd4_close_open_stateid(str
bool unhashed;
LIST_HEAD(reaplist);
 
-   s->st_stid.sc_type = NFS4_CLOSED_STID;
spin_lock(&clp->cl_lock);
unhashed = unhash_open_stateid(s, &reaplist);
 
@@ -5357,10 +5406,12 @@ nfsd4_close(struct svc_rqst *rqstp, stru
nfsd4_bump_seqid(cstate, status);
if (status)

[PATCH 4.14 00/95] 4.14.4-stable review

2017-12-04 Thread Greg Kroah-Hartman
This is the start of the stable review cycle for the 4.14.4 release.
There are 95 patches in this series, all will be posted as a response
to this one.  If anyone has any issues with these being applied, please
let me know.

Responses should be made by Wed Dec  6 16:00:27 UTC 2017.
Anything received after that time might be too late.

The whole patch series can be found in one patch at:
kernel.org/pub/linux/kernel/v4.x/stable-review/patch-4.14.4-rc1.gz
or in the git tree and branch at:
  git://git.kernel.org/pub/scm/linux/kernel/git/stable/linux-stable-rc.git 
linux-4.14.y
and the diffstat can be found below.

thanks,

greg k-h

-
Pseudo-Shortlog of commits:

Greg Kroah-Hartman 
Linux 4.14.4-rc1

Greg Kroah-Hartman 
Revert "x86/entry/64: Add missing irqflags tracing to 
native_load_gs_index()"

Ville Syrjälä 
drm/i915: Prevent zero length "index" write

Ville Syrjälä 
drm/i915: Don't try indexed reads to alternate slave addresses

Xiong Zhang 
drm/i915/gvt: Correct ADDR_4K/2M/1G_MASK definition

Chris Wilson 
drm/i915/fbdev: Serialise early hotplug events with async fbdev config

Hans de Goede 
drm/i915: Re-register PMIC bus access notifier on runtime resume

Hans de Goede 
drm/i915: Fix false-positive assert_rpm_wakelock_held in 
i915_pmic_bus_access_notifier v2

NeilBrown 
md: forbid a RAID5 from having both a bitmap and a journal.

Sasha Neftin 
e1000e: fix the use of magic numbers for buffer overrun issue

Don Hiatt 
IB/hfi1: Do not warn on lid conversions for OPA

Don Hiatt 
IB/core: Do not warn on lid conversions for OPA

Sandipan Das 
include/linux/compiler-clang.h: handle randomizable anonymous structs

Michel Dänzer 
drm/amdgpu: Set adev->vcn.irq.num_types for VCN

Leo Liu 
drm/amdgpu: move UVD/VCE and VCN structure out from union

Ville Syrjälä 
drm/edid: Don't send non-zero YQ in AVI infoframe for HDMI 1.x sinks

Laurent Pinchart 
drm/fsl-dcu: Don't set connector DPMS property

Maarten Lankhorst 
drm/fb_helper: Disable all crtc's when initial setup fails.

Rex Zhu 
drm/amd/pp: fix typecast error in powerplay.

Christian König 
drm/ttm: once more fix ttm_buffer_object_transfer

Peter Griffin 
drm/hisilicon: Ensure LDI regs are properly configured.

Jonathan Liu 
drm/panel: simple: Add missing panel_simple_unprepare() calls

Roman Kapl 
drm/radeon: fix atombios on big endian

Jyri Sarha 
drm/tilcdc: Precalculate total frametime in tilcdc_crtc_set_mode()

Ville Syrjälä 
drm/vblank: Tune drm_crtc_accurate_vblank_count() WARN down to a debug

Ville Syrjälä 
drm/vblank: Fix flip event vblank count

Michel Dänzer 
drm/ttm: Always and only destroy bo->ttm_resv in ttm_bo_release_list

Christian König 
drm/amdgpu: reserve root PD while releasing it

Christian König 
dma-buf: make reservation_object_copy_fences rcu save

Christian König 
drm/ttm: fix ttm_bo_cleanup_refs_or_queue once more

Ken Wang 
drm/amdgpu: Remove check which is not valid for certain VBIOS

ozeng 
drm/amdgpu: Properly allocate VM invalidate eng v2

Christian König 
drm/amdgpu: fix error handling in amdgpu_bo_do_create

Ken Wang 
drm/amdgpu: correct reference clock value on vega10

Dan Carpenter 
drm/amdgpu: Potential uninitialized variable in 
amdgpu_vm_update_directories()

Dan Carpenter 
drm/amdgpu: potential uninitialized variable in amdgpu_vce_ring_parse_cs()

Alex Deucher 
Revert "drm/radeon: dont switch vt on suspend"

Jeff Lien 
nvme-pci: add quirk for delay before CHK RDY for WDC SN200

Peter Rosin 
hwmon: (jc42) optionally try to disable the SMBUS timeout

Rui Hua 
bcache: recover data from backing when data is clean

Coly Li 
bcache: only permit to recovery read error when cache device is clean

Huacai Chen 
bcache: Fix building error on MIPS

Vaibhav Jain 
cxl: Check if vphb exists before iterating over AFU devices

Hans de Goede 
i2c: i801: Fix Failed to allocate irq -2147483648 error

Heiner Kallweit 
eeprom: at24: check at24_read/write arguments

Bartosz Golaszewski 
eeprom: at24: correctly set the size for at24mac402

Heiner Kallweit 
eeprom: at24: fix reading from 24MAC402/24MAC602

Lv Zheng 
ACPI / EC: Fix regression related to PM ops support in ECDT device

Bastian Stender 
mmc: core: prepend 0x to OCR entry in sysfs

Bastian Stender 
mmc: core: prepend 0x to pre_eol_info entry in sysfs

Adrian Hunter 
mmc: block: Ensure that debugfs files are removed

Adrian Hunter 
mmc: core: Do not leave the block driver in a suspended state

Adrian Hunter 
mmc: block: Check return value of blk_get_request()

Adrian Hunter 
mmc: block: Fix missing blk_put_request()

Ulf Hansson 
mmc: sdhci: Avoid swiotlb buffer being full

Dr. David Alan Gilbert 
KVM: lapic: Fixup LDR on load in x2apic

Dr. David Alan Gilbert 
KVM: lapic: Split out x2apic ldr calculation

Paolo Bonzini 
KVM: x86: inje

[PATCH 4.14 20/95] mm/hugetlb: fix NULL-pointer dereference on 5-level paging machine

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Kirill A. Shutemov 

commit f4f0a3d85b50a65a348e2b8635041d6b30f01deb upstream.

I made a mistake during converting hugetlb code to 5-level paging: in
huge_pte_alloc() we have to use p4d_alloc(), not p4d_offset().

Otherwise it leads to crash -- NULL-pointer dereference in pud_alloc()
if p4d table is not yet allocated.

It only can happen in 5-level paging mode.  In 4-level paging mode
p4d_offset() always returns pgd, so we are fine.

Link: 
http://lkml.kernel.org/r/20171122121921.64822-1-kirill.shute...@linux.intel.com
Fixes: c2febafc6773 ("mm: convert generic code to 5-level paging")
Signed-off-by: Kirill A. Shutemov 
Acked-by: Vlastimil Babka 
Acked-by: Michal Hocko 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 mm/hugetlb.c |4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

--- a/mm/hugetlb.c
+++ b/mm/hugetlb.c
@@ -4625,7 +4625,9 @@ pte_t *huge_pte_alloc(struct mm_struct *
pte_t *pte = NULL;
 
pgd = pgd_offset(mm, addr);
-   p4d = p4d_offset(pgd, addr);
+   p4d = p4d_alloc(mm, pgd, addr);
+   if (!p4d)
+   return NULL;
pud = pud_alloc(mm, p4d, addr);
if (pud) {
if (sz == PUD_SIZE) {




[PATCH 4.14 09/95] mm: introduce get_user_pages_longterm

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Dan Williams 

commit 2bb6d2837083de722bfdc369cb0d76ce188dd9b4 upstream.

Patch series "introduce get_user_pages_longterm()", v2.

Here is a new get_user_pages api for cases where a driver intends to
keep an elevated page count indefinitely.  This is distinct from usages
like iov_iter_get_pages where the elevated page counts are transient.
The iov_iter_get_pages cases immediately turn around and submit the
pages to a device driver which will put_page when the i/o operation
completes (under kernel control).

In the longterm case userspace is responsible for dropping the page
reference at some undefined point in the future.  This is untenable for
filesystem-dax case where the filesystem is in control of the lifetime
of the block / page and needs reasonable limits on how long it can wait
for pages in a mapping to become idle.

Fixing filesystems to actually wait for dax pages to be idle before
blocks from a truncate/hole-punch operation are repurposed is saved for
a later patch series.

Also, allowing longterm registration of dax mappings is a future patch
series that introduces a "map with lease" semantic where the kernel can
revoke a lease and force userspace to drop its page references.

I have also tagged these for -stable to purposely break cases that might
assume that longterm memory registrations for filesystem-dax mappings
were supported by the kernel.  The behavior regression this policy
change implies is one of the reasons we maintain the "dax enabled.
Warning: EXPERIMENTAL, use at your own risk" notification when mounting
a filesystem in dax mode.

It is worth noting the device-dax interface does not suffer the same
constraints since it does not support file space management operations
like hole-punch.

This patch (of 4):

Until there is a solution to the dma-to-dax vs truncate problem it is
not safe to allow long standing memory registrations against
filesytem-dax vmas.  Device-dax vmas do not have this problem and are
explicitly allowed.

This is temporary until a "memory registration with layout-lease"
mechanism can be implemented for the affected sub-systems (RDMA and
V4L2).

[a...@linux-foundation.org: use kcalloc()]
Link: 
http://lkml.kernel.org/r/151068939435.7446.13560129395419350737.st...@dwillia2-desk3.amr.corp.intel.com
Fixes: 3565fce3a659 ("mm, x86: get_user_pages() for dax mappings")
Signed-off-by: Dan Williams 
Suggested-by: Christoph Hellwig 
Cc: Doug Ledford 
Cc: Hal Rosenstock 
Cc: Inki Dae 
Cc: Jan Kara 
Cc: Jason Gunthorpe 
Cc: Jeff Moyer 
Cc: Joonyoung Shim 
Cc: Kyungmin Park 
Cc: Mauro Carvalho Chehab 
Cc: Mel Gorman 
Cc: Ross Zwisler 
Cc: Sean Hefty 
Cc: Seung-Woo Kim 
Cc: Vlastimil Babka 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 include/linux/fs.h |   14 +++
 include/linux/mm.h |   13 ++
 mm/gup.c   |   64 +
 3 files changed, 91 insertions(+)

--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3175,6 +3175,20 @@ static inline bool vma_is_dax(struct vm_
return vma->vm_file && IS_DAX(vma->vm_file->f_mapping->host);
 }
 
+static inline bool vma_is_fsdax(struct vm_area_struct *vma)
+{
+   struct inode *inode;
+
+   if (!vma->vm_file)
+   return false;
+   if (!vma_is_dax(vma))
+   return false;
+   inode = file_inode(vma->vm_file);
+   if (inode->i_mode == S_IFCHR)
+   return false; /* device-dax */
+   return true;
+}
+
 static inline int iocb_flags(struct file *file)
 {
int res = 0;
--- a/include/linux/mm.h
+++ b/include/linux/mm.h
@@ -1368,6 +1368,19 @@ long get_user_pages_locked(unsigned long
unsigned int gup_flags, struct page **pages, int *locked);
 long get_user_pages_unlocked(unsigned long start, unsigned long nr_pages,
struct page **pages, unsigned int gup_flags);
+#ifdef CONFIG_FS_DAX
+long get_user_pages_longterm(unsigned long start, unsigned long nr_pages,
+   unsigned int gup_flags, struct page **pages,
+   struct vm_area_struct **vmas);
+#else
+static inline long get_user_pages_longterm(unsigned long start,
+   unsigned long nr_pages, unsigned int gup_flags,
+   struct page **pages, struct vm_area_struct **vmas)
+{
+   return get_user_pages(start, nr_pages, gup_flags, pages, vmas);
+}
+#endif /* CONFIG_FS_DAX */
+
 int get_user_pages_fast(unsigned long start, int nr_pages, int write,
struct page **pages);
 
--- a/mm/gup.c
+++ b/mm/gup.c
@@ -1095,6 +1095,70 @@ long get_user_pages(unsigned long start,
 }
 EXPORT_SYMBOL(get_user_pages);
 
+#ifdef CONFIG_FS_DAX
+/*
+ * This is the same as get_user_pages() in that it assumes we are
+ * operating on the current task's mm, but it goes further to validate
+ * that the vmas

[PATCH 4.14 29/95] s390: revert ELF_ET_DYN_BASE base changes

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Martin Schwidefsky 

commit 345f8f34bb473241d62803951c18a844dd705f8d upstream.

This reverts commit a73dc5370e153ac63718d850bddf0c9aa9d871e6.

Reducing the base address for 31-bit PIE executables from
(STACK_TOP/3)*2 to 4MB broke several compat programs which
use -fpie to move the executable out of the lower 16MB.

Signed-off-by: Martin Schwidefsky 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/s390/include/asm/elf.h |   15 ---
 1 file changed, 8 insertions(+), 7 deletions(-)

--- a/arch/s390/include/asm/elf.h
+++ b/arch/s390/include/asm/elf.h
@@ -194,13 +194,14 @@ struct arch_elf_state {
 #define CORE_DUMP_USE_REGSET
 #define ELF_EXEC_PAGESIZE  PAGE_SIZE
 
-/*
- * This is the base location for PIE (ET_DYN with INTERP) loads. On
- * 64-bit, this is raised to 4GB to leave the entire 32-bit address
- * space open for things that want to use the area for 32-bit pointers.
- */
-#define ELF_ET_DYN_BASE(is_compat_task() ? 0x00040UL : \
-   0x1UL)
+/* This is the location that an ET_DYN program is loaded if exec'ed.  Typical
+   use of this is to invoke "./ld.so someprog" to test out a new version of
+   the loader.  We need to make sure that it is out of the way of the program
+   that it will "exec", and that there is sufficient room for the brk. 64-bit
+   tasks are aligned to 4GB. */
+#define ELF_ET_DYN_BASE (is_compat_task() ? \
+   (STACK_TOP / 3 * 2) : \
+   (STACK_TOP / 3 * 2) & ~((1UL << 32) - 1))
 
 /* This yields a mask that user programs can use to figure out what
instruction set this CPU supports. */




[PATCH 4.14 43/95] mmc: block: Fix missing blk_put_request()

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Adrian Hunter 

commit 34c089e806793a66e450b11bd167db6047399fcd upstream.

Ensure blk_get_request() is paired with blk_put_request().

Fixes: 0493f6fe5bde ("mmc: block: Move boot partition locking into a driver op")
Fixes: 627c3ccfb46a ("mmc: debugfs: Move block debugfs into block module")
Signed-off-by: Adrian Hunter 
Reviewed-by: Linus Walleij 
Signed-off-by: Ulf Hansson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/mmc/core/block.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -207,6 +207,7 @@ static ssize_t power_ro_lock_store(struc
req_to_mmc_queue_req(req)->drv_op = MMC_DRV_OP_BOOT_WP;
blk_execute_rq(mq->queue, NULL, req, 0);
ret = req_to_mmc_queue_req(req)->drv_op_result;
+   blk_put_request(req);
 
if (!ret) {
pr_info("%s: Locking boot partition ro until next power on\n",
@@ -2321,6 +2322,7 @@ static int mmc_dbg_card_status_get(void
*val = ret;
ret = 0;
}
+   blk_put_request(req);
 
return ret;
 }
@@ -2351,6 +2353,7 @@ static int mmc_ext_csd_open(struct inode
req_to_mmc_queue_req(req)->drv_op_data = &ext_csd;
blk_execute_rq(mq->queue, NULL, req, 0);
err = req_to_mmc_queue_req(req)->drv_op_result;
+   blk_put_request(req);
if (err) {
pr_err("FAILED %d\n", err);
goto out_free;




Re: polarity inversion on LS1021a

2017-12-04 Thread Alexander Stein
On Monday, December 4, 2017, 4:37:20 PM CET Marc Zyngier wrote:
> On 04/12/17 15:31, Alexander Stein wrote:
> > On Monday, December 4, 2017, 4:11:06 PM CET Rasmus Villemoes wrote:
> >> The LS1021A has a standard GIC-400, but allows inverting the polarity of
> >> six external interrupt lines via a certain register, effectively
> >> supporting IRQ_TYPE_LEVEL_LOW and IRQ_TYPE_EDGE_FALLING for those.
> >>
> >> I'm trying to figure out how one would add support for this. The patch
> >> below works but is obviously just meant to help show what I mean, so
> >> please don't comment on all the things that are wrong with it.
> >>
> >> It feels wrong to create a whole new irqchip driver copy-pasting the
> >> entire irg-gic.c, but I can't figure out how and where one could hook
> >> into the existing one. Any pointers on how to do this properly will be
> >> greatly appreciated.
> > 
> > In my opinion a new irqchip is still required, but solely for modifying
> > SCFG_INTPCR depending on IRQ_TYPE_*
> > You would need to insert it as a cascading interrupt chip in device tree.
> > You also need to protect accesses to this register using a spinlock.
> > This is at least my idea how I would have done it, though never got time
> > for it.
> Almost. See my earlier reply. You just need a very minimal driver that
> only takes care of the polarity thing. Nobody needs to see yet another
> GIC driver...

Ah, maybe I should have made that more clear. Of course only a rather simple
driver for that single register is needed. The driver needs to handle the
infamous big-little-endian mismatch in ls1021a.

Best regards,
Alexander



[PATCH 4.14 46/95] mmc: block: Ensure that debugfs files are removed

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Adrian Hunter 

commit f9f0da98819503b06b35e61869d18cf3a8cd3323 upstream.

The card is not necessarily being removed, but the debugfs files must be
removed when the driver is removed, otherwise they will continue to exist
after unbinding the card from the driver. e.g.

  # echo "mmc1:0001" > /sys/bus/mmc/drivers/mmcblk/unbind
  # cat /sys/kernel/debug/mmc1/mmc1\:0001/ext_csd
  [  173.634584] BUG: unable to handle kernel NULL pointer dereference at 
0050
  [  173.643356] IP: mmc_ext_csd_open+0x5e/0x170

A complication is that the debugfs_root may have already been removed, so
check for that too.

Fixes: 627c3ccfb46a ("mmc: debugfs: Move block debugfs into block module")
Signed-off-by: Adrian Hunter 
Reviewed-by: Linus Walleij 
Signed-off-by: Ulf Hansson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/mmc/core/block.c   |   44 +---
 drivers/mmc/core/debugfs.c |1 +
 2 files changed, 38 insertions(+), 7 deletions(-)

--- a/drivers/mmc/core/block.c
+++ b/drivers/mmc/core/block.c
@@ -119,6 +119,10 @@ struct mmc_blk_data {
struct device_attribute force_ro;
struct device_attribute power_ro_lock;
int area_type;
+
+   /* debugfs files (only in main mmc_blk_data) */
+   struct dentry *status_dentry;
+   struct dentry *ext_csd_dentry;
 };
 
 static DEFINE_MUTEX(open_lock);
@@ -2417,7 +2421,7 @@ static const struct file_operations mmc_
.llseek = default_llseek,
 };
 
-static int mmc_blk_add_debugfs(struct mmc_card *card)
+static int mmc_blk_add_debugfs(struct mmc_card *card, struct mmc_blk_data *md)
 {
struct dentry *root;
 
@@ -2427,28 +2431,53 @@ static int mmc_blk_add_debugfs(struct mm
root = card->debugfs_root;
 
if (mmc_card_mmc(card) || mmc_card_sd(card)) {
-   if (!debugfs_create_file("status", S_IRUSR, root, card,
-&mmc_dbg_card_status_fops))
+   md->status_dentry =
+   debugfs_create_file("status", S_IRUSR, root, card,
+   &mmc_dbg_card_status_fops);
+   if (!md->status_dentry)
return -EIO;
}
 
if (mmc_card_mmc(card)) {
-   if (!debugfs_create_file("ext_csd", S_IRUSR, root, card,
-&mmc_dbg_ext_csd_fops))
+   md->ext_csd_dentry =
+   debugfs_create_file("ext_csd", S_IRUSR, root, card,
+   &mmc_dbg_ext_csd_fops);
+   if (!md->ext_csd_dentry)
return -EIO;
}
 
return 0;
 }
 
+static void mmc_blk_remove_debugfs(struct mmc_card *card,
+  struct mmc_blk_data *md)
+{
+   if (!card->debugfs_root)
+   return;
+
+   if (!IS_ERR_OR_NULL(md->status_dentry)) {
+   debugfs_remove(md->status_dentry);
+   md->status_dentry = NULL;
+   }
+
+   if (!IS_ERR_OR_NULL(md->ext_csd_dentry)) {
+   debugfs_remove(md->ext_csd_dentry);
+   md->ext_csd_dentry = NULL;
+   }
+}
 
 #else
 
-static int mmc_blk_add_debugfs(struct mmc_card *card)
+static int mmc_blk_add_debugfs(struct mmc_card *card, struct mmc_blk_data *md)
 {
return 0;
 }
 
+static void mmc_blk_remove_debugfs(struct mmc_card *card,
+  struct mmc_blk_data *md)
+{
+}
+
 #endif /* CONFIG_DEBUG_FS */
 
 static int mmc_blk_probe(struct mmc_card *card)
@@ -2488,7 +2517,7 @@ static int mmc_blk_probe(struct mmc_card
}
 
/* Add two debugfs entries */
-   mmc_blk_add_debugfs(card);
+   mmc_blk_add_debugfs(card, md);
 
pm_runtime_set_autosuspend_delay(&card->dev, 3000);
pm_runtime_use_autosuspend(&card->dev);
@@ -2514,6 +2543,7 @@ static void mmc_blk_remove(struct mmc_ca
 {
struct mmc_blk_data *md = dev_get_drvdata(&card->dev);
 
+   mmc_blk_remove_debugfs(card, md);
mmc_blk_remove_parts(card, md);
pm_runtime_get_sync(&card->dev);
mmc_claim_host(card->host);
--- a/drivers/mmc/core/debugfs.c
+++ b/drivers/mmc/core/debugfs.c
@@ -314,4 +314,5 @@ err:
 void mmc_remove_card_debugfs(struct mmc_card *card)
 {
debugfs_remove_recursive(card->debugfs_root);
+   card->debugfs_root = NULL;
 }




[PATCH 4.14 50/95] eeprom: at24: fix reading from 24MAC402/24MAC602

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Heiner Kallweit 

commit 644a1f19c6c8393d0c4168a5adf79056da6822eb upstream.

Chip datasheet mentions that word addresses other than the actual
start position of the MAC delivers undefined results. So fix this.
Current implementation doesn't work due to this wrong offset.

Fixes: 0b813658c115 ("eeprom: at24: add support for at24mac series")
Signed-off-by: Heiner Kallweit 
Signed-off-by: Bartosz Golaszewski 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/misc/eeprom/at24.c |3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -365,7 +365,8 @@ static ssize_t at24_eeprom_read_mac(stru
memset(msg, 0, sizeof(msg));
msg[0].addr = client->addr;
msg[0].buf = addrbuf;
-   addrbuf[0] = 0x90 + offset;
+   /* EUI-48 starts from 0x9a, EUI-64 from 0x98 */
+   addrbuf[0] = 0xa0 - at24->chip.byte_len + offset;
msg[0].len = 1;
msg[1].addr = client->addr;
msg[1].flags = I2C_M_RD;




[PATCH 4.14 51/95] eeprom: at24: correctly set the size for at24mac402

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Bartosz Golaszewski 

commit 5478e478eee3b096b8d998d4ed445da30da2dfbc upstream.

There's an ilog2() expansion in AT24_DEVICE_MAGIC() which rounds down
the actual size of EUI-48 byte array in at24mac402 eeproms to 4 from 6,
making it impossible to read it all.

Fix it by manually adjusting the value in probe().

This patch contains a temporary fix that is suitable for stable
branches. Eventually we'll probably remove the call to ilog2() while
converting the magic values to actual structs.

Fixes: 0b813658c115 ("eeprom: at24: add support for at24mac series")
Signed-off-by: Bartosz Golaszewski 
Reviewed-by: Andy Shevchenko 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/misc/eeprom/at24.c |   10 ++
 1 file changed, 10 insertions(+)

--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -632,6 +632,16 @@ static int at24_probe(struct i2c_client
dev_warn(&client->dev,
"page_size looks suspicious (no power of 2)!\n");
 
+   /*
+* REVISIT: the size of the EUI-48 byte array is 6 in at24mac402, while
+* the call to ilog2() in AT24_DEVICE_MAGIC() rounds it down to 4.
+*
+* Eventually we'll get rid of the magic values altoghether in favor of
+* real structs, but for now just manually set the right size.
+*/
+   if (chip.flags & AT24_FLAG_MAC && chip.byte_len == 4)
+   chip.byte_len = 6;
+
/* Use I2C operations unless we're stuck with SMBus extensions. */
if (!i2c_check_functionality(client->adapter, I2C_FUNC_I2C)) {
if (chip.flags & AT24_FLAG_ADDR16)




[PATCH 4.14 56/95] bcache: only permit to recovery read error when cache device is clean

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Coly Li 

commit d59b23795933678c9638fd20c942d2b4f3cd6185 upstream.

When bcache does read I/Os, for example in writeback or writethrough mode,
if a read request on cache device is failed, bcache will try to recovery
the request by reading from cached device. If the data on cached device is
not synced with cache device, then requester will get a stale data.

For critical storage system like database, providing stale data from
recovery may result an application level data corruption, which is
unacceptible.

With this patch, for a failed read request in writeback or writethrough
mode, recovery a recoverable read request only happens when cache device
is clean. That is to say, all data on cached device is up to update.

For other cache modes in bcache, read request will never hit
cached_dev_read_error(), they don't need this patch.

Please note, because cache mode can be switched arbitrarily in run time, a
writethrough mode might be switched from a writeback mode. Therefore
checking dc->has_data in writethrough mode still makes sense.

Changelog:
V4: Fix parens error pointed by Michael Lyle.
v3: By response from Kent Oversteet, he thinks recovering stale data is a
bug to fix, and option to permit it is unnecessary. So this version
the sysfs file is removed.
v2: rename sysfs entry from allow_stale_data_on_failure  to
allow_stale_data_on_failure, and fix the confusing commit log.
v1: initial patch posted.

[small change to patch comment spelling by mlyle]

Signed-off-by: Coly Li 
Signed-off-by: Michael Lyle 
Reported-by: Arne Wolf 
Reviewed-by: Michael Lyle 
Cc: Kent Overstreet 
Cc: Nix 
Cc: Kai Krakow 
Cc: Eric Wheeler 
Cc: Junhui Tang 
Signed-off-by: Jens Axboe 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/md/bcache/request.c |   10 +-
 1 file changed, 9 insertions(+), 1 deletion(-)

--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -698,8 +698,16 @@ static void cached_dev_read_error(struct
 {
struct search *s = container_of(cl, struct search, cl);
struct bio *bio = &s->bio.bio;
+   struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
 
-   if (s->recoverable) {
+   /*
+* If cache device is dirty (dc->has_dirty is non-zero), then
+* recovery a failed read request from cached device may get a
+* stale data back. So read failure recovery is only permitted
+* when cache device is clean.
+*/
+   if (s->recoverable &&
+   (dc && !atomic_read(&dc->has_dirty))) {
/* Retry from the backing device: */
trace_bcache_read_retry(s->orig_bio);
 




[PATCH 4.14 57/95] bcache: recover data from backing when data is clean

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Rui Hua 

commit e393aa2446150536929140739f09c6ecbcbea7f0 upstream.

When we send a read request and hit the clean data in cache device, there
is a situation called cache read race in bcache(see the commit in the tail
of cache_look_up(), the following explaination just copy from there):
The bucket we're reading from might be reused while our bio is in flight,
and we could then end up reading the wrong data. We guard against this
by checking (in bch_cache_read_endio()) if the pointer is stale again;
if so, we treat it as an error (s->iop.error = -EINTR) and reread from
the backing device (but we don't pass that error up anywhere)

It should be noted that cache read race happened under normal
circumstances, not the circumstance when SSD failed, it was counted
and shown in  /sys/fs/bcache/XXX/internal/cache_read_races.

Without this patch, when we use writeback mode, we will never reread from
the backing device when cache read race happened, until the whole cache
device is clean, because the condition
(s->recoverable && (dc && !atomic_read(&dc->has_dirty))) is false in
cached_dev_read_error(). In this situation, the s->iop.error(= -EINTR)
will be passed up, at last, user will receive -EINTR when it's bio end,
this is not suitable, and wield to up-application.

In this patch, we use s->read_dirty_data to judge whether the read
request hit dirty data in cache device, it is safe to reread data from
the backing device when the read request hit clean data. This can not
only handle cache read race, but also recover data when failed read
request from cache device.

[edited by mlyle to fix up whitespace, commit log title, comment
spelling]

Fixes: d59b23795933 ("bcache: only permit to recovery read error when cache 
device is clean")
Signed-off-by: Hua Rui 
Reviewed-by: Michael Lyle 
Reviewed-by: Coly Li 
Signed-off-by: Michael Lyle 
Signed-off-by: Jens Axboe 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/md/bcache/request.c |   13 ++---
 1 file changed, 6 insertions(+), 7 deletions(-)

--- a/drivers/md/bcache/request.c
+++ b/drivers/md/bcache/request.c
@@ -698,16 +698,15 @@ static void cached_dev_read_error(struct
 {
struct search *s = container_of(cl, struct search, cl);
struct bio *bio = &s->bio.bio;
-   struct cached_dev *dc = container_of(s->d, struct cached_dev, disk);
 
/*
-* If cache device is dirty (dc->has_dirty is non-zero), then
-* recovery a failed read request from cached device may get a
-* stale data back. So read failure recovery is only permitted
-* when cache device is clean.
+* If read request hit dirty data (s->read_dirty_data is true),
+* then recovery a failed read request from cached device may
+* get a stale data back. So read failure recovery is only
+* permitted when read request hit clean data in cache device,
+* or when cache read race happened.
 */
-   if (s->recoverable &&
-   (dc && !atomic_read(&dc->has_dirty))) {
+   if (s->recoverable && !s->read_dirty_data) {
/* Retry from the backing device: */
trace_bcache_read_retry(s->orig_bio);
 




[PATCH 4.14 55/95] bcache: Fix building error on MIPS

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Huacai Chen 

commit cf33c1ee5254c6a430bc1538232b49c3ea13e613 upstream.

This patch try to fix the building error on MIPS. The reason is MIPS
has already defined the PTR macro, which conflicts with the PTR macro
in include/uapi/linux/bcache.h.

[fixed by mlyle: corrected a line-length issue]

Signed-off-by: Huacai Chen 
Reviewed-by: Michael Lyle 
Signed-off-by: Michael Lyle 
Signed-off-by: Jens Axboe 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/md/bcache/alloc.c   |2 +-
 drivers/md/bcache/extents.c |2 +-
 drivers/md/bcache/journal.c |2 +-
 include/uapi/linux/bcache.h |2 +-
 4 files changed, 4 insertions(+), 4 deletions(-)

--- a/drivers/md/bcache/alloc.c
+++ b/drivers/md/bcache/alloc.c
@@ -480,7 +480,7 @@ int __bch_bucket_alloc_set(struct cache_
if (b == -1)
goto err;
 
-   k->ptr[i] = PTR(ca->buckets[b].gen,
+   k->ptr[i] = MAKE_PTR(ca->buckets[b].gen,
bucket_to_sector(c, b),
ca->sb.nr_this_dev);
 
--- a/drivers/md/bcache/extents.c
+++ b/drivers/md/bcache/extents.c
@@ -585,7 +585,7 @@ static bool bch_extent_merge(struct btre
return false;
 
for (i = 0; i < KEY_PTRS(l); i++)
-   if (l->ptr[i] + PTR(0, KEY_SIZE(l), 0) != r->ptr[i] ||
+   if (l->ptr[i] + MAKE_PTR(0, KEY_SIZE(l), 0) != r->ptr[i] ||
PTR_BUCKET_NR(b->c, l, i) != PTR_BUCKET_NR(b->c, r, i))
return false;
 
--- a/drivers/md/bcache/journal.c
+++ b/drivers/md/bcache/journal.c
@@ -507,7 +507,7 @@ static void journal_reclaim(struct cache
continue;
 
ja->cur_idx = next;
-   k->ptr[n++] = PTR(0,
+   k->ptr[n++] = MAKE_PTR(0,
  bucket_to_sector(c, ca->sb.d[ja->cur_idx]),
  ca->sb.nr_this_dev);
}
--- a/include/uapi/linux/bcache.h
+++ b/include/uapi/linux/bcache.h
@@ -91,7 +91,7 @@ PTR_FIELD(PTR_GEN,0,  8)
 
 #define PTR_CHECK_DEV  ((1 << PTR_DEV_BITS) - 1)
 
-#define PTR(gen, offset, dev)  \
+#define MAKE_PTR(gen, offset, dev) \
__u64) dev) << 51) | ((__u64) offset) << 8 | gen)
 
 /* Bkey utility code */




[PATCH 4.14 59/95] nvme-pci: add quirk for delay before CHK RDY for WDC SN200

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Jeff Lien 

commit 8c97eeccf0ad8783c057830119467b877bdfced7 upstream.

And increase the existing delay to cover this device as well.

Signed-off-by: Jeff Lien 
Signed-off-by: Christoph Hellwig 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/nvme/host/nvme.h |2 +-
 drivers/nvme/host/pci.c  |2 ++
 2 files changed, 3 insertions(+), 1 deletion(-)

--- a/drivers/nvme/host/nvme.h
+++ b/drivers/nvme/host/nvme.h
@@ -108,7 +108,7 @@ static inline struct nvme_request *nvme_
  * NVME_QUIRK_DELAY_BEFORE_CHK_RDY quirk enabled. The value (in ms) was
  * found empirically.
  */
-#define NVME_QUIRK_DELAY_AMOUNT2000
+#define NVME_QUIRK_DELAY_AMOUNT2300
 
 enum nvme_ctrl_state {
NVME_CTRL_NEW,
--- a/drivers/nvme/host/pci.c
+++ b/drivers/nvme/host/pci.c
@@ -2519,6 +2519,8 @@ static const struct pci_device_id nvme_i
.driver_data = NVME_QUIRK_IDENTIFY_CNS, },
{ PCI_DEVICE(0x1c58, 0x0003),   /* HGST adapter */
.driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
+   { PCI_DEVICE(0x1c58, 0x0023),   /* WDC SN200 adapter */
+   .driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
{ PCI_DEVICE(0x1c5f, 0x0540),   /* Memblaze Pblaze4 adapter */
.driver_data = NVME_QUIRK_DELAY_BEFORE_CHK_RDY, },
{ PCI_DEVICE(0x144d, 0xa821),   /* Samsung PM1725 */




[PATCH 4.14 63/95] drm/amdgpu: correct reference clock value on vega10

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Ken Wang 

commit 76d6172b6fab16455af4b67bb18a3f66011592f8 upstream.

Old value from bringup was wrong.

Signed-off-by: Ken Wang 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/amd/amdgpu/soc15.c |5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -279,10 +279,7 @@ static void soc15_init_golden_registers(
 }
 static u32 soc15_get_xclk(struct amdgpu_device *adev)
 {
-   if (adev->asic_type == CHIP_VEGA10)
-   return adev->clock.spll.reference_freq/4;
-   else
-   return adev->clock.spll.reference_freq;
+   return adev->clock.spll.reference_freq;
 }
 
 




[PATCH 4.14 33/95] arm64: module-plts: factor out PLT generation code for ftrace

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Ard Biesheuvel 

commit 7e8b9c1d2e2f5f45db7d40b50d14f606097c25de upstream.

To allow the ftrace trampoline code to reuse the PLT entry routines,
factor it out and move it into asm/module.h.

Signed-off-by: Ard Biesheuvel 
Signed-off-by: Will Deacon 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/arm64/include/asm/module.h |   44 
 arch/arm64/kernel/module-plts.c |   38 +-
 2 files changed, 46 insertions(+), 36 deletions(-)

--- a/arch/arm64/include/asm/module.h
+++ b/arch/arm64/include/asm/module.h
@@ -45,4 +45,48 @@ extern u64 module_alloc_base;
 #define module_alloc_base  ((u64)_etext - MODULES_VSIZE)
 #endif
 
+struct plt_entry {
+   /*
+* A program that conforms to the AArch64 Procedure Call Standard
+* (AAPCS64) must assume that a veneer that alters IP0 (x16) and/or
+* IP1 (x17) may be inserted at any branch instruction that is
+* exposed to a relocation that supports long branches. Since that
+* is exactly what we are dealing with here, we are free to use x16
+* as a scratch register in the PLT veneers.
+*/
+   __le32  mov0;   /* movn x16, #0x*/
+   __le32  mov1;   /* movk x16, #0x, lsl #16   */
+   __le32  mov2;   /* movk x16, #0x, lsl #32   */
+   __le32  br; /* br   x16 */
+};
+
+static inline struct plt_entry get_plt_entry(u64 val)
+{
+   /*
+* MOVK/MOVN/MOVZ opcode:
+* ++++---+-+-+
+* | sf[31] | opc[30:29] | 100101 | hw[22:21] | imm16[20:5] | Rd[4:0] |
+* ++++---+-+-+
+*
+* Rd := 0x10 (x16)
+* hw := 0b00 (no shift), 0b01 (lsl #16), 0b10 (lsl #32)
+* opc:= 0b11 (MOVK), 0b00 (MOVN), 0b10 (MOVZ)
+* sf := 1 (64-bit variant)
+*/
+   return (struct plt_entry){
+   cpu_to_le32(0x92800010 | (((~val  ) & 0x)) << 5),
+   cpu_to_le32(0xf2a00010 | ((( val >> 16) & 0x)) << 5),
+   cpu_to_le32(0xf2c00010 | ((( val >> 32) & 0x)) << 5),
+   cpu_to_le32(0xd61f0200)
+   };
+}
+
+static inline bool plt_entries_equal(const struct plt_entry *a,
+const struct plt_entry *b)
+{
+   return a->mov0 == b->mov0 &&
+  a->mov1 == b->mov1 &&
+  a->mov2 == b->mov2;
+}
+
 #endif /* __ASM_MODULE_H */
--- a/arch/arm64/kernel/module-plts.c
+++ b/arch/arm64/kernel/module-plts.c
@@ -11,21 +11,6 @@
 #include 
 #include 
 
-struct plt_entry {
-   /*
-* A program that conforms to the AArch64 Procedure Call Standard
-* (AAPCS64) must assume that a veneer that alters IP0 (x16) and/or
-* IP1 (x17) may be inserted at any branch instruction that is
-* exposed to a relocation that supports long branches. Since that
-* is exactly what we are dealing with here, we are free to use x16
-* as a scratch register in the PLT veneers.
-*/
-   __le32  mov0;   /* movn x16, #0x*/
-   __le32  mov1;   /* movk x16, #0x, lsl #16   */
-   __le32  mov2;   /* movk x16, #0x, lsl #32   */
-   __le32  br; /* br   x16 */
-};
-
 static bool in_init(const struct module *mod, void *loc)
 {
return (u64)loc - (u64)mod->init_layout.base < mod->init_layout.size;
@@ -40,33 +25,14 @@ u64 module_emit_plt_entry(struct module
int i = pltsec->plt_num_entries;
u64 val = sym->st_value + rela->r_addend;
 
-   /*
-* MOVK/MOVN/MOVZ opcode:
-* ++++---+-+-+
-* | sf[31] | opc[30:29] | 100101 | hw[22:21] | imm16[20:5] | Rd[4:0] |
-* ++++---+-+-+
-*
-* Rd := 0x10 (x16)
-* hw := 0b00 (no shift), 0b01 (lsl #16), 0b10 (lsl #32)
-* opc:= 0b11 (MOVK), 0b00 (MOVN), 0b10 (MOVZ)
-* sf := 1 (64-bit variant)
-*/
-   plt[i] = (struct plt_entry){
-   cpu_to_le32(0x92800010 | (((~val  ) & 0x)) << 5),
-   cpu_to_le32(0xf2a00010 | ((( val >> 16) & 0x)) << 5),
-   cpu_to_le32(0xf2c00010 | ((( val >> 32) & 0x)) << 5),
-   cpu_to_le32(0xd61f0200)
-   };
+   plt[i] = get_plt_entry(val);
 
/*
 * Check if the entry we just created is a duplicate. Given that the
 * relocations are sorted, this will be the last entry we allocated.
 * (if one exists).
 */
-   if (i > 0 &&
-   plt[i].mov0 == plt[i - 1].mov0 &&
-   plt[i].mo

[PATCH 4.14 66/95] drm/amdgpu: Remove check which is not valid for certain VBIOS

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Ken Wang 

commit ab6613b7eaefe85dadfc86025e901c55d71c0379 upstream.

Fixes vbios fetching on certain headless boards.

Signed-off-by: Ken Wang 
Acked-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c |6 --
 1 file changed, 6 deletions(-)

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_bios.c
@@ -59,12 +59,6 @@ static bool check_atom_bios(uint8_t *bio
return false;
}
 
-   tmp = bios[0x18] | (bios[0x19] << 8);
-   if (bios[tmp + 0x14] != 0x0) {
-   DRM_INFO("Not an x86 BIOS ROM\n");
-   return false;
-   }
-
bios_header_start = bios[0x48] | (bios[0x49] << 8);
if (!bios_header_start) {
DRM_INFO("Can't locate bios header\n");




[PATCH 4.14 76/95] drm/hisilicon: Ensure LDI regs are properly configured.

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Griffin 

commit a2f042430784d86eb2b7a6d2a869f552da30edba upstream.

This patch fixes the following soft lockup:
  BUG: soft lockup - CPU#0 stuck for 23s! [weston:307]

On weston idle-timeout the IP is powered down and reset
asserted. On weston resume we get a massive vblank
IRQ storm due to the LDI registers having lost some state.

This state loss is caused by ade_crtc_atomic_begin() not
calling ade_ldi_set_mode(). With this patch applied
resuming from Weston idle-timeout works well.

Signed-off-by: Peter Griffin 
Tested-by: John Stultz 
Reviewed-by: Xinliang Liu 
Signed-off-by: Xinliang Liu 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
+++ b/drivers/gpu/drm/hisilicon/kirin/kirin_drm_ade.c
@@ -534,9 +534,12 @@ static void ade_crtc_atomic_begin(struct
 {
struct ade_crtc *acrtc = to_ade_crtc(crtc);
struct ade_hw_ctx *ctx = acrtc->ctx;
+   struct drm_display_mode *mode = &crtc->state->mode;
+   struct drm_display_mode *adj_mode = &crtc->state->adjusted_mode;
 
if (!ctx->power_on)
(void)ade_power_up(ctx);
+   ade_ldi_set_mode(acrtc, mode, adj_mode);
 }
 
 static void ade_crtc_atomic_flush(struct drm_crtc *crtc,




[PATCH 4.14 79/95] drm/fb_helper: Disable all crtcs when initial setup fails.

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Maarten Lankhorst 

commit 52dd06506e9bbc2a37b352df7dfc5468f8da21fd upstream.

Some drivers like i915 start with crtc's enabled, but with deferred
fbcon setup they were no longer disabled as part of fbdev setup.
Headless units could no longer enter pc3 state because the crtc was
still enabled.

Fix this by calling restore_fbdev_mode when we would have called
it otherwise once during initial fbdev setup.

Signed-off-by: Maarten Lankhorst 
Fixes: ca91a2758fce ("drm/fb-helper: Support deferred setup")
Reported-by: Thomas Voegtle 
Tested-by: Thomas Voegtle 
Reviewed-by: Daniel Vetter 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20171128111603.62757-1-maarten.lankho...@linux.intel.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/drm_fb_helper.c |4 
 1 file changed, 4 insertions(+)

--- a/drivers/gpu/drm/drm_fb_helper.c
+++ b/drivers/gpu/drm/drm_fb_helper.c
@@ -1809,6 +1809,10 @@ static int drm_fb_helper_single_fb_probe
 
if (crtc_count == 0 || sizes.fb_width == -1 || sizes.fb_height == -1) {
DRM_INFO("Cannot find any crtc or sizes\n");
+
+   /* First time: disable all crtc's.. */
+   if (!fb_helper->deferred_setup && 
!READ_ONCE(fb_helper->dev->master))
+   restore_fbdev_mode(fb_helper);
return -EAGAIN;
}
 




[PATCH 4.14 80/95] drm/fsl-dcu: Dont set connector DPMS property

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Laurent Pinchart 

commit daee54263c1202cbdab85c5e15ae30b417602efb upstream.

Since commit 4a97a3da420b ("drm: Don't update property values for atomic
drivers") atomic drivers must not update property values as properties
are read from the state instead. To catch remaining users, the
drm_object_property_set_value() function now throws a warning when
called by atomic drivers on non-immutable properties, and we hit that
warning when creating connectors.

The easy fix is to just remove the drm_object_property_set_value() as it
is used here to set the initial value of the connector's DPMS property
to OFF. The DPMS property applies on top of the connector's state crtc
pointer (initialized to NULL) that is the main connector on/off control,
and should thus default to ON.

Fixes: 4a97a3da420b ("drm: Don't update property values for atomic drivers")
Signed-off-by: Laurent Pinchart 
Signed-off-by: Stefan Agner 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c |5 -
 1 file changed, 5 deletions(-)

--- a/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
+++ b/drivers/gpu/drm/fsl-dcu/fsl_dcu_drm_rgb.c
@@ -102,7 +102,6 @@ static int fsl_dcu_attach_panel(struct f
 {
struct drm_encoder *encoder = &fsl_dev->encoder;
struct drm_connector *connector = &fsl_dev->connector.base;
-   struct drm_mode_config *mode_config = &fsl_dev->drm->mode_config;
int ret;
 
fsl_dev->connector.encoder = encoder;
@@ -122,10 +121,6 @@ static int fsl_dcu_attach_panel(struct f
if (ret < 0)
goto err_sysfs;
 
-   drm_object_property_set_value(&connector->base,
- mode_config->dpms_property,
- DRM_MODE_DPMS_OFF);
-
ret = drm_panel_attach(panel, connector);
if (ret) {
dev_err(fsl_dev->dev, "failed to attach panel\n");




[PATCH 4.14 86/95] IB/hfi1: Do not warn on lid conversions for OPA

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Don Hiatt 

commit 4988be5813ff2afdc0d8bfa315ef34a577d3efbf upstream.

On OPA devices opa_local_smp_check will receive 32Bit LIDs when the LID
is Extended. In such cases, it is okay to lose the upper 16 bits of the
LID as this information is obtained elsewhere. Do not issue a warning
when calling ib_lid_cpu16() in this case by masking out the upper 16Bits.

[75920.148985] [ cut here ]
[75920.154651] WARNING: CPU: 0 PID: 1718 at ./include/rdma/ib_verbs.h:3788 
hfi1_process_mad+0x1c1f/0x1c80 [hfi1]
[75920.166192] Modules linked in: ib_ipoib hfi1(E) rdmavt(E) rdma_ucm(E) 
ib_ucm(E) rdma_cm(E) ib_cm(E) iw_cm(E) ib_umad(E) ib_uverbs(E) ib_core(E) 
libiscsi scsi_transport_iscsi dm_mirror dm_region_hash dm_log dm_mod dax 
x86_pkg_temp_thermal intel_powerclamp coretemp kvm irqbypass crct10dif_pclmul 
crc32_pclmul ghash_clmulni_intel pcbc aesni_intel mei_me ipmi_si iTCO_wdt 
iTCO_vendor_support crypto_simd ipmi_devintf pcspkr mei sg i2c_i801 glue_helper 
lpc_ich shpchp ioatdma mfd_core wmi ipmi_msghandler cryptd acpi_power_meter 
acpi_pad nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c 
sd_mod mgag200 drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm 
drm igb ptp ahci libahci pps_core crc32c_intel libata dca i2c_algo_bit i2c_core 
[last unloaded: ib_core]
[75920.246331] CPU: 0 PID: 1718 Comm: kworker/0:1H Tainted: GW I E   
4.13.0-rc7+ #1
[75920.255907] Hardware name: Intel Corporation S2600WT2/S2600WT2, BIOS 
SE5C610.86B.01.01.0008.021120151325 02/11/2015
[75920.268158] Workqueue: ib-comp-wq ib_cq_poll_work [ib_core]
[75920.274934] task: 88084a718000 task.stack: c9000a424000
[75920.282123] RIP: 0010:hfi1_process_mad+0x1c1f/0x1c80 [hfi1]
[75920.21] RSP: 0018:c9000a427c38 EFLAGS: 00010206
[75920.295265] RAX: 00010001 RBX: 8808361420e8 RCX: 880837811d80
[75920.303784] RDX: 0002 RSI: 7fff RDI: 880837811d80
[75920.312302] RBP: c9000a427d38 R08:  R09: 8808361420e8
[75920.320819] R10: 88083841f0e8 R11: c9000a427da8 R12: 0001
[75920.329335] R13: 88083781 R14:  R15: 88084f1a4800
[75920.337849] FS:  () GS:88085f40() 
knlGS:
[75920.347450] CS:  0010 DS:  ES:  CR0: 80050033
[75920.354405] CR2: 7f9e4b3d9000 CR3: 01c09000 CR4: 001406f0
[75920.362947] Call Trace:
[75920.366257]  ? ib_mad_recv_done+0x258/0x9b0 [ib_core]
[75920.372457]  ? ib_mad_recv_done+0x258/0x9b0 [ib_core]
[75920.378652]  ? __kmalloc+0x1df/0x210
[75920.383229]  ib_mad_recv_done+0x305/0x9b0 [ib_core]
[75920.389270]  __ib_process_cq+0x5d/0xb0 [ib_core]
[75920.395032]  ib_cq_poll_work+0x20/0x60 [ib_core]
[75920.400777]  process_one_work+0x149/0x360
[75920.405836]  worker_thread+0x4d/0x3c0
[75920.410505]  kthread+0x109/0x140
[75920.414681]  ? rescuer_thread+0x380/0x380
[75920.419731]  ? kthread_park+0x60/0x60
[75920.424406]  ret_from_fork+0x25/0x30
[75920.428972] Code: 4c 89 9d 58 ff ff ff 49 89 45 00 66 b8 00 02 49 89 45 08 
e8 44 27 89 e0 4c 8b 9d 58 ff ff ff e9 d8 f6 ff ff 0f ff e9 55 e7 ff ff <0f> ff 
e9 3b e5 ff ff 0f ff 0f 1f 84 00 00 00 00 00 e9 4b e9 ff
[75921.451269] ---[ end trace cf26df27c9597265 ]---

Fixes: 62ede7779904 ("Add OPA extended LID support")
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Don Hiatt 
Signed-off-by: Dennis Dalessandro 
Reviewed-by: Leon Romanovsky 
Signed-off-by: Doug Ledford 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/infiniband/hw/hfi1/mad.c |7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

--- a/drivers/infiniband/hw/hfi1/mad.c
+++ b/drivers/infiniband/hw/hfi1/mad.c
@@ -4293,7 +4293,6 @@ static int opa_local_smp_check(struct hf
   const struct ib_wc *in_wc)
 {
struct hfi1_pportdata *ppd = ppd_from_ibp(ibp);
-   u16 slid = ib_lid_cpu16(in_wc->slid);
u16 pkey;
 
if (in_wc->pkey_index >= ARRAY_SIZE(ppd->pkeys))
@@ -4320,7 +4319,11 @@ static int opa_local_smp_check(struct hf
 */
if (pkey == LIM_MGMT_P_KEY || pkey == FULL_MGMT_P_KEY)
return 0;
-   ingress_pkey_table_fail(ppd, pkey, slid);
+   /*
+* On OPA devices it is okay to lose the upper 16 bits of LID as this
+* information is obtained elsewhere. Mask off the upper 16 bits.
+*/
+   ingress_pkey_table_fail(ppd, pkey, ib_lid_cpu16(0x & in_wc->slid));
return 1;
 }
 




[PATCH 4.14 88/95] md: forbid a RAID5 from having both a bitmap and a journal.

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: NeilBrown 

commit 230b55fa8d64007339319539f8f8e68114d08529 upstream.

Having both a bitmap and a journal is pointless.
Attempting to do so can corrupt the bitmap if the journal
replay happens before the bitmap is initialized.
Rather than try to avoid this corruption, simply
refuse to allow arrays with both a bitmap and a journal.
So:
 - if raid5_run sees both are present, fail.
 - if adding a bitmap finds a journal is present, fail
 - if adding a journal finds a bitmap is present, fail.

Signed-off-by: NeilBrown 
Tested-by: Joshua Kinard 
Acked-by: Joshua Kinard 
Signed-off-by: Shaohua Li 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/md/bitmap.c |6 ++
 drivers/md/md.c |2 +-
 drivers/md/raid5.c  |7 +++
 3 files changed, 14 insertions(+), 1 deletion(-)

--- a/drivers/md/bitmap.c
+++ b/drivers/md/bitmap.c
@@ -1816,6 +1816,12 @@ struct bitmap *bitmap_create(struct mdde
 
BUG_ON(file && mddev->bitmap_info.offset);
 
+   if (test_bit(MD_HAS_JOURNAL, &mddev->flags)) {
+   pr_notice("md/raid:%s: array with journal cannot have bitmap\n",
+ mdname(mddev));
+   return ERR_PTR(-EBUSY);
+   }
+
bitmap = kzalloc(sizeof(*bitmap), GFP_KERNEL);
if (!bitmap)
return ERR_PTR(-ENOMEM);
--- a/drivers/md/md.c
+++ b/drivers/md/md.c
@@ -6362,7 +6362,7 @@ static int add_new_disk(struct mddev *md
break;
}
}
-   if (has_journal) {
+   if (has_journal || mddev->bitmap) {
export_rdev(rdev);
return -EBUSY;
}
--- a/drivers/md/raid5.c
+++ b/drivers/md/raid5.c
@@ -7156,6 +7156,13 @@ static int raid5_run(struct mddev *mddev
min_offset_diff = diff;
}
 
+   if ((test_bit(MD_HAS_JOURNAL, &mddev->flags) || journal_dev) &&
+   (mddev->bitmap_info.offset || mddev->bitmap_info.file)) {
+   pr_notice("md/raid:%s: array cannot have both journal and 
bitmap\n",
+ mdname(mddev));
+   return -EINVAL;
+   }
+
if (mddev->reshape_position != MaxSector) {
/* Check that we can continue the reshape.
 * Difficulties arise if the stripe we would write to




[PATCH 4.14 90/95] drm/i915: Re-register PMIC bus access notifier on runtime resume

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Hans de Goede 

commit 294cf1af8cf2eb0d1eced377fdfb9a2d3f0e8b42 upstream.

intel_uncore_suspend() unregisters the uncore code's PMIC bus access
notifier and gets called on both normal and runtime suspend.

intel_uncore_resume_early() re-registers the notifier, but only on
normal resume. Add a new intel_uncore_runtime_resume() function which
only re-registers the notifier and call that on runtime resume.

Reported-by: Imre Deak 
Reviewed-by: Imre Deak 
Signed-off-by: Hans de Goede 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20171114135518.15981-2-hdego...@redhat.com
(cherry picked from commit bedf4d79c3654921839b62246b0965ddb308b201)
Signed-off-by: Jani Nikula 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/i915/i915_drv.c |2 ++
 drivers/gpu/drm/i915/intel_uncore.c |6 ++
 drivers/gpu/drm/i915/intel_uncore.h |1 +
 3 files changed, 9 insertions(+)

--- a/drivers/gpu/drm/i915/i915_drv.c
+++ b/drivers/gpu/drm/i915/i915_drv.c
@@ -2591,6 +2591,8 @@ static int intel_runtime_resume(struct d
ret = vlv_resume_prepare(dev_priv, true);
}
 
+   intel_uncore_runtime_resume(dev_priv);
+
/*
 * No point of rolling back things in case of an error, as the best
 * we can do is to hope that things will still work (and disable RPM).
--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -434,6 +434,12 @@ void intel_uncore_resume_early(struct dr
i915_check_and_clear_faults(dev_priv);
 }
 
+void intel_uncore_runtime_resume(struct drm_i915_private *dev_priv)
+{
+   iosf_mbi_register_pmic_bus_access_notifier(
+   &dev_priv->uncore.pmic_bus_access_nb);
+}
+
 void intel_uncore_sanitize(struct drm_i915_private *dev_priv)
 {
i915.enable_rc6 = sanitize_rc6_option(dev_priv, i915.enable_rc6);
--- a/drivers/gpu/drm/i915/intel_uncore.h
+++ b/drivers/gpu/drm/i915/intel_uncore.h
@@ -121,6 +121,7 @@ bool intel_uncore_arm_unclaimed_mmio_det
 void intel_uncore_fini(struct drm_i915_private *dev_priv);
 void intel_uncore_suspend(struct drm_i915_private *dev_priv);
 void intel_uncore_resume_early(struct drm_i915_private *dev_priv);
+void intel_uncore_runtime_resume(struct drm_i915_private *dev_priv);
 
 u64 intel_uncore_edram_size(struct drm_i915_private *dev_priv);
 void assert_forcewakes_inactive(struct drm_i915_private *dev_priv);




[PATCH 4.14 95/95] Revert "x86/entry/64: Add missing irqflags tracing to native_load_gs_index()"

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

This reverts commit f9a64e23a9da528e7d8aa1bd2c7bb92be4ebb724 which is
commit 0d794d0d018f23fb09c50f6ae26868bd6ae343d6 upstream.

Andy writes:

I think the thing to do is to revert the patch from -stable.
The bug it fixes is very minor, and the regression is that it
made a pre-existing bug in some nearly-undebuggable core resume
code much easier to hit.  I don't feel comfortable with a
backport of the latter fix until it has a good long soak in
Linus' tree.

Reported-by: Andy Lutomirski 
Cc: Borislav Petkov 
Cc: Brian Gerst 
Cc: Dave Hansen 
Cc: Josh Poimboeuf 
Cc: Linus Torvalds 
Cc: Peter Zijlstra 
Cc: Thomas Gleixner 
Cc: Ingo Molnar 
Signed-off-by: Greg Kroah-Hartman 
---
 arch/x86/entry/entry_64.S |   10 ++
 1 file changed, 2 insertions(+), 8 deletions(-)

--- a/arch/x86/entry/entry_64.S
+++ b/arch/x86/entry/entry_64.S
@@ -51,19 +51,15 @@ ENTRY(native_usergs_sysret64)
 END(native_usergs_sysret64)
 #endif /* CONFIG_PARAVIRT */
 
-.macro TRACE_IRQS_FLAGS flags:req
+.macro TRACE_IRQS_IRETQ
 #ifdef CONFIG_TRACE_IRQFLAGS
-   bt  $9, \flags  /* interrupts off? */
+   bt  $9, EFLAGS(%rsp)/* interrupts off? */
jnc 1f
TRACE_IRQS_ON
 1:
 #endif
 .endm
 
-.macro TRACE_IRQS_IRETQ
-   TRACE_IRQS_FLAGS EFLAGS(%rsp)
-.endm
-
 /*
  * When dynamic function tracer is enabled it will add a breakpoint
  * to all locations that it is about to modify, sync CPUs, update
@@ -927,13 +923,11 @@ ENTRY(native_load_gs_index)
FRAME_BEGIN
pushfq
DISABLE_INTERRUPTS(CLBR_ANY & ~CLBR_RDI)
-   TRACE_IRQS_OFF
SWAPGS
 .Lgs_change:
movl%edi, %gs
 2: ALTERNATIVE "", "mfence", X86_BUG_SWAPGS_FENCE
SWAPGS
-   TRACE_IRQS_FLAGS (%rsp)
popfq
FRAME_END
ret




[PATCH 4.14 92/95] drm/i915/gvt: Correct ADDR_4K/2M/1G_MASK definition

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Xiong Zhang 

commit b721b65af4eb46df6a1d9e34b14003225e403565 upstream.

For ADDR_4K_MASK, bit[45..12] should be 1, all other bits
should be 0. The current definition wrongly set bit[46] as 1
also. This path fixes this.

v2: Add commit message, fixes and cc stable.(Zhenyu)

Fixes: 2707e4446688("drm/i915/gvt: vGPU graphics memory virtualization")
Signed-off-by: Xiong Zhang 
Signed-off-by: Zhenyu Wang 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/i915/gvt/gtt.c |6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

--- a/drivers/gpu/drm/i915/gvt/gtt.c
+++ b/drivers/gpu/drm/i915/gvt/gtt.c
@@ -311,9 +311,9 @@ static inline int gtt_set_entry64(void *
 
 #define GTT_HAW 46
 
-#define ADDR_1G_MASK (((1UL << (GTT_HAW - 30 + 1)) - 1) << 30)
-#define ADDR_2M_MASK (((1UL << (GTT_HAW - 21 + 1)) - 1) << 21)
-#define ADDR_4K_MASK (((1UL << (GTT_HAW - 12 + 1)) - 1) << 12)
+#define ADDR_1G_MASK (((1UL << (GTT_HAW - 30)) - 1) << 30)
+#define ADDR_2M_MASK (((1UL << (GTT_HAW - 21)) - 1) << 21)
+#define ADDR_4K_MASK (((1UL << (GTT_HAW - 12)) - 1) << 12)
 
 static unsigned long gen8_gtt_get_pfn(struct intel_gvt_gtt_entry *e)
 {




[PATCH 4.14 73/95] drm/tilcdc: Precalculate total frametime in tilcdc_crtc_set_mode()

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Jyri Sarha 

commit ce99f7206c9105851d97202ed08c058af6f11ac4 upstream.

We need the total frame refresh time to check if we are too close to
vertical sync when updating the two framebuffer DMA registers and risk
a collision. This new method is more accurate that the previous that
based on mode's vrefresh value, which itself is inaccurate or may not
even be initialized.

Reported-by: Kevin Hao 
Fixes: 11abbc9f39e0 ("drm/tilcdc: Set framebuffer DMA address to HW only if 
CRTC is enabled")
Signed-off-by: Jyri Sarha 
Reviewed-by: Tomi Valkeinen 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/tilcdc/tilcdc_crtc.c |   13 -
 1 file changed, 12 insertions(+), 1 deletion(-)

--- a/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
+++ b/drivers/gpu/drm/tilcdc/tilcdc_crtc.c
@@ -24,6 +24,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include "tilcdc_drv.h"
 #include "tilcdc_regs.h"
@@ -48,6 +49,7 @@ struct tilcdc_crtc {
unsigned int lcd_fck_rate;
 
ktime_t last_vblank;
+   unsigned int hvtotal_us;
 
struct drm_framebuffer *curr_fb;
struct drm_framebuffer *next_fb;
@@ -292,6 +294,12 @@ static void tilcdc_crtc_set_clk(struct d
LCDC_V2_CORE_CLK_EN);
 }
 
+uint tilcdc_mode_hvtotal(const struct drm_display_mode *mode)
+{
+   return (uint) div_u64(1000llu * mode->htotal * mode->vtotal,
+ mode->clock);
+}
+
 static void tilcdc_crtc_set_mode(struct drm_crtc *crtc)
 {
struct tilcdc_crtc *tilcdc_crtc = to_tilcdc_crtc(crtc);
@@ -459,6 +467,9 @@ static void tilcdc_crtc_set_mode(struct
drm_framebuffer_reference(fb);
 
crtc->hwmode = crtc->state->adjusted_mode;
+
+   tilcdc_crtc->hvtotal_us =
+   tilcdc_mode_hvtotal(&crtc->hwmode);
 }
 
 static void tilcdc_crtc_enable(struct drm_crtc *crtc)
@@ -648,7 +659,7 @@ int tilcdc_crtc_update_fb(struct drm_crt
spin_lock_irqsave(&tilcdc_crtc->irq_lock, flags);
 
next_vblank = ktime_add_us(tilcdc_crtc->last_vblank,
-  100 / crtc->hwmode.vrefresh);
+  tilcdc_crtc->hvtotal_us);
tdiff = ktime_to_us(ktime_sub(next_vblank, ktime_get()));
 
if (tdiff < TILCDC_VBLANK_SAFETY_THRESHOLD_US)




[PATCH 4.14 65/95] drm/amdgpu: Properly allocate VM invalidate eng v2

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: ozeng 

commit c5066129af4436ab0da8eefe4289774a5409706d upstream.

v1: Properly allocate TLB invalidation engine to avoid conflict.
v2: Added comments to codes

Signed-off-by: Oak Zeng 
Reviewed-by: Alex Deucher 
Acked-by: Christian Konig 
Signed-off-by: Alex Deucher 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c |   15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

--- a/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
+++ b/drivers/gpu/drm/amd/amdgpu/gmc_v9_0.c
@@ -395,7 +395,16 @@ static int gmc_v9_0_early_init(void *han
 static int gmc_v9_0_late_init(void *handle)
 {
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-   unsigned vm_inv_eng[AMDGPU_MAX_VMHUBS] = { 3, 3 };
+   /*
+* The latest engine allocation on gfx9 is:
+* Engine 0, 1: idle
+* Engine 2, 3: firmware
+* Engine 4~13: amdgpu ring, subject to change when ring number changes
+* Engine 14~15: idle
+* Engine 16: kfd tlb invalidation
+* Engine 17: Gart flushes
+*/
+   unsigned vm_inv_eng[AMDGPU_MAX_VMHUBS] = { 4, 4 };
unsigned i;
 
for(i = 0; i < adev->num_rings; ++i) {
@@ -408,9 +417,9 @@ static int gmc_v9_0_late_init(void *hand
 ring->funcs->vmhub);
}
 
-   /* Engine 17 is used for GART flushes */
+   /* Engine 16 is used for KFD and 17 for GART flushes */
for(i = 0; i < AMDGPU_MAX_VMHUBS; ++i)
-   BUG_ON(vm_inv_eng[i] > 17);
+   BUG_ON(vm_inv_eng[i] > 16);
 
return amdgpu_irq_get(adev, &adev->mc.vm_fault, 0);
 }




[PATCH 4.14 74/95] drm/radeon: fix atombios on big endian

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Roman Kapl 

commit 4f626a4ac8f57ddabf06d03870adab91e463217f upstream.

The function for byteswapping the data send to/from atombios was buggy for
num_bytes not divisible by four. The function must be aware of the fact
that after byte-swapping the u32 units, valid bytes might end up after the
num_bytes boundary.

This patch was tested on kernel 3.12 and allowed us to sucesfully use
DisplayPort on and Radeon SI card. Namely it fixed the link training and
EDID readout.

The function is patched both in radeon and amd drivers, since the functions
and the fixes are identical.

Signed-off-by: Roman Kapl 
Signed-off-by: Alex Deucher 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c |   38 ---
 drivers/gpu/drm/radeon/atombios_dp.c |   38 ---
 2 files changed, 36 insertions(+), 40 deletions(-)

--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_atombios.c
@@ -1766,34 +1766,32 @@ bool amdgpu_atombios_scratch_need_asic_i
return true;
 }
 
-/* Atom needs data in little endian format
- * so swap as appropriate when copying data to
- * or from atom. Note that atom operates on
- * dw units.
+/* Atom needs data in little endian format so swap as appropriate when copying
+ * data to or from atom. Note that atom operates on dw units.
+ *
+ * Use to_le=true when sending data to atom and provide at least
+ * ALIGN(num_bytes,4) bytes in the dst buffer.
+ *
+ * Use to_le=false when receiving data from atom and provide ALIGN(num_bytes,4)
+ * byes in the src buffer.
  */
 void amdgpu_atombios_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
 {
 #ifdef __BIG_ENDIAN
-   u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
-   u32 *dst32, *src32;
+   u32 src_tmp[5], dst_tmp[5];
int i;
+   u8 align_num_bytes = ALIGN(num_bytes, 4);
 
-   memcpy(src_tmp, src, num_bytes);
-   src32 = (u32 *)src_tmp;
-   dst32 = (u32 *)dst_tmp;
if (to_le) {
-   for (i = 0; i < ((num_bytes + 3) / 4); i++)
-   dst32[i] = cpu_to_le32(src32[i]);
-   memcpy(dst, dst_tmp, num_bytes);
+   memcpy(src_tmp, src, num_bytes);
+   for (i = 0; i < align_num_bytes / 4; i++)
+   dst_tmp[i] = cpu_to_le32(src_tmp[i]);
+   memcpy(dst, dst_tmp, align_num_bytes);
} else {
-   u8 dws = num_bytes & ~3;
-   for (i = 0; i < ((num_bytes + 3) / 4); i++)
-   dst32[i] = le32_to_cpu(src32[i]);
-   memcpy(dst, dst_tmp, dws);
-   if (num_bytes % 4) {
-   for (i = 0; i < (num_bytes % 4); i++)
-   dst[dws+i] = dst_tmp[dws+i];
-   }
+   memcpy(src_tmp, src, align_num_bytes);
+   for (i = 0; i < align_num_bytes / 4; i++)
+   dst_tmp[i] = le32_to_cpu(src_tmp[i]);
+   memcpy(dst, dst_tmp, num_bytes);
}
 #else
memcpy(dst, src, num_bytes);
--- a/drivers/gpu/drm/radeon/atombios_dp.c
+++ b/drivers/gpu/drm/radeon/atombios_dp.c
@@ -45,34 +45,32 @@ static char *pre_emph_names[] = {
 
 /* radeon AUX functions */
 
-/* Atom needs data in little endian format
- * so swap as appropriate when copying data to
- * or from atom. Note that atom operates on
- * dw units.
+/* Atom needs data in little endian format so swap as appropriate when copying
+ * data to or from atom. Note that atom operates on dw units.
+ *
+ * Use to_le=true when sending data to atom and provide at least
+ * ALIGN(num_bytes,4) bytes in the dst buffer.
+ *
+ * Use to_le=false when receiving data from atom and provide ALIGN(num_bytes,4)
+ * byes in the src buffer.
  */
 void radeon_atom_copy_swap(u8 *dst, u8 *src, u8 num_bytes, bool to_le)
 {
 #ifdef __BIG_ENDIAN
-   u8 src_tmp[20], dst_tmp[20]; /* used for byteswapping */
-   u32 *dst32, *src32;
+   u32 src_tmp[5], dst_tmp[5];
int i;
+   u8 align_num_bytes = ALIGN(num_bytes, 4);
 
-   memcpy(src_tmp, src, num_bytes);
-   src32 = (u32 *)src_tmp;
-   dst32 = (u32 *)dst_tmp;
if (to_le) {
-   for (i = 0; i < ((num_bytes + 3) / 4); i++)
-   dst32[i] = cpu_to_le32(src32[i]);
-   memcpy(dst, dst_tmp, num_bytes);
+   memcpy(src_tmp, src, num_bytes);
+   for (i = 0; i < align_num_bytes / 4; i++)
+   dst_tmp[i] = cpu_to_le32(src_tmp[i]);
+   memcpy(dst, dst_tmp, align_num_bytes);
} else {
-   u8 dws = num_bytes & ~3;
-   for (i = 0; i < ((num_bytes + 3) / 4); i++)
-   dst32[i] = le32_to_cpu(src32[i]);
-   memcpy(dst, dst_tmp, dws);
-   if (num_bytes % 4) {
-  

Re: [PATCH 0/4] Move DP phy switch to PHY driver

2017-12-04 Thread Doug Anderson
Hi,

On Sun, Dec 3, 2017 at 11:46 PM, Heiko Stübner  wrote:
> Hi Chris,
>
> Am Montag, 4. Dezember 2017, 10:47:08 CET schrieb Chris Zhong:
>> On 2017年12月02日 05:58, Heiko Stuebner wrote:
>> > Am Freitag, 1. Dezember 2017, 13:42:46 CET schrieb Doug Anderson:
>> >> Hi,
>> >>
>> >> On Wed, Nov 29, 2017 at 6:27 PM, Chris Zhong  wrote:
>> >>> Hi Doug
>> >>>
>> >>> Thank you for mentioning this patch.
>> >>>
>> >>> I think the focus of the discussion is: can we put the grf control bit
>> >>> to
>> >>> dts.
>> >>>
>> >>> The RK3399 has 2 Type-C phy, but only one DP controller, this
>> >>> "uphy_dp_sel"
>> >>>
>> >>> can help to switch these 2 phy. So I think this bit can be considered as
>> >>> a
>> >>> part of
>> >>>
>> >>> Type-C phy, these 2 phy have different bits, just similar to other bits
>> >>> (such as "pipe-status").
>> >>>
>> >>> Put them to DTS file might be a accepted practice.
>> >>
>> >> I guess the first step would be finding the person to make a decision.
>> >> Is that Heiko?  Olof?  Kishon?  Rob?.  As I see it there are a few
>> >> options:
>> >>
>> >> 1. Land this series as-is.  This makes the new bit work just like all
>> >> the other ones next to it.  If anyone happens to try to use an old
>> >> device tree on a new kernel they'll break.  Seems rather unlikely
>> >> given that the whole type C PHY is not really fully functional
>> >> upstream, but technically this is a no-no from a device tree
>> >> perspective.
>> >>
>> >> 2. Change the series to make this property optional.  If it's not
>> >> there then the code behaves like it always did.  This would address
>> >> the "compatibility" problem but likely wouldn't actually help any real
>> >> people, and it would be extra work.
>> >>
>> >> 3. Redo the driver to deprecate all the old offsets / bits and just
>> >> put the table in the driver, keyed off the compatible string and base
>> >> address if the IO memory.
>> >>
>> >>
>> >> I can't make this decision.  It's up to those folks who would be
>> >> landing the patch and I'd be happy with any of them.  What I'm less
>> >> happy with, however, is the indecision preventing forward progress.
>> >> We should pick one of the above things and land it.  My own personal
>> >> bias is #1: just land the series.  No real people will be hurt and
>> >> it's just adding another property that matches the ones next to it.
>> >
>> > I'd second that #1 . That whole type-c phy thingy never fully worked in
>> > the past (some for the never used dp output), so personally I don't have
>> > issues with going that route.
>> >
>> >>  From a long term perspective (AKA how I'd write the next driver like
>> >>
>> >> this) I personally lean towards to "tables in the driver, not in the
>> >> device tree" but quite honestly I'm happy to take whatever direction
>> >> the maintainers give.
>> >
>> > It looks like we're in agreement here :-) . GRF stuff should not leak into
>> > the devicetree, as it causes endless headaches later. But I guess we'll
>> > need to live with the ones that happened so far.
>>
>> So, the first step is: move all the private property of tcphy to
>> drivers/phy/rockchip/phy-rockchip-typec.c.
>> Second step: new a member: uphy-dp-sel.
>> In my mind, we should have discussed these properties before, and then I
>> moved them all into DTS.
>
> Actually, I was agreeing with Doug, that we probably don't need to rework the
> type-c phy driver. As most properties for it are in the devicetree right now
> we'll need to support them for backwards-compatiblity anyway.
>
> And yes, there probably was discussion over dts vs. driver-table when the
> type-c driver was introduced, but I either missed it or wasn't firm enough
> back then ;-) .
>
> Hence the "we'll need to live with it" for the type-c phy, but should not
> do similar things in future drivers.

So I guess now we're just waiting for some agreement from Kishon that
he's willing to land the PHY change?  Heiko: presumably you could
apply the DP change to drm-misc?  ...or is there some other process
needed there?

-Doug


[PATCH 4.14 91/95] drm/i915/fbdev: Serialise early hotplug events with async fbdev config

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Chris Wilson 

commit a45b30a6c5db631e2ba680304bd5edd0cd1f9643 upstream.

As both the hotplug event and fbdev configuration run asynchronously, it
is possible for them to run concurrently. If configuration fails, we were
freeing the fbdev causing a use-after-free in the hotplug event.

<7>[ 3069.935211] [drm:intel_fb_initial_config [i915]] Not using firmware 
configuration
<7>[ 3069.935225] [drm:drm_setup_crtcs] looking for cmdline mode on connector 77
<7>[ 3069.935229] [drm:drm_setup_crtcs] looking for preferred mode on connector 
77 0
<7>[ 3069.935233] [drm:drm_setup_crtcs] found mode 3200x1800
<7>[ 3069.935236] [drm:drm_setup_crtcs] picking CRTCs for 8192x8192 config
<7>[ 3069.935253] [drm:drm_setup_crtcs] desired mode 3200x1800 set on crtc 43 
(0,0)
<7>[ 3069.935323] [drm:intelfb_create [i915]] no BIOS fb, allocating a new one
<4>[ 3069.967737] general protection fault:  [#1] PREEMPT SMP
<0>[ 3069.977453] -
<4>[ 3069.977457] Modules linked in: i915(+) vgem snd_hda_codec_hdmi 
snd_hda_codec_realtek snd_hda_codec_generic x86_pkg_temp_thermal 
intel_powerclamp coretemp crct10dif_pclmul crc32_pclmul ghash_clmulni_intel 
snd_hda_codec snd_hwdep snd_hda_core snd_pcm r8169 mei_me mii prime_numbers mei 
i2c_hid pinctrl_geminilake pinctrl_intel [last unloaded: i915]
<4>[ 3069.977492] CPU: 1 PID: 15414 Comm: kworker/1:0 Tainted: G U  
4.14.0-CI-CI_DRM_3388+ #1
<4>[ 3069.977497] Hardware name: Intel Corp. Geminilake/GLK RVP1 DDR4 (05), 
BIOS GELKRVPA.X64.0062.B30.1708222146 08/22/2017
<4>[ 3069.977508] Workqueue: events output_poll_execute
<4>[ 3069.977512] task: 880177734e40 task.stack: c90001fe4000
<4>[ 3069.977519] RIP: 0010:__lock_acquire+0x109/0x1b60
<4>[ 3069.977523] RSP: 0018:c90001fe7bb0 EFLAGS: 00010002
<4>[ 3069.977526] RAX: 6b6b6b6b6b6b6b6b RBX: 0282 RCX: 

<4>[ 3069.977530] RDX:  RSI:  RDI: 
880170d4efd0
<4>[ 3069.977534] RBP: c90001fe7c70 R08: 0001 R09: 

<4>[ 3069.977538] R10:  R11: 81899609 R12: 
880170d4efd0
<4>[ 3069.977542] R13: 880177734e40 R14: 0001 R15: 

<4>[ 3069.977547] FS:  () GS:88017fc8() 
knlGS:
<4>[ 3069.977551] CS:  0010 DS:  ES:  CR0: 80050033
<4>[ 3069.977555] CR2: 7f7e8b7bcf04 CR3: 03e0f000 CR4: 
003406e0
<4>[ 3069.977559] Call Trace:
<4>[ 3069.977565]  ? mark_held_locks+0x64/0x90
<4>[ 3069.977571]  ? _raw_spin_unlock_irq+0x24/0x50
<4>[ 3069.977575]  ? _raw_spin_unlock_irq+0x24/0x50
<4>[ 3069.977579]  ? trace_hardirqs_on_caller+0xde/0x1c0
<4>[ 3069.977583]  ? _raw_spin_unlock_irq+0x2f/0x50
<4>[ 3069.977588]  ? finish_task_switch+0xa5/0x210
<4>[ 3069.977592]  ? lock_acquire+0xaf/0x200
<4>[ 3069.977596]  lock_acquire+0xaf/0x200
<4>[ 3069.977600]  ? __mutex_lock+0x5e9/0x9b0
<4>[ 3069.977604]  _raw_spin_lock+0x2a/0x40
<4>[ 3069.977608]  ? __mutex_lock+0x5e9/0x9b0
<4>[ 3069.977612]  __mutex_lock+0x5e9/0x9b0
<4>[ 3069.977616]  ? drm_fb_helper_hotplug_event.part.19+0x16/0xa0
<4>[ 3069.977621]  ? drm_fb_helper_hotplug_event.part.19+0x16/0xa0
<4>[ 3069.977625]  drm_fb_helper_hotplug_event.part.19+0x16/0xa0
<4>[ 3069.977630]  output_poll_execute+0x8d/0x180
<4>[ 3069.977635]  process_one_work+0x22e/0x660
<4>[ 3069.977640]  worker_thread+0x48/0x3a0
<4>[ 3069.977644]  ? _raw_spin_unlock_irqrestore+0x4c/0x60
<4>[ 3069.977649]  kthread+0x102/0x140
<4>[ 3069.977653]  ? process_one_work+0x660/0x660
<4>[ 3069.977657]  ? kthread_create_on_node+0x40/0x40
<4>[ 3069.977662]  ret_from_fork+0x27/0x40
<4>[ 3069.977666] Code: 8d 62 f8 c3 49 81 3c 24 e0 fa 3c 82 41 be 00 00 00 00 
45 0f 45 f0 83 fe 01 77 86 89 f0 49 8b 44 c4 08 48 85 c0 0f 84 76 ff ff ff  
ff 80 38 01 00 00 8b 1d 62 f9 e8 01 45 8b 85 b8 08 00 00 85
<1>[ 3069.977707] RIP: __lock_acquire+0x109/0x1b60 RSP: c90001fe7bb0
<4>[ 3069.977712] ---[ end trace 4ad012eb3af62df7 ]---

In order to keep the dev_priv->ifbdev alive after failure, we have to
avoid the free and leave it empty until we unload the module (which is
less than ideal, but a necessary evil for simplicity). Then we can use
intel_fbdev_sync() to serialise the hotplug event with the configuration.
The serialisation between the two was removed in commit 934458c2c95d
("Revert "drm/i915: Fix races on fbdev""), but the use after free is much
older, commit 366e39b4d2c5 ("drm/i915: Tear down fbdev if initialization
fails")

Fixes: 366e39b4d2c5 ("drm/i915: Tear down fbdev if initialization fails")
Fixes: 934458c2c95d ("Revert "drm/i915: Fix races on fbdev"")
Signed-off-by: Chris Wilson 
Cc: Lukas Wunner 
Cc: Joonas Lahtinen 
Cc: Daniel Vetter 
Reviewed-by: Lukas Wunner 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20171125194155.355-1-ch...@chris-wilson.co.uk
(cherry picked from commit

[PATCH 4.14 89/95] drm/i915: Fix false-positive assert_rpm_wakelock_held in i915_pmic_bus_access_notifier v2

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Hans de Goede 

commit f4359cedfb43b934f38c50d1604db21333abe57b upstream.

assert_rpm_wakelock_held is triggered from i915_pmic_bus_access_notifier
even though it gets unregistered on (runtime) suspend, this is caused
by a race happening under the following circumstances:

intel_runtime_pm_put does:

   atomic_dec(&dev_priv->pm.wakeref_count);

   pm_runtime_mark_last_busy(kdev);
   pm_runtime_put_autosuspend(kdev);

And pm_runtime_put_autosuspend calls intel_runtime_suspend from
a workqueue, so there is ample of time between the atomic_dec() and
intel_runtime_suspend() unregistering the notifier. If the notifier
gets called in this windowd assert_rpm_wakelock_held falsely triggers
(at this point we're not runtime-suspended yet).

This commit adds disable_rpm_wakeref_asserts and
enable_rpm_wakeref_asserts calls around the
intel_uncore_forcewake_get(FORCEWAKE_ALL) call in
i915_pmic_bus_access_notifier fixing the false-positive WARN_ON.

Changes in v2:
-Reword comment explaining why disabling the wakeref asserts is
 ok and necessary

Reported-by: FKr 
Reviewed-by: Imre Deak 
Signed-off-by: Hans de Goede 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20171110150301.9601-2-hdego...@redhat.com
(cherry picked from commit ce30560c80dead91e98a03d90fb8791e57a9b69d)
Signed-off-by: Jani Nikula 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/i915/intel_uncore.c |7 +++
 1 file changed, 7 insertions(+)

--- a/drivers/gpu/drm/i915/intel_uncore.c
+++ b/drivers/gpu/drm/i915/intel_uncore.c
@@ -1171,8 +1171,15 @@ static int i915_pmic_bus_access_notifier
 * bus, which will be busy after this notification, leading to:
 * "render: timed out waiting for forcewake ack request."
 * errors.
+*
+* The notifier is unregistered during intel_runtime_suspend(),
+* so it's ok to access the HW here without holding a RPM
+* wake reference -> disable wakeref asserts for the time of
+* the access.
 */
+   disable_rpm_wakeref_asserts(dev_priv);
intel_uncore_forcewake_get(dev_priv, FORCEWAKE_ALL);
+   enable_rpm_wakeref_asserts(dev_priv);
break;
case MBI_PMIC_BUS_ACCESS_END:
intel_uncore_forcewake_put(dev_priv, FORCEWAKE_ALL);




[PATCH 4.14 87/95] e1000e: fix the use of magic numbers for buffer overrun issue

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Sasha Neftin 

commit c0f4b163a03e73055dd734eaca64b9580e72e7fb upstream.

This is a follow on to commit b10effb92e27 ("fix buffer overrun while the
 I219 is processing DMA transactions") to address David Laights concerns
about the use of "magic" numbers.  So define masks as well as add
additional code comments to give a better understanding of what needs to
be done to avoid a buffer overrun.

Signed-off-by: Sasha Neftin 
Reviewed-by: Alexander H Duyck 
Reviewed-by: Dima Ruinskiy 
Reviewed-by: Raanan Avargil 
Tested-by: Aaron Brown 
Signed-off-by: Jeff Kirsher 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/net/ethernet/intel/e1000e/ich8lan.h |3 ++-
 drivers/net/ethernet/intel/e1000e/netdev.c  |9 ++---
 2 files changed, 8 insertions(+), 4 deletions(-)

--- a/drivers/net/ethernet/intel/e1000e/ich8lan.h
+++ b/drivers/net/ethernet/intel/e1000e/ich8lan.h
@@ -113,7 +113,8 @@
 #define NVM_SIZE_MULTIPLIER 4096   /*multiplier for NVMS field */
 #define E1000_FLASH_BASE_ADDR 0xE000   /*offset of NVM access regs */
 #define E1000_CTRL_EXT_NVMVS 0x3   /*NVM valid sector */
-#define E1000_TARC0_CB_MULTIQ_3_REQ(1 << 28 | 1 << 29)
+#define E1000_TARC0_CB_MULTIQ_3_REQ0x3000
+#define E1000_TARC0_CB_MULTIQ_2_REQ0x2000
 #define PCIE_ICH8_SNOOP_ALLPCIE_NO_SNOOP_ALL
 
 #define E1000_ICH_RAR_ENTRIES  7
--- a/drivers/net/ethernet/intel/e1000e/netdev.c
+++ b/drivers/net/ethernet/intel/e1000e/netdev.c
@@ -3030,9 +3030,12 @@ static void e1000_configure_tx(struct e1
ew32(IOSFPC, reg_val);
 
reg_val = er32(TARC(0));
-   /* SPT and KBL Si errata workaround to avoid Tx hang */
-   reg_val &= ~BIT(28);
-   reg_val |= BIT(29);
+   /* SPT and KBL Si errata workaround to avoid Tx hang.
+* Dropping the number of outstanding requests from
+* 3 to 2 in order to avoid a buffer overrun.
+*/
+   reg_val &= ~E1000_TARC0_CB_MULTIQ_3_REQ;
+   reg_val |= E1000_TARC0_CB_MULTIQ_2_REQ;
ew32(TARC(0), reg_val);
}
 }




[PATCH 4.14 85/95] IB/core: Do not warn on lid conversions for OPA

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Don Hiatt 

commit 6588e412fe872ed81f3fb8d9b4561a66ecb763d0 upstream.

On OPA devices the user_mad recv_handler can receive 32Bit LIDs
(e.g. OPA_PERMISSIVE_LID) and it is okay to lose the upper 16 bits
of the LID as this information is obtained elsewhere. Do not issue
a warning when calling ib_lid_be16() in this case by masking out
the upper 16Bits.

[75667.310846] [ cut here ]
[75667.316447] WARNING: CPU: 0 PID: 1718 at ./include/rdma/ib_verbs.h:3799 
recv_handler+0x15a/0x170 [ib_umad]
[75667.327640] Modules linked in: ib_ipoib hfi1(E) rdmavt(E) rdma_ucm(E) 
ib_ucm(E) rdma_cm(E) ib_cm(E) iw_cm(E) ib_umad(E) ib_uverbs(E) ib_core(E) 
libiscsi scsi_transport_iscsi dm_mirror dm_region_hash dm_log dm_mod dax 
x86_pkg_temp_thermal intel_powerclamp coretemp kvm irqbypass crct10dif_pclmul 
crc32_pclmul ghash_clmulni_intel pcbc aesni_intel mei_me ipmi_si iTCO_wdt 
iTCO_vendor_support crypto_simd ipmi_devintf pcspkr mei sg i2c_i801 glue_helper 
lpc_ich shpchp ioatdma mfd_core wmi ipmi_msghandler cryptd acpi_power_meter 
acpi_pad nfsd auth_rpcgss nfs_acl lockd grace sunrpc ip_tables xfs libcrc32c 
sd_mod mgag200 drm_kms_helper syscopyarea sysfillrect sysimgblt fb_sys_fops ttm 
drm igb ptp ahci libahci pps_core crc32c_intel libata dca i2c_algo_bit i2c_core 
[last unloaded: ib_core]
[75667.407704] CPU: 0 PID: 1718 Comm: kworker/0:1H Tainted: GW I E   
4.13.0-rc7+ #1
[75667.417310] Hardware name: Intel Corporation S2600WT2/S2600WT2, BIOS 
SE5C610.86B.01.01.0008.021120151325 02/11/2015
[75667.429555] Workqueue: ib-comp-wq ib_cq_poll_work [ib_core]
[75667.436360] task: 88084a718000 task.stack: c9000a424000
[75667.443549] RIP: 0010:recv_handler+0x15a/0x170 [ib_umad]
[75667.450090] RSP: 0018:c9000a427ce8 EFLAGS: 00010286
[75667.456508] RAX:  RBX: 88085159ce80 RCX: 
[75667.465094] RDX: 88085a47b068 RSI:  RDI: 88085159cf00
[75667.473668] RBP: c9000a427d38 R08: 0001efc0 R09: 88085159ce80
[75667.482228] R10: 88085f007480 R11: 88084acf20e8 R12: 88085a47b020
[75667.490824] R13: 881056842e10 R14: 881056840200 R15: 88104c8d0800
[75667.499390] FS:  () GS:88085f40() 
knlGS:
[75667.509028] CS:  0010 DS:  ES:  CR0: 80050033
[75667.516080] CR2: 7f9e4b3d9000 CR3: 01c09000 CR4: 001406f0
[75667.524664] Call Trace:
[75667.528044]  ? find_mad_agent+0x7c/0x1b0 [ib_core]
[75667.534031]  ? ib_mark_mad_done+0x73/0xa0 [ib_core]
[75667.540142]  ib_mad_recv_done+0x423/0x9b0 [ib_core]
[75667.546215]  __ib_process_cq+0x5d/0xb0 [ib_core]
[75667.552007]  ib_cq_poll_work+0x20/0x60 [ib_core]
[75667.557766]  process_one_work+0x149/0x360
[75667.562844]  worker_thread+0x4d/0x3c0
[75667.567529]  kthread+0x109/0x140
[75667.571713]  ? rescuer_thread+0x380/0x380
[75667.576775]  ? kthread_park+0x60/0x60
[75667.581447]  ret_from_fork+0x25/0x30
[75667.586014] Code: 43 4a 0f b6 45 c6 88 43 4b 48 8b 45 b0 48 89 43 4c 48 8b 
45 b8 48 89 43 54 8b 45 c0 0f c8 89 43 5c e9 79 ff ff ff e8 16 4e fa e0 <0f> ff 
e9 42 ff ff ff 66 66 66 66 66 66 2e 0f 1f 84 00 00 00 00
[75667.608323] ---[ end trace cf26df27c9597264 ]---

Fixes: 62ede7779904 ("Add OPA extended LID support")
Reviewed-by: Mike Marciniszyn 
Signed-off-by: Don Hiatt 
Signed-off-by: Dennis Dalessandro 
Reviewed-by: Leon Romanovsky 
Signed-off-by: Doug Ledford 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/infiniband/core/user_mad.c |   11 ++-
 1 file changed, 10 insertions(+), 1 deletion(-)

--- a/drivers/infiniband/core/user_mad.c
+++ b/drivers/infiniband/core/user_mad.c
@@ -229,7 +229,16 @@ static void recv_handler(struct ib_mad_a
packet->mad.hdr.status = 0;
packet->mad.hdr.length = hdr_size(file) + mad_recv_wc->mad_len;
packet->mad.hdr.qpn= cpu_to_be32(mad_recv_wc->wc->src_qp);
-   packet->mad.hdr.lid= ib_lid_be16(mad_recv_wc->wc->slid);
+   /*
+* On OPA devices it is okay to lose the upper 16 bits of LID as this
+* information is obtained elsewhere. Mask off the upper 16 bits.
+*/
+   if (agent->device->port_immutable[agent->port_num].core_cap_flags &
+   RDMA_CORE_PORT_INTEL_OPA)
+   packet->mad.hdr.lid = ib_lid_be16(0x &
+ mad_recv_wc->wc->slid);
+   else
+   packet->mad.hdr.lid = ib_lid_be16(mad_recv_wc->wc->slid);
packet->mad.hdr.sl = mad_recv_wc->wc->sl;
packet->mad.hdr.path_bits  = mad_recv_wc->wc->dlid_path_bits;
packet->mad.hdr.pkey_index = mad_recv_wc->wc->pkey_index;




Re: [PATCH v2 00/31] Replacing net_mutex with rw_semaphore

2017-12-04 Thread David Miller
From: Kirill Tkhai 
Date: Mon, 4 Dec 2017 18:54:51 +0300

> Still no comments :(
> 
> Ping, ping, ping.

You cannot force people to prioritize reviewing your patch submission.

Screaming "ping ping ping" doesn't help, in fact is hinders.

> What will we do next?

Be patient.


[PATCH 4.14 84/95] include/linux/compiler-clang.h: handle randomizable anonymous structs

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Sandipan Das 

commit 4ca59b14e588f873795a11cdc77a25c686a29d23 upstream.

The GCC randomize layout plugin can randomize the member offsets of
sensitive kernel data structures.  To use this feature, certain
annotations and members are added to the structures which affect the
member offsets even if this plugin is not used.

All of these structures are completely randomized, except for task_struct
which leaves out some of its members.  All the other members are wrapped
within an anonymous struct with the __randomize_layout attribute.  This is
done using the randomized_struct_fields_start and
randomized_struct_fields_end defines.

When the plugin is disabled, the behaviour of this attribute can vary
based on the GCC version.  For GCC 5.1+, this attribute maps to
__designated_init otherwise it is just an empty define but the anonymous
structure is still present.  For other compilers, both
randomized_struct_fields_start and randomized_struct_fields_end default
to empty defines meaning the anonymous structure is not introduced at
all.

So, if a module compiled with Clang, such as a BPF program, needs to
access task_struct fields such as pid and comm, the offsets of these
members as recognized by Clang are different from those recognized by
modules compiled with GCC.  If GCC 4.6+ is used to build the kernel,
this can be solved by introducing appropriate defines for Clang so that
the anonymous structure is seen when determining the offsets for the
members.

Link: 
http://lkml.kernel.org/r/20171109064645.25581-1-sandi...@linux.vnet.ibm.com
Signed-off-by: Sandipan Das 
Cc: David Rientjes 
Cc: Greg Kroah-Hartman 
Cc: Kate Stewart 
Cc: Thomas Gleixner 
Cc: Naveen N. Rao 
Cc: Alexei Starovoitov 
Signed-off-by: Andrew Morton 
Signed-off-by: Linus Torvalds 
Signed-off-by: Greg Kroah-Hartman 

---
 include/linux/compiler-clang.h |3 +++
 1 file changed, 3 insertions(+)

--- a/include/linux/compiler-clang.h
+++ b/include/linux/compiler-clang.h
@@ -16,3 +16,6 @@
  * with any version that can compile the kernel
  */
 #define __UNIQUE_ID(prefix) __PASTE(__PASTE(__UNIQUE_ID_, prefix), __COUNTER__)
+
+#define randomized_struct_fields_start struct {
+#define randomized_struct_fields_end   };




[PATCH 4.14 75/95] drm/panel: simple: Add missing panel_simple_unprepare() calls

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Jonathan Liu 

commit f3621a8eb59a913612c8e6e37d81f16b649f8b6c upstream.

During panel removal or system shutdown panel_simple_disable() is called
which disables the panel backlight but the panel is still powered due to
missing calls to panel_simple_unprepare().

Fixes: d02fd93e2cd8 ("drm/panel: simple - Disable panel on shutdown")
Signed-off-by: Jonathan Liu 
Signed-off-by: Thierry Reding 
Link: 
https://patchwork.freedesktop.org/patch/msgid/20170807115545.27747-1-net...@gmail.com
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/panel/panel-simple.c |2 ++
 1 file changed, 2 insertions(+)

--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -369,6 +369,7 @@ static int panel_simple_remove(struct de
drm_panel_remove(&panel->base);
 
panel_simple_disable(&panel->base);
+   panel_simple_unprepare(&panel->base);
 
if (panel->ddc)
put_device(&panel->ddc->dev);
@@ -384,6 +385,7 @@ static void panel_simple_shutdown(struct
struct panel_simple *panel = dev_get_drvdata(dev);
 
panel_simple_disable(&panel->base);
+   panel_simple_unprepare(&panel->base);
 }
 
 static const struct drm_display_mode ampire_am_480272h3tmqw_t01h_mode = {




[PATCH 4.14 78/95] drm/amd/pp: fix typecast error in powerplay.

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Rex Zhu 

commit 8d8258bdab735d9f3c4b78e091ecfbb2b2b1f2ca upstream.

resulted in unexpected data truncation

Reviewed-by: Alex Deucher 
Signed-off-by: Rex Zhu 
Signed-off-by: Alex Deucher 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/process_pptables_v1_0.c
@@ -850,9 +850,9 @@ static int init_over_drive_limits(
const ATOM_Tonga_POWERPLAYTABLE *powerplay_table)
 {
hwmgr->platform_descriptor.overdriveLimit.engineClock =
-   le16_to_cpu(powerplay_table->ulMaxODEngineClock);
+   le32_to_cpu(powerplay_table->ulMaxODEngineClock);
hwmgr->platform_descriptor.overdriveLimit.memoryClock =
-   le16_to_cpu(powerplay_table->ulMaxODMemoryClock);
+   le32_to_cpu(powerplay_table->ulMaxODMemoryClock);
 
hwmgr->platform_descriptor.minOverdriveVDDC = 0;
hwmgr->platform_descriptor.maxOverdriveVDDC = 0;




Re: [PATCH tip/core/rcu 02/20] torture: Prepare scripting for shift from %p to %pK

2017-12-04 Thread Paul E. McKenney
On Mon, Dec 04, 2017 at 02:13:38PM +, David Laight wrote:
> From: Paul E. McKenney
> > Sent: 04 December 2017 13:42
> > On Mon, Dec 04, 2017 at 12:32:30PM +, David Laight wrote:
> > > From: Paul E. McKenney
> > > > Sent: 01 December 2017 20:09
> > > >
> > > > Because %p prints "(null)" and %pK prints "" or (on
> > > > 32-bit systems) "", this commit adjusts torture-test scripting
> > > > accordingly.
> > >
> > > Surely NULL v not-NULL is one bit of info that the message needs to 
> > > contain?
> > 
> > Indeed.  So the script needs to check for the strings "",
> > "", and "(null) in the console output".  The "(null)"
> > is what "%p" prints for a NULL pointer, and the other two strings are
> > what "%pK" prints for a NULL pointer.
> > 
> > Or am I missing your point?
> 
> I was thinking that even %pK should print "(null)".

That was my expectation, as in the need for this patch came as a
surprise to me.

> Perhaps it should have printed a fixed, non-zero value for non-zero
> pointers.

I must leave this to the people who have a dog in that contest.  ;-)

Thanx, Paul



Re: [PATCH v3 2/5] kasan/Makefile: Support LLVM style asan parameters.

2017-12-04 Thread Andrey Ryabinin

On 12/02/2017 12:36 AM, Paul Lawrence wrote:
>

Missing:
From: Andrey Ryabinin 

Please, don't change authorship of the patches.

> LLVM doesn't understand GCC-style paramters ("--param asan-foo=bar"),
> thus we currently we don't use inline/globals/stack instrumentation
> when building the kernel with clang.
> 
> Add support for LLVM-style parameters ("-mllvm -asan-foo=bar") to
> enable all KASAN features.
> 
> Signed-off-by: Andrey Ryabinin 
> ---
>  scripts/Makefile.kasan | 29 ++---
>  1 file changed, 18 insertions(+), 11 deletions(-)
> 
> diff --git a/scripts/Makefile.kasan b/scripts/Makefile.kasan
> index 1ce7115aa499..7c00be9216f4 100644
> --- a/scripts/Makefile.kasan
> +++ b/scripts/Makefile.kasan
> @@ -10,10 +10,7 @@ KASAN_SHADOW_OFFSET ?= $(CONFIG_KASAN_SHADOW_OFFSET)
>  



> +   # -fasan-shadow-offset fails without -fsanitize
> +   CFLAGS_KASAN_SHADOW := $(call cc-option, -fsanitize=kernel-address \
> + -fasan-shadow-offset=$(KASAN_SHADOW_OFFSET), \
> + $(call cc-option, -fsanitize=kernel-address \
> + -mllvm -asan-mapping-offset=$(KASAN_SHADOW_OFFSET)))
> +
> +   ifeq ("$(CFLAGS_KASAN_SHADOW)"," ")

This not how it was in my original patch. Why you changed this?
Condition is always false now, so it breaks kasan with 4.9.x gcc.

> +  CFLAGS_KASAN := $(CFLAGS_KASAN_MINIMAL)
> +   else
> +  # Now add all the compiler specific options that are valid standalone
> +  CFLAGS_KASAN := $(CFLAGS_KASAN_SHADOW) \
> + $(call cc-param,asan-globals=1) \


[PATCH v13 5/5] dt-bindings: watchdog: Add bindings for RAVE SP watchdog driver

2017-12-04 Thread Andrey Smirnov
Add Device Tree bindings for RAVE SP watchdog drvier - an MFD cell of
parent RAVE SP driver (documented in
Documentation/devicetree/bindings/mfd/zii,rave-sp.txt).

Cc: linux-kernel@vger.kernel.org
Cc: devicet...@vger.kernel.org
Cc: linux-watch...@vger.kernel.org
Cc: cphe...@gmail.com
Cc: Lucas Stach 
Cc: Nikita Yushchenko 
Cc: Lee Jones 
Cc: Greg Kroah-Hartman 
Cc: Pavel Machek 
Cc: Andy Shevchenko 
Cc: Guenter Roeck 
Cc: Rob Herring 
Cc: Johan Hovold 
Cc: Mark Rutland 
Cc: Sebastian Reichel 
Acked-by: Rob Herring 
Reviewed-by: Guenter Roeck 
Signed-off-by: Nikita Yushchenko 
Signed-off-by: Andrey Smirnov 
---
 .../bindings/watchdog/zii,rave-sp-wdt.txt  | 39 ++
 1 file changed, 39 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/watchdog/zii,rave-sp-wdt.txt

diff --git a/Documentation/devicetree/bindings/watchdog/zii,rave-sp-wdt.txt 
b/Documentation/devicetree/bindings/watchdog/zii,rave-sp-wdt.txt
new file mode 100644
index ..ab16659e781d
--- /dev/null
+++ b/Documentation/devicetree/bindings/watchdog/zii,rave-sp-wdt.txt
@@ -0,0 +1,39 @@
+Zodiac Inflight Innovations RAVE Supervisory Processor Watchdog Bindings
+
+RAVE SP watchdog device is a "MFD cell" device corresponding to
+watchdog functionality of RAVE Supervisory Processor. It is expected
+that its Device Tree node is specified as a child of the node
+corresponding to the parent RAVE SP device (as documented in
+Documentation/devicetree/bindings/mfd/zii,rave-sp.txt)
+
+Required properties:
+- compatible:  Should be "zii,rave-sp-watchdog"
+
+Optional properties:
+
+- wdt-timeout: Two byte nvmem cell specified as per
+   Documentation/devicetree/bindings/nvmem/nvmem.txt
+
+Example:
+
+   rave-sp {
+   compatible = "zii,rave-sp-rdu1";
+   current-speed = <38400>;
+
+   eeprom {
+   compatible = "zii,pic-main-eeprom";
+   #address-cells = <1>;
+   #size-cells = <1>;
+
+   wdt_timeout: wdt-timeout@8E {
+   reg = <0x8E 2>;
+   };
+   };
+
+   watchdog {
+   compatible = "zii,rave-sp-watchdog";
+   nvmem-cells = <&wdt_timeout>;
+   nvmem-cell-names = "wdt-timeout";
+   };
+   }
+
-- 
2.14.3



Re: [PATCH] perf tools: set GUI mode after returning from perf_session__new()

2017-12-04 Thread SeokHo Song
Hi Arnaldo,

2017-12-05 0:45 GMT+09:00 Arnaldo Carvalho de Melo :
> Em Tue, Dec 05, 2017 at 12:05:18AM +0900, Namhyung Kim escreveu:
>> Hi SeokHo,
>>
>> On Sun, Dec 3, 2017 at 10:50 PM, Song Seok Ho <0xdev...@gmail.com> wrote:
>> > If perf_session__new() returns NULL with use_browser set to 2 via --gtk 
>> > option
>> > previously, perf dies quietly without printing any errors.
>> >
>> > The reason behind this is that GTK is not yet initialized when the caller
>> > inside perf_session__new() is trying to print error message to the screen.
>> >
>> > Reorder code to print the messages to stdio when GTK is not yet ready.
>>
>> I'm ok with this change, but it needs to consider other error messages too.
>> There are more pr_err() calls between perf_session__new() and
>> setup_browser(), so I think they have same problem.
>
> So I think I can apply this one, with Namhyung's acked-by and then Song
> can continue with followup patches?
>
> - Arnaldo
>

I've sent a follow-up patch with a new title "[PATCH v2] perf tools:
set browser mode
right before setup_browser()" with Namhyung's Acked-by added.

Addressing Namhyung's comment, I've moved the use_browser variable assignment
code below when setup_browser() is called.

Please let me know if it deserves to be in a different place.

Thanks.


[PATCH v13 3/5] mfd: Add driver for RAVE Supervisory Processor

2017-12-04 Thread Andrey Smirnov
Add a driver for RAVE Supervisory Processor, an MCU implementing
various bits of housekeeping functionality (watchdoging, backlight
control, LED control, etc) on RAVE family of products by Zodiac
Inflight Innovations.

This driver implementes core MFD/serdev device as well as
communication subroutines necessary for commanding the device.

Cc: linux-kernel@vger.kernel.org
Cc: cphe...@gmail.com
Cc: Lucas Stach 
Cc: Nikita Yushchenko 
Cc: Lee Jones 
Cc: Greg Kroah-Hartman 
Cc: Pavel Machek 
Cc: Andy Shevchenko 
Cc: Guenter Roeck 
Cc: Rob Herring 
Cc: Johan Hovold 
Cc: Sebastian Reichel 
Tested-by: Chris Healy 
Reviewed-by: Guenter Roeck 
Reviewed-by: Andy Shevchenko 
Signed-off-by: Andrey Smirnov 
---
 drivers/mfd/Kconfig |   9 +
 drivers/mfd/Makefile|   2 +
 drivers/mfd/rave-sp.c   | 660 
 include/linux/mfd/rave-sp.h |  56 
 4 files changed, 727 insertions(+)
 create mode 100644 drivers/mfd/rave-sp.c
 create mode 100644 include/linux/mfd/rave-sp.h

diff --git a/drivers/mfd/Kconfig b/drivers/mfd/Kconfig
index 1d20a800e967..8faeebbfcc7f 100644
--- a/drivers/mfd/Kconfig
+++ b/drivers/mfd/Kconfig
@@ -1860,4 +1860,13 @@ config MFD_VEXPRESS_SYSREG
  on the ARM Ltd. Versatile Express board.
 
 endmenu
+
+config RAVE_SP_CORE
+   tristate "RAVE SP MCU core driver"
+   depends on SERIAL_DEV_BUS
+   select CRC_CCITT
+   help
+ Select this to get support for the Supervisory Processor
+ device found on several devices in RAVE line of hardware.
+
 endif
diff --git a/drivers/mfd/Makefile b/drivers/mfd/Makefile
index d9474ade32e6..61abc297b97c 100644
--- a/drivers/mfd/Makefile
+++ b/drivers/mfd/Makefile
@@ -230,3 +230,5 @@ obj-$(CONFIG_MFD_STM32_LPTIMER) += stm32-lptimer.o
 obj-$(CONFIG_MFD_STM32_TIMERS) += stm32-timers.o
 obj-$(CONFIG_MFD_MXS_LRADC) += mxs-lradc.o
 obj-$(CONFIG_MFD_SC27XX_PMIC)  += sprd-sc27xx-spi.o
+obj-$(CONFIG_RAVE_SP_CORE) += rave-sp.o
+
diff --git a/drivers/mfd/rave-sp.c b/drivers/mfd/rave-sp.c
new file mode 100644
index ..c51ba2a864d5
--- /dev/null
+++ b/drivers/mfd/rave-sp.c
@@ -0,0 +1,660 @@
+/*
+ * Multifunction core driver for Zodiac Inflight Innovations
+ * SP MCU that is connected via dedicated UART port
+ *
+ * Copyright (C) 2017 Zodiac Inflight Innovations
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+/*
+ * UART protocol using following entities:
+ *  - message to MCU => ACK response
+ *  - event from MCU => event ACK
+ *
+ * Frame structure:
+ *
+ * Where:
+ * - STX - is start of transmission character
+ * - ETX - end of transmission
+ * - DATA - payload
+ * - CHECKSUM - checksum calculated on 
+ *
+ * If  or  contain one of control characters, then it is
+ * escaped using  control code. Added  does not participate in
+ * checksum calculation.
+ */
+#define RAVE_SP_STX0x02
+#define RAVE_SP_ETX0x03
+#define RAVE_SP_DLE0x10
+
+#define RAVE_SP_MAX_DATA_SIZE  64
+#define RAVE_SP_CHECKSUM_SIZE  2  /* Worst case scenario on RDU2 */
+/*
+ * We don't store STX, ETX and unescaped bytes, so Rx is only
+ * DATA + CSUM
+ */
+#define RAVE_SP_RX_BUFFER_SIZE \
+   (RAVE_SP_MAX_DATA_SIZE + RAVE_SP_CHECKSUM_SIZE)
+
+#define RAVE_SP_STX_ETX_SIZE   2
+/*
+ * For Tx we have to have space for everything, STX, EXT and
+ * potentially stuffed DATA + CSUM data + csum
+ */
+#define RAVE_SP_TX_BUFFER_SIZE \
+   (RAVE_SP_STX_ETX_SIZE + 2 * RAVE_SP_RX_BUFFER_SIZE)
+
+#define RAVE_SP_BOOT_SOURCE_GET0
+#define RAVE_SP_BOOT_SOURCE_SET1
+
+#define RAVE_SP_RDU2_BOARD_TYPE_RMB0
+#define RAVE_SP_RDU2_BOARD_TYPE_DEB1
+
+#define RAVE_SP_BOOT_SOURCE_SD 0
+#define RAVE_SP_BOOT_SOURCE_EMMC   1
+#define RAVE_SP_BOOT_SOURCE_NOR2
+
+/**
+ * enum rave_sp_deframer_state - Possible state for de-framer
+ *
+ * @RAVE_SP_EXPECT_SOF: Scanning input for start-of-frame 
marker
+ * @RAVE_SP_EXPECT_DATA:Got start of frame marker, collecting frame
+ * @RAVE_SP_EXPECT_ESCAPED_DATA: Got escape character, collecting

[PATCH v13 4/5] watchdog: Add RAVE SP watchdog driver

2017-12-04 Thread Andrey Smirnov
This driver provides access to RAVE SP watchdog functionality.

Cc: linux-kernel@vger.kernel.org
Cc: linux-watch...@vger.kernel.org
Cc: cphe...@gmail.com
Cc: Lucas Stach 
Cc: Nikita Yushchenko 
Cc: Lee Jones 
Cc: Greg Kroah-Hartman 
Cc: Pavel Machek 
Cc: Andy Shevchenko 
Cc: Guenter Roeck 
Cc: Rob Herring 
Cc: Johan Hovold 
Cc: Sebastian Reichel 
Reviewed-by: Guenter Roeck 
Signed-off-by: Nikita Yushchenko 
Signed-off-by: Andrey Smirnov 
---
 drivers/watchdog/Kconfig   |   7 +
 drivers/watchdog/Makefile  |   1 +
 drivers/watchdog/rave-sp-wdt.c | 357 +
 3 files changed, 365 insertions(+)
 create mode 100644 drivers/watchdog/rave-sp-wdt.c

diff --git a/drivers/watchdog/Kconfig b/drivers/watchdog/Kconfig
index ca200d1f310a..5bf613d3b7d6 100644
--- a/drivers/watchdog/Kconfig
+++ b/drivers/watchdog/Kconfig
@@ -223,6 +223,13 @@ config ZIIRAVE_WATCHDOG
  To compile this driver as a module, choose M here: the
  module will be called ziirave_wdt.
 
+config RAVE_SP_WATCHDOG
+   tristate "RAVE SP Watchdog timer"
+   depends on RAVE_SP_CORE
+   select WATCHDOG_CORE
+   help
+ Support for the watchdog on RAVE SP device.
+
 # ALPHA Architecture
 
 # ARM Architecture
diff --git a/drivers/watchdog/Makefile b/drivers/watchdog/Makefile
index 715a21078e0c..135c5e81f25e 100644
--- a/drivers/watchdog/Makefile
+++ b/drivers/watchdog/Makefile
@@ -224,3 +224,4 @@ obj-$(CONFIG_MAX77620_WATCHDOG) += max77620_wdt.o
 obj-$(CONFIG_ZIIRAVE_WATCHDOG) += ziirave_wdt.o
 obj-$(CONFIG_SOFT_WATCHDOG) += softdog.o
 obj-$(CONFIG_MENF21BMC_WATCHDOG) += menf21bmc_wdt.o
+obj-$(CONFIG_RAVE_SP_WATCHDOG) += rave-sp-wdt.o
diff --git a/drivers/watchdog/rave-sp-wdt.c b/drivers/watchdog/rave-sp-wdt.c
new file mode 100644
index ..7421a884e371
--- /dev/null
+++ b/drivers/watchdog/rave-sp-wdt.c
@@ -0,0 +1,357 @@
+/*
+ *  rave-sp-wdt.c - Watchdog driver present in RAVE SP
+ *
+ * Copyright (C) 2017 Zodiac Inflight Innovation
+ *
+ * Driver for parent device can be found in drivers/mfd/rave-sp.c
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License as
+ * published by the Free Software Foundation; either version 2 of
+ * the License, or (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, see .
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+enum {
+   RAVE_SP_RESET_BYTE = 1,
+   RAVE_SP_RESET_REASON_NORMAL = 0,
+   RAVE_SP_RESET_DELAY_MS = 500,
+};
+
+/**
+ * struct rave_sp_wdt_variant - RAVE SP watchdog variant
+ *
+ * @max_timeout:   Largest possible watchdog timeout setting
+ * @min_timeout:   Smallest possible watchdog timeout setting
+ *
+ * @configure: Function to send configuration command
+ * @restart:   Function to send "restart" command
+ */
+struct rave_sp_wdt_variant {
+   unsigned int max_timeout;
+   unsigned int min_timeout;
+
+   int (*configure)(struct watchdog_device *, bool);
+   int (*restart)(struct watchdog_device *);
+};
+
+/**
+ * struct rave_sp_wdt - RAVE SP watchdog
+ *
+ * @wdd:   Underlying watchdog device
+ * @sp:Pointer to parent RAVE SP device
+ * @variant:   Device specific variant information
+ * @reboot_notifier:   Reboot notifier implementing machine reset
+ */
+struct rave_sp_wdt {
+   struct watchdog_device wdd;
+   struct rave_sp *sp;
+   const struct rave_sp_wdt_variant *variant;
+   struct notifier_block reboot_notifier;
+};
+
+static struct rave_sp_wdt *to_rave_sp_wdt(struct watchdog_device *wdd)
+{
+   return container_of(wdd, struct rave_sp_wdt, wdd);
+}
+
+static int rave_sp_wdt_exec(struct watchdog_device *wdd, void *data,
+   size_t data_size)
+{
+   return rave_sp_exec(to_rave_sp_wdt(wdd)->sp,
+   data, data_size, NULL, 0);
+}
+
+static int rave_sp_wdt_legacy_configure(struct watchdog_device *wdd, bool on)
+{
+   u8 cmd[] = {
+   [0] = RAVE_SP_CMD_SW_WDT,
+   [1] = 0,
+   [2] = 0,
+   [3] = on,
+   [4] = on ? wdd->timeout : 0,
+   };
+
+   return rave_sp_wdt_exec(wdd, cmd, sizeof(cmd));
+}
+
+static int rave_sp_wdt_rdu_configure(struct watchdog_device *wdd, bool on)
+{
+   u8 cmd[] = {
+   [0] = RAVE_SP_CMD_SW_WDT,
+   [1] = 0,
+   [2] = on,
+   [3] = (u8)wdd->timeout,
+   [4] = (u8)(wdd->timeout

[PATCH v13 2/5] serdev: Introduce devm_serdev_device_open()

2017-12-04 Thread Andrey Smirnov
Add code implementing managed version of serdev_device_open() for
serdev device drivers that "open" the device during driver's lifecycle
only once (e.g. opened in .probe() and closed in .remove()).

Cc: linux-kernel@vger.kernel.org
Cc: linux-ser...@vger.kernel.org
Cc: Rob Herring 
Cc: cphe...@gmail.com
Cc: Guenter Roeck 
Cc: Lucas Stach 
Cc: Nikita Yushchenko 
Cc: Lee Jones 
Cc: Greg Kroah-Hartman 
Cc: Pavel Machek 
Cc: Andy Shevchenko 
Cc: Johan Hovold 
Cc: Sebastian Reichel 
Acked-by: Rob Herring 
Reviewed-by: Sebastian Reichel 
Reviewed-by: Guenter Roeck 
Signed-off-by: Andrey Smirnov 
---
 Documentation/driver-model/devres.txt |  3 +++
 drivers/tty/serdev/core.c | 27 +++
 include/linux/serdev.h|  1 +
 3 files changed, 31 insertions(+)

diff --git a/Documentation/driver-model/devres.txt 
b/Documentation/driver-model/devres.txt
index c180045eb43b..7c1bb3d0c222 100644
--- a/Documentation/driver-model/devres.txt
+++ b/Documentation/driver-model/devres.txt
@@ -384,6 +384,9 @@ RESET
   devm_reset_control_get()
   devm_reset_controller_register()
 
+SERDEV
+  devm_serdev_device_open()
+
 SLAVE DMA ENGINE
   devm_acpi_dma_controller_register()
 
diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 34050b439c1f..28133dbd2808 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -132,6 +132,33 @@ void serdev_device_close(struct serdev_device *serdev)
 }
 EXPORT_SYMBOL_GPL(serdev_device_close);
 
+static void devm_serdev_device_release(struct device *dev, void *dr)
+{
+   serdev_device_close(*(struct serdev_device **)dr);
+}
+
+int devm_serdev_device_open(struct device *dev, struct serdev_device *serdev)
+{
+   struct serdev_device **dr;
+   int ret;
+
+   dr = devres_alloc(devm_serdev_device_release, sizeof(*dr), GFP_KERNEL);
+   if (!dr)
+   return -ENOMEM;
+
+   ret = serdev_device_open(serdev);
+   if (ret) {
+   devres_free(dr);
+   return ret;
+   }
+
+   *dr = serdev;
+   devres_add(dev, dr);
+
+   return 0;
+}
+EXPORT_SYMBOL_GPL(devm_serdev_device_open);
+
 void serdev_device_write_wakeup(struct serdev_device *serdev)
 {
complete(&serdev->write_comp);
diff --git a/include/linux/serdev.h b/include/linux/serdev.h
index e69402d4a8ae..9929063bd45d 100644
--- a/include/linux/serdev.h
+++ b/include/linux/serdev.h
@@ -193,6 +193,7 @@ static inline int serdev_controller_receive_buf(struct 
serdev_controller *ctrl,
 
 int serdev_device_open(struct serdev_device *);
 void serdev_device_close(struct serdev_device *);
+int devm_serdev_device_open(struct device *, struct serdev_device *);
 unsigned int serdev_device_set_baudrate(struct serdev_device *, unsigned int);
 void serdev_device_set_flow_control(struct serdev_device *, bool);
 int serdev_device_write_buf(struct serdev_device *, const unsigned char *, 
size_t);
-- 
2.14.3



[PATCH 1/5] aio: Move aio_nr increment to separate function

2017-12-04 Thread Kirill Tkhai
There is no functional changes, only a preparation
for next patches.

Signed-off-by: Kirill Tkhai 
---
 fs/aio.c |   44 
 1 file changed, 32 insertions(+), 12 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index e6de7715228c..04209c0561b2 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -694,13 +694,39 @@ static int ioctx_add_table(struct kioctx *ctx, struct 
mm_struct *mm)
}
 }
 
-static void aio_nr_sub(unsigned nr)
+static bool __try_to_charge_aio_nr(unsigned nr)
+{
+   if (aio_nr + nr > aio_max_nr ||
+   aio_nr + nr < aio_nr)
+   return false;
+
+   aio_nr += nr;
+   return true;
+}
+
+static void __uncharge_aio_nr(unsigned nr)
 {
-   spin_lock(&aio_nr_lock);
if (WARN_ON(aio_nr - nr > aio_nr))
aio_nr = 0;
else
aio_nr -= nr;
+}
+
+static bool try_to_charge_aio_nr(unsigned nr)
+{
+   bool ret;
+
+   spin_lock(&aio_nr_lock);
+   ret = __try_to_charge_aio_nr(nr);
+   spin_unlock(&aio_nr_lock);
+
+   return ret;
+}
+
+static void uncharge_aio_nr(unsigned nr)
+{
+   spin_lock(&aio_nr_lock);
+   __uncharge_aio_nr(nr);
spin_unlock(&aio_nr_lock);
 }
 
@@ -776,15 +802,9 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
ctx->req_batch = 1;
 
/* limit the number of system wide aios */
-   spin_lock(&aio_nr_lock);
-   if (aio_nr + ctx->max_reqs > aio_max_nr ||
-   aio_nr + ctx->max_reqs < aio_nr) {
-   spin_unlock(&aio_nr_lock);
-   err = -EAGAIN;
+   err = -EAGAIN;
+   if (!try_to_charge_aio_nr(ctx->max_reqs))
goto err_ctx;
-   }
-   aio_nr += ctx->max_reqs;
-   spin_unlock(&aio_nr_lock);
 
percpu_ref_get(&ctx->users);/* io_setup() will drop this ref */
percpu_ref_get(&ctx->reqs); /* free_ioctx_users() will drop this */
@@ -801,7 +821,7 @@ static struct kioctx *ioctx_alloc(unsigned nr_events)
return ctx;
 
 err_cleanup:
-   aio_nr_sub(ctx->max_reqs);
+   uncharge_aio_nr(ctx->max_reqs);
 err_ctx:
atomic_set(&ctx->dead, 1);
if (ctx->mmap_size)
@@ -848,7 +868,7 @@ static int kill_ioctx(struct mm_struct *mm, struct kioctx 
*ctx,
 * -EAGAIN with no ioctxs actually in use (as far as userspace
 *  could tell).
 */
-   aio_nr_sub(ctx->max_reqs);
+   uncharge_aio_nr(ctx->max_reqs);
 
if (ctx->mmap_size)
vm_munmap(ctx->mmap_base, ctx->mmap_size);



[PATCH 0/5] blkcg: Limit maximum number of aio requests available for cgroup

2017-12-04 Thread Kirill Tkhai
Hi,

this patch set introduces accounting aio_nr and aio_max_nr per blkio cgroup.
It may be used to limit number of aio requests, which are available for
a cgroup, and could be useful for containers.

The accounting is hierarchical, and aio contexts, allocated in child cgroup,
are accounted in parent cgroups too.

Also, new cgroup file "io.aio_nr" is introduced. It's used to set cgroup
aio requests limit, to show current limit and number of currenly occupied
requests.

Patches 1-3 are refactoring.
Patch 4 is the place where the accounting actually introduced.
Patch 5 adds "io.aio_nr" file.

---

Kirill Tkhai (5):
  aio: Move aio_nr increment to separate function
  aio: Export aio_nr_lock and aio_max_nr initial value to 
include/linux/aio.h
  blkcg: Add blkcg::blkg_aio_nr and blkcg::blkg_aio_max_nr
  blkcg: Charge aio requests in blkio cgroup hierarchy
  blkcg: Add cgroup file to configure blkcg::blkg_aio_max_nr


 block/blk-cgroup.c |   88 +-
 fs/aio.c   |  151 
 include/linux/aio.h|   21 ++
 include/linux/blk-cgroup.h |4 +
 4 files changed, 247 insertions(+), 17 deletions(-)

--
Signed-off-by: Kirill Tkhai 


[PATCH 2/5] aio: Export aio_nr_lock and aio_max_nr initial value to include/linux/aio.h

2017-12-04 Thread Kirill Tkhai
Next patch will use the values in more files, so let's make them visible 
external.

Signed-off-by: Kirill Tkhai 
---
 fs/aio.c|4 ++--
 include/linux/aio.h |4 
 2 files changed, 6 insertions(+), 2 deletions(-)

diff --git a/fs/aio.c b/fs/aio.c
index 04209c0561b2..9dc98a29077c 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -188,10 +188,10 @@ struct aio_kiocb {
struct eventfd_ctx  *ki_eventfd;
 };
 
+DEFINE_SPINLOCK(aio_nr_lock);
 /*-- sysctl variables*/
-static DEFINE_SPINLOCK(aio_nr_lock);
 unsigned long aio_nr;  /* current system wide number of aio requests */
-unsigned long aio_max_nr = 0x1; /* system wide maximum number of aio 
requests */
+unsigned long aio_max_nr = AIO_NR_DEF; /* system wide maximum number of aio 
requests */
 /*end sysctl variables---*/
 
 static struct kmem_cache   *kiocb_cachep;
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 9d8aabecfe2d..5dda2663802f 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -10,6 +10,10 @@ struct mm_struct;
 
 #define KIOCB_KEY  0
 
+#define AIO_NR_INF (-1UL)
+#define AIO_NR_DEF 0x1
+
+extern spinlock_t aio_nr_lock;
 typedef int (kiocb_cancel_fn)(struct kiocb *);
 
 /* prototypes */



[PATCH 3/5] blkcg: Add blkcg::blkg_aio_nr and blkcg::blkg_aio_max_nr

2017-12-04 Thread Kirill Tkhai
This adds new members of struct blkcg, which will
be used to account numbers of cgroup's aio requests.

Also, blkcg_root is used to store sysctl variables
aio_nr and aio_max_nr.

Signed-off-by: Kirill Tkhai 
---
 block/blk-cgroup.c |4 
 fs/aio.c   |2 ++
 include/linux/aio.h|6 ++
 include/linux/blk-cgroup.h |4 
 4 files changed, 16 insertions(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index d3f56baee936..774560469b01 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -27,6 +27,7 @@
 #include 
 #include 
 #include 
+#include 
 #include "blk.h"
 
 #define MAX_KEY_LEN 100
@@ -1101,6 +1102,9 @@ blkcg_css_alloc(struct cgroup_subsys_state *parent_css)
INIT_HLIST_HEAD(&blkcg->blkg_list);
 #ifdef CONFIG_CGROUP_WRITEBACK
INIT_LIST_HEAD(&blkcg->cgwb_list);
+#endif
+#ifdef CONFIG_AIO
+   blkcg->blkg_aio_max_nr = parent_css ? AIO_NR_INF : AIO_NR_DEF;
 #endif
list_add_tail(&blkcg->all_blkcgs_node, &all_blkcgs);
 
diff --git a/fs/aio.c b/fs/aio.c
index 9dc98a29077c..755f97a42ebe 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -189,10 +189,12 @@ struct aio_kiocb {
 };
 
 DEFINE_SPINLOCK(aio_nr_lock);
+#ifndef CONFIG_BLK_CGROUP
 /*-- sysctl variables*/
 unsigned long aio_nr;  /* current system wide number of aio requests */
 unsigned long aio_max_nr = AIO_NR_DEF; /* system wide maximum number of aio 
requests */
 /*end sysctl variables---*/
+#endif
 
 static struct kmem_cache   *kiocb_cachep;
 static struct kmem_cache   *kioctx_cachep;
diff --git a/include/linux/aio.h b/include/linux/aio.h
index 5dda2663802f..de929a8c9c59 100644
--- a/include/linux/aio.h
+++ b/include/linux/aio.h
@@ -2,6 +2,7 @@
 #ifndef __LINUX__AIO_H
 #define __LINUX__AIO_H
 
+#include 
 #include 
 
 struct kioctx;
@@ -26,8 +27,13 @@ static inline void kiocb_set_cancel_fn(struct kiocb *req,
   kiocb_cancel_fn *cancel) { }
 #endif /* CONFIG_AIO */
 
+#if !defined(CONFIG_BLK_CGROUP) || !defined(CONFIG_AIO)
 /* for sysctl: */
 extern unsigned long aio_nr;
 extern unsigned long aio_max_nr;
+#else
+#define aio_nr blkcg_root.blkg_aio_nr
+#define aio_max_nr blkcg_root.blkg_aio_max_nr
+#endif /* !CONFIG_BLK_CGROUP || !CONFIG_AIO */
 
 #endif /* __LINUX__AIO_H */
diff --git a/include/linux/blk-cgroup.h b/include/linux/blk-cgroup.h
index 8bbc3716507a..3d9c176fc173 100644
--- a/include/linux/blk-cgroup.h
+++ b/include/linux/blk-cgroup.h
@@ -55,6 +55,10 @@ struct blkcg {
 #ifdef CONFIG_CGROUP_WRITEBACK
struct list_headcgwb_list;
 #endif
+#ifdef CONFIG_AIO
+   unsigned long   blkg_aio_nr;
+   unsigned long   blkg_aio_max_nr;
+#endif
 };
 
 /*



[PATCH 4/5] blkcg: Charge aio requests in blkio cgroup hierarchy

2017-12-04 Thread Kirill Tkhai
This patch adds accounting of number of requests of allocated aio
contexts per blkio cgroup, and aggregates child cgroups requests
up the hierarhy. This may be used to limit aio requests available
for containers.

By default, newly allocated blkcg::blkg_aio_max_nr is set
to "unlimited" value (see blkcg_css_alloc() in previous patch).
This guarantees that applications, which do not know about
blkcg::blkg_aio_max_nr, will be able to run like they used to do
before, without configuring child cgroup's blkg_aio_max_nr.

For protection "task attach" vs "io_context create/destroy"
read locked cgroup_threadgroup_rwsem is used. We take it
via cgroup_threadgroup_change_*() interfaces, which are used
around the places we charge kioctx::max_reqs and link a ctx
to mm_struct::ioctx_table.

Single allocation are protected aio_nr_lock like it used before.

Signed-off-by: Kirill Tkhai 
---
 block/blk-cgroup.c  |   44 +-
 fs/aio.c|  101 +++
 include/linux/aio.h |   11 ++
 3 files changed, 153 insertions(+), 3 deletions(-)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 774560469b01..9cc6e9574946 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -1217,8 +1217,8 @@ void blkcg_exit_queue(struct request_queue *q)
  */
 static int blkcg_can_attach(struct cgroup_taskset *tset)
 {
-   struct task_struct *task;
-   struct cgroup_subsys_state *dst_css;
+   struct cgroup_subsys_state *dst_css, *old_css;
+   struct task_struct *task, *p;
struct io_context *ioc;
int ret = 0;
 
@@ -1230,11 +1230,46 @@ static int blkcg_can_attach(struct cgroup_taskset *tset)
ret = -EINVAL;
task_unlock(task);
if (ret)
-   break;
+   goto err;
+   if (!thread_group_leader(task))
+   continue;
+   ret = charge_task_aio_nr(task, css_to_blkcg(dst_css));
+   if (ret)
+   goto err;
+   old_css = task_css(task, io_cgrp_id);
+   uncharge_task_aio_nr(task, css_to_blkcg(old_css));
+   }
+err:
+   if (ret) {
+   cgroup_taskset_for_each(p, dst_css, tset) {
+   if (p == task)
+   break;
+   if (!thread_group_leader(p))
+   continue;
+   uncharge_task_aio_nr(p, css_to_blkcg(dst_css));
+   old_css = task_css(p, io_cgrp_id);
+   WARN_ON_ONCE(charge_task_aio_nr(p, 
css_to_blkcg(old_css)));
+   }
}
return ret;
 }
 
+#ifdef CONFIG_AIO
+static void blkcg_cancel_attach(struct cgroup_taskset *tset)
+{
+   struct cgroup_subsys_state *dst_css, *old_css;
+   struct task_struct *p;
+
+   cgroup_taskset_for_each(p, dst_css, tset) {
+   if (!thread_group_leader(p))
+   continue;
+   uncharge_task_aio_nr(p, css_to_blkcg(dst_css));
+   old_css = task_css(p, io_cgrp_id);
+   WARN_ON_ONCE(charge_task_aio_nr(p, css_to_blkcg(old_css)));
+   }
+}
+#endif
+
 static void blkcg_bind(struct cgroup_subsys_state *root_css)
 {
int i;
@@ -1260,6 +1295,9 @@ struct cgroup_subsys io_cgrp_subsys = {
.css_offline = blkcg_css_offline,
.css_free = blkcg_css_free,
.can_attach = blkcg_can_attach,
+#ifdef CONFIG_AIO
+   .cancel_attach = blkcg_cancel_attach,
+#endif
.bind = blkcg_bind,
.dfl_cftypes = blkcg_files,
.legacy_cftypes = blkcg_legacy_files,
diff --git a/fs/aio.c b/fs/aio.c
index 755f97a42ebe..2e63f5c582c0 100644
--- a/fs/aio.c
+++ b/fs/aio.c
@@ -40,6 +40,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -696,6 +697,97 @@ static int ioctx_add_table(struct kioctx *ctx, struct 
mm_struct *mm)
}
 }
 
+#ifdef CONFIG_BLK_CGROUP
+static bool try_to_charge_blkcg(unsigned long nr, struct blkcg *blkg)
+{
+   struct blkcg *tmp = blkg;
+
+   while (blkg) {
+   if (nr + blkg->blkg_aio_nr > blkg->blkg_aio_max_nr ||
+   nr + blkg->blkg_aio_nr < nr)
+   goto fail;
+
+   blkg->blkg_aio_nr += nr;
+   blkg = blkcg_parent(blkg);
+   }
+
+   return true;
+fail:
+   while (tmp != blkg) {
+   tmp->blkg_aio_nr -= nr;
+   tmp = blkcg_parent(tmp);
+   }
+   return false;
+}
+
+
+static void uncharge_blkcg(unsigned long nr, struct blkcg *blkg)
+{
+   while (blkg) {
+   blkg->blkg_aio_nr -= nr;
+   blkg = blkcg_parent(blkg);
+   }
+}
+
+static bool __try_to_charge_aio_nr(unsigned nr)
+{
+   struct blkcg *blkg;
+
+   percpu_rwsem_assert_held(&cgroup_threadgroup_rwsem);
+   blkg = container_of(task_css_check(current, io_cgrp_id, true),
+

[PATCH 5/5] blkcg: Add cgroup file to configure blkcg::blkg_aio_max_nr

2017-12-04 Thread Kirill Tkhai
Add a file to configure per-cgroup maximum number of available
aio requests.

Allow write the values, which are less then currently allocated
numbers of requests.

Show numbers of currently allocated and maximum available requests.

Signed-off-by: Kirill Tkhai 
---
 block/blk-cgroup.c |   40 
 1 file changed, 40 insertions(+)

diff --git a/block/blk-cgroup.c b/block/blk-cgroup.c
index 9cc6e9574946..dc5600ef4523 100644
--- a/block/blk-cgroup.c
+++ b/block/blk-cgroup.c
@@ -981,12 +981,52 @@ static int blkcg_print_stat(struct seq_file *sf, void *v)
return 0;
 }
 
+#ifdef CONFIG_AIO
+static int blkcg_write_aio_max_nr(struct cgroup_subsys_state *css,
+ struct cftype *cftype, u64 val)
+{
+   struct blkcg *blkg = css_to_blkcg(css);
+   int ret = 0;
+
+   percpu_down_read(&cgroup_threadgroup_rwsem);
+   spin_lock(&aio_nr_lock);
+   if (val >= blkg->blkg_aio_nr)
+   blkg->blkg_aio_max_nr = val;
+   else
+   ret = -EBUSY;
+   spin_unlock(&aio_nr_lock);
+   percpu_up_read(&cgroup_threadgroup_rwsem);
+   return ret;
+}
+
+static int blkcg_show_aio_nrs(struct seq_file *sf, void *v)
+{
+   struct blkcg *blkg = css_to_blkcg(seq_css(sf));
+   unsigned long max_nr, nr;
+
+   spin_lock(&aio_nr_lock);
+   max_nr = blkg->blkg_aio_max_nr;
+   nr = blkg->blkg_aio_nr;
+   spin_unlock(&aio_nr_lock);
+
+   seq_printf(sf, "used=%lu, max=%lu\n", nr, max_nr);
+   return 0;
+}
+#endif /* CONFIG_AIO */
+
 static struct cftype blkcg_files[] = {
{
.name = "stat",
.flags = CFTYPE_NOT_ON_ROOT,
.seq_show = blkcg_print_stat,
},
+#ifdef CONFIG_AIO
+   {
+   .name = "aio_nr",
+   .write_u64 = blkcg_write_aio_max_nr,
+   .seq_show = blkcg_show_aio_nrs,
+   },
+#endif
{ } /* terminate */
 };
 



[PATCH v13 1/5] serdev: Make .remove in struct serdev_device_driver optional

2017-12-04 Thread Andrey Smirnov
Using devres infrastructure it is possible to write a serdev driver
that doesn't have any code that needs to be called as a part of
.remove. Add code to make .remove optional.

Cc: linux-kernel@vger.kernel.org
Cc: linux-ser...@vger.kernel.org
Cc: Rob Herring 
Cc: cphe...@gmail.com
Cc: Guenter Roeck 
Cc: Lucas Stach 
Cc: Nikita Yushchenko 
Cc: Lee Jones 
Cc: Greg Kroah-Hartman 
Cc: Pavel Machek 
Cc: Andy Shevchenko 
Cc: Johan Hovold 
Cc: Sebastian Reichel 
Acked-by: Rob Herring 
Reviewed-by: Sebastian Reichel 
Reviewed-by: Guenter Roeck 
Signed-off-by: Andrey Smirnov 
---
 drivers/tty/serdev/core.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/tty/serdev/core.c b/drivers/tty/serdev/core.c
index 1bef39828ca7..34050b439c1f 100644
--- a/drivers/tty/serdev/core.c
+++ b/drivers/tty/serdev/core.c
@@ -268,8 +268,8 @@ static int serdev_drv_probe(struct device *dev)
 static int serdev_drv_remove(struct device *dev)
 {
const struct serdev_device_driver *sdrv = 
to_serdev_device_driver(dev->driver);
-
-   sdrv->remove(to_serdev_device(dev));
+   if (sdrv->remove)
+   sdrv->remove(to_serdev_device(dev));
return 0;
 }
 
-- 
2.14.3



Re: [PATCH v2 00/31] Replacing net_mutex with rw_semaphore

2017-12-04 Thread Kirill Tkhai
On 04.12.2017 19:10, David Miller wrote:
> From: Kirill Tkhai 
> Date: Mon, 4 Dec 2017 18:54:51 +0300
> 
>> Still no comments :(
>>
>> Ping, ping, ping.
> 
> You cannot force people to prioritize reviewing your patch submission.
> 
> Screaming "ping ping ping" doesn't help, in fact is hinders.
> 
>> What will we do next?
> 
> Be patient.

Ok, thanks


RE: [PATCH 1/1] gianfar: fix a flooded alignment reports because of padding issue.

2017-12-04 Thread Claudiu Manoil
>-Original Message-
>From: Zumeng Chen [mailto:zumeng.c...@gmail.com]
>Sent: Monday, December 04, 2017 5:22 AM
>To: net...@vger.kernel.org; linux-kernel@vger.kernel.org
>Cc: Claudiu Manoil ; da...@davemloft.net
>Subject: [PATCH 1/1] gianfar: fix a flooded alignment reports because of 
>padding
>issue.
>
>According to LS1021A RM, the value of PAL can be set so that the start of the
>IP header in the receive data buffer is aligned to a 32-bit boundary. Normally,
>setting PAL = 2 provides minimal padding to ensure such alignment of the IP
>header.
>
>However every incoming packet's 8-byte time stamp will be inserted into the
>packet data buffer as padding alignment bytes when hardware time stamping is
>enabled.
>
>So we set the padding 8+2 here to avoid the flooded alignment faults:
>
>root@128:~# cat /proc/cpu/alignment
>User:   0
>System: 17539 (inet_gro_receive+0x114/0x2c0)
>Skipped:0
>Half:   0
>Word:   0
>DWord:  0
>Multi:  17539
>User faults:2 (fixup)
>
[...]
>
> drivers/net/ethernet/freescale/gianfar.c | 6 --
> 1 file changed, 4 insertions(+), 2 deletions(-)
>
>diff --git a/drivers/net/ethernet/freescale/gianfar.c
>b/drivers/net/ethernet/freescale/gianfar.c
>index e616b71..e47945f 100644
>--- a/drivers/net/ethernet/freescale/gianfar.c
>+++ b/drivers/net/ethernet/freescale/gianfar.c
>@@ -1413,9 +1413,11 @@ static int gfar_probe(struct platform_device *ofdev)
>
>   gfar_init_addr_hash_table(priv);
>
>-  /* Insert receive time stamps into padding alignment bytes */
>+  /* Insert receive time stamps into padding alignment bytes, and
>+   * plus 2 bytes padding to ensure the cpu alignment.
>+   */
>   if (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)
>-  priv->padding = 8;
>+  priv->padding = 8 + DEFAULT_PADDING;
>
>   if (dev->features & NETIF_F_IP_CSUM ||
>   priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)
>--
>2.5.0

Why handle only the rx timestamp path (HAS_TIMER) when the issue, as presented 
by you, should be applicable to the default path as well?

The code change according to the patch description should be more likely:

+   priv->padding = DEFAULT_PADDING;
/* Insert receive time stamps into padding alignment bytes */
if (priv->device_flags & FSL_GIANFAR_DEV_HAS_TIMER)
-   priv->padding = 8;
+   priv->padding += 8;


Do you have any performance numbers for this change?

Thanks,
Claudiu


[PATCH 4.14 28/95] lockd: lost rollback of set_grace_period() in lockd_down_net()

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Vasily Averin 

commit 3a2b19d1ee5633f76ae8a88da7bc039a5d1732aa upstream.

Commit efda760fe95ea ("lockd: fix lockd shutdown race") is incorrect,
it removes lockd_manager and disarm grace_period_end for init_net only.

If nfsd was started from another net namespace lockd_up_net() calls
set_grace_period() that adds lockd_manager into per-netns list
and queues grace_period_end delayed work.

These action should be reverted in lockd_down_net().
Otherwise it can lead to double list_add on after restart nfsd in netns,
and to use-after-free if non-disarmed delayed work will be executed after netns 
destroy.

Fixes: efda760fe95e ("lockd: fix lockd shutdown race")
Signed-off-by: Vasily Averin 
Signed-off-by: J. Bruce Fields 
Signed-off-by: Greg Kroah-Hartman 

---
 fs/lockd/svc.c |2 ++
 1 file changed, 2 insertions(+)

--- a/fs/lockd/svc.c
+++ b/fs/lockd/svc.c
@@ -274,6 +274,8 @@ static void lockd_down_net(struct svc_se
if (ln->nlmsvc_users) {
if (--ln->nlmsvc_users == 0) {
nlm_shutdown_hosts_net(net);
+   cancel_delayed_work_sync(&ln->grace_period_end);
+   locks_end_grace(&ln->lockd_manager);
svc_shutdown_net(serv, net);
dprintk("lockd_down_net: per-net data destroyed; 
net=%p\n", net);
}




[PATCH 4.14 36/95] powerpc/kexec: Fix kexec/kdump in P9 guest kernels

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Michael Ellerman 

commit 2621e945fbf1d6df5f3f0ba7be5bae3d2cf9b6a5 upstream.

The code that cleans up the IAMR/AMOR before kexec'ing failed to
remember that when we're running as a guest AMOR is not writable, it's
hypervisor privileged.

They symptom is that the kexec stops before entering purgatory and
nothing else is seen on the console. If you examine the state of the
system all threads will be in the 0x700 program check handler.

Fix it by making the write to AMOR dependent on HV mode.

Fixes: 1e2a516e89fc ("powerpc/kexec: Fix radix to hash kexec due to IAMR/AMOR")
Reported-by: Yilin Zhang 
Debugged-by: David Gibson 
Signed-off-by: Michael Ellerman 
Acked-by: Balbir Singh 
Reviewed-by: David Gibson 
Tested-by: David Gibson 
Signed-off-by: Michael Ellerman 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/powerpc/kernel/misc_64.S |2 ++
 1 file changed, 2 insertions(+)

--- a/arch/powerpc/kernel/misc_64.S
+++ b/arch/powerpc/kernel/misc_64.S
@@ -623,7 +623,9 @@ BEGIN_FTR_SECTION
 * NOTE, we rely on r0 being 0 from above.
 */
mtspr   SPRN_IAMR,r0
+BEGIN_FTR_SECTION_NESTED(42)
mtspr   SPRN_AMOR,r0
+END_FTR_SECTION_NESTED_IFSET(CPU_FTR_HVMODE, 42)
 END_FTR_SECTION_IFSET(CPU_FTR_ARCH_300)
 
/* save regs for local vars on new stack.




Re: [PATCH net-next v2] net: dsa: Allow compiling out legacy support

2017-12-04 Thread David Miller
From: Florian Fainelli 
Date: Fri,  1 Dec 2017 19:31:41 -0800

> Introduce a configuration option: CONFIG_NET_DSA_LEGACY allowing to compile 
> out
> support for the old platform device and Device Tree binding registration.
> Support for these configurations is scheduled to be removed in 4.17.
> 
> Signed-off-by: Florian Fainelli 

This doesn't apply cleanly, please respin.

Thanks Florian.


[PATCH 4.14 35/95] powerpc/powernv: Fix kexec crashes caused by tlbie tracing

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Mahesh Salgaonkar 

commit a3961f824cdbe7eb431254dc7d8f6f6767f474aa upstream.

Rebooting into a new kernel with kexec fails in trace_tlbie() which is
called from native_hpte_clear(). This happens if the running kernel
has CONFIG_LOCKDEP enabled. With lockdep enabled, the tracepoints
always execute few RCU checks regardless of whether tracing is on or
off. We are already in the last phase of kexec sequence in real mode
with HILE_BE set. At this point the RCU check ends up in
RCU_LOCKDEP_WARN and causes kexec to fail.

Fix this by not calling trace_tlbie() from native_hpte_clear().

mpe: It's not safe to call trace points at this point in the kexec
path, even if we could avoid the RCU checks/warnings. The only
solution is to not call them.

Fixes: 0428491cba92 ("powerpc/mm: Trace tlbie(l) instructions")
Signed-off-by: Mahesh Salgaonkar 
Reported-by: Aneesh Kumar K.V 
Suggested-by: Michael Ellerman 
Acked-by: Naveen N. Rao 
Signed-off-by: Michael Ellerman 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/powerpc/mm/hash_native_64.c |   15 ---
 1 file changed, 12 insertions(+), 3 deletions(-)

--- a/arch/powerpc/mm/hash_native_64.c
+++ b/arch/powerpc/mm/hash_native_64.c
@@ -47,7 +47,8 @@
 
 DEFINE_RAW_SPINLOCK(native_tlbie_lock);
 
-static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
+static inline unsigned long  ___tlbie(unsigned long vpn, int psize,
+   int apsize, int ssize)
 {
unsigned long va;
unsigned int penc;
@@ -100,7 +101,15 @@ static inline void __tlbie(unsigned long
 : "memory");
break;
}
-   trace_tlbie(0, 0, va, 0, 0, 0, 0);
+   return va;
+}
+
+static inline void __tlbie(unsigned long vpn, int psize, int apsize, int ssize)
+{
+   unsigned long rb;
+
+   rb = ___tlbie(vpn, psize, apsize, ssize);
+   trace_tlbie(0, 0, rb, 0, 0, 0, 0);
 }
 
 static inline void __tlbiel(unsigned long vpn, int psize, int apsize, int 
ssize)
@@ -652,7 +661,7 @@ static void native_hpte_clear(void)
if (hpte_v & HPTE_V_VALID) {
hpte_decode(hptep, slot, &psize, &apsize, &ssize, &vpn);
hptep->v = 0;
-   __tlbie(vpn, psize, apsize, ssize);
+   ___tlbie(vpn, psize, apsize, ssize);
}
}
 




[PATCH 4.14 32/95] apparmor: fix oops in audit_signal_cb hook

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: John Johansen 

commit b12cbb21586277f72533769832c24cc6c1d60ab3 upstream.

The apparmor_audit_data struct ordering got messed up during a merge
conflict, resulting in the signal integer and peer pointer being in
a union instead of a struct.

For most of the 4.13 and 4.14 life cycle, this was hidden by
commit 651e28c5537a ("apparmor: add base infastructure for socket
mediation") which fixed the apparmor_audit_data struct when its data
was added. When that commit was reverted in -rc7 the signal audit bug
was exposed, and unfortunately it never showed up in any of the
testing until after 4.14 was released. Shaun Khan, Zephaniah
E. Loss-Cutler-Hull filed nearly simultaneous bug reports (with
different oopes, the smaller of which is included below).

Full credit goes to Tetsuo Handa for jumping on this as well and
noticing the audit data struct problem and reporting it.

[   76.178568] BUG: unable to handle kernel paging request at
0eee3bc0
[   76.178579] IP: audit_signal_cb+0x6c/0xe0
[   76.178581] PGD 1a640a067 P4D 1a640a067 PUD 0
[   76.178586] Oops:  [#1] PREEMPT SMP
[   76.178589] Modules linked in: fuse rfcomm bnep usblp uvcvideo btusb
btrtl btbcm btintel bluetooth ecdh_generic ip6table_filter ip6_tables
xt_tcpudp nf_conntrack_ipv4 nf_defrag_ipv4 xt_conntrack nf_conntrack
iptable_filter ip_tables x_tables intel_rapl joydev wmi_bmof serio_raw
iwldvm iwlwifi shpchp kvm_intel kvm irqbypass autofs4 algif_skcipher
nls_iso8859_1 nls_cp437 crc32_pclmul ghash_clmulni_intel
[   76.178620] CPU: 0 PID: 10675 Comm: pidgin Not tainted
4.14.0-f1-dirty #135
[   76.178623] Hardware name: Hewlett-Packard HP EliteBook Folio
9470m/18DF, BIOS 68IBD Ver. F.62 10/22/2015
[   76.178625] task: 9c7a94c31dc0 task.stack: a09b02a4c000
[   76.178628] RIP: 0010:audit_signal_cb+0x6c/0xe0
[   76.178631] RSP: 0018:a09b02a4fc08 EFLAGS: 00010292
[   76.178634] RAX: a09b02a4fd60 RBX: 9c7aee0741f8 RCX:

[   76.178636] RDX: ee012290 RSI: 0006 RDI:
9c7a9493d800
[   76.178638] RBP: a09b02a4fd40 R08: 004d R09:
a09b02a4fc46
[   76.178641] R10: a09b02a4fcb8 R11: 9c7ab44f5072 R12:
a09b02a4fd40
[   76.178643] R13: 9e447be0 R14: 9c7a94c31dc0 R15:
0001
[   76.178646] FS:  7f8b11ba2a80() GS:9c7afea0()
knlGS:
[   76.178648] CS:  0010 DS:  ES:  CR0: 80050033
[   76.178650] CR2: 0eee3bc0 CR3: 0003d5209002 CR4:
001606f0
[   76.178652] Call Trace:
[   76.178660]  common_lsm_audit+0x1da/0x780
[   76.178665]  ? d_absolute_path+0x60/0x90
[   76.178669]  ? aa_check_perms+0xcd/0xe0
[   76.178672]  aa_check_perms+0xcd/0xe0
[   76.178675]  profile_signal_perm.part.0+0x90/0xa0
[   76.178679]  aa_may_signal+0x16e/0x1b0
[   76.178686]  apparmor_task_kill+0x51/0x120
[   76.178690]  security_task_kill+0x44/0x60
[   76.178695]  group_send_sig_info+0x25/0x60
[   76.178699]  kill_pid_info+0x36/0x60
[   76.178703]  SYSC_kill+0xdb/0x180
[   76.178707]  ? preempt_count_sub+0x92/0xd0
[   76.178712]  ? _raw_write_unlock_irq+0x13/0x30
[   76.178716]  ? task_work_run+0x6a/0x90
[   76.178720]  ? exit_to_usermode_loop+0x80/0xa0
[   76.178723]  entry_SYSCALL_64_fastpath+0x13/0x94
[   76.178727] RIP: 0033:0x7f8b0e58b767
[   76.178729] RSP: 002b:7fff19efd4d8 EFLAGS: 0206 ORIG_RAX:
003e
[   76.178732] RAX: ffda RBX: 557f3e3c2050 RCX:
7f8b0e58b767
[   76.178735] RDX:  RSI:  RDI:
263b
[   76.178737] RBP:  R08: 557f3e3c2270 R09:
0001
[   76.178739] R10: 022d R11: 0206 R12:

[   76.178741] R13: 0001 R14: 557f3e3c13c0 R15:

[   76.178745] Code: 48 8b 55 18 48 89 df 41 b8 20 00 08 01 5b 5d 48 8b
42 10 48 8b 52 30 48 63 48 4c 48 8b 44 c8 48 31 c9 48 8b 70 38 e9 f4 fd
00 00 <48> 8b 14 d5 40 27 e5 9e 48 c7 c6 7d 07 19 9f 48 89 df e8 fd 35
[   76.178794] RIP: audit_signal_cb+0x6c/0xe0 RSP: a09b02a4fc08
[   76.178796] CR2: 0eee3bc0
[   76.178799] ---[ end trace 514af9529297f1a3 ]---

Fixes: cd1dbf76b23d ("apparmor: add the ability to mediate signals")
Reported-by: Zephaniah E. Loss-Cutler-Hull 
Reported-by: Shuah Khan 
Suggested-by: Tetsuo Handa 
Tested-by: Ivan Kozik 
Tested-by: Zephaniah E. Loss-Cutler-Hull 
Tested-by: Christian Boltz 
Tested-by: Shuah Khan 
Signed-off-by: John Johansen 
Signed-off-by: Greg Kroah-Hartman 

---
 security/apparmor/include/audit.h |   12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

--- a/security/apparmor/include/audit.h
+++ b/security/apparmor/include/audit.h
@@ -121,17 +121,19 @@ struct apparmor_audit_data {
/* these entries require a custom callback fn */
struct {
struct aa_label *peer;
- 

[PATCH 4.14 34/95] arm64: ftrace: emit ftrace-mod.o contents through code

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Ard Biesheuvel 

commit be0f272bfc83797f70d44faca86954df62e2bbc0 upstream.

When building the arm64 kernel with both CONFIG_ARM64_MODULE_PLTS and
CONFIG_DYNAMIC_FTRACE enabled, the ftrace-mod.o object file is built
with the kernel and contains a trampoline that is linked into each
module, so that modules can be loaded far away from the kernel and
still reach the ftrace entry point in the core kernel with an ordinary
relative branch, as is emitted by the compiler instrumentation code
dynamic ftrace relies on.

In order to be able to build out of tree modules, this object file
needs to be included into the linux-headers or linux-devel packages,
which is undesirable, as it makes arm64 a special case (although a
precedent does exist for 32-bit PPC).

Given that the trampoline essentially consists of a PLT entry, let's
not bother with a source or object file for it, and simply patch it
in whenever the trampoline is being populated, using the existing
PLT support routines.

Signed-off-by: Ard Biesheuvel 
Signed-off-by: Will Deacon 
Signed-off-by: Greg Kroah-Hartman 

---
 arch/arm64/Makefile |3 ---
 arch/arm64/include/asm/module.h |2 +-
 arch/arm64/kernel/Makefile  |3 ---
 arch/arm64/kernel/ftrace-mod.S  |   18 --
 arch/arm64/kernel/ftrace.c  |   14 --
 arch/arm64/kernel/module-plts.c |   12 
 arch/arm64/kernel/module.lds|1 +
 7 files changed, 22 insertions(+), 31 deletions(-)

--- a/arch/arm64/Makefile
+++ b/arch/arm64/Makefile
@@ -77,9 +77,6 @@ endif
 
 ifeq ($(CONFIG_ARM64_MODULE_PLTS),y)
 KBUILD_LDFLAGS_MODULE  += -T $(srctree)/arch/arm64/kernel/module.lds
-ifeq ($(CONFIG_DYNAMIC_FTRACE),y)
-KBUILD_LDFLAGS_MODULE  += $(objtree)/arch/arm64/kernel/ftrace-mod.o
-endif
 endif
 
 # Default value
--- a/arch/arm64/include/asm/module.h
+++ b/arch/arm64/include/asm/module.h
@@ -32,7 +32,7 @@ struct mod_arch_specific {
struct mod_plt_sec  init;
 
/* for CONFIG_DYNAMIC_FTRACE */
-   void*ftrace_trampoline;
+   struct plt_entry*ftrace_trampoline;
 };
 #endif
 
--- a/arch/arm64/kernel/Makefile
+++ b/arch/arm64/kernel/Makefile
@@ -63,6 +63,3 @@ extra-y   += $(head-y) 
vmlinux.lds
 ifeq ($(CONFIG_DEBUG_EFI),y)
 AFLAGS_head.o += -DVMLINUX_PATH="\"$(realpath $(objtree)/vmlinux)\""
 endif
-
-# will be included by each individual module but not by the core kernel itself
-extra-$(CONFIG_DYNAMIC_FTRACE) += ftrace-mod.o
--- a/arch/arm64/kernel/ftrace-mod.S
+++ /dev/null
@@ -1,18 +0,0 @@
-/*
- * Copyright (C) 2017 Linaro Ltd 
- *
- * This program is free software; you can redistribute it and/or modify
- * it under the terms of the GNU General Public License version 2 as
- * published by the Free Software Foundation.
- */
-
-#include 
-#include 
-
-   .section".text.ftrace_trampoline", "ax"
-   .align  3
-0: .quad   0
-__ftrace_trampoline:
-   ldr x16, 0b
-   br  x16
-ENDPROC(__ftrace_trampoline)
--- a/arch/arm64/kernel/ftrace.c
+++ b/arch/arm64/kernel/ftrace.c
@@ -76,7 +76,7 @@ int ftrace_make_call(struct dyn_ftrace *
 
if (offset < -SZ_128M || offset >= SZ_128M) {
 #ifdef CONFIG_ARM64_MODULE_PLTS
-   unsigned long *trampoline;
+   struct plt_entry trampoline;
struct module *mod;
 
/*
@@ -104,22 +104,24 @@ int ftrace_make_call(struct dyn_ftrace *
 * is added in the future, but for now, the pr_err() below
 * deals with a theoretical issue only.
 */
-   trampoline = (unsigned long *)mod->arch.ftrace_trampoline;
-   if (trampoline[0] != addr) {
-   if (trampoline[0] != 0) {
+   trampoline = get_plt_entry(addr);
+   if (!plt_entries_equal(mod->arch.ftrace_trampoline,
+  &trampoline)) {
+   if (!plt_entries_equal(mod->arch.ftrace_trampoline,
+  &(struct plt_entry){})) {
pr_err("ftrace: far branches to multiple entry 
points unsupported inside a single module\n");
return -EINVAL;
}
 
/* point the trampoline to our ftrace entry point */
module_disable_ro(mod);
-   trampoline[0] = addr;
+   *mod->arch.ftrace_trampoline = trampoline;
module_enable_ro(mod, true);
 
/* update trampoline before patching in the branch */
smp_wmb();
}
-   addr = (unsigned long)&trampoline[1];
+   addr = (unsigned long)(void *)mod->arch.ftrace_trampoline;
 #else /* CO

Re: [Xen-devel] [PATCH V2] Xen/pciback: Implement PCI slot or bus reset with 'do_flr' SysFS attribute

2017-12-04 Thread Govinda Tatti

Jan,

Do you have any further comments on the current version of this patch?. 
Otherwise, I will work on the review comments and publish next version 
of this patch later this week. Please let me know. Thanks.


Cheers
GOVINDA
On 12/1/2017 10:16 AM, Govinda Tatti wrote:


On 11/30/2017 8:46 AM, Jan Beulich wrote:

On 30.11.17 at 15:15,  wrote:

On 11/30/2017 2:27 AM, Jan Beulich wrote:

On 29.11.17 at 18:38,  wrote:
In the case of bus or slot reset, our goal is to reset connected 
PCIe

fabric/card/endpoint.
The connected card/endpoint can be multi-function device. So, same
walk-through and checking
is needed irrespective of type of reset being used.

I don't follow: The scope of other devices/functions possibly
affected by a reset depends on the type of reset, doesn't it?
For PCIe platforms, both slot and bus reset endup resetting all 
connected

device/functions on thesecondary bus (behind the root-port or
downstream-port).

According to my understanding this contradicts the comment
ahead of pci_reset_slot(), which talks of multiple slots per bus.
In such a setup, I can't see why resetting on slot would affect
other slots on the same bus. At the same time the comment
says that the slot reset may resolve to a bus one when there's
just a single slot on the bus.

For legacy PCI/PCI-X, we can have multiple slots per bus but not with
PCI-Express
(each link will be on a separate bus).

Is that true even for root complex integrated end points? A
random system's lspci output doesn't seem to agree with what
you say. A typical example would be USB controllers all sitting
on bus 0, but having different slot numbers. You clearly won't
be able to ever bus-reset these, and if you checked all devices
on bus 0 you would then also not be able to slot-reset them.

Here, slot reset refers to any PCIe slot that implements or supports
hotplug feature. The slot reset ultimately invokes "pciehp_reset_slot()".
W.r.t integrated endpoints, these can be reset either through FLR or
secondary bus reset methods only.

Cheers
GOVINDA

___
Xen-devel mailing list
xen-de...@lists.xenproject.org
https://lists.xenproject.org/mailman/listinfo/xen-devel




[PATCH 4.14 58/95] hwmon: (jc42) optionally try to disable the SMBUS timeout

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Rosin 

commit 68615eb01f82256c19e41967bfb3eef902f77033 upstream.

With a nxp,se97 chip on an atmel sama5d31 board, the I2C adapter driver
is not always capable of avoiding the 25-35 ms timeout as specified by
the SMBUS protocol. This may cause silent corruption of the last bit of
any transfer, e.g. a one is read instead of a zero if the sensor chip
times out. This also affects the eeprom half of the nxp-se97 chip, where
this silent corruption was originally noticed. Other I2C adapters probably
suffer similar issues, e.g. bit-banging comes to mind as risky...

The SMBUS register in the nxp chip is not a standard Jedec register, but
it is not special to the nxp chips either, at least the atmel chips
have the same mechanism. Therefore, do not special case this on the
manufacturer, it is opt-in via the device property anyway.

Signed-off-by: Peter Rosin 
Acked-by: Rob Herring 
Signed-off-by: Guenter Roeck 
Signed-off-by: Greg Kroah-Hartman 

---
 Documentation/devicetree/bindings/hwmon/jc42.txt |4 
 drivers/hwmon/jc42.c |   21 +
 2 files changed, 25 insertions(+)

--- a/Documentation/devicetree/bindings/hwmon/jc42.txt
+++ b/Documentation/devicetree/bindings/hwmon/jc42.txt
@@ -34,6 +34,10 @@ Required properties:
 
 - reg: I2C address
 
+Optional properties:
+- smbus-timeout-disable: When set, the smbus timeout function will be disabled.
+This is not supported on all chips.
+
 Example:
 
 temp-sensor@1a {
--- a/drivers/hwmon/jc42.c
+++ b/drivers/hwmon/jc42.c
@@ -22,6 +22,7 @@
  * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
  */
 
+#include 
 #include 
 #include 
 #include 
@@ -45,6 +46,7 @@ static const unsigned short normal_i2c[]
 #define JC42_REG_TEMP  0x05
 #define JC42_REG_MANID 0x06
 #define JC42_REG_DEVICEID  0x07
+#define JC42_REG_SMBUS 0x22 /* NXP and Atmel, possibly others? */
 
 /* Status bits in temperature register */
 #define JC42_ALARM_CRIT_BIT15
@@ -75,6 +77,9 @@ static const unsigned short normal_i2c[]
 #define GT_MANID   0x1c68  /* Giantec */
 #define GT_MANID2  0x132d  /* Giantec, 2nd mfg ID */
 
+/* SMBUS register */
+#define SMBUS_STMOUT   BIT(7)  /* SMBus time-out, active low */
+
 /* Supported chips */
 
 /* Analog Devices */
@@ -495,6 +500,22 @@ static int jc42_probe(struct i2c_client
 
data->extended = !!(cap & JC42_CAP_RANGE);
 
+   if (device_property_read_bool(dev, "smbus-timeout-disable")) {
+   int smbus;
+
+   /*
+* Not all chips support this register, but from a
+* quick read of various datasheets no chip appears
+* incompatible with the below attempt to disable
+* the timeout. And the whole thing is opt-in...
+*/
+   smbus = i2c_smbus_read_word_swapped(client, JC42_REG_SMBUS);
+   if (smbus < 0)
+   return smbus;
+   i2c_smbus_write_word_swapped(client, JC42_REG_SMBUS,
+smbus | SMBUS_STMOUT);
+   }
+
config = i2c_smbus_read_word_swapped(client, JC42_REG_CONFIG);
if (config < 0)
return config;




[PATCH 4.14 31/95] omapdrm: hdmi4: Correct the SoC revision matching

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Peter Ujfalusi 

commit 23970e150a0a49f9a966c46e5d22fed06226098f upstream.

I believe the intention of the commit 2c9fc9bf45f8
("drm: omapdrm: Move FEAT_HDMI_* features to hdmi4 driver")
was to identify omap4430 ES1.x, omap4430 ES2.x and other OMAP4 revisions,
like omap4460.

By using family=OMAP4 in the match the code will treat omap4460 ES1.x in a
same way as it would treat omap4430 ES1.x

This breaks HDMI audio on OMAP4460 devices (PandaES for example).

Correct the match rule so we are not going to get false positive match.

Fixes: 2c9fc9bf45f8 ("drm: omapdrm: Move FEAT_HDMI_* features to hdmi4 driver")

Signed-off-by: Peter Ujfalusi 
Reviewed-by: Laurent Pinchart 
Signed-off-by: Tomi Valkeinen 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/omapdrm/dss/hdmi4_core.c |   23 +--
 1 file changed, 17 insertions(+), 6 deletions(-)

--- a/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c
+++ b/drivers/gpu/drm/omapdrm/dss/hdmi4_core.c
@@ -889,25 +889,36 @@ struct hdmi4_features {
bool audio_use_mclk;
 };
 
-static const struct hdmi4_features hdmi4_es1_features = {
+static const struct hdmi4_features hdmi4430_es1_features = {
.cts_swmode = false,
.audio_use_mclk = false,
 };
 
-static const struct hdmi4_features hdmi4_es2_features = {
+static const struct hdmi4_features hdmi4430_es2_features = {
.cts_swmode = true,
.audio_use_mclk = false,
 };
 
-static const struct hdmi4_features hdmi4_es3_features = {
+static const struct hdmi4_features hdmi4_features = {
.cts_swmode = true,
.audio_use_mclk = true,
 };
 
 static const struct soc_device_attribute hdmi4_soc_devices[] = {
-   { .family = "OMAP4", .revision = "ES1.?", .data = &hdmi4_es1_features },
-   { .family = "OMAP4", .revision = "ES2.?", .data = &hdmi4_es2_features },
-   { .family = "OMAP4",  .data = &hdmi4_es3_features },
+   {
+   .machine = "OMAP4430",
+   .revision = "ES1.?",
+   .data = &hdmi4430_es1_features,
+   },
+   {
+   .machine = "OMAP4430",
+   .revision = "ES2.?",
+   .data = &hdmi4430_es2_features,
+   },
+   {
+   .family = "OMAP4",
+   .data = &hdmi4_features,
+   },
{ /* sentinel */ }
 };
 




Re: [PATCH resend v2] mux: core: Fix double get_device()

2017-12-04 Thread Peter Rosin
On 2017-11-28 10:05, Hans de Goede wrote:
> class_find_device already does a get_device on the returned device.
> So the device returned by of_find_mux_chip_by_node is already referenced
> and we should not reference it again (and unref it on error).
> 
> Also rename of_find_mux_chip_by_node to of_get_mux_chip_by_node to
> make it clear that it returns a reference.

Yep, I forgot. Sorry about that. I'll try to do better this time...

Cheers,
Peter

> Signed-off-by: Hans de Goede 
> ---
> Changes in v2:
> -Do not rename of_find_mux_chip_by_node
> ---
>  drivers/mux/core.c | 4 +++-
>  1 file changed, 3 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/mux/core.c b/drivers/mux/core.c
> index 2260063b0ea8..6e5cf9d9cd99 100644
> --- a/drivers/mux/core.c
> +++ b/drivers/mux/core.c
> @@ -413,6 +413,7 @@ static int of_dev_node_match(struct device *dev, const 
> void *data)
>   return dev->of_node == data;
>  }
>  
> +/* Note this function returns a reference to the mux_chip dev. */
>  static struct mux_chip *of_find_mux_chip_by_node(struct device_node *np)
>  {
>   struct device *dev;
> @@ -466,6 +467,7 @@ struct mux_control *mux_control_get(struct device *dev, 
> const char *mux_name)
>   (!args.args_count && (mux_chip->controllers > 1))) {
>   dev_err(dev, "%pOF: wrong #mux-control-cells for %pOF\n",
>   np, args.np);
> + put_device(&mux_chip->dev);
>   return ERR_PTR(-EINVAL);
>   }
>  
> @@ -476,10 +478,10 @@ struct mux_control *mux_control_get(struct device *dev, 
> const char *mux_name)
>   if (controller >= mux_chip->controllers) {
>   dev_err(dev, "%pOF: bad mux controller %u specified in %pOF\n",
>   np, controller, args.np);
> + put_device(&mux_chip->dev);
>   return ERR_PTR(-EINVAL);
>   }
>  
> - get_device(&mux_chip->dev);
>   return &mux_chip->mux[controller];
>  }
>  EXPORT_SYMBOL_GPL(mux_control_get);
> 



[PATCH 4.14 53/95] i2c: i801: Fix Failed to allocate irq -2147483648 error

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Hans de Goede 

commit 6e0c9507bf51e1517a80ad0ac171e5402528fcef upstream.

On Apollo Lake devices the BIOS does not set up IRQ routing for the i801
SMBUS controller IRQ, so we end up with dev->irq set to IRQ_NOTCONNECTED.

Detect this and do not try to use the irq in this case silencing:
i801_smbus :00:1f.1: Failed to allocate irq -2147483648: -107

BugLink: https://communities.intel.com/thread/114759
Signed-off-by: Hans de Goede 
Reviewed-by: Jean Delvare 
Signed-off-by: Wolfram Sang 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/i2c/busses/i2c-i801.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/i2c/busses/i2c-i801.c
+++ b/drivers/i2c/busses/i2c-i801.c
@@ -1617,6 +1617,9 @@ static int i801_probe(struct pci_dev *de
/* Default timeout in interrupt mode: 200 ms */
priv->adapter.timeout = HZ / 5;
 
+   if (dev->irq == IRQ_NOTCONNECTED)
+   priv->features &= ~FEATURE_IRQ;
+
if (priv->features & FEATURE_IRQ) {
u16 pcictl, pcists;
 




[PATCH 4.14 52/95] eeprom: at24: check at24_read/write arguments

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Heiner Kallweit 

commit d9bcd462daf34aebb8de9ad7f76de0198bb5a0f0 upstream.

So far we completely rely on the caller to provide valid arguments.
To be on the safe side perform an own sanity check.

Signed-off-by: Heiner Kallweit 
Signed-off-by: Bartosz Golaszewski 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/misc/eeprom/at24.c |6 ++
 1 file changed, 6 insertions(+)

--- a/drivers/misc/eeprom/at24.c
+++ b/drivers/misc/eeprom/at24.c
@@ -507,6 +507,9 @@ static int at24_read(void *priv, unsigne
if (unlikely(!count))
return count;
 
+   if (off + count > at24->chip.byte_len)
+   return -EINVAL;
+
/*
 * Read data from chip, protecting against concurrent updates
 * from this host, but not from other I2C masters.
@@ -539,6 +542,9 @@ static int at24_write(void *priv, unsign
if (unlikely(!count))
return -EINVAL;
 
+   if (off + count > at24->chip.byte_len)
+   return -EINVAL;
+
/*
 * Write data to chip, protecting against concurrent updates
 * from this host, but not from other I2C masters.




[PATCH 4.14 54/95] cxl: Check if vphb exists before iterating over AFU devices

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Vaibhav Jain 

commit 12841f87b7a8ceb3d54f171660f72a86941bfcb3 upstream.

During an eeh a kernel-oops is reported if no vPHB is allocated to the
AFU. This happens as during AFU init, an error in creation of vPHB is
a non-fatal error. Hence afu->phb should always be checked for NULL
before iterating over it for the virtual AFU pci devices.

This patch fixes the kenel-oops by adding a NULL pointer check for
afu->phb before it is dereferenced.

Fixes: 9e8df8a21963 ("cxl: EEH support")
Signed-off-by: Vaibhav Jain 
Acked-by: Andrew Donnellan 
Acked-by: Frederic Barrat 
Signed-off-by: Michael Ellerman 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/misc/cxl/pci.c |   12 ++--
 1 file changed, 10 insertions(+), 2 deletions(-)

--- a/drivers/misc/cxl/pci.c
+++ b/drivers/misc/cxl/pci.c
@@ -2043,6 +2043,9 @@ static pci_ers_result_t cxl_vphb_error_d
/* There should only be one entry, but go through the list
 * anyway
 */
+   if (afu->phb == NULL)
+   return result;
+
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) {
if (!afu_dev->driver)
continue;
@@ -2084,8 +2087,7 @@ static pci_ers_result_t cxl_pci_error_de
 * Tell the AFU drivers; but we don't care what they
 * say, we're going away.
 */
-   if (afu->phb != NULL)
-   cxl_vphb_error_detected(afu, state);
+   cxl_vphb_error_detected(afu, state);
}
return PCI_ERS_RESULT_DISCONNECT;
}
@@ -2225,6 +2227,9 @@ static pci_ers_result_t cxl_pci_slot_res
if (cxl_afu_select_best_mode(afu))
goto err;
 
+   if (afu->phb == NULL)
+   continue;
+
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) 
{
/* Reset the device context.
 * TODO: make this less disruptive
@@ -2287,6 +2292,9 @@ static void cxl_pci_resume(struct pci_de
for (i = 0; i < adapter->slices; i++) {
afu = adapter->afu[i];
 
+   if (afu->phb == NULL)
+   continue;
+
list_for_each_entry(afu_dev, &afu->phb->bus->devices, bus_list) 
{
if (afu_dev->driver && afu_dev->driver->err_handler &&
afu_dev->driver->err_handler->resume)




[PATCH 4.14 48/95] mmc: core: prepend 0x to OCR entry in sysfs

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Bastian Stender 

commit c892b0d81705c566f575e489efc3c50762db1bde upstream.

The sysfs entry "ocr" was missing the 0x prefix to identify it as hex
formatted.

Fixes: 5fb06af7a33b ("mmc: core: Extend sysfs with OCR register")
Signed-off-by: Bastian Stender 
[Ulf: Amended change to also cover SD-cards]
Signed-off-by: Ulf Hansson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/mmc/core/mmc.c |2 +-
 drivers/mmc/core/sd.c  |2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -790,7 +790,7 @@ MMC_DEV_ATTR(enhanced_area_offset, "%llu
 MMC_DEV_ATTR(enhanced_area_size, "%u\n", card->ext_csd.enhanced_area_size);
 MMC_DEV_ATTR(raw_rpmb_size_mult, "%#x\n", card->ext_csd.raw_rpmb_size_mult);
 MMC_DEV_ATTR(rel_sectors, "%#x\n", card->ext_csd.rel_sectors);
-MMC_DEV_ATTR(ocr, "%08x\n", card->ocr);
+MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr);
 MMC_DEV_ATTR(cmdq_en, "%d\n", card->ext_csd.cmdq_en);
 
 static ssize_t mmc_fwrev_show(struct device *dev,
--- a/drivers/mmc/core/sd.c
+++ b/drivers/mmc/core/sd.c
@@ -675,7 +675,7 @@ MMC_DEV_ATTR(manfid, "0x%06x\n", card->c
 MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
 MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
 MMC_DEV_ATTR(serial, "0x%08x\n", card->cid.serial);
-MMC_DEV_ATTR(ocr, "%08x\n", card->ocr);
+MMC_DEV_ATTR(ocr, "0x%08x\n", card->ocr);
 
 
 static ssize_t mmc_dsr_show(struct device *dev,




[PATCH 4.14 30/95] drm: omapdrm: Fix DPI on platforms using the DSI VDDS

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Laurent Pinchart 

commit bf25dac38f71d392a31ec074f55cbc941f1eaf1d upstream.

Commit d178e034d565 ("drm: omapdrm: Move FEAT_DPI_USES_VDDS_DSI feature
to dpi code") replaced usage of platform data version with SoC matching
to configure DPI VDDS. The SoC match entries were incorrect, they should
have matched on the machine name instead of the SoC family. Fix it.

The result was observed on OpenPandora with OMAP3530 where the panel only
had the Blue channel and Red&Green were missing. It was not observed on
GTA04 with DM3730.

Fixes: d178e034d565 ("drm: omapdrm: Move FEAT_DPI_USES_VDDS_DSI feature to dpi 
code")
Signed-off-by: Laurent Pinchart 
Reported-by: H. Nikolaus Schaller 
Tested-by: H. Nikolaus Schaller 
Signed-off-by: Tomi Valkeinen 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/gpu/drm/omapdrm/dss/dpi.c |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

--- a/drivers/gpu/drm/omapdrm/dss/dpi.c
+++ b/drivers/gpu/drm/omapdrm/dss/dpi.c
@@ -566,8 +566,8 @@ static int dpi_verify_pll(struct dss_pll
 }
 
 static const struct soc_device_attribute dpi_soc_devices[] = {
-   { .family = "OMAP3[456]*" },
-   { .family = "[AD]M37*" },
+   { .machine = "OMAP3[456]*" },
+   { .machine = "[AD]M37*" },
{ /* sentinel */ }
 };
 




[PATCH 4.14 49/95] ACPI / EC: Fix regression related to PM ops support in ECDT device

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Lv Zheng 

commit a64a62ce9a380213dc9e192f762266d70c9b40ec upstream.

On platforms (ASUS X550ZE and possibly all ASUS X series) with valid ECDT
EC but invalid DSDT EC, EC PM ops won't be invoked as ECDT EC is not an
ACPI device. Thus the following commit actually removed post-resume
acpi_ec_enable_event() invocation for such platforms, and triggered a
regression on them that after being resumed, EC (actually should be ECDT)
driver stops handling EC events:

 Commit: c2b46d679b30c5c0d7eb47a21085943242bdd8dc
 Subject: ACPI / EC: Add PM operations to improve event handling for resume 
process

Notice that the root cause actually is "ECDT is not an ACPI device" rather
than "the timing of acpi_ec_enable_event() invocation", this patch fixes
this issue by enumerating ECDT EC as an ACPI device. Due to the existence
of the noirq stage, the ability of tuning the timing of
acpi_ec_enable_event() invocation is still meaningful.

This patch is a little bit different from the posted fix by moving
acpi_config_boot_ec() from acpi_ec_ecdt_start() to acpi_ec_add() to make
sure that EC event handling won't be stopped as long as the ACPI EC driver
is bound. Thus the following sequence shouldn't disable EC event handling:
unbind,suspend,resume,bind.

Fixes: c2b46d679b30 (ACPI / EC: Add PM operations to improve event handling for 
resume process)
Link: https://bugzilla.kernel.org/show_bug.cgi?id=196847
Reported-by: Luya Tshimbalanga 
Tested-by: Luya Tshimbalanga 
Signed-off-by: Lv Zheng 
Signed-off-by: Rafael J. Wysocki 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/acpi/ec.c   |   69 
 drivers/acpi/internal.h |1 
 drivers/acpi/scan.c |   21 +
 include/acpi/acpi_bus.h |1 
 include/acpi/acpi_drivers.h |1 
 5 files changed, 69 insertions(+), 24 deletions(-)

--- a/drivers/acpi/ec.c
+++ b/drivers/acpi/ec.c
@@ -1597,32 +1597,41 @@ static int acpi_ec_add(struct acpi_devic
 {
struct acpi_ec *ec = NULL;
int ret;
+   bool is_ecdt = false;
+   acpi_status status;
 
strcpy(acpi_device_name(device), ACPI_EC_DEVICE_NAME);
strcpy(acpi_device_class(device), ACPI_EC_CLASS);
 
-   ec = acpi_ec_alloc();
-   if (!ec)
-   return -ENOMEM;
-   if (ec_parse_device(device->handle, 0, ec, NULL) !=
-   AE_CTRL_TERMINATE) {
+   if (!strcmp(acpi_device_hid(device), ACPI_ECDT_HID)) {
+   is_ecdt = true;
+   ec = boot_ec;
+   } else {
+   ec = acpi_ec_alloc();
+   if (!ec)
+   return -ENOMEM;
+   status = ec_parse_device(device->handle, 0, ec, NULL);
+   if (status != AE_CTRL_TERMINATE) {
ret = -EINVAL;
goto err_alloc;
+   }
}
 
if (acpi_is_boot_ec(ec)) {
-   boot_ec_is_ecdt = false;
-   /*
-* Trust PNP0C09 namespace location rather than ECDT ID.
-*
-* But trust ECDT GPE rather than _GPE because of ASUS quirks,
-* so do not change boot_ec->gpe to ec->gpe.
-*/
-   boot_ec->handle = ec->handle;
-   acpi_handle_debug(ec->handle, "duplicated.\n");
-   acpi_ec_free(ec);
-   ec = boot_ec;
-   ret = acpi_config_boot_ec(ec, ec->handle, true, false);
+   boot_ec_is_ecdt = is_ecdt;
+   if (!is_ecdt) {
+   /*
+* Trust PNP0C09 namespace location rather than
+* ECDT ID. But trust ECDT GPE rather than _GPE
+* because of ASUS quirks, so do not change
+* boot_ec->gpe to ec->gpe.
+*/
+   boot_ec->handle = ec->handle;
+   acpi_handle_debug(ec->handle, "duplicated.\n");
+   acpi_ec_free(ec);
+   ec = boot_ec;
+   }
+   ret = acpi_config_boot_ec(ec, ec->handle, true, is_ecdt);
} else
ret = acpi_ec_setup(ec, true);
if (ret)
@@ -1635,8 +1644,10 @@ static int acpi_ec_add(struct acpi_devic
ret = !!request_region(ec->command_addr, 1, "EC cmd");
WARN(!ret, "Could not request EC cmd io port 0x%lx", ec->command_addr);
 
-   /* Reprobe devices depending on the EC */
-   acpi_walk_dep_device_list(ec->handle);
+   if (!is_ecdt) {
+   /* Reprobe devices depending on the EC */
+   acpi_walk_dep_device_list(ec->handle);
+   }
acpi_handle_debug(ec->handle, "enumerated.\n");
return 0;
 
@@ -1692,6 +1703,7 @@ ec_parse_io_ports(struct acpi_resource *
 
 static const struct acpi_device_id ec_device_ids[] = {
{"PNP0C09

Re: [PATCH v4.1] phylib: Add device reset GPIO support

2017-12-04 Thread Richard Leitner

On 12/04/2017 01:35 PM, Geert Uytterhoeven wrote:
> From: Sergei Shtylyov 
> 
> The PHY devices sometimes do have their reset signal (maybe even power
> supply?) tied to some GPIO and sometimes it also does happen that a boot
> loader does not leave it deasserted. So far this issue has been attacked
> from (as I believe) a wrong angle: by teaching the MAC driver to manipulate
> the GPIO in question; that solution, when applied to the device trees, led
> to adding the PHY reset GPIO properties to the MAC device node, with one
> exception: Cadence MACB driver which could handle the "reset-gpios" prop
> in a PHY device subnode. I believe that the correct approach is to teach
> the 'phylib' to get the MDIO device reset GPIO from the device tree node
> corresponding to this device -- which this patch is doing...
> 
> Note that I had to modify the AT803x PHY driver as it would stop working
> otherwise -- it made use of the reset GPIO for its own purposes...
> 
> Signed-off-by: Sergei Shtylyov 
> Acked-by: Rob Herring 
> [geert: Propagate actual errors from fwnode_get_named_gpiod()]
> [geert: Avoid destroying initial setup]
> [geert: Consolidate GPIO descriptor acquiring code]
> Signed-off-by: Geert Uytterhoeven 
> ---

Successfully tested this patch on a i.MX6SOLO based board containing a
LAN8710 PHY:

Tested-by: Richard Leitner 


Re: [PATCH 03/10] net: ezchip: nps_enet: Fix platform_get_irq's error checking

2017-12-04 Thread David Miller
From: Arvind Yadav 
Date: Sun,  3 Dec 2017 00:56:15 +0530

> The platform_get_irq() function returns negative if an error occurs.
> zero or positive number on success. platform_get_irq() error checking
> for zero is not correct. And remove unnecessary check for free_netdev().
> 
> Signed-off-by: Arvind Yadav 
> ---
>  drivers/net/ethernet/ezchip/nps_enet.c | 7 +++
>  1 file changed, 3 insertions(+), 4 deletions(-)
> 
> diff --git a/drivers/net/ethernet/ezchip/nps_enet.c 
> b/drivers/net/ethernet/ezchip/nps_enet.c
> index 659f1ad..82dc6d0 100644
> --- a/drivers/net/ethernet/ezchip/nps_enet.c
> +++ b/drivers/net/ethernet/ezchip/nps_enet.c
> @@ -623,9 +623,9 @@ static s32 nps_enet_probe(struct platform_device *pdev)
>  
>   /* Get IRQ number */
>   priv->irq = platform_get_irq(pdev, 0);
> - if (!priv->irq) {
> + if (priv->irq <= 0) {
>   dev_err(dev, "failed to retrieve  value from device 
> tree\n");
> - err = -ENODEV;
> + err = priv->irq ? priv->irq : -ENODEV;

If platform_get_irq() returns "zero or positive number on success" then this
test is wrong and should be "if (priv->irq < 0)"

Also, this series is a mix of different kinds of changes.

Please separate out the platform IRQ error checking and just submit exactly
those changes as a patch series.

The other bug fixes should be submitted outside of those changes since they
are unrelated.


[PATCH 4.14 47/95] mmc: core: prepend 0x to pre_eol_info entry in sysfs

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Bastian Stender 

commit 80a780a167d9267c72867b806142bd6ec69ba123 upstream.

The sysfs entry "pre_eol_info" was missing the 0x prefix to identify it
as hex formatted.

Fixes: 46bc5c408e4e ("mmc: core: Export device lifetime information through 
sysfs")
Signed-off-by: Bastian Stender 
Signed-off-by: Ulf Hansson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/mmc/core/mmc.c |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

--- a/drivers/mmc/core/mmc.c
+++ b/drivers/mmc/core/mmc.c
@@ -780,7 +780,7 @@ MMC_DEV_ATTR(manfid, "0x%06x\n", card->c
 MMC_DEV_ATTR(name, "%s\n", card->cid.prod_name);
 MMC_DEV_ATTR(oemid, "0x%04x\n", card->cid.oemid);
 MMC_DEV_ATTR(prv, "0x%x\n", card->cid.prv);
-MMC_DEV_ATTR(pre_eol_info, "%02x\n", card->ext_csd.pre_eol_info);
+MMC_DEV_ATTR(pre_eol_info, "0x%02x\n", card->ext_csd.pre_eol_info);
 MMC_DEV_ATTR(life_time, "0x%02x 0x%02x\n",
card->ext_csd.device_life_time_est_typ_a,
card->ext_csd.device_life_time_est_typ_b);




Re: 4.14: WARNING: CPU: 4 PID: 2895 at block/blk-mq.c:1144 with virtio-blk (also 4.12 stable)

2017-12-04 Thread Christoph Hellwig
On Wed, Nov 29, 2017 at 08:18:09PM +0100, Christian Borntraeger wrote:
> Works fine under KVM with virtio-blk, but still hangs during boot in an LPAR.
> FWIW, the system not only has scsi disks via fcp but also DASDs as a boot 
> disk.
> Seems that this is the place where the system stops. (see the sysrq-t output
> at the bottom).

Can you check which of the patches in the tree is the culprit?


[PATCH 4.14 45/95] mmc: core: Do not leave the block driver in a suspended state

2017-12-04 Thread Greg Kroah-Hartman
4.14-stable review patch.  If anyone has any objections, please let me know.

--

From: Adrian Hunter 

commit ebe7dd45cf49e3b49cacbaace17f9f878f21fbea upstream.

The block driver must be resumed if the mmc bus fails to suspend the card.

Signed-off-by: Adrian Hunter 
Reviewed-by: Linus Walleij 
Signed-off-by: Ulf Hansson 
Signed-off-by: Greg Kroah-Hartman 

---
 drivers/mmc/core/bus.c |3 +++
 1 file changed, 3 insertions(+)

--- a/drivers/mmc/core/bus.c
+++ b/drivers/mmc/core/bus.c
@@ -157,6 +157,9 @@ static int mmc_bus_suspend(struct device
return ret;
 
ret = host->bus_ops->suspend(host);
+   if (ret)
+   pm_generic_resume(dev);
+
return ret;
 }
 




  1   2   3   4   5   6   7   8   9   10   >