[PATCH v9] powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform
This patch adds support for OPAL EPOW (Environmental and Power Warnings) and DPO (Delayed Power Off) events for the PowerNV platform. These events are generated on FSP (Flexible Service Processor) based systems. EPOW events are generated due to various critical system conditions that require system shutdown. A few examples of these conditions are high ambient temperature or system running on UPS power with low UPS battery. DPO event is generated in response to admin initiated system shutdown request. Upon receipt of EPOW and DPO events the host kernel invokes orderly_poweroff() for performing graceful system shutdown. Signed-off-by: Vipin K Parashar vi...@linux.vnet.ibm.com Acked-by: Vaibhav Jain vaib...@linux.vnet.ibm.com --- arch/powerpc/include/asm/opal-api.h| 40 +++ arch/powerpc/include/asm/opal.h| 3 +- arch/powerpc/platforms/powernv/opal-power.c| 147 ++--- arch/powerpc/platforms/powernv/opal-wrappers.S | 1 + 4 files changed, 173 insertions(+), 18 deletions(-) diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h index e9e4c52..442995b 100644 --- a/arch/powerpc/include/asm/opal-api.h +++ b/arch/powerpc/include/asm/opal-api.h @@ -756,6 +756,46 @@ struct opal_i2c_request { __be64 buffer_ra; /* Buffer real address */ }; +/* + * EPOW status sharing (OPAL and the host) + * + * The host will pass on OPAL, a buffer of length OPAL_SYSEPOW_MAX + * with individual elements being 16 bits wide to fetch the system + * wide EPOW status. Each element in the buffer will contain the + * EPOW status in it's bit representation for a particular EPOW sub + * class as defiend here. So multiple detailed EPOW status bits + * specific for any sub class can be represented in a single buffer + * element as it's bit representation. + */ + +/* System EPOW type */ +enum OpalSysEpow { + OPAL_SYSEPOW_POWER = 0,/* Power EPOW */ + OPAL_SYSEPOW_TEMP = 1,/* Temperature EPOW */ + OPAL_SYSEPOW_COOLING= 2,/* Cooling EPOW */ + OPAL_SYSEPOW_MAX= 3,/* Max EPOW categories */ +}; + +/* Power EPOW */ +enum OpalSysPower { + OPAL_SYSPOWER_UPS = 0x0001, /* System on UPS power */ + OPAL_SYSPOWER_CHNG = 0x0002, /* System power config change */ + OPAL_SYSPOWER_FAIL = 0x0004, /* System impending power failure */ + OPAL_SYSPOWER_INCL = 0x0008, /* System incomplete power */ +}; + +/* Temperature EPOW */ +enum OpalSysTemp { + OPAL_SYSTEMP_AMB= 0x0001, /* System over ambient temperature */ + OPAL_SYSTEMP_INT= 0x0002, /* System over internal temperature */ + OPAL_SYSTEMP_HMD= 0x0004, /* System over ambient humidity */ +}; + +/* Cooling EPOW */ +enum OpalSysCooling { + OPAL_SYSCOOL_INSF = 0x0001, /* System insufficient cooling */ +}; + #endif /* __ASSEMBLY__ */ #endif /* __OPAL_API_H */ diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index 958e941..a091c27 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h @@ -141,7 +141,8 @@ int64_t opal_pci_fence_phb(uint64_t phb_id); int64_t opal_pci_reinit(uint64_t phb_id, uint64_t reinit_scope, uint64_t data); int64_t opal_pci_mask_pe_error(uint64_t phb_id, uint16_t pe_number, uint8_t error_type, uint8_t mask_action); int64_t opal_set_slot_led_status(uint64_t phb_id, uint64_t slot_id, uint8_t led_type, uint8_t led_action); -int64_t opal_get_epow_status(__be64 *status); +int64_t opal_get_epow_status(__be16 *epow_status, __be16 *num_epow_classes); +int64_t opal_get_dpo_status(__be64 *dpo_timeout); int64_t opal_set_system_attention_led(uint8_t led_action); int64_t opal_pci_next_error(uint64_t phb_id, __be64 *first_frozen_pe, __be16 *pci_error_type, __be16 *severity); diff --git a/arch/powerpc/platforms/powernv/opal-power.c b/arch/powerpc/platforms/powernv/opal-power.c index ac46c2c..58dc330 100644 --- a/arch/powerpc/platforms/powernv/opal-power.c +++ b/arch/powerpc/platforms/powernv/opal-power.c @@ -9,9 +9,12 @@ * 2 of the License, or (at your option) any later version. */ +#define pr_fmt(fmt)opal-power: fmt + #include linux/kernel.h #include linux/reboot.h #include linux/notifier.h +#include linux/of.h #include asm/opal.h #include asm/machdep.h @@ -19,30 +22,116 @@ #define SOFT_OFF 0x00 #define SOFT_REBOOT 0x01 +/* Detect EPOW event */ +static bool detect_epow(void) +{ + u16 epow; + int i, rc; + __be16 epow_classes; + __be16 opal_epow_status[OPAL_SYSEPOW_MAX] = {0}; + + /* + * Check for EPOW event. Kernel sends supported EPOW classes info + * to OPAL. OPAL returns EPOW info along with classes present. + */ + epow_classes = cpu_to_be16(OPAL_SYSEPOW_MAX); + rc = opal_get_epow_status(opal_epow_status, epow_classes); + if (rc != OPAL_SUCCESS) { +
Re: [PATCH V3 2/5] mm: mlock: Add new mlock, munlock, and munlockall system calls
On Tue, Jul 07, 2015 at 01:03:40PM -0400, Eric B Munson wrote: diff --git a/arch/arm/kernel/calls.S b/arch/arm/kernel/calls.S index 05745eb..514e77b 100644 --- a/arch/arm/kernel/calls.S +++ b/arch/arm/kernel/calls.S @@ -397,6 +397,9 @@ /* 385 */CALL(sys_memfd_create) CALL(sys_bpf) CALL(sys_execveat) + CALL(sys_mlock2) + CALL(sys_munlock2) +/* 400 */CALL(sys_munlockall2) s/400/390/ diff --git a/arch/arm64/include/asm/unistd32.h b/arch/arm64/include/asm/unistd32.h index cef934a..318072aa 100644 --- a/arch/arm64/include/asm/unistd32.h +++ b/arch/arm64/include/asm/unistd32.h @@ -797,3 +797,9 @@ __SYSCALL(__NR_memfd_create, sys_memfd_create) __SYSCALL(__NR_bpf, sys_bpf) #define __NR_execveat 387 __SYSCALL(__NR_execveat, compat_sys_execveat) +#define __NR_mlock2 388 +__SYSCALL(__NR_mlock2, sys_mlock2) +#define __NR_munlock2 389 +__SYSCALL(__NR_munlock2, sys_munlock2) +#define __NR_munlockall2 390 +__SYSCALL(__NR_munlockall2, sys_munlockall2) These look fine. Catalin ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v9] powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform
This patch adds support for OPAL EPOW (Environmental and Power Warnings) and DPO (Delayed Power Off) events for the PowerNV platform. These events are generated on FSP (Flexible Service Processor) based systems. EPOW events are generated due to various critical system conditions that require system shutdown. A few examples of these conditions are high ambient temperature or system running on UPS power with low UPS battery. DPO event is generated in response to admin initiated system shutdown request. Upon receipt of EPOW and DPO events the host kernel invokes orderly_poweroff() for performing graceful system shutdown. Changes in v9: - Edited commit log for EPOW acronym expansion and reviewers list. Changes in v8: - Added logic to filter events which doesn't require system shutdown for EPOW scenario. - Re-phrased patch description. Changes in v7: - Fixed logic to check epow support to avoid EPOW, DPO handling path for BMC systems. Changes in v6: - Made below changes as suggested by Michael Ellerman on previous patch. - Changed EPOW, DPO notifier blocks to use opal_power_control_event() and enhanced opal_power_control_event() to handle EPOW and DPO events. - Reorganized code and added/changed few variable, function names removing older ones. - Minor cleanup like removing unused headers, blank lines etc. Changes in v5: - Made changes to address review comments on previous patch. Changes in v4: - Made changes to address review comments on previous patch. Changes in v3: - Made changes to immediately call orderly_poweroff upon receipt of OPAL EPOW, DPO notifications. - Made code changes to address review comments on previous patch. - Made code changes to use existing OPAL EPOW API. - Removed patch to extract EPOW event timeout from OPAL device-tree. Changes in v2: - Made code changes to improve code as per previous review comments. - Added patch to obtain EPOW event timeout values from OPAL device-tree. Vipin K Parashar (1): powerpc/powernv: Add poweroff (EPOW, DPO) events support for PowerNV platform arch/powerpc/include/asm/opal-api.h| 40 +++ arch/powerpc/include/asm/opal.h| 3 +- arch/powerpc/platforms/powernv/opal-power.c| 147 ++--- arch/powerpc/platforms/powernv/opal-wrappers.S | 1 + 4 files changed, 173 insertions(+), 18 deletions(-) -- 1.9.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [2/2] cxl: Fail mmap if requested mapping is larger than assigned problem state area
On Tue, 2015-07-07 at 05:45:46 UTC, Ian Munsie wrote: From: Ian Munsie imun...@au1.ibm.com This patch makes the mmap call fail outright if the requested region is larger than the problem state area assigned to the context so the error is reported immediately rather than waiting for an attempt to access an address out of bounds. Although we never expect users to map more than the assigned problem state area and are not aware of anyone doing this (other than for testing), this does have the potential to break users if someone has used a larger range regardless. I'm submitting it for consideration, but if this change is not considered acceptable the previous patch is sufficient to prevent access out of bounds without breaking anyone. Signed-off-by: Ian Munsie imun...@au1.ibm.com Applied to powerpc fixes, thanks. https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/commit/?h=fixesid=5caaf5346892d1e7f0b8b7223062644f8538483f cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: cxl: Fix refcounting in kernel API
On Tue, 2015-07-07 at 01:01:17 UTC, Michael Neuling wrote: Currently the kernel API AFU dev refcounting is done on context start and stop. This patch moves this refcounting to context init and release, bringing it inline with how the userspace API does it. Without this we've seen the refcounting on the AFU get out of whack between the user and kernel API usage. This causes the AFU structures to be freed when they are actually still in use. This fixes some kref warnings we've been seeing and spurious ErrIVTE IRQs. Signed-off-by: Michael Neuling mi...@neuling.org Acked-by: Ian Munsie imun...@au1.ibm.com Applied to powerpc fixes, thanks. https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/commit/?h=fixesid=3f8dc44d88d3e86178eb9322c779c599f3745b21 cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: powerpc/perf/24x7: Fix lockdep warning
On Tue, 2015-07-07 at 19:37:25 UTC, Sukadev Bhattiprolu wrote: From 370152d9427e57cd9632b00189f71099f8e85544 Mon Sep 17 00:00:00 2001 From: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Date: Tue, 7 Jul 2015 12:21:10 -0400 Subject: [PATCH 1/1] powerpc/perf/24x7: Fix lockdep warning The sysfs attributes for the 24x7 counters are dynamically allocated. Initialize the attributes using sysfs_attr_init() to fix following warning which occurs when CONFIG_DEBUG_LOCK_VMALLOC=y. [0.346249] audit: initializing netlink subsys (disabled) [0.346284] audit: type=2000 audit(1436295254.340:1): initialized [0.346489] BUG: key c000efe90198 not in .data! [0.346491] DEBUG_LOCKS_WARN_ON(1) [0.346502] [ cut here ] [0.346504] WARNING: at ../kernel/locking/lockdep.c:3002 [0.346506] Modules linked in: Reported-by: Gustavo Luiz Duarte gustav...@linux.vnet.ibm.com Signed-off-by: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Tested-by: Gustavo Luiz Duarte gustav...@linux.vnet.ibm.com Applied to powerpc fixes, thanks. https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/commit/?h=fixesid=442053e57a4fc58b719b6ceab60f29ef9cf4404c cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 30/37] usb: gadget: s3c-hsudc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/s3c-hsudc.c | 15 +++ 1 file changed, 15 insertions(+) diff --git a/drivers/usb/gadget/udc/s3c-hsudc.c b/drivers/usb/gadget/udc/s3c-hsudc.c index 85a712a..e9def42 100644 --- a/drivers/usb/gadget/udc/s3c-hsudc.c +++ b/drivers/usb/gadget/udc/s3c-hsudc.c @@ -1005,6 +1005,21 @@ static void s3c_hsudc_initep(struct s3c_hsudc *hsudc, hsep-stopped = 0; hsep-wedge = 0; + if (epnum == 0) { + hsep-ep.caps.type_control = true; + hsep-ep.caps.dir_in = true; + hsep-ep.caps.dir_out = true; + } else { + hsep-ep.caps.type_iso = true; + hsep-ep.caps.type_bulk = true; + hsep-ep.caps.type_int = true; + } + + if (epnum 1) + hsep-ep.caps.dir_in = true; + else + hsep-ep.caps.dir_out = true; + set_index(hsudc, epnum); writel(hsep-ep.maxpacket, hsudc-regs + S3C_MPR); } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [kexec-lite PATCH V2] trampoline: Reset primary cpu endian to big-endian
Hi Scott, Is kexec-lite meant to be specific to book3s-64? It was originally built to test book3s-64 kexec. Likely some other issues need fixing for other ppc sub arches, but it is nice to have a very simple kexec. Anton ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RESEND PATCH] rtc/rtc-opal: Enable alarms only when opal supports tpo
rtc-opal driver provides support for rtc alarms via times-power-on(tpo). However some platforms like BML use a fake rtc clock and don't support tpo. Such platforms are indicated by the missing 'has-tpo' property in the device tree. Current implementation however enables callback for rtc_class_ops.read/set alarm irrespective of the tpo support from the platform. This results in a failed opal call when kernel tries to read an existing alarms via opal_get_tpo_time during rtc device registration. This patch fixes is issue by setting opal_rtc_ops.read/set_alarm callback pointers only when tpo is supported. Acked-by: Michael Neuling mi...@neuling.org Acked-by: Neelesh Gupta neele...@linux.vnet.ibm.com Signed-off-by: Vaibhav Jain vaib...@linux.vnet.ibm.com --- drivers/rtc/rtc-opal.c | 9 + 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/drivers/rtc/rtc-opal.c b/drivers/rtc/rtc-opal.c index 7061dca..1125641 100644 --- a/drivers/rtc/rtc-opal.c +++ b/drivers/rtc/rtc-opal.c @@ -190,11 +190,9 @@ exit: return rc; } -static const struct rtc_class_ops opal_rtc_ops = { +static struct rtc_class_ops opal_rtc_ops = { .read_time = opal_get_rtc_time, .set_time = opal_set_rtc_time, - .read_alarm = opal_get_tpo_time, - .set_alarm = opal_set_tpo_time, }; static int opal_rtc_probe(struct platform_device *pdev) @@ -202,8 +200,11 @@ static int opal_rtc_probe(struct platform_device *pdev) struct rtc_device *rtc; if (pdev-dev.of_node of_get_property(pdev-dev.of_node, has-tpo, -NULL)) +NULL)) { device_set_wakeup_capable(pdev-dev, true); + opal_rtc_ops.read_alarm = opal_get_tpo_time; + opal_rtc_ops.set_alarm = opal_set_tpo_time; + } rtc = devm_rtc_device_register(pdev-dev, DRVNAME, opal_rtc_ops, THIS_MODULE); -- 2.2.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] powerpc/irq: Enable facility unavailable exceptions in /proc/interrupts
This patch enables facility unavailable exceptions for generic facility, FPU, ALTIVEC and VSX in /proc/interrupts listing by incrementing their respective newly added IRQ statistical counters as and when these IRQs happen. This also adds multiple helper functions which will be called from within the interrupt handler context to update their statistics. With this patch being applied, /proc/interrupts looks something like this after running various workloads which create these exceptions. CPU0 CPU1 16: 4262 6166 XICS 2 Level IPI 17: 0 0 XICS 4101 Level virtio0 18: 0 0 XICS 4100 Level ohci_hcd:usb1 20: 0 0 XICS 4096 Level RAS_EPOW 21: 5730 1744 XICS 4102 Level ibmvscsi 22:147 0 XICS 4103 Level hvc_console 24: 0 0 XICS 4104 Level virtio1-config 25: 19167 XICS 4105 Level virtio1-input.0 26: 1 0 XICS 4106 Level virtio1-output.0 LOC: 5278 7996 Local timer interrupts for timer event device LOC: 49 24 Local timer interrupts for others SPU: 0 0 Spurious interrupts PMI: 0 0 Performance monitoring interrupts MCE: 0 0 Machine check exceptions DBL: 0 0 Doorbell interrupts FAC: 0 0 Facility unavailable excpetions FPU: 12172 2549 FPU unavailable excpetions ALT: 22454 7226 ALTIVEC unavailable excpetions VSX: 14 90 VSX unavailable excpetions --- Signed-off-by: Anshuman Khandual khand...@linux.vnet.ibm.com --- arch/powerpc/include/asm/hardirq.h | 4 arch/powerpc/kernel/exceptions-64s.S | 2 ++ arch/powerpc/kernel/irq.c| 23 +++ arch/powerpc/kernel/traps.c | 29 + 4 files changed, 58 insertions(+) diff --git a/arch/powerpc/include/asm/hardirq.h b/arch/powerpc/include/asm/hardirq.h index 8add8b8..bd31390 100644 --- a/arch/powerpc/include/asm/hardirq.h +++ b/arch/powerpc/include/asm/hardirq.h @@ -15,6 +15,10 @@ typedef struct { #ifdef CONFIG_PPC_DOORBELL unsigned int doorbell_irqs; #endif + unsigned int fac_unav_exceptions; + unsigned int fpu_unav_exceptions; + unsigned int altivec_unav_exceptions; + unsigned int vsx_unav_exceptions; } cacheline_aligned irq_cpustat_t; DECLARE_PER_CPU_SHARED_ALIGNED(irq_cpustat_t, irq_stat); diff --git a/arch/powerpc/kernel/exceptions-64s.S b/arch/powerpc/kernel/exceptions-64s.S index 0a0399c2..a86180c 100644 --- a/arch/powerpc/kernel/exceptions-64s.S +++ b/arch/powerpc/kernel/exceptions-64s.S @@ -1158,6 +1158,7 @@ BEGIN_FTR_SECTION END_FTR_SECTION_IFSET(CPU_FTR_TM) #endif bl load_up_fpu + bl fpu_unav_exceptions_count b fast_exception_return #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 2: /* User process was in a transaction */ @@ -1184,6 +1185,7 @@ BEGIN_FTR_SECTION END_FTR_SECTION_NESTED(CPU_FTR_TM, CPU_FTR_TM, 69) #endif bl load_up_altivec + bl altivec_unav_exceptions_count b fast_exception_return #ifdef CONFIG_PPC_TRANSACTIONAL_MEM 2: /* User process was in a transaction */ diff --git a/arch/powerpc/kernel/irq.c b/arch/powerpc/kernel/irq.c index 4509603..fa6559c 100644 --- a/arch/powerpc/kernel/irq.c +++ b/arch/powerpc/kernel/irq.c @@ -397,6 +397,25 @@ int arch_show_interrupts(struct seq_file *p, int prec) seq_printf(p, Doorbell interrupts\n); } #endif + seq_printf(p, %*s: , prec, FAC); + for_each_online_cpu(j) + seq_printf(p, %10u , per_cpu(irq_stat, j).fac_unav_exceptions); + seq_printf(p, Facility unavailable excpetions\n); + + seq_printf(p, %*s: , prec, FPU); + for_each_online_cpu(j) + seq_printf(p, %10u , per_cpu(irq_stat, j).fpu_unav_exceptions); + seq_printf(p, FPU unavailable excpetions\n); + + seq_printf(p, %*s: , prec, ALT); + for_each_online_cpu(j) + seq_printf(p, %10u , per_cpu(irq_stat, j).altivec_unav_exceptions); + seq_printf(p, ALTIVEC unavailable excpetions\n); + + seq_printf(p, %*s: , prec, VSX); + for_each_online_cpu(j) + seq_printf(p, %10u , per_cpu(irq_stat, j).vsx_unav_exceptions); + seq_printf(p, VSX unavailable excpetions\n); return 0; } @@ -416,6 +435,10 @@ u64 arch_irq_stat_cpu(unsigned int cpu) #ifdef CONFIG_PPC_DOORBELL sum += per_cpu(irq_stat, cpu).doorbell_irqs; #endif + sum += per_cpu(irq_stat, cpu).fac_unav_exceptions; + sum += per_cpu(irq_stat, cpu).fpu_unav_exceptions; + sum +=
Re: ipmi/powernv: Fix a minor bug
On Wed, 2015-08-07 at 06:27:28 UTC, Neelesh Gupta wrote: If the OPAL call to receive the ipmi message fails, then we free up the smi message before returning. But, the driver still holds the reference to old smi message in the 'cur_msg' which is dangerous if the driver derefernces it later and it will further block the subsequent ipmi operations. This doesn't sound like a minor bug ? What are the actual symptoms of the bug? Does it crash, always, sometimes? Does it actually block the subsequent ipmi operations? Even if this *is* a minor bug, please give it a proper subject that describes what it does. Also which commit introduced the bug? And finally you don't seem to have CC'ed the ipmi maintainers? cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [1/2] cxl: Fix off by one error allowing subsequent mmap page to be accessed
On Tue, 2015-07-07 at 05:45:45 UTC, Ian Munsie wrote: From: Ian Munsie imun...@au1.ibm.com It was discovered that if a process mmaped their problem state area they were able to access one page more than expected, potentially allowing them to access the problem state area of an unrelated process. This was due to a simple off by one error in the mmap fault handler introduced in 0712dc7e73e59d79bcead5d5520acf4e9e917e87 (cxl: Fix issues when unmapping contexts), which is fixed in this patch. Cc: sta...@vger.kernel.org Fixes: 0712dc7e73e5 (cxl: Fix issues when unmapping contexts) Signed-off-by: Ian Munsie imun...@au1.ibm.com Applied to powerpc fixes, thanks. https://git.kernel.org/cgit/linux/kernel/git/powerpc/linux.git/commit/?h=fixesid=10a5894f2dedd8a26b3132497445b314c0d952c4 cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 31/37] usb: gadget: s3c2410_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/s3c2410_udc.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/gadget/udc/s3c2410_udc.c b/drivers/usb/gadget/udc/s3c2410_udc.c index 5d9aa81..eb3571e 100644 --- a/drivers/usb/gadget/udc/s3c2410_udc.c +++ b/drivers/usb/gadget/udc/s3c2410_udc.c @@ -1691,6 +1691,8 @@ static struct s3c2410_udc memory = { .name = ep0name, .ops= s3c2410_ep_ops, .maxpacket = EP0_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, }, @@ -1702,6 +1704,8 @@ static struct s3c2410_udc memory = { .name = ep1-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, @@ -1714,6 +1718,8 @@ static struct s3c2410_udc memory = { .name = ep2-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, @@ -1726,6 +1732,8 @@ static struct s3c2410_udc memory = { .name = ep3-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, @@ -1738,6 +1746,8 @@ static struct s3c2410_udc memory = { .name = ep4-bulk, .ops= s3c2410_ep_ops, .maxpacket = EP_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .fifo_size = EP_FIFO_SIZE, -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 10/37] usb: gadget: bcm63xx_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/bcm63xx_udc.c | 25 + 1 file changed, 21 insertions(+), 4 deletions(-) diff --git a/drivers/usb/gadget/udc/bcm63xx_udc.c b/drivers/usb/gadget/udc/bcm63xx_udc.c index 9db968b..c5e0894 100644 --- a/drivers/usb/gadget/udc/bcm63xx_udc.c +++ b/drivers/usb/gadget/udc/bcm63xx_udc.c @@ -44,9 +44,25 @@ #define DRV_MODULE_NAMEbcm63xx_udc static const char bcm63xx_ep0name[] = ep0; -static const char *const bcm63xx_ep_name[] = { - bcm63xx_ep0name, - ep1in-bulk, ep2out-bulk, ep3in-int, ep4out-int, + +static const struct { + const char *name; + const struct usb_ep_caps caps; +} bcm63xx_ep_info[] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + + EP_INFO(bcm63xx_ep0name, CONTROL, ALL), + EP_INFO(ep1in-bulk, BULK, IN), + EP_INFO(ep2out-bulk, BULK, OUT), + EP_INFO(ep3in-int,INT,IN), + EP_INFO(ep4out-int, INT,OUT), + +#undef EP_INFO }; static bool use_fullspeed; @@ -943,7 +959,8 @@ static int bcm63xx_init_udc_hw(struct bcm63xx_udc *udc) for (i = 0; i BCM63XX_NUM_EP; i++) { struct bcm63xx_ep *bep = udc-bep[i]; - bep-ep.name = bcm63xx_ep_name[i]; + bep-ep.name = bcm63xx_ep_info[i].name; + bep-ep.caps = bcm63xx_ep_info[i].caps; bep-ep_num = i; bep-ep.ops = bcm63xx_udc_ep_ops; list_add_tail(bep-ep.ep_list, udc-gadget.ep_list); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 14/37] usb: gadget: fsl_qe_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fsl_qe_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/fsl_qe_udc.c b/drivers/usb/gadget/udc/fsl_qe_udc.c index e0822f1..5fb6f8b 100644 --- a/drivers/usb/gadget/udc/fsl_qe_udc.c +++ b/drivers/usb/gadget/udc/fsl_qe_udc.c @@ -2417,6 +2417,17 @@ static int qe_ep_config(struct qe_udc *udc, unsigned char pipe_num) strcpy(ep-name, ep_name[pipe_num]); ep-ep.name = ep_name[pipe_num]; + if (pipe_num == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; + ep-ep.ops = qe_ep_ops; ep-stopped = 1; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 16/37] usb: gadget: fusb300_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fusb300_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/fusb300_udc.c b/drivers/usb/gadget/udc/fusb300_udc.c index 3970f45..948845c 100644 --- a/drivers/usb/gadget/udc/fusb300_udc.c +++ b/drivers/usb/gadget/udc/fusb300_udc.c @@ -1450,6 +1450,17 @@ static int fusb300_probe(struct platform_device *pdev) ep-ep.name = fusb300_ep_name[i]; ep-ep.ops = fusb300_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, HS_BULK_MAX_PACKET_SIZE); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(fusb300-ep[0]-ep, HS_CTL_MAX_PACKET_SIZE); fusb300-ep[0]-epnum = 0; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 25/37] usb: gadget: omap_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/omap_udc.c | 22 ++ 1 file changed, 22 insertions(+) diff --git a/drivers/usb/gadget/udc/omap_udc.c b/drivers/usb/gadget/udc/omap_udc.c index e2fcdb8..9b7d394 100644 --- a/drivers/usb/gadget/udc/omap_udc.c +++ b/drivers/usb/gadget/udc/omap_udc.c @@ -2579,6 +2579,28 @@ omap_ep_setup(char *name, u8 addr, u8 type, ep-double_buf = dbuf; ep-udc = udc; + switch (type) { + case USB_ENDPOINT_XFER_CONTROL: + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; + break; + case USB_ENDPOINT_XFER_ISOC: + ep-ep.caps.type_iso = true; + break; + case USB_ENDPOINT_XFER_BULK: + ep-ep.caps.type_bulk = true; + break; + case USB_ENDPOINT_XFER_INT: + ep-ep.caps.type_int = true; + break; + }; + + if (addr USB_DIR_IN) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; + ep-ep.name = ep-name; ep-ep.ops = omap_ep_ops; ep-maxpacket = maxp; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 27/37] usb: gadget: pxa25x_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/pxa25x_udc.c | 32 1 file changed, 32 insertions(+) diff --git a/drivers/usb/gadget/udc/pxa25x_udc.c b/drivers/usb/gadget/udc/pxa25x_udc.c index f6cbe66..1301e29 100644 --- a/drivers/usb/gadget/udc/pxa25x_udc.c +++ b/drivers/usb/gadget/udc/pxa25x_udc.c @@ -1821,6 +1821,8 @@ static struct pxa25x_udc memory = { .name = ep0name, .ops= pxa25x_ep_ops, .maxpacket = EP0_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, + USB_EP_CAPS_DIR_ALL), }, .dev= memory, .reg_udccs = UDCCS0, @@ -1833,6 +1835,8 @@ static struct pxa25x_udc memory = { .name = ep1in-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1846,6 +1850,8 @@ static struct pxa25x_udc memory = { .name = ep2out-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_OUT), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1861,6 +1867,8 @@ static struct pxa25x_udc memory = { .name = ep3in-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = ISO_FIFO_SIZE, @@ -1874,6 +1882,8 @@ static struct pxa25x_udc memory = { .name = ep4out-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_OUT), }, .dev= memory, .fifo_size = ISO_FIFO_SIZE, @@ -1888,6 +1898,8 @@ static struct pxa25x_udc memory = { .name = ep5in-int, .ops= pxa25x_ep_ops, .maxpacket = INT_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = INT_FIFO_SIZE, @@ -1903,6 +1915,8 @@ static struct pxa25x_udc memory = { .name = ep6in-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1916,6 +1930,8 @@ static struct pxa25x_udc memory = { .name = ep7out-bulk, .ops= pxa25x_ep_ops, .maxpacket = BULK_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_OUT), }, .dev= memory, .fifo_size = BULK_FIFO_SIZE, @@ -1930,6 +1946,8 @@ static struct pxa25x_udc memory = { .name = ep8in-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_IN), }, .dev= memory, .fifo_size = ISO_FIFO_SIZE, @@ -1943,6 +1961,8 @@ static struct pxa25x_udc memory = { .name = ep9out-iso, .ops= pxa25x_ep_ops, .maxpacket = ISO_FIFO_SIZE, +
[PATCH 28/37] usb: gadget: pxa27x_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/pxa27x_udc.h | 33 ++--- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/udc/pxa27x_udc.h b/drivers/usb/gadget/udc/pxa27x_udc.h index 11e1423..ded058c 100644 --- a/drivers/usb/gadget/udc/pxa27x_udc.h +++ b/drivers/usb/gadget/udc/pxa27x_udc.h @@ -234,25 +234,28 @@ /* * Endpoint definition helpers */ -#define USB_EP_DEF(addr, bname, dir, type, maxpkt) \ -{ .usb_ep = { .name = bname, .ops = pxa_ep_ops, .maxpacket = maxpkt, }, \ +#define USB_EP_DEF(addr, bname, dir, type, maxpkt, ctype, cdir) \ +{ .usb_ep = { .name = bname, .ops = pxa_ep_ops, .maxpacket = maxpkt, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## ctype, \ + USB_EP_CAPS_DIR_ ## cdir), }, \ .desc = {.bEndpointAddress = addr | (dir ? USB_DIR_IN : 0), \ - .bmAttributes = type, \ + .bmAttributes = USB_ENDPOINT_XFER_ ## type, \ .wMaxPacketSize = maxpkt, }, \ .dev = memory \ } -#define USB_EP_BULK(addr, bname, dir) \ - USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_BULK, BULK_FIFO_SIZE) -#define USB_EP_ISO(addr, bname, dir) \ - USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_ISOC, ISO_FIFO_SIZE) -#define USB_EP_INT(addr, bname, dir) \ - USB_EP_DEF(addr, bname, dir, USB_ENDPOINT_XFER_INT, INT_FIFO_SIZE) -#define USB_EP_IN_BULK(n) USB_EP_BULK(n, ep #n in-bulk, 1) -#define USB_EP_OUT_BULK(n) USB_EP_BULK(n, ep #n out-bulk, 0) -#define USB_EP_IN_ISO(n) USB_EP_ISO(n, ep #n in-iso, 1) -#define USB_EP_OUT_ISO(n) USB_EP_ISO(n, ep #n out-iso, 0) -#define USB_EP_IN_INT(n) USB_EP_INT(n, ep #n in-int, 1) -#define USB_EP_CTRLUSB_EP_DEF(0, ep0, 0, 0, EP0_FIFO_SIZE) +#define USB_EP_BULK(addr, bname, dir, cdir) \ + USB_EP_DEF(addr, bname, dir, BULK, BULK_FIFO_SIZE, BULK, cdir) +#define USB_EP_ISO(addr, bname, dir, cdir) \ + USB_EP_DEF(addr, bname, dir, ISOC, ISO_FIFO_SIZE, ISO, cdir) +#define USB_EP_INT(addr, bname, dir, cdir) \ + USB_EP_DEF(addr, bname, dir, INT, INT_FIFO_SIZE, INT, cdir) +#define USB_EP_IN_BULK(n) USB_EP_BULK(n, ep #n in-bulk, 1, IN) +#define USB_EP_OUT_BULK(n) USB_EP_BULK(n, ep #n out-bulk, 0, OUT) +#define USB_EP_IN_ISO(n) USB_EP_ISO(n, ep #n in-iso, 1, IN) +#define USB_EP_OUT_ISO(n) USB_EP_ISO(n, ep #n out-iso, 0, OUT) +#define USB_EP_IN_INT(n) USB_EP_INT(n, ep #n in-int, 1, IN) +#define USB_EP_CTRLUSB_EP_DEF(0, ep0, 0, CONTROL, \ + EP0_FIFO_SIZE, CONTROL, ALL) #define PXA_EP_DEF(_idx, _addr, dir, _type, maxpkt, _config, iface, altset) \ { \ -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V3 0/5] Allow user to request memory to be locked on page fault
On Tue, 07 Jul 2015, Andrew Morton wrote: On Tue, 7 Jul 2015 13:03:38 -0400 Eric B Munson emun...@akamai.com wrote: mlock() allows a user to control page out of program memory, but this comes at the cost of faulting in the entire mapping when it is allocated. For large mappings where the entire area is not necessary this is not ideal. Instead of forcing all locked pages to be present when they are allocated, this set creates a middle ground. Pages are marked to be placed on the unevictable LRU (locked) when they are first used, but they are not faulted in by the mlock call. This series introduces a new mlock() system call that takes a flags argument along with the start address and size. This flags argument gives the caller the ability to request memory be locked in the traditional way, or to be locked after the page is faulted in. New calls are added for munlock() and munlockall() which give the called a way to specify which flags are supposed to be cleared. A new MCL flag is added to mirror the lock on fault behavior from mlock() in mlockall(). Finally, a flag for mmap() is added that allows a user to specify that the covered are should not be paged out, but only after the memory has been used the first time. Thanks for sticking with this. Adding new syscalls is a bit of a hassle but I do think we end up with a better interface - the existing mlock/munlock/mlockall interfaces just aren't appropriate for these things. I don't know whether these syscalls should be documented via new manpages, or if we should instead add them to the existing mlock/munlock/mlockall manpages. Michael, could you please advise? Thanks for adding the series. I owe you several updates (getting the new syscall right for all architectures and a set of tests for the new syscalls). Would you prefer a new pair of patches or I update this set? Eric signature.asc Description: Digital signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 36/37] usb: gadget: atmel_usba_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/atmel_usba_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/atmel_usba_udc.c b/drivers/usb/gadget/udc/atmel_usba_udc.c index 37d414e..267d84f 100644 --- a/drivers/usb/gadget/udc/atmel_usba_udc.c +++ b/drivers/usb/gadget/udc/atmel_usba_udc.c @@ -2067,6 +2067,17 @@ static struct usba_ep * usba_udc_pdata(struct platform_device *pdev, ep-can_dma = pdata-ep[i].can_dma; ep-can_isoc = pdata-ep[i].can_isoc; + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = ep-can_isoc; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; + if (i) list_add_tail(ep-ep.ep_list, udc-gadget.ep_list); } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 00/37] usb: gadget: rework ep matching and claiming mechanism
Hello, This patch series reworks endpoint matching and claiming mechanism in epautoconf. The patch (1) introduces new safer endpoint claiming method, basing on new 'claimed' flag. It was discussed here [1]. I proposed this solution over year ago and it was accepted, but apparently I forgot to send the final version of patch. Patches (2-3) add the 'capabilities flags' structure and helper macros. This solution is inspired by the 'feature flags' originally proposed by Felipe Balbi in 2013 [2], but unfortunately implementation of this feature has never been completed. Patches (4-36) add' capabilites flags' support to all UDC drivers present in the kernel tree. It's needed to be done before replacing old endpoint matching mechanism, otherwise UDC drivers which doesn't set 'capabilities flags' won't work with new autoconfig. Patch (37) finally replaces old endpoint matching method with the new one basing on capabilities flags. These changes aims to get rid of code, which guesses endpoint capabilities basing on it's name, and introduce new better replacement. In result we have better way to describe types and directions supported by each endpoint. For example the old name-based method didn't allow to have endpoint supporing two types of transfers - there were only ability to support one or all endpoint types. The 'capabilities flags' feature supply precise, flexible and extendible mechanism of description of endpoint hardware limitations, which is desired for proper endpoint matching. Best regards, Robert Baldyga [1] https://lkml.org/lkml/2014/6/16/94 [2] http://www.spinics.net/lists/linux-usb/msg99662.html Robert Baldyga (37): usb: gadget: encapsulate endpoint claiming mechanism usb: gadget: add endpoint capabilities flags usb: gadget: add endpoint capabilities helper macros staging: emxx_udc: add ep capabilities support usb: chipidea: udc: add ep capabilities support usb: dwc2: gadget: add ep capabilities support usb: dwc3: gadget: add ep capabilities support usb: gadget: amd5536udc: add ep capabilities support usb: gadget: at91_udc: add ep capabilities support usb: gadget: bcm63xx_udc: add ep capabilities support usb: gadget: bdc: add ep capabilities support usb: gadget: dummy-hcd: add ep capabilities support usb: gadget: fotg210-udc: add ep capabilities support usb: gadget: fsl_qe_udc: add ep capabilities support usb: gadget: fsl_udc_core: add ep capabilities support usb: gadget: fusb300_udc: add ep capabilities support usb: gadget: goku_udc: add ep capabilities support usb: gadget: gr_udc: add ep capabilities support usb: gadget: lpc32xx_udc: add ep capabilities support usb: gadget: m66592-udc: add ep capabilities support usb: gadget: mv_u3d_core: add ep capabilities support usb: gadget: mv_udc_core: add ep capabilities support usb: gadget: net2272: add ep capabilities support usb: gadget: net2280: add ep capabilities support usb: gadget: omap_udc: add ep capabilities support usb: gadget: pch_ud: add ep capabilities support usb: gadget: pxa25x_udc: add ep capabilities support usb: gadget: pxa27x_udc: add ep capabilities support usb: gadget: r8a66597-udc: add ep capabilities support usb: gadget: s3c-hsudc: add ep capabilities support usb: gadget: s3c2410_udc: add ep capabilities support usb: gadget: udc-xilinx: add ep capabilities support usb: isp1760: udc: add ep capabilities support usb: musb: gadget: add ep capabilities support usb: renesas: gadget: add ep capabilities support usb: gadget: atmel_usba_udc: add ep capabilities support usb: gadget: epautoconf: add endpoint capabilities flags verification drivers/staging/emxx_udc/emxx_udc.c | 60 drivers/usb/chipidea/udc.c | 14 ++ drivers/usb/dwc2/gadget.c | 13 ++ drivers/usb/dwc3/gadget.c | 13 ++ drivers/usb/gadget/epautoconf.c | 83 +++-- drivers/usb/gadget/udc/amd5536udc.c | 57 ++ drivers/usb/gadget/udc/at91_udc.c | 33 + drivers/usb/gadget/udc/atmel_usba_udc.c | 11 + drivers/usb/gadget/udc/bcm63xx_udc.c| 25 -- drivers/usb/gadget/udc/bdc/bdc_ep.c | 9 drivers/usb/gadget/udc/dummy_hcd.c | 65 -- drivers/usb/gadget/udc/fotg210-udc.c| 11 + drivers/usb/gadget/udc/fsl_qe_udc.c | 11 + drivers/usb/gadget/udc/fsl_udc_core.c | 13 ++ drivers/usb/gadget/udc/fusb300_udc.c| 11 + drivers/usb/gadget/udc/goku_udc.c | 8 drivers/usb/gadget/udc/gr_udc.c | 11 + drivers/usb/gadget/udc/lpc32xx_udc.c| 32 + drivers/usb/gadget/udc/m66592-udc.c | 11 + drivers/usb/gadget/udc/mv_u3d_core.c| 9 drivers/usb/gadget/udc/mv_udc_core.c| 9 drivers/usb/gadget/udc/net2272.c| 11 + drivers/usb/gadget/udc/net2280.c| 50 +++-
[PATCH 08/37] usb: gadget: amd5536udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/amd5536udc.c | 57 ++--- 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/drivers/usb/gadget/udc/amd5536udc.c b/drivers/usb/gadget/udc/amd5536udc.c index de7e5e2..1a1d91c 100644 --- a/drivers/usb/gadget/udc/amd5536udc.c +++ b/drivers/usb/gadget/udc/amd5536udc.c @@ -138,15 +138,51 @@ static DECLARE_TASKLET(disconnect_tasklet, udc_tasklet_disconnect, /* endpoint names used for print */ static const char ep0_string[] = ep0in; -static const char *const ep_string[] = { - ep0_string, - ep1in-int, ep2in-bulk, ep3in-bulk, ep4in-bulk, ep5in-bulk, - ep6in-bulk, ep7in-bulk, ep8in-bulk, ep9in-bulk, ep10in-bulk, - ep11in-bulk, ep12in-bulk, ep13in-bulk, ep14in-bulk, - ep15in-bulk, ep0out, ep1out-bulk, ep2out-bulk, ep3out-bulk, - ep4out-bulk, ep5out-bulk, ep6out-bulk, ep7out-bulk, - ep8out-bulk, ep9out-bulk, ep10out-bulk, ep11out-bulk, - ep12out-bulk, ep13out-bulk, ep14out-bulk, ep15out-bulk +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + + EP_INFO(ep0_string, CONTROL, IN), + EP_INFO(ep1in-int,BULK, IN), + EP_INFO(ep2in-bulk, BULK, IN), + EP_INFO(ep3in-bulk, BULK, IN), + EP_INFO(ep4in-bulk, BULK, IN), + EP_INFO(ep5in-bulk, BULK, IN), + EP_INFO(ep6in-bulk, BULK, IN), + EP_INFO(ep7in-bulk, BULK, IN), + EP_INFO(ep8in-bulk, BULK, IN), + EP_INFO(ep9in-bulk, BULK, IN), + EP_INFO(ep10in-bulk, BULK, IN), + EP_INFO(ep11in-bulk, BULK, IN), + EP_INFO(ep12in-bulk, BULK, IN), + EP_INFO(ep13in-bulk, BULK, IN), + EP_INFO(ep14in-bulk, BULK, IN), + EP_INFO(ep15in-bulk, BULK, IN), + EP_INFO(ep0out, CONTROL, OUT), + EP_INFO(ep1out-bulk, BULK, OUT), + EP_INFO(ep2out-bulk, BULK, OUT), + EP_INFO(ep3out-bulk, BULK, OUT), + EP_INFO(ep4out-bulk, BULK, OUT), + EP_INFO(ep5out-bulk, BULK, OUT), + EP_INFO(ep6out-bulk, BULK, OUT), + EP_INFO(ep7out-bulk, BULK, OUT), + EP_INFO(ep8out-bulk, BULK, OUT), + EP_INFO(ep9out-bulk, BULK, OUT), + EP_INFO(ep10out-bulk, BULK, OUT), + EP_INFO(ep11out-bulk, BULK, OUT), + EP_INFO(ep12out-bulk, BULK, OUT), + EP_INFO(ep13out-bulk, BULK, OUT), + EP_INFO(ep14out-bulk, BULK, OUT), + EP_INFO(ep15out-bulk, BULK, OUT), + +#undef EP_INFO }; /* DMA usage flag */ @@ -1517,7 +1553,8 @@ static void udc_setup_endpoints(struct udc *dev) for (tmp = 0; tmp UDC_EP_NUM; tmp++) { ep = dev-ep[tmp]; ep-dev = dev; - ep-ep.name = ep_string[tmp]; + ep-ep.name = ep_info[tmp].name; + ep-ep.caps = ep_info[tmp].caps; ep-num = tmp; /* txfifo size is calculated at enable time */ ep-txfifo = dev-txfifo; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 13/37] usb: gadget: fotg210-udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fotg210-udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/fotg210-udc.c b/drivers/usb/gadget/udc/fotg210-udc.c index e547ea7..960c70c 100644 --- a/drivers/usb/gadget/udc/fotg210-udc.c +++ b/drivers/usb/gadget/udc/fotg210-udc.c @@ -1153,6 +1153,17 @@ static int fotg210_udc_probe(struct platform_device *pdev) ep-ep.name = fotg210_ep_name[i]; ep-ep.ops = fotg210_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(fotg210-ep[0]-ep, 0x40); fotg210-gadget.ep0 = fotg210-ep[0]-ep; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 18/37] usb: gadget: gr_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/gr_udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/gr_udc.c b/drivers/usb/gadget/udc/gr_udc.c index c886887..8aa2593 100644 --- a/drivers/usb/gadget/udc/gr_udc.c +++ b/drivers/usb/gadget/udc/gr_udc.c @@ -2018,12 +2018,23 @@ static int gr_ep_init(struct gr_udc *dev, int num, int is_in, u32 maxplimit) usb_ep_set_maxpacket_limit(ep-ep, MAX_CTRL_PL_SIZE); ep-bytes_per_buffer = MAX_CTRL_PL_SIZE; + + ep-ep.caps.type_control = true; } else { usb_ep_set_maxpacket_limit(ep-ep, (u16)maxplimit); list_add_tail(ep-ep.ep_list, dev-gadget.ep_list); + + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; } list_add_tail(ep-ep_list, dev-ep_list); + if (is_in) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; + ep-tailbuf = dma_alloc_coherent(dev-dev, ep-ep.maxpacket_limit, ep-tailbuf_paddr, GFP_ATOMIC); if (!ep-tailbuf) -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 22/37] usb: gadget: mv_udc_core: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/mv_udc_core.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/mv_udc_core.c b/drivers/usb/gadget/udc/mv_udc_core.c index d32160d..306a7ff 100644 --- a/drivers/usb/gadget/udc/mv_udc_core.c +++ b/drivers/usb/gadget/udc/mv_udc_core.c @@ -1257,6 +1257,9 @@ static int eps_init(struct mv_udc *udc) ep-wedge = 0; ep-stopped = 0; usb_ep_set_maxpacket_limit(ep-ep, EP0_MAX_PKT_SIZE); + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; ep-ep_num = 0; ep-ep.desc = mv_ep0_desc; INIT_LIST_HEAD(ep-queue); @@ -1269,14 +1272,20 @@ static int eps_init(struct mv_udc *udc) if (i % 2) { snprintf(name, sizeof(name), ep%din, i / 2); ep-direction = EP_DIR_IN; + ep-ep.caps.dir_in = true; } else { snprintf(name, sizeof(name), ep%dout, i / 2); ep-direction = EP_DIR_OUT; + ep-ep.caps.dir_out = true; } ep-udc = udc; strncpy(ep-name, name, sizeof(ep-name)); ep-ep.name = ep-name; + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + ep-ep.ops = mv_ep_ops; ep-stopped = 0; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v4 3/7] powerpc/powernv: Nest PMU detection and device tree parser
Create a file nest-pmu.c to contain nest pmu related functions. Code to detect nest pmu support and parser to collect per-chip reserved memory region information from device tree (DT). Detection mechanism is to look for specific property ibm,ima-chip in DT. For Nest pmu, device tree will have two set of information. 1) Per-chip reserved memory region for nest pmu counter collection area. 2) Supported Nest PMUs and events Device tree layout for the Nest PMU as follows. / -- DT root folder | -nest-ima -- Nest PMU folder | -ima-chip@chip-id -- Per-chip folder for reserved region information | -ibm,chip-id-- Chip id -ibm,ima-chip -reg-- HOMER PORE Nest Counter collection Address (RA) -size -- size to map in kernel space -Alink_BW-- Nest PMU folder | -Alink0 -- Nest PMU Alink Event file -scale.Alink0.scale -- Event scale file -unit.Alink0.unit -- Event unit file -device_type-- nest-ima-unit marker Subsequent patch will parse the next part of the DT to find various Nest PMUs and their events. Cc: Michael Ellerman m...@ellerman.id.au Cc: Benjamin Herrenschmidt b...@kernel.crashing.org Cc: Paul Mackerras pau...@samba.org Cc: Anton Blanchard an...@samba.org Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Cc: Anshuman Khandual khand...@linux.vnet.ibm.com Cc: Stephane Eranian eran...@google.com Signed-off-by: Madhavan Srinivasan ma...@linux.vnet.ibm.com --- arch/powerpc/perf/Makefile | 2 +- arch/powerpc/perf/nest-pmu.c | 85 2 files changed, 86 insertions(+), 1 deletion(-) create mode 100644 arch/powerpc/perf/nest-pmu.c diff --git a/arch/powerpc/perf/Makefile b/arch/powerpc/perf/Makefile index f9c083a..6da656b 100644 --- a/arch/powerpc/perf/Makefile +++ b/arch/powerpc/perf/Makefile @@ -5,7 +5,7 @@ obj-$(CONFIG_PERF_EVENTS) += callchain.o obj-$(CONFIG_PPC_PERF_CTRS)+= core-book3s.o bhrb.o obj64-$(CONFIG_PPC_PERF_CTRS) += power4-pmu.o ppc970-pmu.o power5-pmu.o \ power5+-pmu.o power6-pmu.o power7-pmu.o \ - power8-pmu.o + power8-pmu.o nest-pmu.o obj32-$(CONFIG_PPC_PERF_CTRS) += mpc7450-pmu.o obj-$(CONFIG_FSL_EMB_PERF_EVENT) += core-fsl-emb.o diff --git a/arch/powerpc/perf/nest-pmu.c b/arch/powerpc/perf/nest-pmu.c new file mode 100644 index 000..e7d45ed --- /dev/null +++ b/arch/powerpc/perf/nest-pmu.c @@ -0,0 +1,85 @@ +/* + * Nest Performance Monitor counter support for POWER8 processors. + * + * Copyright (C) 2015 Madhavan Srinivasan, IBM Corporation. + * + * 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 nest-pmu.h + +static struct perchip_nest_info p8_nest_perchip_info[P8_NEST_MAX_CHIPS]; + +static int nest_ima_dt_parser(void) +{ + const __be32 *gcid; + const __be64 *chip_ima_reg; + const __be64 *chip_ima_size; + struct device_node *dev; + struct perchip_nest_info *p8ni; + int idx; + + /* +* nest-ima folder contains two things, +* a) per-chip reserved memory region for Nest PMU Counter data +* b) Support Nest PMU units and their event files +*/ + for_each_node_with_property(dev, ibm,ima-chip) { + gcid = of_get_property(dev, ibm,chip-id, NULL); + chip_ima_reg = of_get_property(dev, reg, NULL); + chip_ima_size = of_get_property(dev, size, NULL); + + if ((!gcid) || (!chip_ima_reg) || (!chip_ima_size)) { + pr_err(Nest_PMU: device %s missing property\n, + dev-full_name); + return -ENODEV; + } + + /* chip id to save reserve memory region */ + idx = (uint32_t)be32_to_cpup(gcid); + + /* +* Using a local variable to make it compact and +* easier to read +*/ + p8ni = p8_nest_perchip_info[idx]; + p8ni-pbase = be64_to_cpup(chip_ima_reg); + p8ni-size = be64_to_cpup(chip_ima_size); + p8ni-vbase = (uint64_t) phys_to_virt(p8ni-pbase); + } + + return 0; +} + +static int __init nest_pmu_init(void) +{ + int ret = -ENODEV; + + /* +* Lets do this only if we are hypervisor +*/ + if (!cur_cpu_spec-oprofile_cpu_type || + !(strcmp(cur_cpu_spec-oprofile_cpu_type, ppc64/power8) == 0) || + !cpu_has_feature(CPU_FTR_HVMODE)) + return ret; + + /* +* Nest PMU information is grouped under nest-ima node +* of the top-level device-tree directory. Detect Nest PMU +
[PATCH v4 4/7] powerpc/powernv: detect supported nest pmus and its events
Parse device tree to detect supported nest pmu units. Traverse through each nest pmu unit folder to find supported events and corresponding unit/scale files (if any). The nest unit event file from DT, will contain the offset in the reserved memory region to get the counter data for a given event. Kernel code uses this offset as event configuration value. Device tree parser code also looks for scale/unit in the file name and passes on the file as an event attr for perf tool to use in the post processing. Cc: Michael Ellerman m...@ellerman.id.au Cc: Benjamin Herrenschmidt b...@kernel.crashing.org Cc: Paul Mackerras pau...@samba.org Cc: Anton Blanchard an...@samba.org Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Cc: Anshuman Khandual khand...@linux.vnet.ibm.com Cc: Stephane Eranian eran...@google.com Signed-off-by: Madhavan Srinivasan ma...@linux.vnet.ibm.com --- arch/powerpc/perf/nest-pmu.c | 124 ++- 1 file changed, 123 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/perf/nest-pmu.c b/arch/powerpc/perf/nest-pmu.c index e7d45ed..6116ff3 100644 --- a/arch/powerpc/perf/nest-pmu.c +++ b/arch/powerpc/perf/nest-pmu.c @@ -11,6 +11,119 @@ #include nest-pmu.h static struct perchip_nest_info p8_nest_perchip_info[P8_NEST_MAX_CHIPS]; +static struct nest_pmu *per_nest_pmu_arr[P8_NEST_MAX_PMUS]; + +static int nest_event_info(struct property *pp, char *start, + struct nest_ima_events *p8_events, int flg, u32 val) +{ + char *buf; + + /* memory for event name */ + buf = kzalloc(P8_NEST_MAX_PMU_NAME_LEN, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + strncpy(buf, start, strlen(start)); + p8_events-ev_name = buf; + + /* memory for content */ + buf = kzalloc(P8_NEST_MAX_PMU_NAME_LEN, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + if (flg) { + /* string content*/ + if (!pp-value || + (strnlen(pp-value, pp-length) == pp-length)) + return -EINVAL; + + strncpy(buf, (const char *)pp-value, pp-length); + } else + sprintf(buf, event=0x%x, val); + + p8_events-ev_value = buf; + return 0; +} + +static int nest_pmu_create(struct device_node *dev, int pmu_index) +{ + struct nest_ima_events **p8_events_arr, *p8_events; + struct nest_pmu *pmu_ptr; + struct property *pp; + char *buf, *start; + const __be32 *lval; + u32 val; + int idx = 0, ret; + + if (!dev) + return -EINVAL; + + /* memory for nest pmus */ + pmu_ptr = kzalloc(sizeof(struct nest_pmu), GFP_KERNEL); + if (!pmu_ptr) + return -ENOMEM; + + /* Needed for hotplug/migration */ + per_nest_pmu_arr[pmu_index] = pmu_ptr; + + /* memory for nest pmu events */ + p8_events_arr = kzalloc((sizeof(struct nest_ima_events) * 64), + GFP_KERNEL); + if (!p8_events_arr) + return -ENOMEM; + p8_events = (struct nest_ima_events *)p8_events_arr; + + /* +* Loop through each property +*/ + for_each_property_of_node(dev, pp) { + start = pp-name; + + if (!strcmp(pp-name, name)) { + if (!pp-value || + (strnlen(pp-value, pp-length) == pp-length)) + return -EINVAL; + + buf = kzalloc(P8_NEST_MAX_PMU_NAME_LEN, GFP_KERNEL); + if (!buf) + return -ENOMEM; + + /* Save the name to register it later */ + sprintf(buf, Nest_%s, (char *)pp-value); + pmu_ptr-pmu.name = (char *)buf; + continue; + } + + /* Skip these, we dont need it */ + if (!strcmp(pp-name, phandle) || + !strcmp(pp-name, device_type) || + !strcmp(pp-name, linux,phandle)) + continue; + + if (strncmp(pp-name, unit., 5) == 0) { + /* Skip first few chars in the name */ + start += 5; + ret = nest_event_info(pp, start, p8_events++, 1, 0); + } else if (strncmp(pp-name, scale., 6) == 0) { + /* Skip first few chars in the name */ + start += 6; + ret = nest_event_info(pp, start, p8_events++, 1, 0); + } else { + lval = of_get_property(dev, pp-name, NULL); + val = (uint32_t)be32_to_cpup(lval); + + ret = nest_event_info(pp, start, p8_events++, 0, val); + } + + if (ret) + return ret; + + /* book keeping
[PATCH 32/37] usb: gadget: udc-xilinx: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/udc-xilinx.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/udc-xilinx.c b/drivers/usb/gadget/udc/udc-xilinx.c index 1f24274..1cbb0ac 100644 --- a/drivers/usb/gadget/udc/udc-xilinx.c +++ b/drivers/usb/gadget/udc/udc-xilinx.c @@ -1317,12 +1317,21 @@ static void xudc_eps_init(struct xusb_udc *udc) snprintf(ep-name, EPNAME_SIZE, ep%d, ep_number); ep-ep_usb.name = ep-name; ep-ep_usb.ops = xusb_ep_ops; + + ep-ep_usb.caps.type_iso = true; + ep-ep_usb.caps.type_bulk = true; + ep-ep_usb.caps.type_int = true; } else { ep-ep_usb.name = ep0name; usb_ep_set_maxpacket_limit(ep-ep_usb, EP0_MAX_PACKET); ep-ep_usb.ops = xusb_ep0_ops; + + ep-ep_usb.caps.type_control = true; } + ep-ep_usb.caps.dir_in = true; + ep-ep_usb.caps.dir_out = true; + ep-udc = udc; ep-epnumber = ep_number; ep-desc = NULL; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 37/37] usb: gadget: epautoconf: add endpoint capabilities flags verification
Introduce endpoint matching mechanism basing on endpoint capabilities flags. We check if endpoint supports transfer type and direction requested in ep descriptor. Since we have this new endpoint matching mechanism there is no need to have old code guessing endpoint capabilities basing on its name, so we are getting rid of it. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 72 + 1 file changed, 22 insertions(+), 50 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 8e00ca7..38df22a 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -47,7 +47,6 @@ ep_matches ( ) { u8 type; - const char *tmp; u16 max; int num_req_streams = 0; @@ -56,58 +55,31 @@ ep_matches ( if (ep-claimed) return 0; - /* only support ep0 for portable CONTROL traffic */ type = usb_endpoint_type(desc); - if (USB_ENDPOINT_XFER_CONTROL == type) - return 0; - - /* some other naming convention */ - if ('e' != ep-name[0]) + switch (type) { + case USB_ENDPOINT_XFER_CONTROL: + /* only support ep0 for portable CONTROL traffic */ return 0; + case USB_ENDPOINT_XFER_ISOC: + if (!ep-caps.type_iso) + return 0; + break; + case USB_ENDPOINT_XFER_BULK: + if (!ep-caps.type_bulk) + return 0; + break; + case USB_ENDPOINT_XFER_INT: + if (!ep-caps.type_int) + return 0; + break; + } - /* type-restriction: -iso, -bulk, or -int. -* direction-restriction: in, out. -*/ - if ('-' != ep-name[2]) { - tmp = strrchr (ep-name, '-'); - if (tmp) { - switch (type) { - case USB_ENDPOINT_XFER_INT: - /* bulk endpoints handle interrupt transfers, -* except the toggle-quirky iso-synch kind -*/ - if ('s' == tmp[2]) // == -iso - return 0; - /* for now, avoid PXA interrupt-in; -* it's documented as never using DATA1. -*/ - if (gadget_is_pxa (gadget) -'i' == tmp [1]) - return 0; - break; - case USB_ENDPOINT_XFER_BULK: - if ('b' != tmp[1]) // != -bulk - return 0; - break; - case USB_ENDPOINT_XFER_ISOC: - if ('s' != tmp[2]) // != -iso - return 0; - } - } else { - tmp = ep-name + strlen (ep-name); - } - - /* direction-restriction: ..in-.., out-.. */ - tmp--; - if (!isdigit (*tmp)) { - if (desc-bEndpointAddress USB_DIR_IN) { - if ('n' != *tmp) - return 0; - } else { - if ('t' != *tmp) - return 0; - } - } + if (usb_endpoint_dir_in(desc)) { + if (!ep-caps.dir_in) + return 0; + } else { + if (!ep-caps.dir_out) + return 0; } /* -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 02/37] usb: gadget: add endpoint capabilities flags
Introduce struct usb_ep_caps which contains information about capabilities of usb endpoints - supported transfer types and directions. This structure should be filled by UDC driver for each of its endpoints, and will be used in epautoconf in new ep matching mechanism which will replace ugly guessing of endpoint capabilities basing on its name. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- include/linux/usb/gadget.h | 21 + 1 file changed, 21 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index fcb0a4e..6f3e0fb 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -141,10 +141,29 @@ struct usb_ep_ops { }; /** + * struct usb_ep_caps - endpoint capabilities description + * @type_control:Endpoint supports control type (reserved for ep0). + * @type_iso:Endpoint supports isochronous transfers. + * @type_bulk:Endpoint supports bulk transfers. + * @type_int:Endpoint supports interrupt transfers. + * @dir_in:Endpoint supports IN direction. + * @dir_out:Endpoint supports OUT direction. + */ +struct usb_ep_caps { + unsigned type_control:1; + unsigned type_iso:1; + unsigned type_bulk:1; + unsigned type_int:1; + unsigned dir_in:1; + unsigned dir_out:1; +}; + +/** * struct usb_ep - device side representation of USB endpoint * @name:identifier for the endpoint, such as ep-a or ep9in-bulk * @ops: Function pointers used to access hardware-specific operations. * @ep_list:the gadget's ep_list holds all of its endpoints + * @caps:The structure describing types and directions supported by endoint. * @maxpacket:The maximum packet size used on this endpoint. The initial * value can sometimes be reduced (hardware allowing), according to * the endpoint descriptor used to configure the endpoint. @@ -167,12 +186,14 @@ struct usb_ep_ops { * gadget-ep_list. the control endpoint (gadget-ep0) is not in that list, * and is accessed only in response to a driver setup() callback. */ + struct usb_ep { void*driver_data; const char *name; const struct usb_ep_ops *ops; struct list_headep_list; + struct usb_ep_caps caps; boolclaimed; unsignedmaxpacket:16; unsignedmaxpacket_limit:16; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 07/37] usb: dwc3: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/dwc3/gadget.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/dwc3/gadget.c b/drivers/usb/dwc3/gadget.c index 333a7c0..8d1f768 100644 --- a/drivers/usb/dwc3/gadget.c +++ b/drivers/usb/dwc3/gadget.c @@ -1713,6 +1713,19 @@ static int dwc3_gadget_init_hw_endpoints(struct dwc3 *dwc, return ret; } + if (epnum == 0) { + dep-endpoint.caps.type_control = true; + } else { + dep-endpoint.caps.type_iso = true; + dep-endpoint.caps.type_bulk = true; + dep-endpoint.caps.type_int = true; + } + + if (epnum 1) + dep-endpoint.caps.dir_in = true; + else + dep-endpoint.caps.dir_out = true; + INIT_LIST_HEAD(dep-request_list); INIT_LIST_HEAD(dep-req_queued); } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 15/37] usb: gadget: fsl_udc_core: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/fsl_udc_core.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/gadget/udc/fsl_udc_core.c b/drivers/usb/gadget/udc/fsl_udc_core.c index c60022b..aab5221 100644 --- a/drivers/usb/gadget/udc/fsl_udc_core.c +++ b/drivers/usb/gadget/udc/fsl_udc_core.c @@ -2313,6 +2313,19 @@ static int struct_ep_setup(struct fsl_udc *udc, unsigned char index, ep-ep.ops = fsl_ep_ops; ep-stopped = 0; + if (index == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + if (index 1) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; + /* for ep0: maxP defined in desc * for other eps, maxP is set by epautoconfig() called by gadget layer */ -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 20/37] usb: gadget: m66592-udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/m66592-udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/m66592-udc.c b/drivers/usb/gadget/udc/m66592-udc.c index 309706f..e404553 100644 --- a/drivers/usb/gadget/udc/m66592-udc.c +++ b/drivers/usb/gadget/udc/m66592-udc.c @@ -1644,6 +1644,17 @@ static int m66592_probe(struct platform_device *pdev) ep-ep.name = m66592_ep_name[i]; ep-ep.ops = m66592_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, 512); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(m66592-ep[0].ep, 64); m66592-ep[0].pipenum = 0; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 26/37] usb: gadget: pch_ud: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/pch_udc.c | 14 -- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/drivers/usb/gadget/udc/pch_udc.c b/drivers/usb/gadget/udc/pch_udc.c index 613547f..cc8fb3c 100644 --- a/drivers/usb/gadget/udc/pch_udc.c +++ b/drivers/usb/gadget/udc/pch_udc.c @@ -2895,11 +2895,21 @@ static void pch_udc_pcd_reinit(struct pch_udc_dev *dev) ep-in = ~i 1; ep-ep.name = ep_string[i]; ep-ep.ops = pch_udc_ep_ops; - if (ep-in) + if (ep-in) { ep-offset_addr = ep-num * UDC_EP_REG_SHIFT; - else + ep-ep.caps.dir_in = true; + } else { ep-offset_addr = (UDC_EPINT_OUT_SHIFT + ep-num) * UDC_EP_REG_SHIFT; + ep-ep.caps.dir_out = true; + } + if (i == UDC_EP0IN_IDX || i == UDC_EP0OUT_IDX) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } /* need to set ep-ep.maxpacket and set Default Configuration?*/ usb_ep_set_maxpacket_limit(ep-ep, UDC_BULK_MAX_PKT_SIZE); list_add_tail(ep-ep.ep_list, dev-gadget.ep_list); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 21/37] usb: gadget: mv_u3d_core: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/mv_u3d_core.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/mv_u3d_core.c b/drivers/usb/gadget/udc/mv_u3d_core.c index ea35a24..4c48969 100644 --- a/drivers/usb/gadget/udc/mv_u3d_core.c +++ b/drivers/usb/gadget/udc/mv_u3d_core.c @@ -1324,6 +1324,9 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d) ep-ep.ops = mv_u3d_ep_ops; ep-wedge = 0; usb_ep_set_maxpacket_limit(ep-ep, MV_U3D_EP0_MAX_PKT_SIZE); + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; ep-ep_num = 0; ep-ep.desc = mv_u3d_ep0_desc; INIT_LIST_HEAD(ep-queue); @@ -1339,14 +1342,20 @@ static int mv_u3d_eps_init(struct mv_u3d *u3d) if (i 1) { snprintf(name, sizeof(name), ep%din, i 1); ep-direction = MV_U3D_EP_DIR_IN; + ep-ep.caps.dir_in = true; } else { snprintf(name, sizeof(name), ep%dout, i 1); ep-direction = MV_U3D_EP_DIR_OUT; + ep-ep.caps.dir_out = true; } ep-u3d = u3d; strncpy(ep-name, name, sizeof(ep-name)); ep-ep.name = ep-name; + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + ep-ep.ops = mv_u3d_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, (unsigned short) ~0); ep-ep_num = i / 2; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v4 1/7] powerpc/powernv: Data structure and macros definition
Create new header file nest-pmu.h to add the data structures and macros needed for the nest pmu support. Cc: Michael Ellerman m...@ellerman.id.au Cc: Benjamin Herrenschmidt b...@kernel.crashing.org Cc: Paul Mackerras pau...@samba.org Cc: Anton Blanchard an...@samba.org Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Cc: Anshuman Khandual khand...@linux.vnet.ibm.com Cc: Stephane Eranian eran...@google.com Signed-off-by: Madhavan Srinivasan ma...@linux.vnet.ibm.com --- arch/powerpc/perf/nest-pmu.h | 53 1 file changed, 53 insertions(+) create mode 100644 arch/powerpc/perf/nest-pmu.h diff --git a/arch/powerpc/perf/nest-pmu.h b/arch/powerpc/perf/nest-pmu.h new file mode 100644 index 000..ecb5d26 --- /dev/null +++ b/arch/powerpc/perf/nest-pmu.h @@ -0,0 +1,53 @@ +/* + * Nest Performance Monitor counter support for POWER8 processors. + * + * Copyright (C) 2015 Madhavan Srinivasan, IBM Corporation. + * + * 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 linux/perf_event.h +#include linux/slab.h +#include linux/of.h +#include linux/io.h +#include asm/opal.h + +#define P8_NEST_MAX_CHIPS 32 +#define P8_NEST_MAX_PMUS 32 +#define P8_NEST_MAX_PMU_NAME_LEN 256 +#define P8_NEST_MAX_EVENTS_SUPPORTED 256 +#define P8_NEST_ENGINE_START 1 +#define P8_NEST_ENGINE_STOP0 + +/* + * Structure to hold per chip specific memory address + * information for nest pmus. Nest Counter data are exported + * in per-chip reserved memory region by the PORE Engine. + */ +struct perchip_nest_info { + uint32_t chip_id; + uint64_t pbase; + uint64_t vbase; + uint32_t size; +}; + +/* + * Place holder for nest pmu events and values. + */ +struct nest_ima_events { + const char *ev_name; + const char *ev_value; +}; + +/* + * Device tree parser code detects nest pmu support and + * registers new nest pmus. This structure will + * hold the pmu functions and attrs for each nest pmu and + * will be referenced at the time of pmu registration. + */ +struct nest_pmu { + struct pmu pmu; + const struct attribute_group *attr_groups[4]; +}; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v4 2/7] powerpc/powernv: Add OPAL support for Nest PMU
Nest Counters can be configured via PORE Engine and OPAL provides an interface to start/stop it. OPAL side patches are posted in the skiboot mailing. Cc: Stewart Smith stew...@linux.vnet.ibm.com Cc: Jeremy Kerr j...@ozlabs.org Cc: Benjamin Herrenschmidt b...@kernel.crashing.org Cc: Michael Ellerman m...@ellerman.id.au Cc: Paul Mackerras pau...@samba.org Cc: Anton Blanchard an...@samba.org Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Cc: Anshuman Khandual khand...@linux.vnet.ibm.com Cc: Stephane Eranian eran...@google.com Signed-off-by: Madhavan Srinivasan ma...@linux.vnet.ibm.com --- arch/powerpc/include/asm/opal-api.h| 3 ++- arch/powerpc/include/asm/opal.h| 1 + arch/powerpc/platforms/powernv/opal-wrappers.S | 1 + 3 files changed, 4 insertions(+), 1 deletion(-) diff --git a/arch/powerpc/include/asm/opal-api.h b/arch/powerpc/include/asm/opal-api.h index e9e4c52..4cd8128 100644 --- a/arch/powerpc/include/asm/opal-api.h +++ b/arch/powerpc/include/asm/opal-api.h @@ -154,7 +154,8 @@ #define OPAL_FLASH_WRITE 111 #define OPAL_FLASH_ERASE 112 #define OPAL_PRD_MSG 113 -#define OPAL_LAST 113 +#define OPAL_NEST_IMA_CONTROL 116 +#define OPAL_LAST 116 /* Device tree flags */ diff --git a/arch/powerpc/include/asm/opal.h b/arch/powerpc/include/asm/opal.h index 958e941..7cb6215 100644 --- a/arch/powerpc/include/asm/opal.h +++ b/arch/powerpc/include/asm/opal.h @@ -202,6 +202,7 @@ int64_t opal_flash_write(uint64_t id, uint64_t offset, uint64_t buf, uint64_t size, uint64_t token); int64_t opal_flash_erase(uint64_t id, uint64_t offset, uint64_t size, uint64_t token); +int64_t opal_nest_ima_control(uint32_t value); /* Internal functions */ extern int early_init_dt_scan_opal(unsigned long node, const char *uname, diff --git a/arch/powerpc/platforms/powernv/opal-wrappers.S b/arch/powerpc/platforms/powernv/opal-wrappers.S index d6a7b82..c475c04 100644 --- a/arch/powerpc/platforms/powernv/opal-wrappers.S +++ b/arch/powerpc/platforms/powernv/opal-wrappers.S @@ -297,3 +297,4 @@ OPAL_CALL(opal_flash_read, OPAL_FLASH_READ); OPAL_CALL(opal_flash_write,OPAL_FLASH_WRITE); OPAL_CALL(opal_flash_erase,OPAL_FLASH_ERASE); OPAL_CALL(opal_prd_msg,OPAL_PRD_MSG); +OPAL_CALL(opal_nest_ima_control, OPAL_NEST_IMA_CONTROL); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v4 5/7] powerpc/powernv: add event attribute and group to nest pmu
Add code to create event/format attributes and attribute groups for each nest pmu. Cc: Michael Ellerman m...@ellerman.id.au Cc: Benjamin Herrenschmidt b...@kernel.crashing.org Cc: Paul Mackerras pau...@samba.org Cc: Anton Blanchard an...@samba.org Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Cc: Anshuman Khandual khand...@linux.vnet.ibm.com Cc: Stephane Eranian eran...@google.com Signed-off-by: Madhavan Srinivasan ma...@linux.vnet.ibm.com --- arch/powerpc/perf/nest-pmu.c | 57 1 file changed, 57 insertions(+) diff --git a/arch/powerpc/perf/nest-pmu.c b/arch/powerpc/perf/nest-pmu.c index 6116ff3..20ed9f8 100644 --- a/arch/powerpc/perf/nest-pmu.c +++ b/arch/powerpc/perf/nest-pmu.c @@ -13,6 +13,17 @@ static struct perchip_nest_info p8_nest_perchip_info[P8_NEST_MAX_CHIPS]; static struct nest_pmu *per_nest_pmu_arr[P8_NEST_MAX_PMUS]; +PMU_FORMAT_ATTR(event, config:0-20); +struct attribute *p8_nest_format_attrs[] = { + format_attr_event.attr, + NULL, +}; + +struct attribute_group p8_nest_format_group = { + .name = format, + .attrs = p8_nest_format_attrs, +}; + static int nest_event_info(struct property *pp, char *start, struct nest_ima_events *p8_events, int flg, u32 val) { @@ -45,6 +56,48 @@ static int nest_event_info(struct property *pp, char *start, return 0; } +/* + * Populate event name and string in attribute + */ +struct attribute *dev_str_attr(const char *name, const char *str) +{ + struct perf_pmu_events_attr *attr; + + attr = kzalloc(sizeof(*attr), GFP_KERNEL); + + attr-event_str = str; + attr-attr.attr.name = name; + attr-attr.attr.mode = 0444; + attr-attr.show = perf_event_sysfs_show; + + return attr-attr.attr; +} + +int update_events_in_group( + struct nest_ima_events *p8_events, int idx, struct nest_pmu *pmu) +{ + struct attribute_group *attr_group; + struct attribute **attrs; + int i; + + /* Allocate memory for event attribute group */ + attr_group = kzalloc(((sizeof(struct attribute *) * (idx + 1)) + + sizeof(*attr_group)), GFP_KERNEL); + if (!attr_group) + return -ENOMEM; + + attrs = (struct attribute **)(attr_group + 1); + attr_group-name = events; + attr_group-attrs = attrs; + + for (i = 0; i idx; i++, p8_events++) + attrs[i] = dev_str_attr((char *)p8_events-ev_name, + (char *)p8_events-ev_value); + + pmu-attr_groups[0] = attr_group; + return 0; +} + static int nest_pmu_create(struct device_node *dev, int pmu_index) { struct nest_ima_events **p8_events_arr, *p8_events; @@ -91,6 +144,7 @@ static int nest_pmu_create(struct device_node *dev, int pmu_index) /* Save the name to register it later */ sprintf(buf, Nest_%s, (char *)pp-value); pmu_ptr-pmu.name = (char *)buf; + pmu_ptr-attr_groups[1] = p8_nest_format_group; continue; } @@ -122,6 +176,9 @@ static int nest_pmu_create(struct device_node *dev, int pmu_index) idx++; } + update_events_in_group( + (struct nest_ima_events *)p8_events_arr, idx, pmu_ptr); + return 0; } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v4 0/7]powerpc/powernv: Nest Instrumentation support
This patchset enables Nest Instrumentation support on powerpc. POWER8 has per-chip Nest Intrumentation which provides various per-chip metrics like memory, powerbus, Xlink and Alink bandwidth. Nest Instrumentation provides an interface (via PORE Engine) to configure and move the nest counter data to memory. From kernel side, OPAL Call interface is used to activate/deactivate PORE Engine for nest data collection. OPAL at boot, detects the feature, initializes it and pass on the nest units and other related information such as memory region, events supported so on, to kernel via device-tree. Kernel code then, parses the device-tree for nest pmu support and registers nest pmu with the events available. PORE Engine collects and accumulate nest counter data in per-chip reserved memory region, hence device-tree also exports per-chip nest accumulation memory region. And individual event offset are used as event configuration values. Here is sample perf usage to explain the interface. #./perf list iTLB-load-misses [Hardware cache event] Nest_Alink_BW/Alink0/ [Kernel PMU event] Nest_Alink_BW/Alink1/ [Kernel PMU event] Nest_Alink_BW/Alink2/ [Kernel PMU event] Nest_MCS_Read_BW/MCS_00/ [Kernel PMU event] Nest_MCS_Read_BW/MCS_01/ [Kernel PMU event] Nest_MCS_Read_BW/MCS_02/ [Kernel PMU event] Nest_MCS_Read_BW/MCS_03/ [Kernel PMU event] Nest_MCS_Write_BW/MCS_00/ [Kernel PMU event] Nest_MCS_Write_BW/MCS_01/ [Kernel PMU event] Nest_MCS_Write_BW/MCS_02/ [Kernel PMU event] Nest_MCS_Write_BW/MCS_03/ [Kernel PMU event] Nest_PowerBus_BW/External/ [Kernel PMU event] Nest_PowerBus_BW/Internal/ [Kernel PMU event] Nest_Xlink_BW/Xlink0/ [Kernel PMU event] Nest_Xlink_BW/Xlink1/ [Kernel PMU event] Nest_Xlink_BW/Xlink2/ [Kernel PMU event] rNNN [Raw hardware event descriptor] cpu/t1=v1[,t2=v2,t3 ...]/modifier [Raw hardware event descriptor] . # ./perf stat -e 'Nest_Xlink_BW/Xlink1/' -a -A sleep 1 Performance counter stats for 'system wide': CPU0 15,913.18 MiB Nest_Xlink_BW/Xlink1/ CPU3211,955.88 MiB Nest_Xlink_BW/Xlink1/ CPU6411,042.43 MiB Nest_Xlink_BW/Xlink1/ CPU9614,065.27 MiB Nest_Xlink_BW/Xlink1/ 1.001062038 seconds time elapsed # ./perf stat -e 'Nest_Alink_BW/Alink0/,Nest_Alink_BW/Alink1/,Nest_Alink_BW/Alink2/' -a -A -I 1000 sleep 5 Performance counter stats for 'system wide': CPU0 0.00 MiB Nest_Alink_BW/Alink0/ (100.00%) CPU32 0.00 MiB Nest_Alink_BW/Alink0/ (100.00%) CPU64 0.00 MiB Nest_Alink_BW/Alink0/ (100.00%) CPU96 0.00 MiB Nest_Alink_BW/Alink0/ (100.00%) CPU0 1,430.43 MiB Nest_Alink_BW/Alink1/ (100.00%) CPU32 320.99 MiB Nest_Alink_BW/Alink1/ (100.00%) CPU64 3,443.83 MiB Nest_Alink_BW/Alink1/ (100.00%) CPU96 1,904.41 MiB Nest_Alink_BW/Alink1/ (100.00%) CPU0 2,856.85 MiB Nest_Alink_BW/Alink2/ CPU32 7.50 MiB Nest_Alink_BW/Alink2/ CPU64 4,034.29 MiB Nest_Alink_BW/Alink2/ CPU96 288.49 MiB Nest_Alink_BW/Alink2/ . OPAL side patches are posted in the skiboot mailing list. Changelog from v3: No logic change, just a rebase to latest upstream kernel. Changelog from v2: 1) Changed variable and macro names to be consistent. 2) Made changes to commit message and code comment messages 3) Moved format attribute related code from patch 6 to 5 4) Added check for pmu register function 5) Changed cpu_init and cpu_exit functions to use first online cpu of the chip, there by making code lot simplier. Changelog from v1: 1) No logic changes, re-ordered patches make each patch compile without errors 2) Added comments based on the review feedback. 3) removed perf_event_del function and replaced it with perf_event_stop. 4) Moved Nest feature detection code out of parser function. 5) Optimized functions and removed some variables. 6) squashed the makefile changes, instead of the separate patch 7) squashed the cpumask and hotplug patches as single patch 8) Added cpu checks in
[PATCH v4 6/7] powerpc/powernv: generic nest pmu event functions
Add set of generic nest pmu related event functions to be used by each nest pmu. Add code to register nest pmus. Cc: Michael Ellerman m...@ellerman.id.au Cc: Benjamin Herrenschmidt b...@kernel.crashing.org Cc: Paul Mackerras pau...@samba.org Cc: Anton Blanchard an...@samba.org Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Cc: Anshuman Khandual khand...@linux.vnet.ibm.com Cc: Stephane Eranian eran...@google.com Signed-off-by: Madhavan Srinivasan ma...@linux.vnet.ibm.com --- arch/powerpc/perf/nest-pmu.c | 104 +++ 1 file changed, 104 insertions(+) diff --git a/arch/powerpc/perf/nest-pmu.c b/arch/powerpc/perf/nest-pmu.c index 20ed9f8..c2ada13 100644 --- a/arch/powerpc/perf/nest-pmu.c +++ b/arch/powerpc/perf/nest-pmu.c @@ -24,6 +24,100 @@ struct attribute_group p8_nest_format_group = { .attrs = p8_nest_format_attrs, }; +static int p8_nest_event_init(struct perf_event *event) +{ + int chip_id; + + if (event-attr.type != event-pmu-type) + return -ENOENT; + + /* Sampling not supported yet */ + if (event-hw.sample_period) + return -EINVAL; + + /* unsupported modes and filters */ + if (event-attr.exclude_user || + event-attr.exclude_kernel || + event-attr.exclude_hv || + event-attr.exclude_idle || + event-attr.exclude_host || + event-attr.exclude_guest) + return -EINVAL; + + if (event-cpu 0) + return -EINVAL; + + chip_id = topology_physical_package_id(event-cpu); + event-hw.event_base = event-attr.config + + p8_nest_perchip_info[chip_id].vbase; + + return 0; +} + +static void p8_nest_read_counter(struct perf_event *event) +{ + uint64_t *addr; + u64 data = 0; + + addr = (u64 *)event-hw.event_base; + data = __be64_to_cpu(*addr); + local64_set(event-hw.prev_count, data); +} + +static void p8_nest_perf_event_update(struct perf_event *event) +{ + u64 counter_prev, counter_new, final_count; + uint64_t *addr; + + addr = (uint64_t *)event-hw.event_base; + counter_prev = local64_read(event-hw.prev_count); + counter_new = __be64_to_cpu(*addr); + final_count = counter_new - counter_prev; + + local64_set(event-hw.prev_count, counter_new); + local64_add(final_count, event-count); +} + +static void p8_nest_event_start(struct perf_event *event, int flags) +{ + event-hw.state = 0; + p8_nest_read_counter(event); +} + +static void p8_nest_event_stop(struct perf_event *event, int flags) +{ + if (flags PERF_EF_UPDATE) + p8_nest_perf_event_update(event); +} + +static int p8_nest_event_add(struct perf_event *event, int flags) +{ + if (flags PERF_EF_START) + p8_nest_event_start(event, flags); + + return 0; +} + +/* + * Populate pmu ops in the structure + */ +static int update_pmu_ops(struct nest_pmu *pmu) +{ + if (!pmu) + return -EINVAL; + + pmu-pmu.task_ctx_nr = perf_invalid_context; + pmu-pmu.event_init = p8_nest_event_init; + pmu-pmu.add = p8_nest_event_add; + pmu-pmu.del = p8_nest_event_stop; + pmu-pmu.start = p8_nest_event_start; + pmu-pmu.stop = p8_nest_event_stop; + pmu-pmu.read = p8_nest_perf_event_update; + pmu-pmu.attr_groups = pmu-attr_groups; + + return 0; +} + static int nest_event_info(struct property *pp, char *start, struct nest_ima_events *p8_events, int flg, u32 val) { @@ -179,6 +273,16 @@ static int nest_pmu_create(struct device_node *dev, int pmu_index) update_events_in_group( (struct nest_ima_events *)p8_events_arr, idx, pmu_ptr); + update_pmu_ops(pmu_ptr); + /* Register the pmu */ + ret = perf_pmu_register(pmu_ptr-pmu, pmu_ptr-pmu.name, -1); + if (ret) { + pr_err(Nest PMU %s Register failed\n, pmu_ptr-pmu.name); + return ret; + } + + pr_info(%s performance monitor hardware support registered\n, + pmu_ptr-pmu.name); return 0; } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 34/37] usb: musb: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/musb/musb_gadget.c | 12 1 file changed, 12 insertions(+) diff --git a/drivers/usb/musb/musb_gadget.c b/drivers/usb/musb/musb_gadget.c index 625d482f..043248a 100644 --- a/drivers/usb/musb/musb_gadget.c +++ b/drivers/usb/musb/musb_gadget.c @@ -1729,6 +1729,7 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) INIT_LIST_HEAD(ep-end_point.ep_list); if (!epnum) { usb_ep_set_maxpacket_limit(ep-end_point, 64); + ep-end_point.caps.type_control = true; ep-end_point.ops = musb_g_ep0_ops; musb-g.ep0 = ep-end_point; } else { @@ -1736,9 +1737,20 @@ init_peripheral_ep(struct musb *musb, struct musb_ep *ep, u8 epnum, int is_in) usb_ep_set_maxpacket_limit(ep-end_point, hw_ep-max_packet_sz_tx); else usb_ep_set_maxpacket_limit(ep-end_point, hw_ep-max_packet_sz_rx); + ep-end_point.caps.type_iso = true; + ep-end_point.caps.type_bulk = true; + ep-end_point.caps.type_int = true; ep-end_point.ops = musb_ep_ops; list_add_tail(ep-end_point.ep_list, musb-g.ep_list); } + + if (!epnum || hw_ep-is_shared_fifo) { + ep-end_point.caps.dir_in = true; + ep-end_point.caps.dir_out = true; + } else if (is_in) + ep-end_point.caps.dir_in = true; + else + ep-end_point.caps.dir_out = true; } /* -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 05/37] usb: chipidea: udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/chipidea/udc.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/drivers/usb/chipidea/udc.c b/drivers/usb/chipidea/udc.c index 764f668..eff7cfb 100644 --- a/drivers/usb/chipidea/udc.c +++ b/drivers/usb/chipidea/udc.c @@ -1624,6 +1624,20 @@ static int init_eps(struct ci_hdrc *ci) hwep-ep.name = hwep-name; hwep-ep.ops = usb_ep_ops; + + if (i == 0) { + hwep-ep.caps.type_control = true; + } else { + hwep-ep.caps.type_iso = true; + hwep-ep.caps.type_bulk = true; + hwep-ep.caps.type_int = true; + } + + if (j == TX) + hwep-ep.caps.dir_in = true; + else + hwep-ep.caps.dir_out = true; + /* * for ep0: maxP defined in desc, for other * eps, maxP is set by epautoconfig() called -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 11/37] usb: gadget: bdc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/bdc/bdc_ep.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/usb/gadget/udc/bdc/bdc_ep.c b/drivers/usb/gadget/udc/bdc/bdc_ep.c index b04980c..f9a8f57 100644 --- a/drivers/usb/gadget/udc/bdc/bdc_ep.c +++ b/drivers/usb/gadget/udc/bdc/bdc_ep.c @@ -1952,12 +1952,18 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir) ep-bdc = bdc; ep-dir = dir; + if (dir) + ep-usb_ep.caps.dir_in = true; + else + ep-usb_ep.caps.dir_out = true; + /* ep-ep_num is the index inside bdc_ep */ if (epnum == 1) { ep-ep_num = 1; bdc-bdc_ep_array[ep-ep_num] = ep; snprintf(ep-name, sizeof(ep-name), ep%d, epnum - 1); usb_ep_set_maxpacket_limit(ep-usb_ep, EP0_MAX_PKT_SIZE); + ep-usb_ep.caps.type_control = true; ep-comp_desc = NULL; bdc-gadget.ep0 = ep-usb_ep; } else { @@ -1971,6 +1977,9 @@ static int init_ep(struct bdc *bdc, u32 epnum, u32 dir) dir 1 ? in : out); usb_ep_set_maxpacket_limit(ep-usb_ep, 1024); + ep-usb_ep.caps.type_iso = true; + ep-usb_ep.caps.type_bulk = true; + ep-usb_ep.caps.type_int = true; ep-usb_ep.max_streams = 0; list_add_tail(ep-usb_ep.ep_list, bdc-gadget.ep_list); } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 17/37] usb: gadget: goku_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/goku_udc.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/usb/gadget/udc/goku_udc.c b/drivers/usb/gadget/udc/goku_udc.c index 9e8d842..46b8d14 100644 --- a/drivers/usb/gadget/udc/goku_udc.c +++ b/drivers/usb/gadget/udc/goku_udc.c @@ -1257,6 +1257,14 @@ static void udc_reinit (struct goku_udc *dev) INIT_LIST_HEAD (ep-queue); ep_reset(NULL, ep); + + if (i == 0) + ep-ep.caps.type_control = true; + else + ep-ep.caps.type_bulk = true; + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } dev-ep[0].reg_mode = NULL; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 19/37] usb: gadget: lpc32xx_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/lpc32xx_udc.c | 32 1 file changed, 32 insertions(+) diff --git a/drivers/usb/gadget/udc/lpc32xx_udc.c b/drivers/usb/gadget/udc/lpc32xx_udc.c index 3b6a785..00b5006 100644 --- a/drivers/usb/gadget/udc/lpc32xx_udc.c +++ b/drivers/usb/gadget/udc/lpc32xx_udc.c @@ -2575,6 +2575,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep0, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_CONTROL, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 0, @@ -2586,6 +2588,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep1-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 2, @@ -2597,6 +2601,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep2-bulk, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 4, @@ -2608,6 +2614,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep3-iso, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 1023, .hwep_num_base = 6, @@ -2619,6 +2627,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep4-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 8, @@ -2630,6 +2640,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep5-bulk, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 10, @@ -2641,6 +2653,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep6-iso, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 1023, .hwep_num_base = 12, @@ -2652,6 +2666,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep7-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 14, @@ -2663,6 +2679,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep8-bulk, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_BULK, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 64, .hwep_num_base = 16, @@ -2674,6 +2692,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep9-iso, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ISO, + USB_EP_CAPS_DIR_ALL), }, .maxpacket = 1023, .hwep_num_base = 18, @@ -2685,6 +2705,8 @@ static const struct lpc32xx_udc controller_template = { .ep = { .name = ep10-int, .ops= lpc32xx_ep_ops, + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_INT, + USB_EP_CAPS_DIR_ALL), },
[PATCH 29/37] usb: gadget: r8a66597-udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/r8a66597-udc.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/usb/gadget/udc/r8a66597-udc.c b/drivers/usb/gadget/udc/r8a66597-udc.c index 0293f71..baa0609 100644 --- a/drivers/usb/gadget/udc/r8a66597-udc.c +++ b/drivers/usb/gadget/udc/r8a66597-udc.c @@ -1935,6 +1935,16 @@ static int r8a66597_probe(struct platform_device *pdev) ep-ep.name = r8a66597_ep_name[i]; ep-ep.ops = r8a66597_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, 512); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(r8a66597-ep[0].ep, 64); r8a66597-ep[0].pipenum = 0; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 35/37] usb: renesas: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/renesas_usbhs/mod_gadget.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/drivers/usb/renesas_usbhs/mod_gadget.c b/drivers/usb/renesas_usbhs/mod_gadget.c index dc2aa32..ed8d890 100644 --- a/drivers/usb/renesas_usbhs/mod_gadget.c +++ b/drivers/usb/renesas_usbhs/mod_gadget.c @@ -1041,12 +1041,18 @@ int usbhs_mod_gadget_probe(struct usbhs_priv *priv) if (usbhsg_is_dcp(uep)) { gpriv-gadget.ep0 = uep-ep; usb_ep_set_maxpacket_limit(uep-ep, 64); + uep-ep.caps.type_control = true; } /* init normal pipe */ else { usb_ep_set_maxpacket_limit(uep-ep, 512); + uep-ep.caps.type_iso = true; + uep-ep.caps.type_bulk = true; + uep-ep.caps.type_int = true; list_add_tail(uep-ep.ep_list, gpriv-gadget.ep_list); } + uep-ep.caps.dir_in = true; + uep-ep.caps.dir_out = true; } ret = usb_add_gadget_udc(dev, gpriv-gadget); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 03/37] usb: gadget: add endpoint capabilities helper macros
Add macros useful while initializing array of endpoint capabilities structures. These macros makes structure initialization more compact to decrease number of code lines and increase readability of code. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- include/linux/usb/gadget.h | 20 1 file changed, 20 insertions(+) diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 6f3e0fb..e6cbc25 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -158,6 +158,26 @@ struct usb_ep_caps { unsigned dir_out:1; }; +#define USB_EP_CAPS_TYPE_CONTROL 0x01 +#define USB_EP_CAPS_TYPE_ISO 0x02 +#define USB_EP_CAPS_TYPE_BULK0x04 +#define USB_EP_CAPS_TYPE_INT 0x08 +#define USB_EP_CAPS_TYPE_ALL \ + (USB_EP_CAPS_TYPE_ISO | USB_EP_CAPS_TYPE_BULK | USB_EP_CAPS_TYPE_INT) +#define USB_EP_CAPS_DIR_IN 0x01 +#define USB_EP_CAPS_DIR_OUT 0x02 +#define USB_EP_CAPS_DIR_ALL (USB_EP_CAPS_DIR_IN | USB_EP_CAPS_DIR_OUT) + +#define USB_EP_CAPS(_type, _dir) \ + { \ + .type_control = !!(_type USB_EP_CAPS_TYPE_CONTROL), \ + .type_iso = !!(_type USB_EP_CAPS_TYPE_ISO), \ + .type_bulk = !!(_type USB_EP_CAPS_TYPE_BULK), \ + .type_int = !!(_type USB_EP_CAPS_TYPE_INT), \ + .dir_in = !!(_dir USB_EP_CAPS_DIR_IN), \ + .dir_out = !!(_dir USB_EP_CAPS_DIR_OUT), \ + } + /** * struct usb_ep - device side representation of USB endpoint * @name:identifier for the endpoint, such as ep-a or ep9in-bulk -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 23/37] usb: gadget: net2272: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/net2272.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/gadget/udc/net2272.c b/drivers/usb/gadget/udc/net2272.c index 195baf3..34ec1ec 100644 --- a/drivers/usb/gadget/udc/net2272.c +++ b/drivers/usb/gadget/udc/net2272.c @@ -1404,6 +1404,17 @@ net2272_usb_reinit(struct net2272 *dev) else ep-fifo_size = 64; net2272_ep_reset(ep); + + if (i == 0) { + ep-ep.caps.type_control = true; + } else { + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; + } + + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; } usb_ep_set_maxpacket_limit(dev-ep[0].ep, 64); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 24/37] usb: gadget: net2280: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/net2280.c | 50 ++-- 1 file changed, 38 insertions(+), 12 deletions(-) diff --git a/drivers/usb/gadget/udc/net2280.c b/drivers/usb/gadget/udc/net2280.c index 2bee912..0295cf7 100644 --- a/drivers/usb/gadget/udc/net2280.c +++ b/drivers/usb/gadget/udc/net2280.c @@ -74,19 +74,41 @@ static const char driver_desc[] = DRIVER_DESC; static const u32 ep_bit[9] = { 0, 17, 2, 19, 4, 1, 18, 3, 20 }; static const char ep0name[] = ep0; -static const char *const ep_name[] = { - ep0name, - ep-a, ep-b, ep-c, ep-d, - ep-e, ep-f, ep-g, ep-h, -}; -/* Endpoint names for usb3380 advance mode */ -static const char *const ep_name_adv[] = { - ep0name, - ep1in, ep2out, ep3in, ep4out, - ep1out, ep2in, ep3out, ep4in, +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info_dft[] = { /* Default endpoint configuration */ + EP_INFO(ep0name, CONTROL, ALL), + EP_INFO(ep-a, ALL,ALL), + EP_INFO(ep-b, ALL,ALL), + EP_INFO(ep-c, ALL,ALL), + EP_INFO(ep-d, ALL,ALL), + EP_INFO(ep-e, ALL,ALL), + EP_INFO(ep-f, ALL,ALL), + EP_INFO(ep-g, ALL,ALL), + EP_INFO(ep-h, ALL,ALL), +}, ep_info_adv[] = { /* Endpoints for usb3380 advance mode */ + EP_INFO(ep0name, CONTROL, ALL), + EP_INFO(ep1in,ALL,IN), + EP_INFO(ep2out, ALL,OUT), + EP_INFO(ep3in,ALL,IN), + EP_INFO(ep4out, ALL,OUT), + EP_INFO(ep1out, ALL,OUT), + EP_INFO(ep2in,ALL,IN), + EP_INFO(ep3out, ALL,OUT), + EP_INFO(ep4in,ALL,IN), }; +#undef EP_INFO + /* mode 0 == ep-{a,b,c,d} 1K fifo each * mode 1 == ep-{a,b} 2K fifo each, ep-{c,d} unavailable * mode 2 == ep-a 2K fifo, ep-{b,c} 1K each, ep-d unavailable @@ -2055,7 +2077,8 @@ static void usb_reinit_228x(struct net2280 *dev) for (tmp = 0; tmp 7; tmp++) { struct net2280_ep *ep = dev-ep[tmp]; - ep-ep.name = ep_name[tmp]; + ep-ep.name = ep_info_dft[tmp].name; + ep-ep.caps = ep_info_dft[tmp].caps; ep-dev = dev; ep-num = tmp; @@ -2095,7 +2118,10 @@ static void usb_reinit_338x(struct net2280 *dev) for (i = 0; i dev-n_ep; i++) { struct net2280_ep *ep = dev-ep[i]; - ep-ep.name = dev-enhanced_mode ? ep_name_adv[i] : ep_name[i]; + ep-ep.name = dev-enhanced_mode ? ep_info_adv[i].name : + ep_info_dft[i].name; + ep-ep.caps = dev-enhanced_mode ? ep_info_adv[i].caps : + ep_info_dft[i].caps; ep-dev = dev; ep-num = i; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 33/37] usb: isp1760: udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/isp1760/isp1760-udc.c | 11 +++ 1 file changed, 11 insertions(+) diff --git a/drivers/usb/isp1760/isp1760-udc.c b/drivers/usb/isp1760/isp1760-udc.c index 3699962..1c3d0fd 100644 --- a/drivers/usb/isp1760/isp1760-udc.c +++ b/drivers/usb/isp1760/isp1760-udc.c @@ -1383,13 +1383,24 @@ static void isp1760_udc_init_eps(struct isp1760_udc *udc) */ if (ep_num == 0) { usb_ep_set_maxpacket_limit(ep-ep, 64); + ep-ep.caps.type_control = true; + ep-ep.caps.dir_in = true; + ep-ep.caps.dir_out = true; ep-maxpacket = 64; udc-gadget.ep0 = ep-ep; } else { usb_ep_set_maxpacket_limit(ep-ep, 512); + ep-ep.caps.type_iso = true; + ep-ep.caps.type_bulk = true; + ep-ep.caps.type_int = true; ep-maxpacket = 0; list_add_tail(ep-ep.ep_list, udc-gadget.ep_list); } + + if (is_in) + ep-ep.caps.dir_in = true; + else + ep-ep.caps.dir_out = true; } } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 01/37] usb: gadget: encapsulate endpoint claiming mechanism
So far it was necessary for usb functions to set ep-driver_data in endpoint obtained from autoconfig to non-null value, to indicate that endpoint is claimed by function (in autoconfig it was checked if endpoint has set this field to non-null value, and if it has, it was assumed that it is claimed). It could cause bugs becouse if some function doesn't set this field autoconfig could return the same endpoint more than one time. To help to avoid such bugs this patch adds claimed flag to struct usb_ep, and encapsulates endpoint claiming mechanism inside usb_ep_autoconfig_ss() and usb_ep_autoconfig_reset(), so now usb functions doesn't need to perform any additional actions to mark endpoint obtained from autoconfig as claimed. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/epautoconf.c | 11 ++- include/linux/usb/gadget.h | 1 + 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/drivers/usb/gadget/epautoconf.c b/drivers/usb/gadget/epautoconf.c index 919cdfd..8e00ca7 100644 --- a/drivers/usb/gadget/epautoconf.c +++ b/drivers/usb/gadget/epautoconf.c @@ -53,7 +53,7 @@ ep_matches ( int num_req_streams = 0; /* endpoint already claimed? */ - if (NULL != ep-driver_data) + if (ep-claimed) return 0; /* only support ep0 for portable CONTROL traffic */ @@ -240,7 +240,7 @@ find_ep (struct usb_gadget *gadget, const char *name) * updated with the assigned number of streams if it is * different from the original value. To prevent the endpoint * from being returned by a later autoconfig call, claim it by - * assigning ep-driver_data to some non-null value. + * assigning ep-claimed to true. * * On failure, this returns a null endpoint descriptor. */ @@ -323,6 +323,7 @@ struct usb_ep *usb_ep_autoconfig_ss( found_ep: ep-desc = NULL; ep-comp_desc = NULL; + ep-claimed = true; return ep; } EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); @@ -354,7 +355,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig_ss); * descriptor bEndpointAddress. For bulk endpoints, the wMaxPacket value * is initialized as if the endpoint were used at full speed. To prevent * the endpoint from being returned by a later autoconfig call, claim it - * by assigning ep-driver_data to some non-null value. + * by assigning ep-claimed to true. * * On failure, this returns a null endpoint descriptor. */ @@ -373,7 +374,7 @@ EXPORT_SYMBOL_GPL(usb_ep_autoconfig); * * Use this for devices where one configuration may need to assign * endpoint resources very differently from the next one. It clears - * state such as ep-driver_data and the record of assigned endpoints + * state such as ep-claimed and the record of assigned endpoints * used by usb_ep_autoconfig(). */ void usb_ep_autoconfig_reset (struct usb_gadget *gadget) @@ -381,7 +382,7 @@ void usb_ep_autoconfig_reset (struct usb_gadget *gadget) struct usb_ep *ep; list_for_each_entry (ep, gadget-ep_list, ep_list) { - ep-driver_data = NULL; + ep-claimed = false; } gadget-in_epnum = 0; gadget-out_epnum = 0; diff --git a/include/linux/usb/gadget.h b/include/linux/usb/gadget.h index 4f3dfb7..fcb0a4e 100644 --- a/include/linux/usb/gadget.h +++ b/include/linux/usb/gadget.h @@ -173,6 +173,7 @@ struct usb_ep { const char *name; const struct usb_ep_ops *ops; struct list_headep_list; + boolclaimed; unsignedmaxpacket:16; unsignedmaxpacket_limit:16; unsignedmax_streams:16; -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 04/37] staging: emxx_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Fixed typo in epc-nulk to epc-bulk. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/staging/emxx_udc/emxx_udc.c | 60 ++--- 1 file changed, 29 insertions(+), 31 deletions(-) diff --git a/drivers/staging/emxx_udc/emxx_udc.c b/drivers/staging/emxx_udc/emxx_udc.c index 3b7aa36..0d64bee 100644 --- a/drivers/staging/emxx_udc/emxx_udc.c +++ b/drivers/staging/emxx_udc/emxx_udc.c @@ -3153,36 +3153,33 @@ static const struct usb_gadget_ops nbu2ss_gadget_ops = { .ioctl = nbu2ss_gad_ioctl, }; -static const char g_ep0_name[] = ep0; -static const char g_ep1_name[] = ep1-bulk; -static const char g_ep2_name[] = ep2-bulk; -static const char g_ep3_name[] = ep3in-int; -static const char g_ep4_name[] = ep4-iso; -static const char g_ep5_name[] = ep5-iso; -static const char g_ep6_name[] = ep6-bulk; -static const char g_ep7_name[] = ep7-bulk; -static const char g_ep8_name[] = ep8in-int; -static const char g_ep9_name[] = ep9-iso; -static const char g_epa_name[] = epa-iso; -static const char g_epb_name[] = epb-bulk; -static const char g_epc_name[] = epc-nulk; -static const char g_epd_name[] = epdin-int; - -static const char *gp_ep_name[NUM_ENDPOINTS] = { - g_ep0_name, - g_ep1_name, - g_ep2_name, - g_ep3_name, - g_ep4_name, - g_ep5_name, - g_ep6_name, - g_ep7_name, - g_ep8_name, - g_ep9_name, - g_epa_name, - g_epb_name, - g_epc_name, - g_epd_name, +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[NUM_ENDPOINTS] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + + EP_INFO(ep0, CONTROL, ALL), + EP_INFO(ep1-bulk, BULK, ALL), + EP_INFO(ep2-bulk, BULK, ALL), + EP_INFO(ep3in-int,INT,IN), + EP_INFO(ep4-iso, INT,ALL), + EP_INFO(ep5-iso, ISO,ALL), + EP_INFO(ep6-bulk, ISO,ALL), + EP_INFO(ep7-bulk, BULK, ALL), + EP_INFO(ep8in-int,INT,IN), + EP_INFO(ep9-iso, ISO,ALL), + EP_INFO(epa-iso, ISO,ALL), + EP_INFO(epb-bulk, BULK, ALL), + EP_INFO(epc-bulk, BULK, ALL), + EP_INFO(epdin-int,INT,IN), + +#undef EP_INFO }; /*-*/ @@ -3200,7 +3197,8 @@ static void __init nbu2ss_drv_ep_init(struct nbu2ss_udc *udc) ep-desc = NULL; ep-ep.driver_data = NULL; - ep-ep.name = gp_ep_name[i]; + ep-ep.name = ep_info[i].name; + ep-ep.caps = ep_info[i].caps; ep-ep.ops = nbu2ss_ep_ops; usb_ep_set_maxpacket_limit(ep-ep, -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 06/37] usb: dwc2: gadget: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/dwc2/gadget.c | 13 + 1 file changed, 13 insertions(+) diff --git a/drivers/usb/dwc2/gadget.c b/drivers/usb/dwc2/gadget.c index 4d47b7c..8771b66 100644 --- a/drivers/usb/dwc2/gadget.c +++ b/drivers/usb/dwc2/gadget.c @@ -3289,6 +3289,19 @@ static void s3c_hsotg_initep(struct dwc2_hsotg *hsotg, usb_ep_set_maxpacket_limit(hs_ep-ep, epnum ? 1024 : EP0_MPS_LIMIT); hs_ep-ep.ops = s3c_hsotg_ep_ops; + if (epnum == 0) { + hs_ep-ep.caps.type_control = true; + } else { + hs_ep-ep.caps.type_iso = true; + hs_ep-ep.caps.type_bulk = true; + hs_ep-ep.caps.type_int = true; + } + + if (dir_in) + hs_ep-ep.caps.dir_in = true; + else + hs_ep-ep.caps.dir_out = true; + /* * if we're using dma, we need to set the next-endpoint pointer * to be something valid. -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 09/37] usb: gadget: at91_udc: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/at91_udc.c | 33 - 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/drivers/usb/gadget/udc/at91_udc.c b/drivers/usb/gadget/udc/at91_udc.c index fc42264..a04b073 100644 --- a/drivers/usb/gadget/udc/at91_udc.c +++ b/drivers/usb/gadget/udc/at91_udc.c @@ -59,15 +59,29 @@ #defineDRIVER_VERSION 3 May 2006 static const char driver_name [] = at91_udc; -static const char * const ep_names[] = { - ep0, - ep1, - ep2, - ep3-int, - ep4, - ep5, + +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + + EP_INFO(ep0, CONTROL, ALL), + EP_INFO(ep1, ALL,ALL), + EP_INFO(ep2, ALL,ALL), + EP_INFO(ep3-int, INT,ALL), + EP_INFO(ep4, ALL,ALL), + EP_INFO(ep5, ALL,ALL), + +#undef EP_INFO }; -#define ep0nameep_names[0] + +#define ep0nameep_info[0].name #define VBUS_POLL_TIMEOUT msecs_to_jiffies(1000) @@ -1830,7 +1844,8 @@ static int at91udc_probe(struct platform_device *pdev) for (i = 0; i NUM_ENDPOINTS; i++) { ep = udc-ep[i]; - ep-ep.name = ep_names[i]; + ep-ep.name = ep_info[i].name; + ep-ep.caps = ep_info[i].caps; ep-ep.ops = at91_ep_ops; ep-udc = udc; ep-int_mask = BIT(i); -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH 12/37] usb: gadget: dummy-hcd: add ep capabilities support
Convert endpoint configuration to new capabilities model. Signed-off-by: Robert Baldyga r.bald...@samsung.com --- drivers/usb/gadget/udc/dummy_hcd.c | 65 +- 1 file changed, 50 insertions(+), 15 deletions(-) diff --git a/drivers/usb/gadget/udc/dummy_hcd.c b/drivers/usb/gadget/udc/dummy_hcd.c index 181112c..69fd29a 100644 --- a/drivers/usb/gadget/udc/dummy_hcd.c +++ b/drivers/usb/gadget/udc/dummy_hcd.c @@ -127,23 +127,57 @@ static inline struct dummy_request *usb_request_to_dummy_request static const char ep0name[] = ep0; -static const char *const ep_name[] = { - ep0name,/* everyone has ep0 */ +static const struct { + const char *name; + const struct usb_ep_caps caps; +} ep_info[] = { +#define EP_INFO(_name, _type, _dir) \ + { \ + .name = _name, \ + .caps = USB_EP_CAPS(USB_EP_CAPS_TYPE_ ## _type, \ + USB_EP_CAPS_DIR_ ## _dir), \ + } + /* everyone has ep0 */ + EP_INFO(ep0name,CONTROL, ALL), /* act like a pxa250: fifteen fixed function endpoints */ - ep1in-bulk, ep2out-bulk, ep3in-iso, ep4out-iso, ep5in-int, - ep6in-bulk, ep7out-bulk, ep8in-iso, ep9out-iso, ep10in-int, - ep11in-bulk, ep12out-bulk, ep13in-iso, ep14out-iso, - ep15in-int, - + EP_INFO(ep1in-bulk, BULK, IN), + EP_INFO(ep2out-bulk, BULK, OUT), + EP_INFO(ep3in-iso,ISO,IN), + EP_INFO(ep4out-iso, ISO,OUT), + EP_INFO(ep5in-int,INT,IN), + EP_INFO(ep6in-bulk, BULK, IN), + EP_INFO(ep7out-bulk, BULK, OUT), + EP_INFO(ep8in-iso,ISO,IN), + EP_INFO(ep9out-iso, ISO,OUT), + EP_INFO(ep10in-int, INT,IN), + EP_INFO(ep11in-bulk, BULK, IN), + EP_INFO(ep12out-bulk, BULK, OUT), + EP_INFO(ep13in-iso, ISO,IN), + EP_INFO(ep14out-iso, ISO,OUT), + EP_INFO(ep15in-int, INT,IN), /* or like sa1100: two fixed function endpoints */ - ep1out-bulk, ep2in-bulk, - + EP_INFO(ep1out-bulk, BULK, OUT), + EP_INFO(ep2in-bulk, BULK, IN), /* and now some generic EPs so we have enough in multi config */ - ep3out, ep4in, ep5out, ep6out, ep7in, ep8out, ep9in, - ep10out, ep11out, ep12in, ep13out, ep14in, ep15out, + EP_INFO(ep3out, ALL,OUT), + EP_INFO(ep4in,ALL,IN), + EP_INFO(ep5out, ALL,OUT), + EP_INFO(ep6out, ALL,OUT), + EP_INFO(ep7in,ALL,IN), + EP_INFO(ep8out, ALL,OUT), + EP_INFO(ep9in,ALL,IN), + EP_INFO(ep10out, ALL,OUT), + EP_INFO(ep11out, ALL,OUT), + EP_INFO(ep12in, ALL,IN), + EP_INFO(ep13out, ALL,OUT), + EP_INFO(ep14in, ALL,IN), + EP_INFO(ep15out, ALL,OUT), + +#undef EP_INFO }; -#define DUMMY_ENDPOINTSARRAY_SIZE(ep_name) + +#define DUMMY_ENDPOINTSARRAY_SIZE(ep_info) /*-*/ @@ -938,9 +972,10 @@ static void init_dummy_udc_hw(struct dummy *dum) for (i = 0; i DUMMY_ENDPOINTS; i++) { struct dummy_ep *ep = dum-ep[i]; - if (!ep_name[i]) + if (!ep_info[i].name) break; - ep-ep.name = ep_name[i]; + ep-ep.name = ep_info[i].name; + ep-ep.caps = ep_info[i].caps; ep-ep.ops = dummy_ep_ops; list_add_tail(ep-ep.ep_list, dum-gadget.ep_list); ep-halted = ep-wedged = ep-already_seen = @@ -1684,7 +1719,7 @@ static void dummy_timer(unsigned long _dum_hcd) } for (i = 0; i DUMMY_ENDPOINTS; i++) { - if (!ep_name[i]) + if (!ep_info[i].name) break; dum-ep[i].already_seen = 0; } -- 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v4 7/7] powerpc/powernv: nest pmu cpumask and cpu hotplug support
Adds cpumask attribute to be used by each nest pmu since nest units are per-chip. Only one cpu (first online cpu) from each node/chip is designated to read counters. On cpu hotplug, dying cpu is checked to see whether it is one of the designated cpus, if yes, next online cpu from the same node/chip is designated as new cpu to read counters. Cc: Michael Ellerman m...@ellerman.id.au Cc: Benjamin Herrenschmidt b...@kernel.crashing.org Cc: Paul Mackerras pau...@samba.org Cc: Anton Blanchard an...@samba.org Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com Cc: Anshuman Khandual khand...@linux.vnet.ibm.com Cc: Stephane Eranian eran...@google.com Cc: Preeti U Murthy preet...@andrew.cmu.edu Cc: Ingo Molnar mi...@kernel.org Cc: Peter Zijlstra pet...@infradead.org Signed-off-by: Madhavan Srinivasan ma...@linux.vnet.ibm.com --- arch/powerpc/perf/nest-pmu.c | 146 +++ 1 file changed, 146 insertions(+) diff --git a/arch/powerpc/perf/nest-pmu.c b/arch/powerpc/perf/nest-pmu.c index c2ada13..31943c5 100644 --- a/arch/powerpc/perf/nest-pmu.c +++ b/arch/powerpc/perf/nest-pmu.c @@ -12,6 +12,7 @@ static struct perchip_nest_info p8_nest_perchip_info[P8_NEST_MAX_CHIPS]; static struct nest_pmu *per_nest_pmu_arr[P8_NEST_MAX_PMUS]; +static cpumask_t nest_pmu_cpu_mask; PMU_FORMAT_ATTR(event, config:0-20); struct attribute *p8_nest_format_attrs[] = { @@ -24,6 +25,147 @@ struct attribute_group p8_nest_format_group = { .attrs = p8_nest_format_attrs, }; +static ssize_t nest_pmu_cpumask_get_attr(struct device *dev, + struct device_attribute *attr, char *buf) +{ + return cpumap_print_to_pagebuf(true, buf, nest_pmu_cpu_mask); +} + +static DEVICE_ATTR(cpumask, S_IRUGO, nest_pmu_cpumask_get_attr, NULL); + +static struct attribute *nest_pmu_cpumask_attrs[] = { + dev_attr_cpumask.attr, + NULL, +}; + +static struct attribute_group nest_pmu_cpumask_attr_group = { + .attrs = nest_pmu_cpumask_attrs, +}; + +static void nest_init(void *dummy) +{ + opal_nest_ima_control(P8_NEST_ENGINE_START); +} + +static void nest_change_cpu_context(int old_cpu, int new_cpu) +{ + int i; + + for (i = 0; per_nest_pmu_arr[i] != NULL; i++) + perf_pmu_migrate_context(per_nest_pmu_arr[i]-pmu, + old_cpu, new_cpu); +} + +static void nest_exit_cpu(int cpu) +{ + int nid, target = -1; + struct cpumask *l_cpumask; + + /* +* Check in the designated list for this cpu. Dont bother +* if not one of them. +*/ + if (!cpumask_test_and_clear_cpu(cpu, nest_pmu_cpu_mask)) + return; + + /* +* Now that this cpu is one of the designated, +* find a next cpu a) which is online and b) in same chip. +*/ + nid = cpu_to_node(cpu); + l_cpumask = cpumask_of_node(nid); + target = cpumask_next(cpu, l_cpumask); + + /* +* Update the cpumask with the target cpu and +* migrate the context if needed +*/ + if (target = 0 target = nr_cpu_ids) { + cpumask_set_cpu(target, nest_pmu_cpu_mask); + nest_change_cpu_context(cpu, target); + } +} + +static void nest_init_cpu(int cpu) +{ + int nid, fcpu, ncpu; + struct cpumask *l_cpumask, tmp_mask; + + nid = cpu_to_node(cpu); + l_cpumask = cpumask_of_node(nid); + + /* +* if empty cpumask, just add incoming cpu and move on. +*/ + if (!cpumask_and(tmp_mask, l_cpumask, nest_pmu_cpu_mask)) { + cpumask_set_cpu(cpu, nest_pmu_cpu_mask); + return; + } + + /* +* Alway have the first online cpu of a chip as designated one. +*/ + fcpu = cpumask_first(l_cpumask); + ncpu = cpumask_next(cpu, l_cpumask); + if (cpu == fcpu) { + if (cpumask_test_and_clear_cpu(ncpu, nest_pmu_cpu_mask)) { + cpumask_set_cpu(cpu, nest_pmu_cpu_mask); + nest_change_cpu_context(ncpu, cpu); + } + } +} + +static int nest_pmu_cpu_notifier(struct notifier_block *self, + unsigned long action, void *hcpu) +{ + long cpu = (long)hcpu; + + switch (action ~CPU_TASKS_FROZEN) { + case CPU_ONLINE: + nest_init_cpu(cpu); + break; + case CPU_DOWN_PREPARE: + nest_exit_cpu(cpu); + break; + default: + break; + } + + return NOTIFY_OK; +} + +static struct notifier_block nest_pmu_cpu_nb = { + .notifier_call = nest_pmu_cpu_notifier, + .priority = CPU_PRI_PERF + 1, +}; + +void nest_pmu_cpumask_init(void) +{ + const struct cpumask *l_cpumask; + int cpu, nid; + + cpu_notifier_register_begin(); + + /* +* Nest PMUs are per-chip counters. So designate a cpu +* from each
Re: [PATCH V3 0/5] Allow user to request memory to be locked on page fault
On Wed, 8 Jul 2015 09:23:02 -0400 Eric B Munson emun...@akamai.com wrote: I don't know whether these syscalls should be documented via new manpages, or if we should instead add them to the existing mlock/munlock/mlockall manpages. Michael, could you please advise? Thanks for adding the series. I owe you several updates (getting the new syscall right for all architectures and a set of tests for the new syscalls). Would you prefer a new pair of patches or I update this set? It doesn't matter much. I guess a full update will be more convenient at your end. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2] Caps in not always shift
From: Dinar Valeev dval...@suse.com Caps behaves like shift only for latin characters. In case we're typing - for example with caps enabled, SLOF picks _ char from shifted table. Threat caps as shift only for letters. Signed-off-by: Dinar Valeev dval...@suse.com --- lib/libusb/usb-hid.c | 32 +--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/lib/libusb/usb-hid.c b/lib/libusb/usb-hid.c index f0cab8a..18210ae 100644 --- a/lib/libusb/usb-hid.c +++ b/lib/libusb/usb-hid.c @@ -28,6 +28,10 @@ #define HID_REQ_SET_IDLE0x0A #define HID_REQ_SET_PROTOCOL0x0B +//key position for latin letters +#define KEYP_LATIN_A 4 +#define KEYP_LATIN_Z 29 + //#define KEY_DEBUG /* HID SPEC - 7.2.6 Set_Protocol Request */ @@ -83,6 +87,8 @@ uint8_t set_leds; const uint8_t *key_std = NULL; const uint8_t *key_std_shift = NULL; +uint8_t ctrl; /* modifiers */ + /** * read character from Keyboard-Buffer * @@ -111,6 +117,18 @@ static void write_key(uint8_t key) } /** + * Checks if keypos is a latin key + * @param keypos + * @return - + */ +void check_latin(uint8_t keypos) + if (keypos KEYP_LATIN_A || keypos KEYP_LATIN_Z) { + return true; + } else { + return false; + } + +/** * Convert keyboard usage-ID to ANSI-Code * * @param Ctrl=Modifier Byte @@ -120,22 +138,24 @@ static void write_key(uint8_t key) static void get_char(uint8_t ctrl, uint8_t keypos) { uint8_t ch; + bool caps = false; #ifdef KEY_DEBUG printf(pos %02X\n, keypos); #endif if (set_leds LED_CAPS_LOCK) /* is CAPS Lock set ? */ - ctrl |= MODIFIER_SHIFT; /* simulate shift */ + caps = true; - if (ctrl == 0) { + /* caps is a shift only for latin chars */ + if ((!caps ctrl == 0) || (caps !check_latin(keypos))) { ch = key_std[keypos]; if (ch != 0) write_key(ch); return; } - if (ctrl MODIFIER_SHIFT) { + if ((ctrl MODIFIER_SHIFT) || caps) { ch = key_std_shift[keypos]; if (ch != 0) write_key(ch); @@ -187,6 +207,12 @@ static void check_key_code(uint8_t *buf) set_leds ^= LED_CAPS_LOCK; break; + case 0x36: /*Shift pressed*/ + ctrl |= MODIFIER_SHIFT; + break; + case 0xb6: /*Shift unpressed*/ + ctrl = ~MODIFIER_SHIFT; + break; case 0x3a: /* F1 */ write_key(0x1b); write_key(0x5b); -- 2.1.4 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
PASEMI: PA6T board doesn't boot with the RC1 of kernel 4.2 anymore
Dear Linuxppc-dev mailing list, I used git bisect and found out that the following commit is the problem. commit 3ceaccdf92073d193f0bfbe24280dd736e3fed86 Author: Dave Hansen dave.han...@linux.intel.com Log: git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-git git bisect start b953c0d234bc72e8489d3bf51a276c5c4ec85345 (Linux 4.1) git bisect bad d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (Linux 4.2-rc1) Output: Bisecting: 6261 revisions left to test after this (roughly 13 steps) [4570a37169d4b44d316f40b2ccc681dc93fedc7b] Merge tag 'sound-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound git bisect bad Output: Bisecting: 3295 revisions left to test after this (roughly 12 steps) [4e241557fc1cb560bd9e77ca1b4a9352732a5427] Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm git bisect bad Output: Bisecting: 1625 revisions left to test after this (roughly 11 steps) [44d21c3f3a2ef2f58b18bda64c52c99e723f3f4a] Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 git bisect bad Output: Bisecting: 712 revisions left to test after this (roughly 10 steps) [e75c73ad64478c12b3a44b86a3e7f62a4f65b93e] Merge branch 'x86-fpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect bad (sometimes the kernel boots but the mouse doesn't work) Output: Bisecting: 371 revisions left to test after this (roughly 9 steps) [c58267e9fa7b0345dd9006939254701e3622ca6a] Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect good Output: Bisecting: 185 revisions left to test after this (roughly 8 steps) [59a36d16be8f9f68410f1bd396577fb7f31ae877] x86/fpu: Factor out fpu/regset.h from fpu/internal.h git bisect good Output: Bisecting: 93 revisions left to test after this (roughly 7 steps) [23b7776290b10297fe2cae0fb5f166a4f2c68121] Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect good Output: Bisecting: 46 revisions left to test after this (roughly 6 steps) [0c4109bec0a6cde471bef3a21cd6f8384a614469] x86/fpu/xstate: Fix up bad get_xsave_addr() assumptions git bisect good Output: Bisecting: 19 revisions left to test after this (roughly 5 steps) [cfe3eceb7a2eb91284d5605c5315249bb165e9d3] Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect good Output: Bisecting: 9 revisions left to test after this (roughly 3 steps) [cd4996dce18b619bd7b3acf75c91f49c77f05a97] x86/mpx: Trace allocation of new bounds tables git bisect good Output: Bisecting: 4 revisions left to test after this (roughly 2 steps) [613fcb7d3c79ec25b5913a6aa974c9047c31e68c] x86/mpx: Support 32-bit binaries on 64-bit kernels git bisect good Output: Bisecting: 2 revisions left to test after this (roughly 1 step) [bea03c50b871a2fa922f31ad7c9993bb4fc7b192] x86/mpx: Do not count MPX VMAs as neighbors when unmapping git bisect bad (sometimes the kernel boots but the mouse doesn't work) Output: Bisecting: 0 revisions left to test after this (roughly 0 steps) [3ceaccdf92073d193f0bfbe24280dd736e3fed86] x86/mpx: Rewrite the unmap code git bisect bad (sometimes the kernel boots but the mouse doesn't work) Output: 3ceaccdf92073d193f0bfbe24280dd736e3fed86 is the first bad commit commit 3ceaccdf92073d193f0bfbe24280dd736e3fed86 Author: Dave Hansen dave.han...@linux.intel.com Date: Sun Jun 7 11:37:06 2015 -0700 x86/mpx: Rewrite the unmap code The MPX code needs to clear out bounds tables for memory which is no longer in use. We do this when a userspace mapping is torn down (unmapped). There are two modes: 1. An entire bounds table becomes unused, and can be freed and its pointer removed from the bounds directory. This happens either when a large mapping is torn down, or when a small mapping is torn down and it is the last mapping covered by a bounds table. 2. Only part of a bounds table becomes unused, in which case we free the backing memory as if MADV_DONTNEED was called. The old code was a spaghetti mess of edge bounds tables where the edges were handled specially, even if we were unmapping an entire one. Non-edge bounds tables are always fully unmapped, but share a different code path from the edge ones. The old code had a bug where it was unmapping too much memory. I worked on fixing it for two days and gave up. I didn't write the original code. I didn't particularly like it, but it worked, so I left it. After my debug session, I realized it was undebuggagle *and* buggy, so out it went. I also wrote a new unmapping test program which uncovers bugs pretty nicely. Signed-off-by: Dave Hansen dave.han...@linux.intel.com Reviewed-by: Thomas Gleixner
Re: [PATCH V3 3/5] mm: mlock: Introduce VM_LOCKONFAULT and add mlock flags to enable it
On Tue, 7 Jul 2015 13:03:41 -0400 Eric B Munson emun...@akamai.com wrote: This patch introduces the ability to request that pages are not pre-faulted, but are placed on the unevictable LRU when they are finally faulted in. This can be done area at a time via the mlock2(MLOCK_ONFAULT) or the mlockall(MCL_ONFAULT) system calls. These calls can be undone via munlock2(MLOCK_ONFAULT) or munlockall2(MCL_ONFAULT). Quick, possibly dumb question: I've been beating my head against these for a little bit, and I can't figure out what's supposed to happen in this case: mlock2(addr, len, MLOCK_ONFAULT); munlock2(addr, len, MLOCK_LOCKED); It looks to me like it will clear VM_LOCKED without actually unlocking any pages. Is that the intended result? Thanks, jon ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V3 3/5] mm: mlock: Introduce VM_LOCKONFAULT and add mlock flags to enable it
On Wed, 8 Jul 2015 16:34:56 -0400 Eric B Munson emun...@akamai.com wrote: Quick, possibly dumb question: I've been beating my head against these for a little bit, and I can't figure out what's supposed to happen in this case: mlock2(addr, len, MLOCK_ONFAULT); munlock2(addr, len, MLOCK_LOCKED); It looks to me like it will clear VM_LOCKED without actually unlocking any pages. Is that the intended result? This is not quite right, what happens when you call munlock2(addr, len, MLOCK_LOCKED); is we call apply_vma_flags(addr, len, VM_LOCKED, false). From your explanation, it looks like what I said *was* right...what I was missing was the fact that VM_LOCKED isn't set in the first place. So that call would be a no-op, clearing a flag that's already cleared. One other question...if I call mlock2(MLOCK_ONFAULT) on a range that already has resident pages, I believe that those pages will not be locked until they are reclaimed and faulted back in again, right? I suspect that could be surprising to users. Thanks, jon ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v4 4/7] powerpc/powernv: detect supported nest pmus and its events
Madhavan Srinivasan [ma...@linux.vnet.ibm.com] wrote: | Parse device tree to detect supported nest pmu units. Traverse | through each nest pmu unit folder to find supported events and | corresponding unit/scale files (if any). | | The nest unit event file from DT, will contain the offset in the | reserved memory region to get the counter data for a given event. | Kernel code uses this offset as event configuration value. | | Device tree parser code also looks for scale/unit in the file name and | passes on the file as an event attr for perf tool to use in the post | processing. | | Cc: Michael Ellerman m...@ellerman.id.au | Cc: Benjamin Herrenschmidt b...@kernel.crashing.org | Cc: Paul Mackerras pau...@samba.org | Cc: Anton Blanchard an...@samba.org | Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com | Cc: Anshuman Khandual khand...@linux.vnet.ibm.com | Cc: Stephane Eranian eran...@google.com | Signed-off-by: Madhavan Srinivasan ma...@linux.vnet.ibm.com | --- | arch/powerpc/perf/nest-pmu.c | 124 ++- | 1 file changed, 123 insertions(+), 1 deletion(-) | | diff --git a/arch/powerpc/perf/nest-pmu.c b/arch/powerpc/perf/nest-pmu.c | index e7d45ed..6116ff3 100644 | --- a/arch/powerpc/perf/nest-pmu.c | +++ b/arch/powerpc/perf/nest-pmu.c | @@ -11,6 +11,119 @@ | #include nest-pmu.h | | static struct perchip_nest_info p8_nest_perchip_info[P8_NEST_MAX_CHIPS]; | +static struct nest_pmu *per_nest_pmu_arr[P8_NEST_MAX_PMUS]; | + | +static int nest_event_info(struct property *pp, char *start, nit: s/start/name/? | + struct nest_ima_events *p8_events, int flg, u32 val) nit: s/flg/string/? | +{ | + char *buf; | + | + /* memory for event name */ | + buf = kzalloc(P8_NEST_MAX_PMU_NAME_LEN, GFP_KERNEL); | + if (!buf) | + return -ENOMEM; | + | + strncpy(buf, start, strlen(start)); | + p8_events-ev_name = buf; | + | + /* memory for content */ | + buf = kzalloc(P8_NEST_MAX_PMU_NAME_LEN, GFP_KERNEL); | + if (!buf) | + return -ENOMEM; | + | + if (flg) { | + /* string content*/ | + if (!pp-value || | +(strnlen(pp-value, pp-length) == pp-length)) | + return -EINVAL; | + | + strncpy(buf, (const char *)pp-value, pp-length); | + } else | + sprintf(buf, event=0x%x, val); | + | + p8_events-ev_value = buf; | + return 0; | +} | + | +static int nest_pmu_create(struct device_node *dev, int pmu_index) | +{ | + struct nest_ima_events **p8_events_arr, *p8_events; | + struct nest_pmu *pmu_ptr; | + struct property *pp; | + char *buf, *start; | + const __be32 *lval; | + u32 val; | + int idx = 0, ret; | + | + if (!dev) | + return -EINVAL; | + | + /* memory for nest pmus */ | + pmu_ptr = kzalloc(sizeof(struct nest_pmu), GFP_KERNEL); | + if (!pmu_ptr) | + return -ENOMEM; | + | + /* Needed for hotplug/migration */ | + per_nest_pmu_arr[pmu_index] = pmu_ptr; | + | + /* memory for nest pmu events */ | + p8_events_arr = kzalloc((sizeof(struct nest_ima_events) * 64), | + GFP_KERNEL); | + if (!p8_events_arr) | + return -ENOMEM; | + p8_events = (struct nest_ima_events *)p8_events_arr; | + | + /* | + * Loop through each property | + */ | + for_each_property_of_node(dev, pp) { | + start = pp-name; | + | + if (!strcmp(pp-name, name)) { | + if (!pp-value || | +(strnlen(pp-value, pp-length) == pp-length)) | + return -EINVAL; Do we need to check the string length here? If so, should we check against size we are going to allocate below (P8_NEST_MAX_PMU_NAME_LEN)? Or is it possible pp-value is not NULL terminated? | + | + buf = kzalloc(P8_NEST_MAX_PMU_NAME_LEN, GFP_KERNEL); | + if (!buf) | + return -ENOMEM; | + | + /* Save the name to register it later */ | + sprintf(buf, Nest_%s, (char *)pp-value); | + pmu_ptr-pmu.name = (char *)buf; | + continue; | + } | + | + /* Skip these, we dont need it */ | + if (!strcmp(pp-name, phandle) || | + !strcmp(pp-name, device_type) || | + !strcmp(pp-name, linux,phandle)) | + continue; | + | + if (strncmp(pp-name, unit., 5) == 0) { | + /* Skip first few chars in the name */ | + start += 5; | + ret = nest_event_info(pp, start, p8_events++, 1, 0); | + } else if (strncmp(pp-name, scale., 6) == 0) { | + /* Skip first few chars in the name */ | + start += 6; | +
Re: [PATCH V3 3/5] mm: mlock: Introduce VM_LOCKONFAULT and add mlock flags to enable it
On Wed, 08 Jul 2015, Jonathan Corbet wrote: On Tue, 7 Jul 2015 13:03:41 -0400 Eric B Munson emun...@akamai.com wrote: This patch introduces the ability to request that pages are not pre-faulted, but are placed on the unevictable LRU when they are finally faulted in. This can be done area at a time via the mlock2(MLOCK_ONFAULT) or the mlockall(MCL_ONFAULT) system calls. These calls can be undone via munlock2(MLOCK_ONFAULT) or munlockall2(MCL_ONFAULT). Quick, possibly dumb question: I've been beating my head against these for a little bit, and I can't figure out what's supposed to happen in this case: mlock2(addr, len, MLOCK_ONFAULT); munlock2(addr, len, MLOCK_LOCKED); It looks to me like it will clear VM_LOCKED without actually unlocking any pages. Is that the intended result? This is not quite right, what happens when you call munlock2(addr, len, MLOCK_LOCKED); is we call apply_vma_flags(addr, len, VM_LOCKED, false). The false argument means that we intend to clear the specified flags. Here is the relevant snippet: ... newflags = vma-vm_flags; if (add_flags) { newflags = ~(VM_LOCKED | VM_LOCKONFAULT); newflags |= flags; } else { newflags = ~flags; } ... Note that when we are adding flags, we first clear both VM_LOCKED and VM_LOCKONFAULT. This was done to match the behavior found in mlockall(). When we are remove flags, we simply clear the specified flag(s). So in your example the state of the VMAs covered by addr and len would remain unchanged. It sounds like apply_vma_flags() needs a comment covering this topic, I will include that in the set I am working on now. Eric signature.asc Description: Digital signature ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2 1/2] powerpc/kexec: Reset secondary cpu endianess before kexec
On Wed, 2015-07-08 at 14:37 +1000, Samuel Mendoza-Jonas wrote: If the target kernel does not inlcude the FIXUP_ENDIAN check, coming from a different-endian kernel will cause the target kernel to panic. All ppc64 kernels can handle starting in big-endian mode, so return to big-endian before branching into the target kernel. This mainly affects pseries as secondaries on powernv are returned to OPAL. Signed-off-by: Samuel Mendoza-Jonas sam...@au1.ibm.com --- v2: Add an #ifdef for subarch-specific code Neaten the endian check (and extra call to mfmsr!) by modifying the msr and branching to the target kernel in the same call to rfid. arch/powerpc/kernel/misc_64.S | 13 +++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/arch/powerpc/kernel/misc_64.S b/arch/powerpc/kernel/misc_64.S index 4e314b9..89f0600 100644 --- a/arch/powerpc/kernel/misc_64.S +++ b/arch/powerpc/kernel/misc_64.S @@ -475,9 +475,18 @@ _GLOBAL(kexec_wait) #ifdef CONFIG_KEXEC /* use no memory without kexec */ lwz r4,0(r5) cmpwi 0,r4,0 - bnea0x60 + beq 99b +#ifdef CONFIG_PPC_BOOK3S_64 + li r10,0x60 + mfmsr r11 + clrrdi r11,r11,1 /* Clear MSR_LE */ + mtsrr0 r10 + mtsrr1 r11 + rfid +#else + b 0x60 +#endif #endif - b 99b b 0x60 needs to be ba 0x60. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 28/37] usb: gadget: pxa27x_udc: add ep capabilities support
Robert Baldyga r.bald...@samsung.com writes: Convert endpoint configuration to new capabilities model. The commit message is very short to judge the patch's correctness. I'll side up with Felipe's opinion. If it's fine by him, so it is by me. Cheers. -- Robert ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2 2/2] powerpc/kexec: Reset HILE before kexec_sequence
Michael Ellerman m...@ellerman.id.au writes: On Wed, 2015-07-08 at 14:37 +1000, Samuel Mendoza-Jonas wrote: On powernv secondary cpus are returned to OPAL, and will then enter the target kernel in big-endian. However if it is set the HILE bit will persist, causing the first exception in the target kernel to be delivered in litte-endian regardless of the kernel endianess. Make sure that the HILE bit is switched off before entering kexec_sequence. Signed-off-by: Samuel Mendoza-Jonas sam...@au1.ibm.com --- arch/powerpc/kernel/machine_kexec_64.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c index 1a74446..2266135c 100644 --- a/arch/powerpc/kernel/machine_kexec_64.c +++ b/arch/powerpc/kernel/machine_kexec_64.c @@ -22,8 +22,10 @@ #include asm/page.h #include asm/current.h #include asm/machdep.h +#include asm/opal.h #include asm/cacheflush.h #include asm/paca.h +#include asm/firmware.h #include asm/mmu.h #include asm/sections.h /* _end */ #include asm/prom.h @@ -356,6 +358,10 @@ void default_machine_kexec(struct kimage *image) * switched to a static version! */ +/* Reset HILE in case we kexec into an older BE kernel */ +if (firmware_has_feature(FW_FEATURE_OPALv3)) +opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE); It's not safe to do this here. We are still in virtual mode and have external interrupts enabled, so you could easily take an exception of some kind and then you'd blow up. Mashing the keyboard during kexec might even be enough. Hrm... interrupts are disabled in kexec_sequence, should we be doing this there instead I wonder? At this point we're pretty much at the point of no return, so maybe we just need to disable interrupts first? I think a better API would be that opal_return_cpu() deals with this under the covers. I think we talked about that, so maybe there was some reason that wasn't possible. opal_return_cpu() acts on current CPU which if we started flipping HILE there we'd hit PowerISA 2.07 Section 2.11: The contents of the HILE bit must be the same for all threads under the control of a given instance of the hypervisor; otherwise all results are undefined. so we'd have to do something kind of funny in opal_return_cpu() to work out what's going on. Keeping in mind that opal_return_cpu() is also used in the fsp code update path (which I haven't gone and really looked at in this context though). I'm not convinced that opal_return_cpu() doing the HILE switch is safe when we'd be relying on the kernel to pretty much do this all at the same time (when we really have opal_reinit_cpus to do that) Although PowerISA also says: The HILE bit is set, by an implementa- tion-dependent method, during system initialization, and cannot be modified after system initialization. Which... umm... we are clearly doing and have been since we started supporting LE powernv, so there's something somewhere in some document describing it all... I just have to find it (or poke Ben to find out where he worked it out from). ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V3 2/5] mm: mlock: Add new mlock, munlock, and munlockall system calls
On Wed, Jul 8, 2015 at 8:46 AM, Heiko Carstens heiko.carst...@de.ibm.com wrote: diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S index 1acad02..f6d81d6 100644 --- a/arch/s390/kernel/syscalls.S +++ b/arch/s390/kernel/syscalls.S @@ -363,3 +363,6 @@ SYSCALL(sys_bpf,compat_sys_bpf) SYSCALL(sys_s390_pci_mmio_write,compat_sys_s390_pci_mmio_write) SYSCALL(sys_s390_pci_mmio_read,compat_sys_s390_pci_mmio_read) SYSCALL(sys_execveat,compat_sys_execveat) +SYSCALL(sys_mlock2,compat_sys_mlock2)/* 355 */ +SYSCALL(sys_munlock2,compat_sys_munlock2) +SYSCALL(sys_munlockall2,compat_sys_munlockall2) FWIW, you would also need to add matching lines to the two files arch/s390/include/uapi/asm/unistd.h arch/s390/kernel/compat_wrapper.c so that the system call would be wired up on s390. Similar comment for m68k: arch/m68k/include/asm/unistd.h arch/m68k/include/uapi/asm/unistd.h I think you best look at the last commits that added system calls, for all architectures, to make sure you don't do partial updates. 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
RE: [PATCH 2/2] rheap: move rheap.c from arch/powerpc/lib/ to lib/
So I will add two func for my use, do you think it is ok? I need to align the address of allocated muram. And I will set algo = gen_pool_first_fit_align. +unsigned long gen_pool_alloc_align(struct gen_pool *pool, size_t size, + unsigned long align) +{ + struct gen_pool_chunk *chunk; + unsigned long addr = 0; + unsigned long align_mask; + int order = pool-min_alloc_order; + int nbits, start_bit = 0, end_bit, remain; + +#ifndef CONFIG_ARCH_HAVE_NMI_SAFE_CMPXCHG + BUG_ON(in_nmi()); +#endif + + if (size == 0) + return 0; + + align_mask = ((align + (1UL order) - 1) order) - 1; + nbits = (size + (1UL order) - 1) order; + rcu_read_lock(); + list_for_each_entry_rcu(chunk, pool-chunks, next_chunk) { + if (size atomic_read(chunk-avail)) + continue; + + end_bit = chunk_size(chunk) order; +retry: + start_bit = pool-algo(chunk-bits, end_bit, start_bit, nbits, + pool-data, align_mask); + if (start_bit = end_bit) + continue; + remain = bitmap_set_ll(chunk-bits, start_bit, nbits); + if (remain) { + remain = bitmap_clear_ll(chunk-bits, start_bit, +nbits - remain); + BUG_ON(remain); + goto retry; + } + + addr = chunk-start_addr + ((unsigned long)start_bit order); + size = nbits order; + atomic_sub(size, chunk-avail); + break; + } + rcu_read_unlock(); + return addr; +} +EXPORT_SYMBOL(gen_pool_alloc); + * gen_pool_first_fit_align - find the first available region + * of memory matching the size requirement. The region will be aligned + * to the order of the size specified. + * @map: The address to base the search on + * @size: The bitmap size in bits + * @start: The bitnumber to start searching at + * @nr: The number of zeroed bits we're looking for + * @data: additional data - unused + */ +unsigned long gen_pool_first_fit_align(unsigned long *map, + unsigned long size, unsigned long start, + unsigned int nr, void *data, unsigned long align_mask) +{ + return bitmap_find_next_zero_area(map, size, start, nr, align_mask); +} +EXPORT_SYMBOL(gen_pool_first_fit_align); + Best Regards Zhao Qiang -Original Message- From: Wood Scott-B07421 Sent: Wednesday, July 08, 2015 11:28 AM To: Zhao Qiang-B45475 Cc: linuxppc-dev@lists.ozlabs.org; Xie Xiaobo-R63061 Subject: Re: [PATCH 2/2] rheap: move rheap.c from arch/powerpc/lib/ to lib/ On Tue, 2015-07-07 at 22:26 -0500, Zhao Qiang-B45475 wrote: Now the point is, genalloc is not so proper to qe muram while rheap is written to manage muram, rheap is not specific to muram. if use genalloc instead of rheap, there will be amounts of work to do. Not much. I think I've spent more time responding to continual e-mails on this topic than it would have taken to convert it. :-P I have a suggestion, how about to put rheap under drivers/soc/qe, because rheap is To manage muram when it is added to sdk. No. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] ipmi/powernv: Fix a minor bug
If the OPAL call to receive the ipmi message fails, then we free up the smi message before returning. But, the driver still holds the reference to old smi message in the 'cur_msg' which is dangerous if the driver derefernces it later and it will further block the subsequent ipmi operations. So, to fix it up, we need to nullify 'cur_msg' in the error case. Signed-off-by: Neelesh Gupta neele...@linux.vnet.ibm.com --- drivers/char/ipmi/ipmi_powernv.c |1 + 1 file changed, 1 insertion(+) diff --git a/drivers/char/ipmi/ipmi_powernv.c b/drivers/char/ipmi/ipmi_powernv.c index 9b409c0..08dd38f 100644 --- a/drivers/char/ipmi/ipmi_powernv.c +++ b/drivers/char/ipmi/ipmi_powernv.c @@ -143,6 +143,7 @@ static int ipmi_powernv_recv(struct ipmi_smi_powernv *smi) pr_devel(%s: - %d (size %lld)\n, __func__, rc, rc == 0 ? size : 0); if (rc) { + smi-cur_msg = NULL; spin_unlock_irqrestore(smi-msg_lock, flags); ipmi_free_smi_msg(msg); return 0; ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] powerpc/kexec: Reset HILE before kexec_sequence
Samuel Mendoza-Jonas sam...@au1.ibm.com writes: On powernv secondary cpus are returned to OPAL, and will then enter the target kernel in big-endian. However if it is set the HILE bit will persist, causing the first exception in the target kernel to be delivered in litte-endian regardless of the kernel endianess. Make sure that the HILE bit is switched off before entering kexec_sequence. Signed-off-by: Samuel Mendoza-Jonas sam...@au1.ibm.com Discussed with Sam on IRC, this makes kexec environment the same (or at least closer to) booting the initial payload, which is a Good Thing(TM). The ignoring of any error from opal_reinit_cpus() (as done in this patch) is probably a good idea as we're either running on old firmware which doesn't have the call (in which case we'd explode no matter what) or we're on some crazy theoretical chip that doesn't do HILE=0, in which case this gives us the best chance for compatibility. Reviewed-by: Stewart Smith stew...@linux.vnet.ibm.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V3 2/5] mm: mlock: Add new mlock, munlock, and munlockall system calls
On Tue, Jul 07, 2015 at 01:03:40PM -0400, Eric B Munson wrote: With the refactored mlock code, introduce new system calls for mlock, munlock, and munlockall. The new calls will allow the user to specify what lock states are being added or cleared. mlock2 and munlock2 are trivial at the moment, but a follow on patch will add a new mlock state making them useful. munlock2 addresses a limitation of the current implementation. If a user calls mlockall(MCL_CURRENT | MCL_FUTURE) and then later decides that MCL_FUTURE should be removed, they would have to call munlockall() followed by mlockall(MCL_CURRENT) which could potentially be very expensive. The new munlockall2 system call allows a user to simply clear the MCL_FUTURE flag. Signed-off-by: Eric B Munson emun...@akamai.com ... diff --git a/arch/s390/kernel/syscalls.S b/arch/s390/kernel/syscalls.S index 1acad02..f6d81d6 100644 --- a/arch/s390/kernel/syscalls.S +++ b/arch/s390/kernel/syscalls.S @@ -363,3 +363,6 @@ SYSCALL(sys_bpf,compat_sys_bpf) SYSCALL(sys_s390_pci_mmio_write,compat_sys_s390_pci_mmio_write) SYSCALL(sys_s390_pci_mmio_read,compat_sys_s390_pci_mmio_read) SYSCALL(sys_execveat,compat_sys_execveat) +SYSCALL(sys_mlock2,compat_sys_mlock2)/* 355 */ +SYSCALL(sys_munlock2,compat_sys_munlock2) +SYSCALL(sys_munlockall2,compat_sys_munlockall2) FWIW, you would also need to add matching lines to the two files arch/s390/include/uapi/asm/unistd.h arch/s390/kernel/compat_wrapper.c so that the system call would be wired up on s390. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] rheap: move rheap.c from arch/powerpc/lib/ to lib/
On Wed, 2015-07-08 at 22:18 -0500, Zhao Qiang-B45475 wrote: -Original Message- From: Wood Scott-B07421 Sent: Thursday, July 09, 2015 2:59 AM To: Zhao Qiang-B45475 Cc: linuxppc-dev@lists.ozlabs.org; Xie Xiaobo-R63061 Subject: Re: [PATCH 2/2] rheap: move rheap.c from arch/powerpc/lib/ to lib/ On Wed, 2015-07-08 at 02:25 -0500, Zhao Qiang-B45475 wrote: So I will add two func for my use, do you think it is ok? I need to align the address of allocated muram. And I will set algo = gen_pool_first_fit_align. +unsigned long gen_pool_alloc_align(struct gen_pool *pool, size_t size, + unsigned long align) Again, please explain why you need this for CPM/QE. I don't see rh_alloc_align() currently being used by either. Also, please stop top-posting. unsigned long rh_alloc(struct _rh_info *info, int size, const char *owner) { return rh_alloc_align(info, size, info-alignment, owner); } EXPORT_SYMBOL_GPL(rh_alloc); That doesn't involve a different alignment for each allocation. It uses the same alignment for all of them, and the alignment that cpm_common.c provides to rh_init() is 1 byte. ...but sigh, cpm_muram_alloc() is changing cpm_muram_info.alignment behind the rheap code's back. Despite the existence of rh_alloc_align(). So yes, add aligned allocation functionality to genalloc, but don't duplicate gen_pool_alloc() to do so. Instead, rename gen_pool_alloc() to gen_pool_alloc_align() with an alignment parameter (also modifying the algo function to take an alignment arg, which gen_pool_first_fit_order_align() would ignore), and provide a gen_pool_alloc() wrapper that specifies 1 as the required alignment. Also be sure to CC lkml on the patchset since you're touching core code that doesn't have its own maintainer or list. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] cxl: Destroy cxl_adapter_idr on module_exit
Destroy cxl_adapter_idr on module exit, reclaiming the allocated memory. This was detected by the following semantic patch (written by Luis Rodriguez mcg...@suse.com) SmPL @ defines_module_init @ declarer name module_init, module_exit; declarer name DEFINE_IDR; identifier init; @@ module_init(init); @ defines_module_exit @ identifier exit; @@ module_exit(exit); @ declares_idr depends on defines_module_init defines_module_exit @ identifier idr; @@ DEFINE_IDR(idr); @ on_exit_calls_destroy depends on declares_idr defines_module_exit @ identifier declares_idr.idr, defines_module_exit.exit; @@ exit(void) { ... idr_destroy(idr); ... } @ missing_module_idr_destroy depends on declares_idr defines_module_exit !on_exit_calls_destroy @ identifier declares_idr.idr, defines_module_exit.exit; @@ exit(void) { ... +idr_destroy(idr); } /SmPL Signed-off-by: Johannes Thumshirn jthumsh...@suse.de --- drivers/misc/cxl/main.c | 1 + 1 file changed, 1 insertion(+) diff --git a/drivers/misc/cxl/main.c b/drivers/misc/cxl/main.c index 833348e..4e58e0b 100644 --- a/drivers/misc/cxl/main.c +++ b/drivers/misc/cxl/main.c @@ -222,6 +222,7 @@ static void exit_cxl(void) cxl_debugfs_exit(); cxl_file_exit(); unregister_cxl_calls(cxl_calls); + idr_destroy(cxl_adapter_idr); } module_init(init_cxl); -- 2.4.3 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
RE: [PATCH 2/2] rheap: move rheap.c from arch/powerpc/lib/ to lib/
-Original Message- From: Wood Scott-B07421 Sent: Thursday, July 09, 2015 2:59 AM To: Zhao Qiang-B45475 Cc: linuxppc-dev@lists.ozlabs.org; Xie Xiaobo-R63061 Subject: Re: [PATCH 2/2] rheap: move rheap.c from arch/powerpc/lib/ to lib/ On Wed, 2015-07-08 at 02:25 -0500, Zhao Qiang-B45475 wrote: So I will add two func for my use, do you think it is ok? I need to align the address of allocated muram. And I will set algo = gen_pool_first_fit_align. +unsigned long gen_pool_alloc_align(struct gen_pool *pool, size_t size, + unsigned long align) Again, please explain why you need this for CPM/QE. I don't see rh_alloc_align() currently being used by either. Also, please stop top-posting. unsigned long rh_alloc(struct _rh_info *info, int size, const char *owner) { return rh_alloc_align(info, size, info-alignment, owner); } EXPORT_SYMBOL_GPL(rh_alloc); -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v2] powerpc/powernv: Fix race in updating core_idle_state
I recommend creating an alias or script that does: $ git log --pretty=fixes -n 1 $commit | xclip FWIW, having finally got around to doing this, I found I first needed the following snippet in ~/.gitconfig from https://www.kernel.org/doc/Documentation/SubmittingPatches [core] abbrev = 12 [pretty] fixes = Fixes: %h (\%s\) Otherwise git doesn't know what the pretty format is. -- Regards, Daniel signature.asc Description: This is a digitally signed message part ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: PASEMI: PA6T board doesn't boot with the RC1 of kernel 4.2 anymore
On Wed, 2015-07-08 at 20:00 +0200, Christian Zigotzky wrote: Dear Linuxppc-dev mailing list, I used git bisect and found out that the following commit is the problem. commit 3ceaccdf92073d193f0bfbe24280dd736e3fed86 Author: Dave Hansen dave.han...@linux.intel.com There is no way that commit affects anything on that platform, it only changes a file in arch/x86 that isn't compiled on a powerpc build. You must have made a mistake in your bisection, possibly the one sometimes boots should be considered good, but I can't say for sure. Michael has a PA6T board at work, so I assume he will see if he can reproduce. Ben. Log: git clone git://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git linux-git git bisect start b953c0d234bc72e8489d3bf51a276c5c4ec85345 (Linux 4.1) git bisect bad d770e558e21961ad6cfdf0ff7df0eb5d7d4f0754 (Linux 4.2-rc1) Output: Bisecting: 6261 revisions left to test after this (roughly 13 steps) [4570a37169d4b44d316f40b2ccc681dc93fedc7b] Merge tag 'sound-4.2-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound git bisect bad Output: Bisecting: 3295 revisions left to test after this (roughly 12 steps) [4e241557fc1cb560bd9e77ca1b4a9352732a5427] Merge tag 'for-linus' of git://git.kernel.org/pub/scm/virt/kvm/kvm git bisect bad Output: Bisecting: 1625 revisions left to test after this (roughly 11 steps) [44d21c3f3a2ef2f58b18bda64c52c99e723f3f4a] Merge git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 git bisect bad Output: Bisecting: 712 revisions left to test after this (roughly 10 steps) [e75c73ad64478c12b3a44b86a3e7f62a4f65b93e] Merge branch 'x86-fpu-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect bad (sometimes the kernel boots but the mouse doesn't work) Output: Bisecting: 371 revisions left to test after this (roughly 9 steps) [c58267e9fa7b0345dd9006939254701e3622ca6a] Merge branch 'perf-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect good Output: Bisecting: 185 revisions left to test after this (roughly 8 steps) [59a36d16be8f9f68410f1bd396577fb7f31ae877] x86/fpu: Factor out fpu/regset.h from fpu/internal.h git bisect good Output: Bisecting: 93 revisions left to test after this (roughly 7 steps) [23b7776290b10297fe2cae0fb5f166a4f2c68121] Merge branch 'sched-core-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect good Output: Bisecting: 46 revisions left to test after this (roughly 6 steps) [0c4109bec0a6cde471bef3a21cd6f8384a614469] x86/fpu/xstate: Fix up bad get_xsave_addr() assumptions git bisect good Output: Bisecting: 19 revisions left to test after this (roughly 5 steps) [cfe3eceb7a2eb91284d5605c5315249bb165e9d3] Merge branch 'x86-efi-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip git bisect good Output: Bisecting: 9 revisions left to test after this (roughly 3 steps) [cd4996dce18b619bd7b3acf75c91f49c77f05a97] x86/mpx: Trace allocation of new bounds tables git bisect good Output: Bisecting: 4 revisions left to test after this (roughly 2 steps) [613fcb7d3c79ec25b5913a6aa974c9047c31e68c] x86/mpx: Support 32-bit binaries on 64-bit kernels git bisect good Output: Bisecting: 2 revisions left to test after this (roughly 1 step) [bea03c50b871a2fa922f31ad7c9993bb4fc7b192] x86/mpx: Do not count MPX VMAs as neighbors when unmapping git bisect bad (sometimes the kernel boots but the mouse doesn't work) Output: Bisecting: 0 revisions left to test after this (roughly 0 steps) [3ceaccdf92073d193f0bfbe24280dd736e3fed86] x86/mpx: Rewrite the unmap code git bisect bad (sometimes the kernel boots but the mouse doesn't work) Output: 3ceaccdf92073d193f0bfbe24280dd736e3fed86 is the first bad commit commit 3ceaccdf92073d193f0bfbe24280dd736e3fed86 Author: Dave Hansen dave.han...@linux.intel.com Date: Sun Jun 7 11:37:06 2015 -0700 x86/mpx: Rewrite the unmap code The MPX code needs to clear out bounds tables for memory which is no longer in use. We do this when a userspace mapping is torn down (unmapped). There are two modes: 1. An entire bounds table becomes unused, and can be freed and its pointer removed from the bounds directory. This happens either when a large mapping is torn down, or when a small mapping is torn down and it is the last mapping covered by a bounds table. 2. Only part of a bounds table becomes unused, in which case we free the backing memory as if MADV_DONTNEED was called. The old code was a spaghetti mess of edge bounds tables where the edges were handled specially, even if we were unmapping an entire one. Non-edge
Re: [RFC PATCH 1/2] powerpc/numa: fix cpu_to_node() usage during boot
On Thu, 2 Jul 2015, Nishanth Aravamudan wrote: Much like on x86, now that powerpc is using USE_PERCPU_NUMA_NODE_ID, we have an ordering issue during boot with early calls to cpu_to_node(). The value returned by those calls now depend on the per-cpu area being setup, but that is not guaranteed to be the case during boot. Instead, we need to add an early_cpu_to_node() which doesn't use the per-CPU area and call that from certain spots that are known to invoke cpu_to_node() before the per-CPU areas are not configured. On an example 2-node NUMA system with the following topology: available: 2 nodes (0-1) node 0 cpus: 0 1 2 3 node 0 size: 2029 MB node 0 free: 1753 MB node 1 cpus: 4 5 6 7 node 1 size: 2045 MB node 1 free: 1945 MB node distances: node 0 1 0: 10 40 1: 40 10 we currently emit at boot: [0.00] pcpu-alloc: [0] 0 1 2 3 [0] 4 5 6 7 After this commit, we correctly emit: [0.00] pcpu-alloc: [0] 0 1 2 3 [1] 4 5 6 7 Signed-off-by: Nishanth Aravamudan n...@linux.vnet.ibm.com diff --git a/arch/powerpc/include/asm/topology.h b/arch/powerpc/include/asm/topology.h index 5f1048e..f2c4c89 100644 --- a/arch/powerpc/include/asm/topology.h +++ b/arch/powerpc/include/asm/topology.h @@ -39,6 +39,8 @@ static inline int pcibus_to_node(struct pci_bus *bus) extern int __node_distance(int, int); #define node_distance(a, b) __node_distance(a, b) +extern int early_cpu_to_node(int); + extern void __init dump_numa_cpu_topology(void); extern int sysfs_add_device_to_node(struct device *dev, int nid); diff --git a/arch/powerpc/kernel/setup_64.c b/arch/powerpc/kernel/setup_64.c index c69671c..23a2cf3 100644 --- a/arch/powerpc/kernel/setup_64.c +++ b/arch/powerpc/kernel/setup_64.c @@ -715,8 +715,8 @@ void __init setup_arch(char **cmdline_p) static void * __init pcpu_fc_alloc(unsigned int cpu, size_t size, size_t align) { - return __alloc_bootmem_node(NODE_DATA(cpu_to_node(cpu)), size, align, - __pa(MAX_DMA_ADDRESS)); + return __alloc_bootmem_node(NODE_DATA(early_cpu_to_node(cpu)), size, + align, __pa(MAX_DMA_ADDRESS)); } static void __init pcpu_fc_free(void *ptr, size_t size) @@ -726,7 +726,7 @@ static void __init pcpu_fc_free(void *ptr, size_t size) static int pcpu_cpu_distance(unsigned int from, unsigned int to) { - if (cpu_to_node(from) == cpu_to_node(to)) + if (early_cpu_to_node(from) == early_cpu_to_node(to)) return LOCAL_DISTANCE; else return REMOTE_DISTANCE; diff --git a/arch/powerpc/mm/numa.c b/arch/powerpc/mm/numa.c index 5e80621..9ffabf4 100644 --- a/arch/powerpc/mm/numa.c +++ b/arch/powerpc/mm/numa.c @@ -157,6 +157,11 @@ static void map_cpu_to_node(int cpu, int node) cpumask_set_cpu(cpu, node_to_cpumask_map[node]); } +int early_cpu_to_node(int cpu) +{ + return numa_cpu_lookup_table[cpu]; +} + #if defined(CONFIG_HOTPLUG_CPU) || defined(CONFIG_PPC_SPLPAR) static void unmap_cpu_from_node(unsigned long cpu) { early_cpu_to_node() looks like it's begging to be __init since we shouldn't have a need to reference to numa_cpu_lookup_table after boot and that appears like it can be done if pcpu_cpu_distance() is made __init in this patch and smp_prepare_boot_cpu() is made __init in the next patch. So I think this is fine, but those functions and things like reset_numa_cpu_lookup_table() should be in init.text. After the percpu areas on initialized and cpu_to_node() is correct, it would be really nice to be able to make numa_cpu_lookup_table[] be __initdata since it shouldn't be necessary anymore. That probably has cpu callbacks that need to be modified to no longer look at numa_cpu_lookup_table[] or pass the value in, but it would make it much cleaner. Then nobody will have to worry about figuring out whether early_cpu_to_node() or cpu_to_node() is the right one to call. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC,1/2] powerpc/numa: fix cpu_to_node() usage during boot
On 08.07.2015 [14:00:56 +1000], Michael Ellerman wrote: On Thu, 2015-02-07 at 23:02:02 UTC, Nishanth Aravamudan wrote: Much like on x86, now that powerpc is using USE_PERCPU_NUMA_NODE_ID, we have an ordering issue during boot with early calls to cpu_to_node(). now that .. implies we changed something and broke this. What commit was it that changed the behaviour? Well, that's something I'm trying to still unearth. In the commits before and after adding USE_PERCPU_NUMA_NODE_ID (8c272261194d powerpc/numa: Enable USE_PERCPU_NUMA_NODE_ID), the dmesg reports: pcpu-alloc: [0] 0 1 2 3 4 5 6 7 At least prior to 8c272261194d, this might have been due to the old powerpc-specific cpu_to_node(): static inline int cpu_to_node(int cpu) { int nid; nid = numa_cpu_lookup_table[cpu]; /* * During early boot, the numa-cpu lookup table might not have been * setup for all CPUs yet. In such cases, default to node 0. */ return (nid 0) ? 0 : nid; } which might imply that no one cares or that simply no one noticed. The value returned by those calls now depend on the per-cpu area being setup, but that is not guaranteed to be the case during boot. Instead, we need to add an early_cpu_to_node() which doesn't use the per-CPU area and call that from certain spots that are known to invoke cpu_to_node() before the per-CPU areas are not configured. On an example 2-node NUMA system with the following topology: available: 2 nodes (0-1) node 0 cpus: 0 1 2 3 node 0 size: 2029 MB node 0 free: 1753 MB node 1 cpus: 4 5 6 7 node 1 size: 2045 MB node 1 free: 1945 MB node distances: node 0 1 0: 10 40 1: 40 10 we currently emit at boot: [0.00] pcpu-alloc: [0] 0 1 2 3 [0] 4 5 6 7 After this commit, we correctly emit: [0.00] pcpu-alloc: [0] 0 1 2 3 [1] 4 5 6 7 So it looks fairly sane, and I guess it's a bug fix. But I'm a bit reluctant to put it in straight away without some time in next. I'm fine with that -- it could use some more extensive testing, admittedly (I only have been able to verify the pcpu areas are being correctly allocated on the right node so far). I still need to test with hotplug and things like that. Hence the RFC. It looks like the symptom is that the per-cpu areas are all allocated on node 0, is that all that goes wrong? Yes, that's the symptom. I cc'd a few folks to see if they could help indicate the performance implications of such a setup -- sorry, I should have been more explicit about that. Thanks, Nish ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: PASEMI: PA6T board doesn't boot with the RC1 of kernel 4.2 anymore
On Thu, 2015-07-09 at 08:36 +1000, Benjamin Herrenschmidt wrote: On Wed, 2015-07-08 at 20:00 +0200, Christian Zigotzky wrote: Dear Linuxppc-dev mailing list, I used git bisect and found out that the following commit is the problem. commit 3ceaccdf92073d193f0bfbe24280dd736e3fed86 Author: Dave Hansen dave.han...@linux.intel.com There is no way that commit affects anything on that platform, it only changes a file in arch/x86 that isn't compiled on a powerpc build. You must have made a mistake in your bisection, possibly the one sometimes boots should be considered good, but I can't say for sure. Michael has a PA6T board at work, so I assume he will see if he can reproduce. Yeah I can't reproduce here. I think you need to bisect again and look for the particular crash you reported. If you see that crash then mark it bad, else mark it good. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH v4 5/7] powerpc/powernv: add event attribute and group to nest pmu
Madhavan Srinivasan [ma...@linux.vnet.ibm.com] wrote: | Add code to create event/format attributes and attribute groups for | each nest pmu. | | Cc: Michael Ellerman m...@ellerman.id.au | Cc: Benjamin Herrenschmidt b...@kernel.crashing.org | Cc: Paul Mackerras pau...@samba.org | Cc: Anton Blanchard an...@samba.org | Cc: Sukadev Bhattiprolu suka...@linux.vnet.ibm.com | Cc: Anshuman Khandual khand...@linux.vnet.ibm.com | Cc: Stephane Eranian eran...@google.com | Signed-off-by: Madhavan Srinivasan ma...@linux.vnet.ibm.com | --- | arch/powerpc/perf/nest-pmu.c | 57 | 1 file changed, 57 insertions(+) | | diff --git a/arch/powerpc/perf/nest-pmu.c b/arch/powerpc/perf/nest-pmu.c | index 6116ff3..20ed9f8 100644 | --- a/arch/powerpc/perf/nest-pmu.c | +++ b/arch/powerpc/perf/nest-pmu.c | @@ -13,6 +13,17 @@ | static struct perchip_nest_info p8_nest_perchip_info[P8_NEST_MAX_CHIPS]; | static struct nest_pmu *per_nest_pmu_arr[P8_NEST_MAX_PMUS]; | | +PMU_FORMAT_ATTR(event, config:0-20); | +struct attribute *p8_nest_format_attrs[] = { name collision unlikely, but could this be static struct? | + format_attr_event.attr, | + NULL, | +}; | + | +struct attribute_group p8_nest_format_group = { static struct? | + .name = format, | + .attrs = p8_nest_format_attrs, | +}; | + | static int nest_event_info(struct property *pp, char *start, | struct nest_ima_events *p8_events, int flg, u32 val) | { | @@ -45,6 +56,48 @@ static int nest_event_info(struct property *pp, char *start, | return 0; | } | | +/* | + * Populate event name and string in attribute | + */ | +struct attribute *dev_str_attr(const char *name, const char *str) static function? | +{ | + struct perf_pmu_events_attr *attr; | + | + attr = kzalloc(sizeof(*attr), GFP_KERNEL); | + We recently needed following in 24x7 counters to keep lockdep happy: sysfs_attr_init(attr-attr.attr); | + attr-event_str = str; | + attr-attr.attr.name = name; | + attr-attr.attr.mode = 0444; | + attr-attr.show = perf_event_sysfs_show; | + | + return attr-attr.attr; | +} | + | +int update_events_in_group( static function? nit: do we need a new line before the first parameter? some functions in the file don't add the new line. | + struct nest_ima_events *p8_events, int nevents, struct nest_pmu *pmu) s/idx/nevents/? | +{ | + struct attribute_group *attr_group; | + struct attribute **attrs; | + int i; | + | + /* Allocate memory for event attribute group */ | + attr_group = kzalloc(((sizeof(struct attribute *) * (idx + 1)) + | + sizeof(*attr_group)), GFP_KERNEL); | + if (!attr_group) | + return -ENOMEM; | + | + attrs = (struct attribute **)(attr_group + 1); Can you add a comment on the +1? | + attr_group-name = events; | + attr_group-attrs = attrs; | + | + for (i = 0; i idx; i++, p8_events++) | + attrs[i] = dev_str_attr((char *)p8_events-ev_name, | + (char *)p8_events-ev_value); | + | + pmu-attr_groups[0] = attr_group; The -attr_groups[0] is initialized here, after the -attr_groups[1] and attr_groups[2] are initialized in caller. Since, -attr_groups[1] and -attr_groups[2] are set to global (loop-invariant) values, can we initialize all the attribute-groups here? May need to rename function. | + return 0; | +} | + | static int nest_pmu_create(struct device_node *dev, int pmu_index) | { | struct nest_ima_events **p8_events_arr, *p8_events; | @@ -91,6 +144,7 @@ static int nest_pmu_create(struct device_node *dev, int pmu_index) | /* Save the name to register it later */ | sprintf(buf, Nest_%s, (char *)pp-value); | pmu_ptr-pmu.name = (char *)buf; | + pmu_ptr-attr_groups[1] = p8_nest_format_group; | continue; | } | | @@ -122,6 +176,9 @@ static int nest_pmu_create(struct device_node *dev, int pmu_index) | idx++; | } | | + update_events_in_group( nit: need newline before first param? | + (struct nest_ima_events *)p8_events_arr, idx, pmu_ptr); | + | return 0; | } | | -- | 1.9.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] cxl: Destroy cxl_adapter_idr on module_exit
Acked-by: Ian Munsie imun...@au1.ibm.com We are probably also missing an idr_destroy(afu-contexts_idr); in cxl_release_afu() as well if you wanted to send a patch for that. Cheers, -Ian ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC,1/2] powerpc/numa: fix cpu_to_node() usage during boot
On Wed, 8 Jul 2015, Nishanth Aravamudan wrote: It looks like the symptom is that the per-cpu areas are all allocated on node 0, is that all that goes wrong? Yes, that's the symptom. I cc'd a few folks to see if they could help indicate the performance implications of such a setup -- sorry, I should have been more explicit about that. Yeah, not sure it's really a bugfix but rather a performance optimization since cpu_to_node() with CONFIG_USE_PERCPU_NUMA_NODE_ID is only about performance. ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2 2/2] powerpc/kexec: Reset HILE before kexec_sequence
On Wed, 2015-07-08 at 16:51 +1000, Stewart Smith wrote: Michael Ellerman m...@ellerman.id.au writes: On Wed, 2015-07-08 at 14:37 +1000, Samuel Mendoza-Jonas wrote: On powernv secondary cpus are returned to OPAL, and will then enter the target kernel in big-endian. However if it is set the HILE bit will persist, causing the first exception in the target kernel to be delivered in litte-endian regardless of the kernel endianess. Make sure that the HILE bit is switched off before entering kexec_sequence. Signed-off-by: Samuel Mendoza-Jonas sam...@au1.ibm.com --- arch/powerpc/kernel/machine_kexec_64.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c index 1a74446..2266135c 100644 --- a/arch/powerpc/kernel/machine_kexec_64.c +++ b/arch/powerpc/kernel/machine_kexec_64.c @@ -356,6 +358,10 @@ void default_machine_kexec(struct kimage *image) * switched to a static version! */ + /* Reset HILE in case we kexec into an older BE kernel */ + if (firmware_has_feature(FW_FEATURE_OPALv3)) + opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE); It's not safe to do this here. We are still in virtual mode and have external interrupts enabled, so you could easily take an exception of some kind and then you'd blow up. Mashing the keyboard during kexec might even be enough. Hrm... interrupts are disabled in kexec_sequence, should we be doing this there instead I wonder? At this point we're pretty much at the point of no return, so maybe we just need to disable interrupts first? I think a better API would be that opal_return_cpu() deals with this under the covers. I think we talked about that, so maybe there was some reason that wasn't possible. opal_return_cpu() acts on current CPU which if we started flipping HILE there we'd hit PowerISA 2.07 Section 2.11: The contents of the HILE bit must be the same for all threads under the control of a given instance of the hypervisor; otherwise all results are undefined. so we'd have to do something kind of funny in opal_return_cpu() to work out what's going on. Keeping in mind that opal_return_cpu() is also used in the fsp code update path (which I haven't gone and really looked at in this context though). I'm not convinced that opal_return_cpu() doing the HILE switch is safe when we'd be relying on the kernel to pretty much do this all at the same time (when we really have opal_reinit_cpus to do that) Yeah I agree. What I meant is that after you return a cpu to OPAL, when you (or actually someone else) restart it, at that point it should be put into a well defined state, including HILE. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH V2 2/2] powerpc/kexec: Reset HILE before kexec_sequence
On 08/07/15 16:51, Stewart Smith wrote: Michael Ellerman m...@ellerman.id.au writes: On Wed, 2015-07-08 at 14:37 +1000, Samuel Mendoza-Jonas wrote: On powernv secondary cpus are returned to OPAL, and will then enter the target kernel in big-endian. However if it is set the HILE bit will persist, causing the first exception in the target kernel to be delivered in litte-endian regardless of the kernel endianess. Make sure that the HILE bit is switched off before entering kexec_sequence. Signed-off-by: Samuel Mendoza-Jonas sam...@au1.ibm.com --- arch/powerpc/kernel/machine_kexec_64.c | 6 ++ 1 file changed, 6 insertions(+) diff --git a/arch/powerpc/kernel/machine_kexec_64.c b/arch/powerpc/kernel/machine_kexec_64.c index 1a74446..2266135c 100644 --- a/arch/powerpc/kernel/machine_kexec_64.c +++ b/arch/powerpc/kernel/machine_kexec_64.c @@ -22,8 +22,10 @@ #include asm/page.h #include asm/current.h #include asm/machdep.h +#include asm/opal.h #include asm/cacheflush.h #include asm/paca.h +#include asm/firmware.h #include asm/mmu.h #include asm/sections.h /* _end */ #include asm/prom.h @@ -356,6 +358,10 @@ void default_machine_kexec(struct kimage *image) * switched to a static version! */ + /* Reset HILE in case we kexec into an older BE kernel */ + if (firmware_has_feature(FW_FEATURE_OPALv3)) + opal_reinit_cpus(OPAL_REINIT_CPUS_HILE_BE); It's not safe to do this here. We are still in virtual mode and have external interrupts enabled, so you could easily take an exception of some kind and then you'd blow up. Mashing the keyboard during kexec might even be enough. Hrm... interrupts are disabled in kexec_sequence, should we be doing this there instead I wonder? At this point we're pretty much at the point of no return, so maybe we just need to disable interrupts first? I think a better API would be that opal_return_cpu() deals with this under the covers. I think we talked about that, so maybe there was some reason that wasn't possible. opal_return_cpu() acts on current CPU which if we started flipping HILE there we'd hit PowerISA 2.07 Section 2.11: The contents of the HILE bit must be the same for all threads under the control of a given instance of the hypervisor; otherwise all results are undefined. so we'd have to do something kind of funny in opal_return_cpu() to work out what's going on. Keeping in mind that opal_return_cpu() is also used in the fsp code update path (which I haven't gone and really looked at in this context though). I'm not convinced that opal_return_cpu() doing the HILE switch is safe when we'd be relying on the kernel to pretty much do this all at the same time (when we really have opal_reinit_cpus to do that) Having discovered opal_call_realmode, it looks like we can probably do this safely in real mode just before moving the kernel around and releasing the secondaries into the next kernel. I'll test this and send a V2 if it looks good. Although PowerISA also says: The HILE bit is set, by an implementa- tion-dependent method, during system initialization, and cannot be modified after system initialization. Which... umm... we are clearly doing and have been since we started supporting LE powernv, so there's something somewhere in some document describing it all... I just have to find it (or poke Ben to find out where he worked it out from). -- --- LTC Ozlabs IBM ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH 2/2] powerpc/smp: use early_cpu_to_node() instead of direct references to numa_cpu_lookup_table
On Thu, 2 Jul 2015, Nishanth Aravamudan wrote: A simple move to a wrapper function to numa_cpu_lookup_table, now that power has the early_cpu_to_node() API. Signed-off-by: Nishanth Aravamudan n...@linux.vnet.ibm.com When early_cpu_to_node() is __init: Acked-by: David Rientjes rient...@google.com ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
PASEMI: PA6T board doesn't boot with the RC1 of kernel 4.2 anymore
Hi All Many thanks for your answers. You're right. It is something wrong with my bisect. I will do another bisect. I will evaluate the one sometimes boots with good. Thanks Christian On 09 July 2015 03:42 AM, Michael Ellerman wrote: On Thu, 2015-07-09 at 08:36 +1000, Benjamin Herrenschmidt wrote: On Wed, 2015-07-08 at 20:00 +0200, Christian Zigotzky wrote: Dear Linuxppc-dev mailing list, I used git bisect and found out that the following commit is the problem. commit 3ceaccdf92073d193f0bfbe24280dd736e3fed86 Author: Dave Hansen dave.han...@linux.intel.com There is no way that commit affects anything on that platform, it only changes a file in arch/x86 that isn't compiled on a powerpc build. You must have made a mistake in your bisection, possibly the one sometimes boots should be considered good, but I can't say for sure. Michael has a PA6T board at work, so I assume he will see if he can reproduce. Yeah I can't reproduce here. I think you need to bisect again and look for the particular crash you reported. If you see that crash then mark it bad, else mark it good. cheers ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 2/2] rheap: move rheap.c from arch/powerpc/lib/ to lib/
On Wed, 2015-07-08 at 02:25 -0500, Zhao Qiang-B45475 wrote: So I will add two func for my use, do you think it is ok? I need to align the address of allocated muram. And I will set algo = gen_pool_first_fit_align. +unsigned long gen_pool_alloc_align(struct gen_pool *pool, size_t size, + unsigned long align) Again, please explain why you need this for CPM/QE. I don't see rh_alloc_align() currently being used by either. Also, please stop top-posting. -Scott ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev