Re: [PATCH 1/1] drivers/char/mem.c
On Saturday 22 September 2012, Teodori Serge wrote: > replace 'arch_has_dev_port()' to 'CONFIG_DEVPORT' > > modified: arch/powerpc/include/asm/io.h > modified: drivers/char/mem.c > modified: include/linux/io.h > > why do we need 'arch_has_dev_port()' if we have a 'CONFIG_DEVPORT'? > > Signed-off-by: Teodori Serge > --- > arch/powerpc/include/asm/io.h |2 +- > drivers/char/mem.c|6 -- > include/linux/io.h|9 - > 3 files changed, 1 insertion(+), 16 deletions(-) > > diff --git a/arch/powerpc/include/asm/io.h b/arch/powerpc/include/asm/io.h > index f94ef42..cb8b663 100644 > --- a/arch/powerpc/include/asm/io.h > +++ b/arch/powerpc/include/asm/io.h > @@ -25,7 +25,7 @@ extern struct pci_dev *isa_bridge_pcidev; > /* > * has legacy ISA devices ? > */ > -#define arch_has_dev_port() (isa_bridge_pcidev != NULL) > +#define CONFIG_DEVPORT (isa_bridge_pcidev != NULL) > #endif > > #include By convention, CONFIG_* symbols should only be set by Kconfig and not used for runtime checks. Also, the existing checks for those symbols check for whether it is defined, not for the actual value. With what you have there, the driver will always enable /dev/ports because CONFIG_DEVPORT is defined. What are you actually trying to achieve? Arnd ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH] powerpc: Remove tlb batching hack for nighthawk
On Fri, 21 Sep 2012 18:08:28 +1000 Michael Ellerman wrote: > In hpte_init_native() we call tlb_batching_enabled() to decide if we > should setup ppc_md.flush_hash_range. > > tlb_batching_enabled() checks the _unflattened_ device tree, to see > if we are running on a nighthawk. > > Since commit a223535 ("dont allow pSeries_probe to succeed without > initialising MMU", Dec 2006), hpte_init_native() has been called from > pSeries_probe() - at which point we have not yet unflattened the > device tree. > > This means tlb_batching_enabled() will always return true, so the hack > has effectively been disabled since Dec 2006. Ergo, I think we can > drop it. Ouch. We probably had the last nighthawk in existence and we crushed it years ago. So: Acked-by: Anton Blanchard Anton ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [PATCH 1/1] drivers/char/tpm: remove tasklet and cleanup
On Wed, 12 Sep 2012, Ashley Lai wrote: > This patch removed the tasklet and moved the wait queue into the > private structure. It also cleaned up the response CRQ path. > > Signed-off-by: Ashley Lai Kent: any comment on this? You should probably push this to me via your tree. > --- > James, > > This patch is based on your "next" branch. > git://git.kernel.org/pub/scm/linux/kernel/git/jmorris/linux-security.git > > Thanks, > Ashley Lai > --- > drivers/char/tpm/tpm_ibmvtpm.c | 81 > +++--- > drivers/char/tpm/tpm_ibmvtpm.h | 5 ++- > 2 files changed, 30 insertions(+), 56 deletions(-) > > diff --git a/drivers/char/tpm/tpm_ibmvtpm.c b/drivers/char/tpm/tpm_ibmvtpm.c > index efc4ab3..88a95ea 100644 > --- a/drivers/char/tpm/tpm_ibmvtpm.c > +++ b/drivers/char/tpm/tpm_ibmvtpm.c > @@ -38,8 +38,6 @@ static struct vio_device_id tpm_ibmvtpm_device_table[] > __devinitdata = { > }; > MODULE_DEVICE_TABLE(vio, tpm_ibmvtpm_device_table); > > -DECLARE_WAIT_QUEUE_HEAD(wq); > - > /** > * ibmvtpm_send_crq - Send a CRQ request > * @vdev:vio device struct > @@ -83,6 +81,7 @@ static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 *buf, > size_t count) > { > struct ibmvtpm_dev *ibmvtpm; > u16 len; > + int sig; > > ibmvtpm = (struct ibmvtpm_dev *)chip->vendor.data; > > @@ -91,22 +90,23 @@ static int tpm_ibmvtpm_recv(struct tpm_chip *chip, u8 > *buf, size_t count) > return 0; > } > > - wait_event_interruptible(wq, ibmvtpm->crq_res.len != 0); > + sig = wait_event_interruptible(ibmvtpm->wq, ibmvtpm->res_len != 0); > + if (sig) > + return -EINTR; > + > + len = ibmvtpm->res_len; > > - if (count < ibmvtpm->crq_res.len) { > + if (count < len) { > dev_err(ibmvtpm->dev, > "Invalid size in recv: count=%ld, crq_size=%d\n", > - count, ibmvtpm->crq_res.len); > + count, len); > return -EIO; > } > > spin_lock(&ibmvtpm->rtce_lock); > - memcpy((void *)buf, (void *)ibmvtpm->rtce_buf, ibmvtpm->crq_res.len); > - memset(ibmvtpm->rtce_buf, 0, ibmvtpm->crq_res.len); > - ibmvtpm->crq_res.valid = 0; > - ibmvtpm->crq_res.msg = 0; > - len = ibmvtpm->crq_res.len; > - ibmvtpm->crq_res.len = 0; > + memcpy((void *)buf, (void *)ibmvtpm->rtce_buf, len); > + memset(ibmvtpm->rtce_buf, 0, len); > + ibmvtpm->res_len = 0; > spin_unlock(&ibmvtpm->rtce_lock); > return len; > } > @@ -273,7 +273,6 @@ static int __devexit tpm_ibmvtpm_remove(struct vio_dev > *vdev) > int rc = 0; > > free_irq(vdev->irq, ibmvtpm); > - tasklet_kill(&ibmvtpm->tasklet); > > do { > if (rc) > @@ -372,7 +371,6 @@ static int ibmvtpm_reset_crq(struct ibmvtpm_dev *ibmvtpm) > static int tpm_ibmvtpm_resume(struct device *dev) > { > struct ibmvtpm_dev *ibmvtpm = ibmvtpm_get_data(dev); > - unsigned long flags; > int rc = 0; > > do { > @@ -387,10 +385,11 @@ static int tpm_ibmvtpm_resume(struct device *dev) > return rc; > } > > - spin_lock_irqsave(&ibmvtpm->lock, flags); > - vio_disable_interrupts(ibmvtpm->vdev); > - tasklet_schedule(&ibmvtpm->tasklet); > - spin_unlock_irqrestore(&ibmvtpm->lock, flags); > + rc = vio_enable_interrupts(ibmvtpm->vdev); > + if (rc) { > + dev_err(dev, "Error vio_enable_interrupts rc=%d\n", rc); > + return rc; > + } > > rc = ibmvtpm_crq_send_init(ibmvtpm); > if (rc) > @@ -467,7 +466,7 @@ static struct ibmvtpm_crq *ibmvtpm_crq_get_next(struct > ibmvtpm_dev *ibmvtpm) > if (crq->valid & VTPM_MSG_RES) { > if (++crq_q->index == crq_q->num_entry) > crq_q->index = 0; > - rmb(); > + smp_rmb(); > } else > crq = NULL; > return crq; > @@ -535,11 +534,9 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq, > ibmvtpm->vtpm_version = crq->data; > return; > case VTPM_TPM_COMMAND_RES: > - ibmvtpm->crq_res.valid = crq->valid; > - ibmvtpm->crq_res.msg = crq->msg; > - ibmvtpm->crq_res.len = crq->len; > - ibmvtpm->crq_res.data = crq->data; > - wake_up_interruptible(&wq); > + /* len of the data in rtce buffer */ > + ibmvtpm->res_len = crq->len; > + wake_up_interruptible(&ibmvtpm->wq); > return; > default: > return; > @@ -559,38 +556,19 @@ static void ibmvtpm_crq_process(struct ibmvtpm_crq *crq, > static irqreturn_t ibmvtpm_interrupt(int irq, void *vtpm_instance) > { > struct ibmvtpm_dev *ibmvtpm = (struct ibmvtpm_dev *) vtpm_instance; > - unsigned long flags; > - > -
Re: [PATCH v3 1/2] mmc: Move mmc_delay() to include/linux/mmc/core.h
On 09/21/2012 08:33 AM, Arnd Bergmann wrote: On Friday 21 September 2012, Chunhe Lan wrote: On 08/10/2012 09:27 AM, Arnd Bergmann wrote: On Friday 10 August 2012, Chunhe Lan wrote: cond_resched(); mdelay(ms); sets off alarm bells, and I would always replace that with msleep(). I think that it does not replace with msleep(). When the time of sleep is very short, program should not been scheduled in the context. Because it expends the more time. A time measured in miliseconds is never "very short" for the scheduler, a lot of things can happen during that time span. The code I quoted also does not care too much about accuracy, otherwise it would adapt the time in the mdelay based on whether the cond_resched() actually schedules to another thread. OK. As you have mentioned, it would been modified to such: static inline void mmc_delay(unsigned int ms) { if (ms < 1000 / HZ) { cond_resched(); msleep(ms); } else { msleep(ms); } } OR such: static inline void mmc_delay(unsigned int ms) { msleep(ms); } OR other code? Thanks, Chunhe Arnd ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[RFC PATCH powerpc] Fix a lazy irq related WARING in arch_local_irq_restore()
This patch tries to fix a WARNING in irq.c(below), when doing cpu offline/online. The reason is that if the preferred offline state is CPU_STATE_INACTIVE, when cpu offline, pseries_mach_cpu_die() calls extended_cede_processor() to cede the processor. After the hv call returns, the MSR_EE is enabled, while the irq_happened in paca should already be set as PACA_IRQ_HARD_DIS. Then when the cpu is put online again, the warning is reported when start_secondary() tries to enable irq. [ Sometimes, we don't see this warning, that's because when we come to local_irq_enable(), there might already have been some interrupts occurred, e.g. PACA_IRQ_DEC is already set. ] The patch tries to clear MSR_EE by calling __hard_irq_disable() after cede returns, and before calling start_secondary_resume(). [ 56.618846] WARNING: at arch/powerpc/kernel/irq.c:240 [ 56.618851] Modules linked in: rcutorture ipv6 dm_mod ext3 jbd mbcache sg sd_mod crc_t10dif ibmvscsic scsi_transport_srp scsi_tgt ibmveth [ 56.618883] NIP: c000ff94 LR: c067a5e0 CTR: 0001 [ 56.618889] REGS: c001fef6bbe0 TRAP: 0700 Not tainted (3.6.0-rc1-autokern1) [ 56.618894] MSR: 80029032 CR: 4282 XER: 2000 [ 56.618913] SOFTE: 1 [ 56.618916] CFAR: c067a5dc [ 56.618920] TASK = c001feed79a0[0] 'swapper/5' THREAD: c001fef68000 CPU: 5 GPR00: 0001 c001fef6be60 c0f9ca08 0001 GPR04: 0001 0008 0001 GPR08: c001feed79a0 0008a800 GPR12: 2282 cf330f00 c001fef6bf90 0f394b4c GPR16: GPR20: GPR24: c0fe8f80 0008 0028 GPR28: 0020 c0f1ab40 0001 [ 56.619014] NIP [c000ff94] .arch_local_irq_restore+0x34/0xa0 [ 56.619020] LR [c067a5e0] .start_secondary+0x368/0x37c [ 56.619025] Call Trace: [ 56.619030] [c001fef6be60] [c1ba0500] 0xc1ba0500 (unreliable) [ 56.619038] [c001fef6bed0] [c067a5e0] .start_secondary+0x368/0x37c [ 56.619046] [c001fef6bf90] [c0009380] .start_secondary_resume+0x10/0x14 [ 56.619052] Instruction dump: [ 56.619056] f8010010 f821ff91 986d022a 2fa3 419e0054 880d022b 78000621 41820048 [ 56.619071] 2f81 40de0064 7ca6 78008fe2 <0b00> 2fa0 40de0050 3800 [ 56.619088] ---[ end trace 0199c0d783d7f9ba ]--- Reported-by: Paul E. McKenney Signed-off-by: Li Zhong --- arch/powerpc/platforms/pseries/hotplug-cpu.c |2 ++ 1 files changed, 2 insertions(+), 0 deletions(-) diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c b/arch/powerpc/platforms/pseries/hotplug-cpu.c index 64c97d8..8de539a 100644 --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c @@ -137,6 +137,8 @@ static void pseries_mach_cpu_die(void) if (get_preferred_offline_state(cpu) == CPU_STATE_ONLINE) { unregister_slb_shadow(hwcpu); + __hard_irq_disable(); + /* * Call to start_secondary_resume() will not return. * Kernel stack will be reset and start_secondary() -- 1.7.1 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH powerpc] Fix a lazy irq related WARING in arch_local_irq_restore()
On Mon, 2012-09-24 at 11:56 +0800, Li Zhong wrote: > This patch tries to fix a WARNING in irq.c(below), when doing cpu > offline/online. > > The reason is that if the preferred offline state is CPU_STATE_INACTIVE, when > cpu offline, pseries_mach_cpu_die() calls extended_cede_processor() to cede > the processor. After the hv call returns, the MSR_EE is enabled, while > the irq_happened in paca should already be set as PACA_IRQ_HARD_DIS. > > Then when the cpu is put online again, the warning is reported when > start_secondary() tries to enable irq. [ Sometimes, we don't see this warning, > that's because when we come to local_irq_enable(), there might already have > been > some interrupts occurred, e.g. PACA_IRQ_DEC is already set. ] > > The patch tries to clear MSR_EE by calling __hard_irq_disable() after cede > returns, and before calling start_secondary_resume(). Is that enough ? Do we know for sure we won't get a stray IPI or interrupt which then will reach us with an inconsistent HW/SW enable state ? We might need to "sanitize" the enable state in the PACA before we actually enter NAP or in the return from NAP code, like we do for normal idle code... Cheers, Ben. > [ 56.618846] WARNING: at arch/powerpc/kernel/irq.c:240 > [ 56.618851] Modules linked in: rcutorture ipv6 dm_mod ext3 jbd mbcache sg > sd_mod crc_t10dif ibmvscsic scsi_transport_srp scsi_tgt ibmveth > [ 56.618883] NIP: c000ff94 LR: c067a5e0 CTR: > 0001 > [ 56.618889] REGS: c001fef6bbe0 TRAP: 0700 Not tainted > (3.6.0-rc1-autokern1) > [ 56.618894] MSR: 80029032 CR: 4282 XER: > 2000 > [ 56.618913] SOFTE: 1 > [ 56.618916] CFAR: c067a5dc > [ 56.618920] TASK = c001feed79a0[0] 'swapper/5' THREAD: > c001fef68000 CPU: 5 > GPR00: 0001 c001fef6be60 c0f9ca08 0001 > GPR04: 0001 0008 0001 > GPR08: c001feed79a0 0008a800 > GPR12: 2282 cf330f00 c001fef6bf90 0f394b4c > GPR16: > GPR20: > GPR24: c0fe8f80 0008 0028 > GPR28: 0020 c0f1ab40 0001 > [ 56.619014] NIP [c000ff94] .arch_local_irq_restore+0x34/0xa0 > [ 56.619020] LR [c067a5e0] .start_secondary+0x368/0x37c > [ 56.619025] Call Trace: > [ 56.619030] [c001fef6be60] [c1ba0500] 0xc1ba0500 > (unreliable) > [ 56.619038] [c001fef6bed0] [c067a5e0] > .start_secondary+0x368/0x37c > [ 56.619046] [c001fef6bf90] [c0009380] > .start_secondary_resume+0x10/0x14 > [ 56.619052] Instruction dump: > [ 56.619056] f8010010 f821ff91 986d022a 2fa3 419e0054 880d022b 78000621 > 41820048 > [ 56.619071] 2f81 40de0064 7ca6 78008fe2 <0b00> 2fa0 > 40de0050 3800 > [ 56.619088] ---[ end trace 0199c0d783d7f9ba ]--- > > Reported-by: Paul E. McKenney > Signed-off-by: Li Zhong > --- > arch/powerpc/platforms/pseries/hotplug-cpu.c |2 ++ > 1 files changed, 2 insertions(+), 0 deletions(-) > > diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c > b/arch/powerpc/platforms/pseries/hotplug-cpu.c > index 64c97d8..8de539a 100644 > --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c > +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c > @@ -137,6 +137,8 @@ static void pseries_mach_cpu_die(void) > if (get_preferred_offline_state(cpu) == CPU_STATE_ONLINE) { > unregister_slb_shadow(hwcpu); > > + __hard_irq_disable(); > + > /* >* Call to start_secondary_resume() will not return. >* Kernel stack will be reset and start_secondary() ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH][v2] powerpc/fsl-pci: use 'Header Type' to identify PCIE mode
The original code uses 'Programming Interface' field to judge if PCIE is EP or RC mode, however, some latest silicons do not support this functionality. According to PCIE specification, 'Header Type' offset 0x0e is used to indicate header type, so change code to use 'Header Type' field to judge PCIE mode. Because FSL PCI controller does not support 'Header Type', patch still uses 'Programming Interface' to identify PCI mode. Signed-off-by: Minghuan Lian Signed-off-by: Roy Zang --- Change log: v2 - keep the original PCI initialization order according to kumar's recommendations. arch/powerpc/sysdev/fsl_pci.c | 37 - 1 file changed, 24 insertions(+), 13 deletions(-) diff --git a/arch/powerpc/sysdev/fsl_pci.c b/arch/powerpc/sysdev/fsl_pci.c index c37f461..468e76c 100644 --- a/arch/powerpc/sysdev/fsl_pci.c +++ b/arch/powerpc/sysdev/fsl_pci.c @@ -38,15 +38,15 @@ static int fsl_pcie_bus_fixup, is_mpc83xx_pci; static void __devinit quirk_fsl_pcie_header(struct pci_dev *dev) { - u8 progif; + u8 hdr_type; /* if we aren't a PCIe don't bother */ if (!pci_find_capability(dev, PCI_CAP_ID_EXP)) return; /* if we aren't in host mode don't bother */ - pci_read_config_byte(dev, PCI_CLASS_PROG, &progif); - if (progif & 0x1) + pci_read_config_byte(dev, PCI_HEADER_TYPE, &hdr_type); + if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) return; dev->class = PCI_CLASS_BRIDGE_PCI << 8; @@ -425,7 +425,7 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary) struct pci_controller *hose; struct resource rsrc; const int *bus_range; - u8 progif; + u8 hdr_type, progif; if (!of_device_is_available(dev)) { pr_warning("%s: disabled\n", dev->full_name); @@ -457,15 +457,17 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary) setup_indirect_pci(hose, rsrc.start, rsrc.start + 0x4, PPC_INDIRECT_TYPE_BIG_ENDIAN); - early_read_config_byte(hose, 0, 0, PCI_CLASS_PROG, &progif); - if ((progif & 1) == 1) { - /* unmap cfg_data & cfg_addr separately if not on same page */ - if (((unsigned long)hose->cfg_data & PAGE_MASK) != - ((unsigned long)hose->cfg_addr & PAGE_MASK)) - iounmap(hose->cfg_data); - iounmap(hose->cfg_addr); - pcibios_free_controller(hose); - return -ENODEV; + if (early_find_capability(hose, 0, 0, PCI_CAP_ID_EXP)) { + /* For PCIE read HEADER_TYPE to identify controler mode */ + early_read_config_byte(hose, 0, 0, PCI_HEADER_TYPE, &hdr_type); + if ((hdr_type & 0x7f) != PCI_HEADER_TYPE_BRIDGE) + goto no_bridge; + + } else { + /* For PCI read PROG to identify controller mode */ + early_read_config_byte(hose, 0, 0, PCI_CLASS_PROG, &progif); + if ((progif & 1) == 1) + goto no_bridge; } setup_pci_cmd(hose); @@ -494,6 +496,15 @@ int __init fsl_add_bridge(struct device_node *dev, int is_primary) setup_pci_atmu(hose, &rsrc); return 0; + +no_bridge: + /* unmap cfg_data & cfg_addr separately if not on same page */ + if (((unsigned long)hose->cfg_data & PAGE_MASK) != + ((unsigned long)hose->cfg_addr & PAGE_MASK)) + iounmap(hose->cfg_data); + iounmap(hose->cfg_addr); + pcibios_free_controller(hose); + return -ENODEV; } #endif /* CONFIG_FSL_SOC_BOOKE || CONFIG_PPC_86xx */ -- 1.7.9.5 ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH v2] Powerpc 8xx CPM_UART desynchronisation
This patch fixes a desynchronisation problem with CPM UART driver on Powerpc MPC8xx. The problem happens if data is received before the device is open by the user application. Signed-off-by: Christophe Leroy --- linux-3.5-vanilla/drivers/tty/serial/cpm_uart/cpm_uart_core.c 2012-07-21 22:58:29.0 +0200 +++ linux-3.5/drivers/tty/serial/cpm_uart/cpm_uart_core.c 2012-08-09 17:38:37.0 +0200 @@ -417,6 +417,7 @@ clrbits32(&pinfo->sccp->scc_gsmrl, SCC_GSMRL_ENR); clrbits16(&pinfo->sccp->scc_sccm, UART_SCCM_RX); } + cpm_uart_initbd(pinfo); cpm_line_cr_cmd(pinfo, CPM_CR_INIT_TRX); } /* Install interrupt handler. */ ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] Powerpc 8xx CPM_UART too many interrupts
Setting the fifo to only 1 byte generates one interrupt every 1ms at 9600 bauds. This is too much. This patch reduces the threshold to speeds below 2400 bauds like in the 8250 UART driver. Signed-off-by: Christophe Leroy --- linux-3.5-vanilla/drivers/tty/serial/cpm_uart/cpm_uart_core.c 2012-07-21 22:58:29.0 +0200 +++ linux-3.5/drivers/tty/serial/cpm_uart/cpm_uart_core.c 2012-08-09 17:38:37.0 +0200 @@ -71,7 +71,7 @@ /**/ -#define HW_BUF_SPD_THRESHOLD9600 +#define HW_BUF_SPD_THRESHOLD2400 /* * Check, if transmit buffers are processed @@ -505,7 +505,7 @@ pr_debug("CPM uart[%d]:set_termios\n", port->line); baud = uart_get_baud_rate(port, termios, old, 0, port->uartclk / 16); - if (baud <= HW_BUF_SPD_THRESHOLD || + if (baud < HW_BUF_SPD_THRESHOLD || (pinfo->port.state && pinfo->port.state->port.tty->low_latency)) pinfo->rx_fifosize = 1; else ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] Powerpc 8xx CPM_UART maxidl should not depend on fifo size
maxidl register was set to fifo size. There is no reason to set this register to same value as fifo size. Setting it now to 0x10 by default as in the UCC UART driver. Signed-off-by: Christophe Leroy --- linux-3.5-vanilla/drivers/tty/serial/cpm_uart/cpm_uart_core.c 2012-07-21 22:58:29.0 +0200 +++ linux-3.5/drivers/tty/serial/cpm_uart/cpm_uart_core.c 2012-08-09 17:38:37.0 +0200 @@ -799,7 +799,7 @@ cpm_set_scc_fcr(sup); out_be16(&sup->scc_genscc.scc_mrblr, pinfo->rx_fifosize); - out_be16(&sup->scc_maxidl, pinfo->rx_fifosize); + out_be16(&sup->scc_maxidl, 0x10); out_be16(&sup->scc_brkcr, 1); out_be16(&sup->scc_parec, 0); out_be16(&sup->scc_frmec, 0); @@ -873,7 +873,7 @@ /* Using idle character time requires some additional tuning. */ out_be16(&up->smc_mrblr, pinfo->rx_fifosize); - out_be16(&up->smc_maxidl, pinfo->rx_fifosize); + out_be16(&up->smc_maxidl, 0x10); out_be16(&up->smc_brklen, 0); out_be16(&up->smc_brkec, 0); out_be16(&up->smc_brkcr, 1); ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
[PATCH] Powerpc 8xx CPM_UART setting MAXIDL register proportionaly to baud rate
MAXIDL is the timeout after which a receive buffer is closed when not full if no more characters are received. We calculate it from the baudrate so that the duration is always the same at standard rates: about 4ms. At 9600 bauds it gives a timeout of 4 characters, which is the timeout on the 8250 UART. Signed-off-by: Christophe Leroy --- linux-3.5-vanilla/drivers/tty/serial/cpm_uart/cpm_uart_core.c 2012-07-21 22:58:29.0 +0200 +++ linux-3.5/drivers/tty/serial/cpm_uart/cpm_uart_core.c 2012-08-09 17:38:37.0 +0200 @@ -501,6 +501,7 @@ struct uart_cpm_port *pinfo = (struct uart_cpm_port *)port; smc_t __iomem *smcp = pinfo->smcp; scc_t __iomem *sccp = pinfo->sccp; + int maxidl; pr_debug("CPM uart[%d]:set_termios\n", port->line); @@ -511,6 +512,17 @@ else pinfo->rx_fifosize = RX_BUF_SIZE; + /* MAXIDL is the timeout after which a receive buffer is closed +* when not full if no more characters are received. +* We calculate it from the baudrate so that the duration is +* always the same at standard rates: about 4ms. +*/ + maxidl = baud / 2400; + if (maxidl < 1) + maxidl = 1; + if (maxidl > 0x10) + maxidl = 0x10; + /* Character length programmed into the mode register is the * sum of: 1 start bit, number of data bits, 0 or 1 parity bit, * 1 or 2 stop bits, minus 1. @@ -611,6 +623,7 @@ * SMC/SCC receiver is disabled. */ out_be16(&pinfo->smcup->smc_mrblr, pinfo->rx_fifosize); + out_be16(&pinfo->smcup->smc_maxidl, maxidl); /* Set the mode register. We want to keep a copy of the * enables, because we want to put them back if they were @@ -623,6 +636,7 @@ SMCMR_SM_UART | prev_mode); } else { out_be16(&pinfo->sccup->scc_genscc.scc_mrblr, pinfo->rx_fifosize); + out_be16(&pinfo->sccup->scc_maxidl, maxidl); out_be16(&sccp->scc_psmr, (sbits << 12) | scval); } ___ Linuxppc-dev mailing list Linuxppc-dev@lists.ozlabs.org https://lists.ozlabs.org/listinfo/linuxppc-dev
Re: [RFC PATCH powerpc] Fix a lazy irq related WARING in arch_local_irq_restore()
On Mon, 2012-09-24 at 15:30 +1000, Benjamin Herrenschmidt wrote: > On Mon, 2012-09-24 at 11:56 +0800, Li Zhong wrote: > > This patch tries to fix a WARNING in irq.c(below), when doing cpu > > offline/online. > > > > The reason is that if the preferred offline state is CPU_STATE_INACTIVE, > > when > > cpu offline, pseries_mach_cpu_die() calls extended_cede_processor() to cede > > the processor. After the hv call returns, the MSR_EE is enabled, while > > the irq_happened in paca should already be set as PACA_IRQ_HARD_DIS. > > > > Then when the cpu is put online again, the warning is reported when > > start_secondary() tries to enable irq. [ Sometimes, we don't see this > > warning, > > that's because when we come to local_irq_enable(), there might already have > > been > > some interrupts occurred, e.g. PACA_IRQ_DEC is already set. ] > > > > The patch tries to clear MSR_EE by calling __hard_irq_disable() after cede > > returns, and before calling start_secondary_resume(). > Hi Ben, > Is that enough ? Do we know for sure we won't get a stray IPI or > interrupt which then will reach us with an inconsistent HW/SW enable > state ? I thought when coming to here, there should be no IPI or interrupt for this cpu ... > We might need to "sanitize" the enable state in the PACA before we > actually enter NAP or in the return from NAP code, like we do for normal > idle code... Do you mean something like this in extended_cede_processor() to make sure HW/SW enable state consistent? + prep_irq_for_idle(); rc = cede_processor(); +#ifdef CONFIG_TRACE_IRQFLAGS +/* Ensure that H_CEDE returns with IRQs on */ +if (WARN_ON(!(mfmsr() & MSR_EE))) +__hard_irq_enable(); +#endif So, normally, we will have irqs SW/HW enabled consistently. But if the above happens (some missing IPI/interrupt ), I'm not sure whether we can leave it to be handled after cpu online again? Please correct me if I misunderstood something. Thanks, Zhong > Cheers, > Ben. > > > [ 56.618846] WARNING: at arch/powerpc/kernel/irq.c:240 > > [ 56.618851] Modules linked in: rcutorture ipv6 dm_mod ext3 jbd mbcache > > sg sd_mod crc_t10dif ibmvscsic scsi_transport_srp scsi_tgt ibmveth > > [ 56.618883] NIP: c000ff94 LR: c067a5e0 CTR: > > 0001 > > [ 56.618889] REGS: c001fef6bbe0 TRAP: 0700 Not tainted > > (3.6.0-rc1-autokern1) > > [ 56.618894] MSR: 80029032 CR: 4282 > > XER: 2000 > > [ 56.618913] SOFTE: 1 > > [ 56.618916] CFAR: c067a5dc > > [ 56.618920] TASK = c001feed79a0[0] 'swapper/5' THREAD: > > c001fef68000 CPU: 5 > > GPR00: 0001 c001fef6be60 c0f9ca08 0001 > > GPR04: 0001 0008 0001 > > GPR08: c001feed79a0 0008a800 > > GPR12: 2282 cf330f00 c001fef6bf90 0f394b4c > > GPR16: > > GPR20: > > GPR24: c0fe8f80 0008 0028 > > GPR28: 0020 c0f1ab40 0001 > > [ 56.619014] NIP [c000ff94] .arch_local_irq_restore+0x34/0xa0 > > [ 56.619020] LR [c067a5e0] .start_secondary+0x368/0x37c > > [ 56.619025] Call Trace: > > [ 56.619030] [c001fef6be60] [c1ba0500] 0xc1ba0500 > > (unreliable) > > [ 56.619038] [c001fef6bed0] [c067a5e0] > > .start_secondary+0x368/0x37c > > [ 56.619046] [c001fef6bf90] [c0009380] > > .start_secondary_resume+0x10/0x14 > > [ 56.619052] Instruction dump: > > [ 56.619056] f8010010 f821ff91 986d022a 2fa3 419e0054 880d022b > > 78000621 41820048 > > [ 56.619071] 2f81 40de0064 7ca6 78008fe2 <0b00> 2fa0 > > 40de0050 3800 > > [ 56.619088] ---[ end trace 0199c0d783d7f9ba ]--- > > > > Reported-by: Paul E. McKenney > > Signed-off-by: Li Zhong > > --- > > arch/powerpc/platforms/pseries/hotplug-cpu.c |2 ++ > > 1 files changed, 2 insertions(+), 0 deletions(-) > > > > diff --git a/arch/powerpc/platforms/pseries/hotplug-cpu.c > > b/arch/powerpc/platforms/pseries/hotplug-cpu.c > > index 64c97d8..8de539a 100644 > > --- a/arch/powerpc/platforms/pseries/hotplug-cpu.c > > +++ b/arch/powerpc/platforms/pseries/hotplug-cpu.c > > @@ -137,6 +137,8 @@ static void pseries_mach_cpu_die(void) > > if (get_preferred_offline_state(cpu) == CPU_STATE_ONLINE) { > > unregister_slb_shadow(hwcpu); > > > > + __hard_irq_disable(); > > + > > /* > > * Call to start_secondary_resume() will not return. > > * Kernel stack will be reset and start_secondary() > >