[PATCH 3/5] powerpc/eeh: Freeze PE before PE reset

2014-08-17 Thread Gavin Shan
The patch adds one more option (EEH_OPT_FREEZE_PE) to set_option()
method to proactively freeze PE, which will be issued before resetting
pass-throughed PE to drop MMIO access during reset because it's
always contributing to recursive EEH error.

Signed-off-by: Gavin Shan gws...@linux.vnet.ibm.com
---
 arch/powerpc/include/asm/eeh.h   |  1 +
 arch/powerpc/kernel/eeh.c|  7 +
 arch/powerpc/platforms/powernv/eeh-ioda.c| 43 +---
 arch/powerpc/platforms/pseries/eeh_pseries.c |  4 ++-
 4 files changed, 44 insertions(+), 11 deletions(-)

diff --git a/arch/powerpc/include/asm/eeh.h b/arch/powerpc/include/asm/eeh.h
index adcddb1..f98b1b5 100644
--- a/arch/powerpc/include/asm/eeh.h
+++ b/arch/powerpc/include/asm/eeh.h
@@ -167,6 +167,7 @@ enum {
 #define EEH_OPT_ENABLE 1   /* EEH enable   */
 #define EEH_OPT_THAW_MMIO  2   /* MMIO enable  */
 #define EEH_OPT_THAW_DMA   3   /* DMA enable   */
+#define EEH_OPT_FREEZE_PE  4   /* Freeze PE*/
 #define EEH_STATE_UNAVAILABLE  (1  0)/* State unavailable*/
 #define EEH_STATE_NOT_SUPPORT  (1  1)/* EEH not supported*/
 #define EEH_STATE_RESET_ACTIVE (1  2)/* Active reset */
diff --git a/arch/powerpc/kernel/eeh.c b/arch/powerpc/kernel/eeh.c
index 17cf52ba..898c75f 100644
--- a/arch/powerpc/kernel/eeh.c
+++ b/arch/powerpc/kernel/eeh.c
@@ -1382,6 +1382,13 @@ int eeh_pe_reset(struct eeh_pe *pe, int option)
break;
case EEH_RESET_HOT:
case EEH_RESET_FUNDAMENTAL:
+   /*
+* Proactively freeze the PE to drop all MMIO access
+* during reset, which should be banned as it's always
+* cause recursive EEH error.
+*/
+   eeh_ops-set_option(pe, EEH_OPT_FREEZE_PE);
+
ret = eeh_ops-reset(pe, option);
break;
default:
diff --git a/arch/powerpc/platforms/powernv/eeh-ioda.c 
b/arch/powerpc/platforms/powernv/eeh-ioda.c
index c945bed..f3027b9 100644
--- a/arch/powerpc/platforms/powernv/eeh-ioda.c
+++ b/arch/powerpc/platforms/powernv/eeh-ioda.c
@@ -189,6 +189,7 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int 
option)
 {
struct pci_controller *hose = pe-phb;
struct pnv_phb *phb = hose-private_data;
+   bool freeze_pe = false;
int enable, ret = 0;
s64 rc;
 
@@ -212,6 +213,10 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int 
option)
case EEH_OPT_THAW_DMA:
enable = OPAL_EEH_ACTION_CLEAR_FREEZE_DMA;
break;
+   case EEH_OPT_FREEZE_PE:
+   freeze_pe = true;
+   enable = OPAL_EEH_ACTION_SET_FREEZE_ALL;
+   break;
default:
pr_warn(%s: Invalid option %d\n,
__func__, option);
@@ -219,17 +224,35 @@ static int ioda_eeh_set_option(struct eeh_pe *pe, int 
option)
}
 
/* If PHB supports compound PE, to handle it */
-   if (phb-unfreeze_pe) {
-   ret = phb-unfreeze_pe(phb, pe-addr, enable);
+   if (freeze_pe) {
+   if (phb-freeze_pe) {
+   phb-freeze_pe(phb, pe-addr);
+   } else {
+   rc = opal_pci_eeh_freeze_set(phb-opal_id,
+pe-addr,
+enable);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn(%s: Failure %lld freezing 
+   PHB#%x-PE#%x\n,
+   __func__, rc,
+   phb-hose-global_number, pe-addr);
+   ret = -EIO;
+   }
+   }
} else {
-   rc = opal_pci_eeh_freeze_clear(phb-opal_id,
-  pe-addr,
-  enable);
-   if (rc != OPAL_SUCCESS) {
-   pr_warn(%s: Failure %lld enable %d for PHB#%x-PE#%x\n,
-   __func__, rc, option, phb-hose-global_number,
-   pe-addr);
-   ret = -EIO;
+   if (phb-unfreeze_pe) {
+   ret = phb-unfreeze_pe(phb, pe-addr, enable);
+   } else {
+   rc = opal_pci_eeh_freeze_clear(phb-opal_id,
+  pe-addr,
+  enable);
+   if (rc != OPAL_SUCCESS) {
+   pr_warn(%s: Failure %lld enable %d 
+   for PHB#%x-PE#%x\n,
+   __func__, rc, option,
+   phb-hose-global_number, pe-addr);
+

[PATCH 0/5] powerpc: EEH fixes

2014-08-17 Thread Gavin Shan
The series of patches is to fix recursive EEH error during recovery
for VFIO-PCI except some cleanup. The recursive EEH error is caused
by MMIO access when the PE is under reset or the PCI device isn't
enabled yet. The solution is to freeze the PE until the PCI device
is enabled after PE reset.

Another issue is that one specific PE is frozen when being passed
through. It caused the device can't work properly in userland (e.g.
QEMU). The fix is to clear the frozen state when passing PE to
userland.

Gavin Shan (5):
  powerpc/eeh: Drop unused argument in eeh_check_failure()
  powerpc/eeh: Add eeh_pe_state sysfs entry
  powerpc/eeh: Freeze PE before PE reset
  powerpc/eeh: Reenable PCI devices after reset
  powerpc/eeh: Clear frozen state on passing device

 arch/powerpc/include/asm/eeh.h   |  30 +++
 arch/powerpc/kernel/eeh.c| 116 +--
 arch/powerpc/kernel/eeh_sysfs.c  |  61 +-
 arch/powerpc/platforms/powernv/eeh-ioda.c|  43 +++---
 arch/powerpc/platforms/pseries/eeh_pseries.c |   4 +-
 5 files changed, 203 insertions(+), 51 deletions(-)

-- 
1.8.3.2

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

Re: Build regressions/improvements in v3.17-rc1

2014-08-17 Thread Geert Uytterhoeven
On Sun, Aug 17, 2014 at 10:45 PM, Geert Uytterhoeven
ge...@linux-m68k.org wrote:
 16 regressions:
   + /scratch/kisskb/src/arch/powerpc/include/asm/floppy.h: error: 
 'isa_bridge_pcidev' undeclared (first use in this function):  = 142:20

powerpc-randconfig

   + /scratch/kisskb/src/fs/hostfs/hostfs_user.c: error: 'AT_FDCWD' undeclared 
 (first use in this function):  = 378
   + /scratch/kisskb/src/fs/hostfs/hostfs_user.c: error: (Each undeclared 
 identifier is reported only once:  = 378
   + /scratch/kisskb/src/fs/hostfs/hostfs_user.c: error: for each function it 
 appears in.):  = 378

um-defconfig

   + /scratch/kisskb/src/kernel/locking/mcs_spinlock.h: error: implicit 
 declaration of function 'cpu_relax_lowlatency' 
 [-Werror=implicit-function-declaration]:  = 87:2

frv-defconfig (somehow the fix never made it past Linus' mbox)

   + error: flush_icache_range [drivers/misc/lkdtm.ko] undefined!:  = N/A

sh-allmodconfig (woohoo, this means it has reached the link phase!)

Gr{oetje,eeting}s,

Geert

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

In personal conversations with technical people, I call myself a hacker. But
when I'm talking to journalists I just say programmer or something like that.
-- Linus Torvalds
___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev

[PATCH v15 4/7] powerpc: add pmd_[dirty|mkclean] for THP

2014-08-17 Thread Minchan Kim
MADV_FREE needs pmd_dirty and pmd_mkclean for detecting recent
overwrite of the contents since MADV_FREE syscall is called for
THP page.

This patch adds pmd_dirty and pmd_mkclean for THP page MADV_FREE
support.

Cc: Benjamin Herrenschmidt b...@kernel.crashing.org
Cc: Paul Mackerras pau...@samba.org
Cc: linuxppc-dev@lists.ozlabs.org
Reviewed-by: Aneesh Kumar K.V aneesh.ku...@linux.vnet.ibm.com
Signed-off-by: Minchan Kim minc...@kernel.org
---
 arch/powerpc/include/asm/pgtable-ppc64.h | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/arch/powerpc/include/asm/pgtable-ppc64.h 
b/arch/powerpc/include/asm/pgtable-ppc64.h
index eb9261024f51..c9a4bbe8e179 100644
--- a/arch/powerpc/include/asm/pgtable-ppc64.h
+++ b/arch/powerpc/include/asm/pgtable-ppc64.h
@@ -468,9 +468,11 @@ static inline pte_t *pmdp_ptep(pmd_t *pmd)
 
 #define pmd_pfn(pmd)   pte_pfn(pmd_pte(pmd))
 #define pmd_young(pmd) pte_young(pmd_pte(pmd))
+#define pmd_dirty(pmd) pte_dirty(pmd_pte(pmd))
 #define pmd_mkold(pmd) pte_pmd(pte_mkold(pmd_pte(pmd)))
 #define pmd_wrprotect(pmd) pte_pmd(pte_wrprotect(pmd_pte(pmd)))
 #define pmd_mkdirty(pmd)   pte_pmd(pte_mkdirty(pmd_pte(pmd)))
+#define pmd_mkclean(pmd)   pte_pmd(pte_mkclean(pmd_pte(pmd)))
 #define pmd_mkyoung(pmd)   pte_pmd(pte_mkyoung(pmd_pte(pmd)))
 #define pmd_mkwrite(pmd)   pte_pmd(pte_mkwrite(pmd_pte(pmd)))
 
-- 
2.0.0

___
Linuxppc-dev mailing list
Linuxppc-dev@lists.ozlabs.org
https://lists.ozlabs.org/listinfo/linuxppc-dev