mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH 1/1] usb: xhci: clear EINT bit in status correctly
@ 2016-12-30  5:29 Lu Baolu
  2016-12-30  5:52 ` kbuild test robot
  2016-12-30  6:19 ` kbuild test robot
  0 siblings, 2 replies; 3+ messages in thread
From: Lu Baolu @ 2016-12-30  5:29 UTC (permalink / raw)
  To: Mathias Nyman; +Cc: linux-usb, linux-kernel, Lu Baolu, stable, Felipe Balbi

EINT(Event Interrupt) is a write-1-to-clear type of bit in xhci
status register. It should be cleared by writing a 1. Writing 0
to this bit has no effect.

Xhci driver tries to clear this bit by writing 0 to it. This is
not the right way to go. This patch corrects this by reading the
register first, then clearing all RO/RW1C/RsvZ bits and setting
the clearing bit, and writing back the new value at last.

Xhci spec requires that software that uses EINT shall clear it
prior to clearing any IP flags in section 5.4.2. This is the
reason why this patch is CC'ed stable as well.

Cc: <stable@vger.kernel.org> # v3.14+
CC: Felipe Balbi <felipe.balbi@linux.intel.com>
Signed-off-by: Lu Baolu <baolu.lu@linux.intel.com>
---
 drivers/usb/host/xhci.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/usb/host/xhci.c b/drivers/usb/host/xhci.c
index 1cd5641..18ea6b8 100644
--- a/drivers/usb/host/xhci.c
+++ b/drivers/usb/host/xhci.c
@@ -721,7 +721,7 @@ void xhci_stop(struct usb_hcd *hcd)
 	xhci_dbg_trace(xhci, trace_xhci_dbg_init,
 			"// Disabling event ring interrupts");
 	temp = readl(&xhci->op_regs->status);
-	writel(temp & ~STS_EINT, &xhci->op_regs->status);
+	writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
 	temp = readl(&xhci->ir_set->irq_pending);
 	writel(ER_IRQ_DISABLE(temp), &xhci->ir_set->irq_pending);
 	xhci_print_ir_set(xhci, 0);
@@ -1054,7 +1054,7 @@ int xhci_resume(struct xhci_hcd *xhci, bool hibernated)
 
 		xhci_dbg(xhci, "// Disabling event ring interrupts\n");
 		temp = readl(&xhci->op_regs->status);
-		writel(temp & ~STS_EINT, &xhci->op_regs->status);
+		writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
 		temp = readl(&xhci->ir_set->irq_pending);
 		writel(ER_IRQ_DISABLE(temp), &xhci->ir_set->irq_pending);
 		xhci_print_ir_set(xhci, 0);
-- 
2.1.4

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] usb: xhci: clear EINT bit in status correctly
  2016-12-30  5:29 [PATCH 1/1] usb: xhci: clear EINT bit in status correctly Lu Baolu
@ 2016-12-30  5:52 ` kbuild test robot
  2016-12-30  6:19 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2016-12-30  5:52 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Mathias Nyman, linux-usb, linux-kernel, Lu Baolu,
	stable, Felipe Balbi

[-- Attachment #1: Type: text/plain, Size: 2392 bytes --]

Hi Lu,

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v4.10-rc1 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Lu-Baolu/usb-xhci-clear-EINT-bit-in-status-correctly/20161230-133444
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: i386-randconfig-x003-201652 (attached as .config)
compiler: gcc-6 (Debian 6.2.0-3) 6.2.0 20160901
reproduce:
        # save the attached .config to linux build tree
        make ARCH=i386 

All warnings (new ones prefixed by >>):

   drivers/usb/host/xhci.c: In function 'xhci_stop':
>> drivers/usb/host/xhci.c:724:14: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
            ~~~~~^~~~~~~~~
   drivers/usb/host/xhci.c: In function 'xhci_resume':
   drivers/usb/host/xhci.c:1057:15: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
      writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
             ~~~~~^~~~~~~~~

vim +724 drivers/usb/host/xhci.c

   708	
   709		/* Deleting Compliance Mode Recovery Timer */
   710		if ((xhci->quirks & XHCI_COMP_MODE_QUIRK) &&
   711				(!(xhci_all_ports_seen_u0(xhci)))) {
   712			del_timer_sync(&xhci->comp_mode_recovery_timer);
   713			xhci_dbg_trace(xhci, trace_xhci_dbg_quirks,
   714					"%s: compliance mode recovery timer deleted",
   715					__func__);
   716		}
   717	
   718		if (xhci->quirks & XHCI_AMD_PLL_FIX)
   719			usb_amd_dev_put();
   720	
   721		xhci_dbg_trace(xhci, trace_xhci_dbg_init,
   722				"// Disabling event ring interrupts");
   723		temp = readl(&xhci->op_regs->status);
 > 724		writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
   725		temp = readl(&xhci->ir_set->irq_pending);
   726		writel(ER_IRQ_DISABLE(temp), &xhci->ir_set->irq_pending);
   727		xhci_print_ir_set(xhci, 0);
   728	
   729		xhci_dbg_trace(xhci, trace_xhci_dbg_init, "cleaning up memory");
   730		xhci_mem_cleanup(xhci);
   731		xhci_dbg_trace(xhci, trace_xhci_dbg_init,
   732				"xhci_stop completed - status = %x",

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 28186 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

* Re: [PATCH 1/1] usb: xhci: clear EINT bit in status correctly
  2016-12-30  5:29 [PATCH 1/1] usb: xhci: clear EINT bit in status correctly Lu Baolu
  2016-12-30  5:52 ` kbuild test robot
@ 2016-12-30  6:19 ` kbuild test robot
  1 sibling, 0 replies; 3+ messages in thread
From: kbuild test robot @ 2016-12-30  6:19 UTC (permalink / raw)
  To: Lu Baolu
  Cc: kbuild-all, Mathias Nyman, linux-usb, linux-kernel, Lu Baolu,
	stable, Felipe Balbi

[-- Attachment #1: Type: text/plain, Size: 10356 bytes --]

Hi Lu,

[auto build test WARNING on usb/usb-testing]
[also build test WARNING on v4.10-rc1 next-20161224]
[if your patch is applied to the wrong git tree, please drop us a note to help improve the system]

url:    https://github.com/0day-ci/linux/commits/Lu-Baolu/usb-xhci-clear-EINT-bit-in-status-correctly/20161230-133444
base:   https://git.kernel.org/pub/scm/linux/kernel/git/gregkh/usb.git usb-testing
config: m68k-allmodconfig (attached as .config)
compiler: m68k-linux-gcc (GCC) 4.9.0
reproduce:
        wget https://git.kernel.org/cgit/linux/kernel/git/wfg/lkp-tests.git/plain/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=m68k 

All warnings (new ones prefixed by >>):

   In file included from include/linux/swab.h:4:0,
                    from include/uapi/linux/byteorder/big_endian.h:12,
                    from include/linux/byteorder/big_endian.h:4,
                    from arch/m68k/include/uapi/asm/byteorder.h:4,
                    from include/asm-generic/bitops/le.h:5,
                    from arch/m68k/include/asm/bitops.h:518,
                    from include/linux/bitops.h:36,
                    from include/linux/kernel.h:10,
                    from include/linux/list.h:8,
                    from include/linux/pci.h:25,
                    from drivers/usb/host/xhci.c:23:
   drivers/usb/host/xhci.c: In function 'xhci_stop':
   drivers/usb/host/xhci.c:724:14: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
                 ^
   include/uapi/linux/swab.h:116:32: note: in definition of macro '__swab32'
     (__builtin_constant_p((__u32)(x)) ? \
                                   ^
   include/linux/byteorder/generic.h:87:21: note: in expansion of macro '__cpu_to_le32'
    #define cpu_to_le32 __cpu_to_le32
                        ^
>> arch/m68k/include/asm/io_mm.h:452:26: note: in expansion of macro 'out_le32'
    #define writel(val,addr) out_le32((addr),(val))
                             ^
   drivers/usb/host/xhci.c:724:2: note: in expansion of macro 'writel'
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
     ^
   drivers/usb/host/xhci.c:724:14: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
                 ^
   include/uapi/linux/swab.h:17:12: note: in definition of macro '___constant_swab32'
     (((__u32)(x) & (__u32)0x000000ffUL) << 24) |  \
               ^
   include/uapi/linux/byteorder/big_endian.h:32:43: note: in expansion of macro '__swab32'
    #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
                                              ^
   include/linux/byteorder/generic.h:87:21: note: in expansion of macro '__cpu_to_le32'
    #define cpu_to_le32 __cpu_to_le32
                        ^
>> arch/m68k/include/asm/io_mm.h:452:26: note: in expansion of macro 'out_le32'
    #define writel(val,addr) out_le32((addr),(val))
                             ^
   drivers/usb/host/xhci.c:724:2: note: in expansion of macro 'writel'
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
     ^
   drivers/usb/host/xhci.c:724:14: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
                 ^
   include/uapi/linux/swab.h:18:12: note: in definition of macro '___constant_swab32'
     (((__u32)(x) & (__u32)0x0000ff00UL) <<  8) |  \
               ^
   include/uapi/linux/byteorder/big_endian.h:32:43: note: in expansion of macro '__swab32'
    #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
                                              ^
   include/linux/byteorder/generic.h:87:21: note: in expansion of macro '__cpu_to_le32'
    #define cpu_to_le32 __cpu_to_le32
                        ^
>> arch/m68k/include/asm/io_mm.h:452:26: note: in expansion of macro 'out_le32'
    #define writel(val,addr) out_le32((addr),(val))
                             ^
   drivers/usb/host/xhci.c:724:2: note: in expansion of macro 'writel'
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
     ^
   drivers/usb/host/xhci.c:724:14: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
                 ^
   include/uapi/linux/swab.h:19:12: note: in definition of macro '___constant_swab32'
     (((__u32)(x) & (__u32)0x00ff0000UL) >>  8) |  \
               ^
   include/uapi/linux/byteorder/big_endian.h:32:43: note: in expansion of macro '__swab32'
    #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
                                              ^
   include/linux/byteorder/generic.h:87:21: note: in expansion of macro '__cpu_to_le32'
    #define cpu_to_le32 __cpu_to_le32
                        ^
>> arch/m68k/include/asm/io_mm.h:452:26: note: in expansion of macro 'out_le32'
    #define writel(val,addr) out_le32((addr),(val))
                             ^
   drivers/usb/host/xhci.c:724:2: note: in expansion of macro 'writel'
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
     ^
   drivers/usb/host/xhci.c:724:14: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
                 ^
   include/uapi/linux/swab.h:20:12: note: in definition of macro '___constant_swab32'
     (((__u32)(x) & (__u32)0xff000000UL) >> 24)))
               ^
   include/uapi/linux/byteorder/big_endian.h:32:43: note: in expansion of macro '__swab32'
    #define __cpu_to_le32(x) ((__force __le32)__swab32((x)))
                                              ^
   include/linux/byteorder/generic.h:87:21: note: in expansion of macro '__cpu_to_le32'
    #define cpu_to_le32 __cpu_to_le32
                        ^
>> arch/m68k/include/asm/io_mm.h:452:26: note: in expansion of macro 'out_le32'
    #define writel(val,addr) out_le32((addr),(val))
                             ^
   drivers/usb/host/xhci.c:724:2: note: in expansion of macro 'writel'
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
     ^
   drivers/usb/host/xhci.c:724:14: warning: suggest parentheses around arithmetic in operand of '|' [-Wparentheses]
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
                 ^
   include/uapi/linux/swab.h:118:12: note: in definition of macro '__swab32'
     __fswab32(x))
               ^
   include/linux/byteorder/generic.h:87:21: note: in expansion of macro '__cpu_to_le32'
    #define cpu_to_le32 __cpu_to_le32
                        ^
>> arch/m68k/include/asm/io_mm.h:452:26: note: in expansion of macro 'out_le32'
    #define writel(val,addr) out_le32((addr),(val))
                             ^
   drivers/usb/host/xhci.c:724:2: note: in expansion of macro 'writel'
     writel(temp & ~0x1fff | STS_EINT, &xhci->op_regs->status);
     ^

vim +/out_le32 +452 arch/m68k/include/asm/io_mm.h

f9569e1d include/asm-m68k/io.h         Al Viro            2007-07-20  436  #define insw(port,buf,nr)  ((void)0)
f9569e1d include/asm-m68k/io.h         Al Viro            2007-07-20  437  #define outsw(port,buf,nr) ((void)0)
f9569e1d include/asm-m68k/io.h         Al Viro            2007-07-20  438  #define insl(port,buf,nr)  ((void)0)
f9569e1d include/asm-m68k/io.h         Al Viro            2007-07-20  439  #define outsl(port,buf,nr) ((void)0)
^1da177e include/asm-m68k/io.h         Linus Torvalds     2005-04-16  440  
^1da177e include/asm-m68k/io.h         Linus Torvalds     2005-04-16  441  /*
^1da177e include/asm-m68k/io.h         Linus Torvalds     2005-04-16  442   * These should be valid on any ioremap()ed region
^1da177e include/asm-m68k/io.h         Linus Torvalds     2005-04-16  443   */
^1da177e include/asm-m68k/io.h         Linus Torvalds     2005-04-16  444  #define readb(addr)      in_8(addr)
^1da177e include/asm-m68k/io.h         Linus Torvalds     2005-04-16  445  #define writeb(val,addr) out_8((addr),(val))
f9569e1d include/asm-m68k/io.h         Al Viro            2007-07-20  446  #define readw(addr)      in_le16(addr)
f9569e1d include/asm-m68k/io.h         Al Viro            2007-07-20  447  #define writew(val,addr) out_le16((addr),(val))
2171a19a include/asm-m68k/io.h         Adrian Bunk        2008-10-13  448  
84b16b7b arch/m68k/include/asm/io_mm.h Michael Schmitz    2013-04-06  449  #endif /* !CONFIG_ISA && !CONFIG_ATARI_ROM_ISA */
2171a19a include/asm-m68k/io.h         Adrian Bunk        2008-10-13  450  
^1da177e include/asm-m68k/io.h         Linus Torvalds     2005-04-16  451  #define readl(addr)      in_le32(addr)
^1da177e include/asm-m68k/io.h         Linus Torvalds     2005-04-16 @452  #define writel(val,addr) out_le32((addr),(val))
^1da177e include/asm-m68k/io.h         Linus Torvalds     2005-04-16  453  
f5db9c6a arch/m68k/include/asm/io_mm.h Geert Uytterhoeven 2012-04-15  454  #define readsb(port, buf, nr)     raw_insb((port), (u8 *)(buf), (nr))
f5db9c6a arch/m68k/include/asm/io_mm.h Geert Uytterhoeven 2012-04-15  455  #define readsw(port, buf, nr)     raw_insw((port), (u16 *)(buf), (nr))
f5db9c6a arch/m68k/include/asm/io_mm.h Geert Uytterhoeven 2012-04-15  456  #define readsl(port, buf, nr)     raw_insl((port), (u32 *)(buf), (nr))
f5db9c6a arch/m68k/include/asm/io_mm.h Geert Uytterhoeven 2012-04-15  457  #define writesb(port, buf, nr)    raw_outsb((port), (u8 *)(buf), (nr))
f5db9c6a arch/m68k/include/asm/io_mm.h Geert Uytterhoeven 2012-04-15  458  #define writesw(port, buf, nr)    raw_outsw((port), (u16 *)(buf), (nr))
f5db9c6a arch/m68k/include/asm/io_mm.h Geert Uytterhoeven 2012-04-15  459  #define writesl(port, buf, nr)    raw_outsl((port), (u32 *)(buf), (nr))
f5db9c6a arch/m68k/include/asm/io_mm.h Geert Uytterhoeven 2012-04-15  460  

:::::: The code at line 452 was first introduced by commit
:::::: 1da177e4c3f41524e886b7f1b8a0c1fc7321cac2 Linux-2.6.12-rc2

:::::: TO: Linus Torvalds <torvalds@ppc970.osdl.org>
:::::: CC: Linus Torvalds <torvalds@ppc970.osdl.org>

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 38889 bytes --]

^ permalink raw reply	[flat|nested] 3+ messages in thread

end of thread, other threads:[~2016-12-30  6:20 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2016-12-30  5:29 [PATCH 1/1] usb: xhci: clear EINT bit in status correctly Lu Baolu
2016-12-30  5:52 ` kbuild test robot
2016-12-30  6:19 ` kbuild test robot

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®