Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux

Pull i2c fixes from Wolfram Sang:

- regression fixes for i801 and designware

- better API and leak fix for releasing DMA safe buffers

- better greppable strings for the bitbang algorithm

* 'i2c/for-current' of git://git.kernel.org/pub/scm/linux/kernel/git/wsa/linux:
i2c: sh_mobile: fix leak when using DMA bounce buffer
i2c: sh_mobile: define start_ch() void as it only returns 0 anyhow
i2c: refactor function to release a DMA safe buffer
i2c: algos: bit: make the error messages grepable
i2c: designware: Re-init controllers with pm_disabled set on resume
i2c: i801: Allow ACPI AML access I/O ports not reserved for SMBus

+66 -44
+7 -3
Documentation/i2c/DMA-considerations
··· 50 50 returned buffer. If NULL is returned, the threshold was not met or a bounce 51 51 buffer could not be allocated. Fall back to PIO in that case. 52 52 53 - In any case, a buffer obtained from above needs to be released. It ensures data 54 - is copied back to the message and a potentially used bounce buffer is freed:: 53 + In any case, a buffer obtained from above needs to be released. Another helper 54 + function ensures a potentially used bounce buffer is freed:: 55 55 56 - i2c_release_dma_safe_msg_buf(msg, dma_buf); 56 + i2c_put_dma_safe_msg_buf(dma_buf, msg, xferred); 57 + 58 + The last argument 'xferred' controls if the buffer is synced back to the 59 + message or not. No syncing is needed in cases setting up DMA had an error and 60 + there was no data transferred. 57 61 58 62 The bounce buffer handling from the core is generic and simple. It will always 59 63 allocate a new bounce buffer. If you want a more sophisticated handling (e.g.
+31 -24
drivers/i2c/algos/i2c-algo-bit.c
··· 110 110 } 111 111 #ifdef DEBUG 112 112 if (jiffies != start && i2c_debug >= 3) 113 - pr_debug("i2c-algo-bit: needed %ld jiffies for SCL to go " 114 - "high\n", jiffies - start); 113 + pr_debug("i2c-algo-bit: needed %ld jiffies for SCL to go high\n", 114 + jiffies - start); 115 115 #endif 116 116 117 117 done: ··· 171 171 setsda(adap, sb); 172 172 udelay((adap->udelay + 1) / 2); 173 173 if (sclhi(adap) < 0) { /* timed out */ 174 - bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, " 175 - "timeout at bit #%d\n", (int)c, i); 174 + bit_dbg(1, &i2c_adap->dev, 175 + "i2c_outb: 0x%02x, timeout at bit #%d\n", 176 + (int)c, i); 176 177 return -ETIMEDOUT; 177 178 } 178 179 /* FIXME do arbitration here: ··· 186 185 } 187 186 sdahi(adap); 188 187 if (sclhi(adap) < 0) { /* timeout */ 189 - bit_dbg(1, &i2c_adap->dev, "i2c_outb: 0x%02x, " 190 - "timeout at ack\n", (int)c); 188 + bit_dbg(1, &i2c_adap->dev, 189 + "i2c_outb: 0x%02x, timeout at ack\n", (int)c); 191 190 return -ETIMEDOUT; 192 191 } 193 192 ··· 216 215 sdahi(adap); 217 216 for (i = 0; i < 8; i++) { 218 217 if (sclhi(adap) < 0) { /* timeout */ 219 - bit_dbg(1, &i2c_adap->dev, "i2c_inb: timeout at bit " 220 - "#%d\n", 7 - i); 218 + bit_dbg(1, &i2c_adap->dev, 219 + "i2c_inb: timeout at bit #%d\n", 220 + 7 - i); 221 221 return -ETIMEDOUT; 222 222 } 223 223 indata *= 2; ··· 267 265 goto bailout; 268 266 } 269 267 if (!scl) { 270 - printk(KERN_WARNING "%s: SCL unexpected low " 271 - "while pulling SDA low!\n", name); 268 + printk(KERN_WARNING 269 + "%s: SCL unexpected low while pulling SDA low!\n", 270 + name); 272 271 goto bailout; 273 272 } 274 273 ··· 281 278 goto bailout; 282 279 } 283 280 if (!scl) { 284 - printk(KERN_WARNING "%s: SCL unexpected low " 285 - "while pulling SDA high!\n", name); 281 + printk(KERN_WARNING 282 + "%s: SCL unexpected low while pulling SDA high!\n", 283 + name); 286 284 goto bailout; 287 285 } 288 286 ··· 295 291 goto bailout; 296 292 } 297 293 if (!sda) { 298 - printk(KERN_WARNING "%s: SDA unexpected low " 299 - "while pulling SCL low!\n", name); 294 + printk(KERN_WARNING 295 + "%s: SDA unexpected low while pulling SCL low!\n", 296 + name); 300 297 goto bailout; 301 298 } 302 299 ··· 309 304 goto bailout; 310 305 } 311 306 if (!sda) { 312 - printk(KERN_WARNING "%s: SDA unexpected low " 313 - "while pulling SCL high!\n", name); 307 + printk(KERN_WARNING 308 + "%s: SDA unexpected low while pulling SCL high!\n", 309 + name); 314 310 goto bailout; 315 311 } 316 312 ··· 358 352 i2c_start(adap); 359 353 } 360 354 if (i && ret) 361 - bit_dbg(1, &i2c_adap->dev, "Used %d tries to %s client at " 362 - "0x%02x: %s\n", i + 1, 355 + bit_dbg(1, &i2c_adap->dev, 356 + "Used %d tries to %s client at 0x%02x: %s\n", i + 1, 363 357 addr & 1 ? "read from" : "write to", addr >> 1, 364 358 ret == 1 ? "success" : "failed, timeout?"); 365 359 return ret; ··· 448 442 if (inval <= 0 || inval > I2C_SMBUS_BLOCK_MAX) { 449 443 if (!(flags & I2C_M_NO_RD_ACK)) 450 444 acknak(i2c_adap, 0); 451 - dev_err(&i2c_adap->dev, "readbytes: invalid " 452 - "block length (%d)\n", inval); 445 + dev_err(&i2c_adap->dev, 446 + "readbytes: invalid block length (%d)\n", 447 + inval); 453 448 return -EPROTO; 454 449 } 455 450 /* The original count value accounts for the extra ··· 513 506 return -ENXIO; 514 507 } 515 508 if (flags & I2C_M_RD) { 516 - bit_dbg(3, &i2c_adap->dev, "emitting repeated " 517 - "start condition\n"); 509 + bit_dbg(3, &i2c_adap->dev, 510 + "emitting repeated start condition\n"); 518 511 i2c_repstart(adap); 519 512 /* okay, now switch into reading mode */ 520 513 addr |= 0x01; ··· 571 564 } 572 565 ret = bit_doAddress(i2c_adap, pmsg); 573 566 if ((ret != 0) && !nak_ok) { 574 - bit_dbg(1, &i2c_adap->dev, "NAK from " 575 - "device addr 0x%02x msg #%d\n", 567 + bit_dbg(1, &i2c_adap->dev, 568 + "NAK from device addr 0x%02x msg #%d\n", 576 569 msgs[i].addr, i); 577 570 goto bailout; 578 571 }
-1
drivers/i2c/busses/i2c-designware-master.c
··· 708 708 i2c_set_adapdata(adap, dev); 709 709 710 710 if (dev->pm_disabled) { 711 - dev_pm_syscore_device(dev->dev, true); 712 711 irq_flags = IRQF_NO_SUSPEND; 713 712 } else { 714 713 irq_flags = IRQF_SHARED | IRQF_COND_SUSPEND;
+6 -1
drivers/i2c/busses/i2c-designware-platdrv.c
··· 434 434 { 435 435 struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 436 436 437 + if (i_dev->pm_disabled) 438 + return 0; 439 + 437 440 i_dev->disable(i_dev); 438 441 i2c_dw_prepare_clk(i_dev, false); 439 442 ··· 447 444 { 448 445 struct dw_i2c_dev *i_dev = dev_get_drvdata(dev); 449 446 450 - i2c_dw_prepare_clk(i_dev, true); 447 + if (!i_dev->pm_disabled) 448 + i2c_dw_prepare_clk(i_dev, true); 449 + 451 450 i_dev->init(i_dev); 452 451 453 452 return 0;
+8 -1
drivers/i2c/busses/i2c-i801.c
··· 1415 1415 } 1416 1416 1417 1417 #ifdef CONFIG_ACPI 1418 + static bool i801_acpi_is_smbus_ioport(const struct i801_priv *priv, 1419 + acpi_physical_address address) 1420 + { 1421 + return address >= priv->smba && 1422 + address <= pci_resource_end(priv->pci_dev, SMBBAR); 1423 + } 1424 + 1418 1425 static acpi_status 1419 1426 i801_acpi_io_handler(u32 function, acpi_physical_address address, u32 bits, 1420 1427 u64 *value, void *handler_context, void *region_context) ··· 1437 1430 */ 1438 1431 mutex_lock(&priv->acpi_lock); 1439 1432 1440 - if (!priv->acpi_reserved) { 1433 + if (!priv->acpi_reserved && i801_acpi_is_smbus_ioport(priv, address)) { 1441 1434 priv->acpi_reserved = true; 1442 1435 1443 1436 dev_warn(&pdev->dev, "BIOS is accessing SMBus registers\n");
+7 -8
drivers/i2c/busses/i2c-sh_mobile.c
··· 507 507 pd->pos = pd->msg->len; 508 508 pd->stop_after_dma = true; 509 509 510 - i2c_release_dma_safe_msg_buf(pd->msg, pd->dma_buf); 511 - 512 510 iic_set_clr(pd, ICIC, 0, ICIC_TDMAE | ICIC_RDMAE); 513 511 } 514 512 ··· 600 602 dma_async_issue_pending(chan); 601 603 } 602 604 603 - static int start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg, 604 - bool do_init) 605 + static void start_ch(struct sh_mobile_i2c_data *pd, struct i2c_msg *usr_msg, 606 + bool do_init) 605 607 { 606 608 if (do_init) { 607 609 /* Initialize channel registers */ ··· 625 627 626 628 /* Enable all interrupts to begin with */ 627 629 iic_wr(pd, ICIC, ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE); 628 - return 0; 629 630 } 630 631 631 632 static int poll_dte(struct sh_mobile_i2c_data *pd) ··· 695 698 pd->send_stop = i == num - 1 || msg->flags & I2C_M_STOP; 696 699 pd->stop_after_dma = false; 697 700 698 - err = start_ch(pd, msg, do_start); 699 - if (err) 700 - break; 701 + start_ch(pd, msg, do_start); 701 702 702 703 if (do_start) 703 704 i2c_op(pd, OP_START, 0); ··· 704 709 timeout = wait_event_timeout(pd->wait, 705 710 pd->sr & (ICSR_TACK | SW_DONE), 706 711 adapter->timeout); 712 + 713 + /* 'stop_after_dma' tells if DMA transfer was complete */ 714 + i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg, pd->stop_after_dma); 715 + 707 716 if (!timeout) { 708 717 dev_err(pd->dev, "Transfer request timed out\n"); 709 718 if (pd->dma_direction != DMA_NONE)
+6 -5
drivers/i2c/i2c-core-base.c
··· 2293 2293 EXPORT_SYMBOL_GPL(i2c_get_dma_safe_msg_buf); 2294 2294 2295 2295 /** 2296 - * i2c_release_dma_safe_msg_buf - release DMA safe buffer and sync with i2c_msg 2297 - * @msg: the message to be synced with 2296 + * i2c_put_dma_safe_msg_buf - release DMA safe buffer and sync with i2c_msg 2298 2297 * @buf: the buffer obtained from i2c_get_dma_safe_msg_buf(). May be NULL. 2298 + * @msg: the message which the buffer corresponds to 2299 + * @xferred: bool saying if the message was transferred 2299 2300 */ 2300 - void i2c_release_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf) 2301 + void i2c_put_dma_safe_msg_buf(u8 *buf, struct i2c_msg *msg, bool xferred) 2301 2302 { 2302 2303 if (!buf || buf == msg->buf) 2303 2304 return; 2304 2305 2305 - if (msg->flags & I2C_M_RD) 2306 + if (xferred && msg->flags & I2C_M_RD) 2306 2307 memcpy(msg->buf, buf, msg->len); 2307 2308 2308 2309 kfree(buf); 2309 2310 } 2310 - EXPORT_SYMBOL_GPL(i2c_release_dma_safe_msg_buf); 2311 + EXPORT_SYMBOL_GPL(i2c_put_dma_safe_msg_buf); 2311 2312 2312 2313 MODULE_AUTHOR("Simon G. Vogl <simon@tk.uni-linz.ac.at>"); 2313 2314 MODULE_DESCRIPTION("I2C-Bus main module");
+1 -1
include/linux/i2c.h
··· 855 855 } 856 856 857 857 u8 *i2c_get_dma_safe_msg_buf(struct i2c_msg *msg, unsigned int threshold); 858 - void i2c_release_dma_safe_msg_buf(struct i2c_msg *msg, u8 *buf); 858 + void i2c_put_dma_safe_msg_buf(u8 *buf, struct i2c_msg *msg, bool xferred); 859 859 860 860 int i2c_handle_smbus_host_notify(struct i2c_adapter *adap, unsigned short addr); 861 861 /**