xhci: Remove more doorbell-related reads

The unused space in the doorbell is now marked as RsvdZ, not RsvdP, so
we can avoid reading the doorbell before writing it.

Update the doorbell-related defines to produce the entire doorbell value
from a single macro. Document the doorbell format in a comment.

Signed-off-by: Matthew Wilcox <willy@linux.intel.com>
Signed-off-by: Sarah Sharp <sarah.a.sharp@linux.intel.com>

authored by Matthew Wilcox and committed by Sarah Sharp 50d64676 7961acd7

+17 -26
+11 -16
drivers/usb/host/xhci-ring.c
··· 308 308 /* Ring the host controller doorbell after placing a command on the ring */ 309 309 void xhci_ring_cmd_db(struct xhci_hcd *xhci) 310 310 { 311 - u32 temp; 312 - 313 311 xhci_dbg(xhci, "// Ding dong!\n"); 314 - temp = xhci_readl(xhci, &xhci->dba->doorbell[0]) & DB_MASK; 315 - xhci_writel(xhci, temp | DB_TARGET_HOST, &xhci->dba->doorbell[0]); 312 + xhci_writel(xhci, DB_VALUE_HOST, &xhci->dba->doorbell[0]); 316 313 /* Flush PCI posted writes */ 317 314 xhci_readl(xhci, &xhci->dba->doorbell[0]); 318 315 } ··· 319 322 unsigned int ep_index, 320 323 unsigned int stream_id) 321 324 { 322 - struct xhci_virt_ep *ep; 323 - unsigned int ep_state; 324 - u32 field; 325 325 __u32 __iomem *db_addr = &xhci->dba->doorbell[slot_id]; 326 + struct xhci_virt_ep *ep = &xhci->devs[slot_id]->eps[ep_index]; 327 + unsigned int ep_state = ep->ep_state; 326 328 327 - ep = &xhci->devs[slot_id]->eps[ep_index]; 328 - ep_state = ep->ep_state; 329 329 /* Don't ring the doorbell for this endpoint if there are pending 330 - * cancellations because the we don't want to interrupt processing. 330 + * cancellations because we don't want to interrupt processing. 331 331 * We don't want to restart any stream rings if there's a set dequeue 332 332 * pointer command pending because the device can choose to start any 333 333 * stream once the endpoint is on the HW schedule. 334 334 * FIXME - check all the stream rings for pending cancellations. 335 335 */ 336 - if (!(ep_state & EP_HALT_PENDING) && !(ep_state & SET_DEQ_PENDING) 337 - && !(ep_state & EP_HALTED)) { 338 - field = xhci_readl(xhci, db_addr) & DB_MASK; 339 - field |= EPI_TO_DB(ep_index) | STREAM_ID_TO_DB(stream_id); 340 - xhci_writel(xhci, field, db_addr); 341 - } 336 + if ((ep_state & EP_HALT_PENDING) || (ep_state & SET_DEQ_PENDING) || 337 + (ep_state & EP_HALTED)) 338 + return; 339 + xhci_writel(xhci, DB_VALUE(ep_index, stream_id), db_addr); 340 + /* The CPU has better things to do at this point than wait for a 341 + * write-posting flush. It'll get there soon enough. 342 + */ 342 343 } 343 344 344 345 /* Ring the doorbell for any rings with pending URBs */
+6 -10
drivers/usb/host/xhci.h
··· 436 436 /** 437 437 * struct doorbell_array 438 438 * 439 + * Bits 0 - 7: Endpoint target 440 + * Bits 8 - 15: RsvdZ 441 + * Bits 16 - 31: Stream ID 442 + * 439 443 * Section 5.6 440 444 */ 441 445 struct xhci_doorbell_array { 442 446 u32 doorbell[256]; 443 447 }; 444 448 445 - #define DB_TARGET_MASK 0xFFFFFF00 446 - #define DB_STREAM_ID_MASK 0x0000FFFF 447 - #define DB_TARGET_HOST 0x0 448 - #define DB_STREAM_ID_HOST 0x0 449 - #define DB_MASK (0xff << 8) 450 - 451 - /* Endpoint Target - bits 0:7 */ 452 - #define EPI_TO_DB(p) (((p) + 1) & 0xff) 453 - #define STREAM_ID_TO_DB(p) (((p) & 0xffff) << 16) 454 - 449 + #define DB_VALUE(ep, stream) ((((ep) + 1) & 0xff) | ((stream) << 16)) 450 + #define DB_VALUE_HOST 0x00000000 455 451 456 452 /** 457 453 * struct xhci_protocol_caps