All of lore.kernel.org
 help / color / mirror / Atom feed
* [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes
@ 2014-03-31 16:26 Paolo Bonzini
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 1/7] smbus: allow returning an error from reads Paolo Bonzini
                   ` (7 more replies)
  0 siblings, 8 replies; 17+ messages in thread
From: Paolo Bonzini @ 2014-03-31 16:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, afaerber

This is a resend of the I2C patches I posted a while ago.
Patches 1-3 are just a rebase.

Patch 4 is the same as before, patches 5-7 make the tmp105
testcase more complete in order to test that change.

Paolo Bonzini (7):
  smbus: allow returning an error from reads
  smbus: return -1 if nothing found at the given address
  pm_smbus: correctly report unclaimed cycles
  tmp105: read temperature in milli-celsius
  tmp105-test: wrap simple building blocks for testing
  tmp105-test: add a second sensor and test that one
  tmp105-test: test QOM property and precision

 hw/i2c/pm_smbus.c      |  63 +++++++++++++++--------
 hw/i2c/smbus.c         |  68 +++++++++++++++++--------
 hw/misc/tmp105.c       |   8 +--
 include/hw/i2c/smbus.h |  18 +++----
 roms/SLOF              |   2 +-
 roms/openbios          |   2 +-
 roms/qemu-palcode      |   2 +-
 roms/seabios           |   2 +-
 tests/tmp105-test.c    | 136 +++++++++++++++++++++++++++++++++++++++++--------
 9 files changed, 220 insertions(+), 81 deletions(-)

-- 
1.9.0

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

* [Qemu-devel] [PATCH for-2.0 1/7] smbus: allow returning an error from reads
  2014-03-31 16:26 [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Paolo Bonzini
@ 2014-03-31 16:26 ` Paolo Bonzini
  2014-03-31 21:20   ` Andreas Färber
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 2/7] smbus: return -1 if nothing found at the given address Paolo Bonzini
                   ` (6 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Paolo Bonzini @ 2014-03-31 16:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, afaerber

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i2c/smbus.c         | 6 +++---
 include/hw/i2c/smbus.h | 6 +++---
 2 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c
index 3febf3c..190f08e 100644
--- a/hw/i2c/smbus.c
+++ b/hw/i2c/smbus.c
@@ -214,7 +214,7 @@ void smbus_quick_command(I2CBus *bus, uint8_t addr, int read)
     i2c_end_transfer(bus);
 }
 
-uint8_t smbus_receive_byte(I2CBus *bus, uint8_t addr)
+int smbus_receive_byte(I2CBus *bus, uint8_t addr)
 {
     uint8_t data;
 
@@ -232,7 +232,7 @@ void smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data)
     i2c_end_transfer(bus);
 }
 
-uint8_t smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command)
+int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command)
 {
     uint8_t data;
     i2c_start_transfer(bus, addr, 0);
@@ -252,7 +252,7 @@ void smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data)
     i2c_end_transfer(bus);
 }
 
-uint16_t smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command)
+int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command)
 {
     uint16_t data;
     i2c_start_transfer(bus, addr, 0);
diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h
index 63f0cc4..285d3b5 100644
--- a/include/hw/i2c/smbus.h
+++ b/include/hw/i2c/smbus.h
@@ -67,11 +67,11 @@ struct SMBusDevice {
 
 /* Master device commands.  */
 void smbus_quick_command(I2CBus *bus, uint8_t addr, int read);
-uint8_t smbus_receive_byte(I2CBus *bus, uint8_t addr);
+int smbus_receive_byte(I2CBus *bus, uint8_t addr);
 void smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data);
-uint8_t smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command);
+int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command);
 void smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data);
-uint16_t smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command);
+int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command);
 void smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data);
 int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data);
 void smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
-- 
1.9.0

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

* [Qemu-devel] [PATCH for-2.0 2/7] smbus: return -1 if nothing found at the given address
  2014-03-31 16:26 [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Paolo Bonzini
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 1/7] smbus: allow returning an error from reads Paolo Bonzini
@ 2014-03-31 16:26 ` Paolo Bonzini
  2014-03-31 21:29   ` Andreas Färber
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 3/7] pm_smbus: correctly report unclaimed cycles Paolo Bonzini
                   ` (5 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Paolo Bonzini @ 2014-03-31 16:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, afaerber

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i2c/smbus.c         | 62 +++++++++++++++++++++++++++++++++++---------------
 include/hw/i2c/smbus.h | 12 +++++-----
 2 files changed, 50 insertions(+), 24 deletions(-)

diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c
index 190f08e..6e27ae8 100644
--- a/hw/i2c/smbus.c
+++ b/hw/i2c/smbus.c
@@ -208,34 +208,44 @@ static int smbus_device_init(I2CSlave *i2c)
 }
 
 /* Master device commands.  */
-void smbus_quick_command(I2CBus *bus, uint8_t addr, int read)
+int smbus_quick_command(I2CBus *bus, uint8_t addr, int read)
 {
-    i2c_start_transfer(bus, addr, read);
+    if (i2c_start_transfer(bus, addr, read)) {
+        return -1;
+    }
     i2c_end_transfer(bus);
+    return 0;
 }
 
 int smbus_receive_byte(I2CBus *bus, uint8_t addr)
 {
     uint8_t data;
 
-    i2c_start_transfer(bus, addr, 1);
+    if (i2c_start_transfer(bus, addr, 1)) {
+        return -1;
+    }
     data = i2c_recv(bus);
     i2c_nack(bus);
     i2c_end_transfer(bus);
     return data;
 }
 
-void smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data)
+int smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data)
 {
-    i2c_start_transfer(bus, addr, 0);
+    if (i2c_start_transfer(bus, addr, 0)) {
+        return -1;
+    }
     i2c_send(bus, data);
     i2c_end_transfer(bus);
+    return 0;
 }
 
 int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command)
 {
     uint8_t data;
-    i2c_start_transfer(bus, addr, 0);
+    if (i2c_start_transfer(bus, addr, 0)) {
+        return -1;
+    }
     i2c_send(bus, command);
     i2c_start_transfer(bus, addr, 1);
     data = i2c_recv(bus);
@@ -244,18 +254,23 @@ int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command)
     return data;
 }
 
-void smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data)
+int smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data)
 {
-    i2c_start_transfer(bus, addr, 0);
+    if (i2c_start_transfer(bus, addr, 0)) {
+        return -1;
+    }
     i2c_send(bus, command);
     i2c_send(bus, data);
     i2c_end_transfer(bus);
+    return 0;
 }
 
 int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command)
 {
     uint16_t data;
-    i2c_start_transfer(bus, addr, 0);
+    if (i2c_start_transfer(bus, addr, 0)) {
+        return -1;
+    }
     i2c_send(bus, command);
     i2c_start_transfer(bus, addr, 1);
     data = i2c_recv(bus);
@@ -265,13 +280,16 @@ int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command)
     return data;
 }
 
-void smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data)
+int smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data)
 {
-    i2c_start_transfer(bus, addr, 0);
+    if (i2c_start_transfer(bus, addr, 0)) {
+        return -1;
+    }
     i2c_send(bus, command);
     i2c_send(bus, data & 0xff);
     i2c_send(bus, data >> 8);
     i2c_end_transfer(bus);
+    return 0;
 }
 
 int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data)
@@ -279,33 +297,41 @@ int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data)
     int len;
     int i;
 
-    i2c_start_transfer(bus, addr, 0);
+    if (i2c_start_transfer(bus, addr, 0)) {
+        return -1;
+    }
     i2c_send(bus, command);
     i2c_start_transfer(bus, addr, 1);
     len = i2c_recv(bus);
-    if (len > 32)
+    if (len > 32) {
         len = 0;
-    for (i = 0; i < len; i++)
+    }
+    for (i = 0; i < len; i++) {
         data[i] = i2c_recv(bus);
+    }
     i2c_nack(bus);
     i2c_end_transfer(bus);
     return len;
 }
 
-void smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
-                       int len)
+int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
+                      int len)
 {
     int i;
 
     if (len > 32)
         len = 32;
 
-    i2c_start_transfer(bus, addr, 0);
+    if (i2c_start_transfer(bus, addr, 0)) {
+        return -1;
+    }
     i2c_send(bus, command);
     i2c_send(bus, len);
-    for (i = 0; i < len; i++)
+    for (i = 0; i < len; i++) {
         i2c_send(bus, data[i]);
+    }
     i2c_end_transfer(bus);
+    return 0;
 }
 
 static void smbus_device_class_init(ObjectClass *klass, void *data)
diff --git a/include/hw/i2c/smbus.h b/include/hw/i2c/smbus.h
index 285d3b5..544bbc1 100644
--- a/include/hw/i2c/smbus.h
+++ b/include/hw/i2c/smbus.h
@@ -66,16 +66,16 @@ struct SMBusDevice {
 };
 
 /* Master device commands.  */
-void smbus_quick_command(I2CBus *bus, uint8_t addr, int read);
+int smbus_quick_command(I2CBus *bus, uint8_t addr, int read);
 int smbus_receive_byte(I2CBus *bus, uint8_t addr);
-void smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data);
+int smbus_send_byte(I2CBus *bus, uint8_t addr, uint8_t data);
 int smbus_read_byte(I2CBus *bus, uint8_t addr, uint8_t command);
-void smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data);
+int smbus_write_byte(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t data);
 int smbus_read_word(I2CBus *bus, uint8_t addr, uint8_t command);
-void smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data);
+int smbus_write_word(I2CBus *bus, uint8_t addr, uint8_t command, uint16_t data);
 int smbus_read_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data);
-void smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
-                       int len);
+int smbus_write_block(I2CBus *bus, uint8_t addr, uint8_t command, uint8_t *data,
+                      int len);
 
 void smbus_eeprom_init(I2CBus *smbus, int nb_eeprom,
                        const uint8_t *eeprom_spd, int size);
-- 
1.9.0

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

* [Qemu-devel] [PATCH for-2.0 3/7] pm_smbus: correctly report unclaimed cycles
  2014-03-31 16:26 [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Paolo Bonzini
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 1/7] smbus: allow returning an error from reads Paolo Bonzini
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 2/7] smbus: return -1 if nothing found at the given address Paolo Bonzini
@ 2014-03-31 16:26 ` Paolo Bonzini
  2014-03-31 21:38   ` Andreas Färber
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 4/7] tmp105: read temperature in milli-celsius Paolo Bonzini
                   ` (4 subsequent siblings)
  7 siblings, 1 reply; 17+ messages in thread
From: Paolo Bonzini @ 2014-03-31 16:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, afaerber

Without this patch, i2cdetect will report all addresses as present.
With it, only 0x50..0x57 are present.

Before:

         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
    10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
    20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
    30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
    40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
    50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
    60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
    70: 70 71 72 73 74 75 76 77

After:

         0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
    00:          -- -- -- -- -- -- -- -- -- -- -- -- --
    10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    50: 50 51 52 53 54 55 56 57 -- -- -- -- -- -- -- --
    60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
    70: -- -- -- -- -- -- -- --

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/i2c/pm_smbus.c | 63 ++++++++++++++++++++++++++++++++++++-------------------
 1 file changed, 41 insertions(+), 22 deletions(-)

diff --git a/hw/i2c/pm_smbus.c b/hw/i2c/pm_smbus.c
index 9f50067..7730100 100644
--- a/hw/i2c/pm_smbus.c
+++ b/hw/i2c/pm_smbus.c
@@ -60,59 +60,78 @@ static void smb_transaction(PMSMBus *s)
     uint8_t cmd = s->smb_cmd;
     uint8_t addr = s->smb_addr >> 1;
     I2CBus *bus = s->smbus;
+    int ret;
 
     SMBUS_DPRINTF("SMBus trans addr=0x%02x prot=0x%02x\n", addr, prot);
     /* Transaction isn't exec if STS_DEV_ERR bit set */
     if ((s->smb_stat & STS_DEV_ERR) != 0)  {
-            goto error;
-        }
+        goto error;
+    }
     switch(prot) {
     case 0x0:
-        smbus_quick_command(bus, addr, read);
-        s->smb_stat |= STS_BYTE_DONE | STS_INTR;
-        break;
+        ret = smbus_quick_command(bus, addr, read);
+        goto done;
     case 0x1:
         if (read) {
-            s->smb_data0 = smbus_receive_byte(bus, addr);
+            ret = smbus_receive_byte(bus, addr);
+            goto data8;
         } else {
-            smbus_send_byte(bus, addr, cmd);
+            ret = smbus_send_byte(bus, addr, cmd);
+            goto done;
         }
-        s->smb_stat |= STS_BYTE_DONE | STS_INTR;
-        break;
     case 0x2:
         if (read) {
-            s->smb_data0 = smbus_read_byte(bus, addr, cmd);
+            ret = smbus_read_byte(bus, addr, cmd);
+            goto data8;
         } else {
-            smbus_write_byte(bus, addr, cmd, s->smb_data0);
+            ret = smbus_write_byte(bus, addr, cmd, s->smb_data0);
+            goto done;
         }
-        s->smb_stat |= STS_BYTE_DONE | STS_INTR;
         break;
     case 0x3:
         if (read) {
-            uint16_t val;
-            val = smbus_read_word(bus, addr, cmd);
-            s->smb_data0 = val;
-            s->smb_data1 = val >> 8;
+            ret = smbus_read_word(bus, addr, cmd);
+            goto data16;
         } else {
-            smbus_write_word(bus, addr, cmd, (s->smb_data1 << 8) | s->smb_data0);
+            ret = smbus_write_word(bus, addr, cmd, (s->smb_data1 << 8) | s->smb_data0);
+            goto done;
         }
-        s->smb_stat |= STS_BYTE_DONE | STS_INTR;
         break;
     case 0x5:
         if (read) {
-            s->smb_data0 = smbus_read_block(bus, addr, cmd, s->smb_data);
+            ret = smbus_read_block(bus, addr, cmd, s->smb_data);
+            goto data8;
         } else {
-            smbus_write_block(bus, addr, cmd, s->smb_data, s->smb_data0);
+            ret = smbus_write_block(bus, addr, cmd, s->smb_data, s->smb_data0);
+            goto done;
         }
-        s->smb_stat |= STS_BYTE_DONE | STS_INTR;
         break;
     default:
         goto error;
     }
+    abort();
+
+data16:
+    if (ret < 0) {
+        goto error;
+    }
+    s->smb_data1 = ret >> 8;
+data8:
+    if (ret < 0) {
+        goto error;
+    }
+    s->smb_data0 = ret;
+done:
+    if (ret < 0) {
+        goto error;
+    }
+    s->smb_stat |= STS_BYTE_DONE | STS_INTR;
     return;
 
-  error:
+error:
     s->smb_stat |= STS_DEV_ERR;
+    return;
+
 }
 
 static void smb_ioport_writeb(void *opaque, hwaddr addr, uint64_t val,
-- 
1.9.0

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

* [Qemu-devel] [PATCH for-2.0 4/7] tmp105: read temperature in milli-celsius
  2014-03-31 16:26 [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Paolo Bonzini
                   ` (2 preceding siblings ...)
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 3/7] pm_smbus: correctly report unclaimed cycles Paolo Bonzini
@ 2014-03-31 16:26 ` Paolo Bonzini
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 5/7] tmp105-test: wrap simple building blocks for testing Paolo Bonzini
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Paolo Bonzini @ 2014-03-31 16:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, afaerber

Right now, the temperature property must be written in milli-celsius, but it
reads back the value in 8.8 fixed point.  Fix this by letting the property
read back the original value (possibly rounded).  Also simplify the code that
does the conversion.

Before:

    (QEMU) qom-set path=/machine/peripheral/sensor property=temperature value=20000
    {u'return': {}}
    (QEMU) qom-get path=sensor property=temperature
    {u'return': 5120}

After:

    (QEMU) qom-set path=/machine/peripheral/sensor property=temperature value=20000
    {u'return': {}}
    (QEMU) qom-get path=sensor property=temperature
    {u'return': 20000}

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 hw/misc/tmp105.c | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/hw/misc/tmp105.c b/hw/misc/tmp105.c
index caec4a5..244c1ef 100644
--- a/hw/misc/tmp105.c
+++ b/hw/misc/tmp105.c
@@ -56,12 +56,14 @@ static void tmp105_get_temperature(Object *obj, Visitor *v, void *opaque,
                                    const char *name, Error **errp)
 {
     TMP105State *s = TMP105(obj);
-    int64_t value = s->temperature;
+    int64_t value = s->temperature * 1000 / 256;
 
     visit_type_int(v, &value, name, errp);
 }
 
-/* Units are 0.001 centigrades relative to 0 C.  */
+/* Units are 0.001 centigrades relative to 0 C.  s->temperature is 8.8
+ * fixed point, so units are 1/256 centigrades.  A simple ratio will do.
+ */
 static void tmp105_set_temperature(Object *obj, Visitor *v, void *opaque,
                                    const char *name, Error **errp)
 {
@@ -80,7 +82,7 @@ static void tmp105_set_temperature(Object *obj, Visitor *v, void *opaque,
         return;
     }
 
-    s->temperature = ((int16_t) (temp * 0x800 / 128000)) << 4;
+    s->temperature = (int16_t) (temp * 256 / 1000);
 
     tmp105_alarm_update(s);
 }
-- 
1.9.0

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

* [Qemu-devel] [PATCH for-2.0 5/7] tmp105-test: wrap simple building blocks for testing
  2014-03-31 16:26 [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Paolo Bonzini
                   ` (3 preceding siblings ...)
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 4/7] tmp105: read temperature in milli-celsius Paolo Bonzini
@ 2014-03-31 16:26 ` Paolo Bonzini
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 6/7] tmp105-test: add a second sensor and test that one Paolo Bonzini
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 17+ messages in thread
From: Paolo Bonzini @ 2014-03-31 16:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, afaerber

The next patches will add more reads and writes.  Add a simple testing
API for this.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/tmp105-test.c | 54 +++++++++++++++++++++++++++++++++++------------------
 1 file changed, 36 insertions(+), 18 deletions(-)

diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index 0834219..20a1894 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -20,39 +20,57 @@
 static I2CAdapter *i2c;
 static uint8_t addr;
 
-static void send_and_receive(void)
+static uint16_t tmp105_get16(I2CAdapter *i2c, uint8_t addr, uint8_t reg)
 {
-    uint8_t cmd[3];
     uint8_t resp[2];
-
-    cmd[0] = TMP105_REG_TEMPERATURE;
-    i2c_send(i2c, addr, cmd, 1);
+    i2c_send(i2c, addr, &reg, 1);
     i2c_recv(i2c, addr, resp, 2);
-    g_assert_cmpuint(((uint16_t)resp[0] << 8) | resp[1], ==, 0);
+    return (resp[0] << 8) | resp[1];
+}
+
+static void tmp105_set8(I2CAdapter *i2c, uint8_t addr, uint8_t reg,
+                        uint8_t value)
+{
+    uint8_t cmd[2];
+    uint8_t resp[1];
 
-    cmd[0] = TMP105_REG_CONFIG;
-    cmd[1] = 0x0; /* matches the reset value */
+    cmd[0] = reg;
+    cmd[1] = value;
     i2c_send(i2c, addr, cmd, 2);
     i2c_recv(i2c, addr, resp, 1);
     g_assert_cmphex(resp[0], ==, cmd[1]);
+}
 
-    cmd[0] = TMP105_REG_T_LOW;
-    cmd[1] = 0x12;
-    cmd[2] = 0x34;
-    i2c_send(i2c, addr, cmd, 3);
-    i2c_recv(i2c, addr, resp, 2);
-    g_assert_cmphex(resp[0], ==, cmd[1]);
-    g_assert_cmphex(resp[1], ==, cmd[2]);
+static void tmp105_set16(I2CAdapter *i2c, uint8_t addr, uint8_t reg,
+                         uint16_t value)
+{
+    uint8_t cmd[3];
+    uint8_t resp[2];
 
-    cmd[0] = TMP105_REG_T_HIGH;
-    cmd[1] = 0x42;
-    cmd[2] = 0x31;
+    cmd[0] = reg;
+    cmd[1] = value >> 8;
+    cmd[2] = value & 255;
     i2c_send(i2c, addr, cmd, 3);
     i2c_recv(i2c, addr, resp, 2);
     g_assert_cmphex(resp[0], ==, cmd[1]);
     g_assert_cmphex(resp[1], ==, cmd[2]);
 }
 
+
+static void send_and_receive(void)
+{
+    uint16_t value;
+
+    value = tmp105_get16(i2c, addr, TMP105_REG_TEMPERATURE);
+    g_assert_cmpuint(value, ==, 0);
+
+    /* reset */
+    tmp105_set8(i2c, addr, TMP105_REG_CONFIG, 0);
+
+    tmp105_set16(i2c, addr, TMP105_REG_T_LOW, 0x1234);
+    tmp105_set16(i2c, addr, TMP105_REG_T_HIGH, 0x4231);
+}
+
 int main(int argc, char **argv)
 {
     QTestState *s = NULL;
-- 
1.9.0

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

* [Qemu-devel] [PATCH for-2.0 6/7] tmp105-test: add a second sensor and test that one
  2014-03-31 16:26 [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Paolo Bonzini
                   ` (4 preceding siblings ...)
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 5/7] tmp105-test: wrap simple building blocks for testing Paolo Bonzini
@ 2014-03-31 16:26 ` Paolo Bonzini
  2014-03-31 21:01   ` Andreas Färber
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 7/7] tmp105-test: test QOM property and precision Paolo Bonzini
  2014-03-31 21:58 ` [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Andreas Färber
  7 siblings, 1 reply; 17+ messages in thread
From: Paolo Bonzini @ 2014-03-31 16:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, afaerber

This will make it easier to reach the device under test via QOM.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/tmp105-test.c | 17 +++++++++--------
 5 files changed, 13 insertions(+), 12 deletions(-)

diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index 20a1894..4e640b4 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -15,10 +15,10 @@
 
 #define OMAP2_I2C_1_BASE 0x48070000
 
-#define N8X0_ADDR 0x48
+#define TMP105_TEST_ID   "tmp105-test"
+#define TMP105_TEST_ADDR 0x49
 
 static I2CAdapter *i2c;
-static uint8_t addr;
 
 static uint16_t tmp105_get16(I2CAdapter *i2c, uint8_t addr, uint8_t reg)
 {
@@ -61,14 +61,14 @@ static void send_and_receive(void)
 {
     uint16_t value;
 
-    value = tmp105_get16(i2c, addr, TMP105_REG_TEMPERATURE);
+    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
     g_assert_cmpuint(value, ==, 0);
 
     /* reset */
-    tmp105_set8(i2c, addr, TMP105_REG_CONFIG, 0);
+    tmp105_set8(i2c, TMP105_TEST_ADDR, TMP105_REG_CONFIG, 0);
 
-    tmp105_set16(i2c, addr, TMP105_REG_T_LOW, 0x1234);
-    tmp105_set16(i2c, addr, TMP105_REG_T_HIGH, 0x4231);
+    tmp105_set16(i2c, TMP105_TEST_ADDR, TMP105_REG_T_LOW, 0x1234);
+    tmp105_set16(i2c, TMP105_TEST_ADDR, TMP105_REG_T_HIGH, 0x4231);
 }
 
 int main(int argc, char **argv)
@@ -78,9 +78,10 @@ int main(int argc, char **argv)
 
     g_test_init(&argc, &argv, NULL);
 
-    s = qtest_start("-machine n800");
+    s = qtest_start("-machine n800 "
+                    "-device tmp105,bus=i2c-bus.0,id=" TMP105_TEST_ID
+                    ",address=0x49");
     i2c = omap_i2c_create(OMAP2_I2C_1_BASE);
-    addr = N8X0_ADDR;
 
     qtest_add_func("/tmp105/tx-rx", send_and_receive);
 
-- 
1.9.0

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

* [Qemu-devel] [PATCH for-2.0 7/7] tmp105-test: test QOM property and precision
  2014-03-31 16:26 [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Paolo Bonzini
                   ` (5 preceding siblings ...)
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 6/7] tmp105-test: add a second sensor and test that one Paolo Bonzini
@ 2014-03-31 16:26 ` Paolo Bonzini
  2014-03-31 21:58 ` [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Andreas Färber
  7 siblings, 0 replies; 17+ messages in thread
From: Paolo Bonzini @ 2014-03-31 16:26 UTC (permalink / raw)
  To: qemu-devel; +Cc: peter.maydell, afaerber

This lets us add a regression test for the first commit in this series.

Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
---
 tests/tmp105-test.c | 79 +++++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 76 insertions(+), 3 deletions(-)

diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
index 4e640b4..15ddaf3 100644
--- a/tests/tmp105-test.c
+++ b/tests/tmp105-test.c
@@ -20,6 +20,14 @@
 
 static I2CAdapter *i2c;
 
+static uint16_t tmp105_get8(I2CAdapter *i2c, uint8_t addr, uint8_t reg)
+{
+    uint8_t resp[1];
+    i2c_send(i2c, addr, &reg, 1);
+    i2c_recv(i2c, addr, resp, 1);
+    return resp[0];
+}
+
 static uint16_t tmp105_get16(I2CAdapter *i2c, uint8_t addr, uint8_t reg)
 {
     uint8_t resp[2];
@@ -56,16 +64,81 @@ static void tmp105_set16(I2CAdapter *i2c, uint8_t addr, uint8_t reg,
     g_assert_cmphex(resp[1], ==, cmd[2]);
 }
 
+static int qmp_tmp105_get_temperature(const char *id)
+{
+    QDict *response;
+    int ret;
 
+    response = qmp("{ 'execute': 'qom-get', 'arguments': { 'path': '%s', "
+                   "'property': 'temperature' } }", id);
+    g_assert(qdict_haskey(response, "return"));
+    ret = qdict_get_int(response, "return");
+    QDECREF(response);
+    return ret;
+}
+
+static void qmp_tmp105_set_temperature(const char *id, int value)
+{
+    QDict *response;
+
+    response = qmp("{ 'execute': 'qom-set', 'arguments': { 'path': '%s', "
+                   "'property': 'temperature', 'value': %d } }", id, value);
+    g_assert(qdict_haskey(response, "return"));
+    QDECREF(response);
+}
+
+#define TMP105_PRECISION (1000/16)
 static void send_and_receive(void)
 {
     uint16_t value;
 
-    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
+    value = qmp_tmp105_get_temperature(TMP105_TEST_ID);
     g_assert_cmpuint(value, ==, 0);
 
-    /* reset */
-    tmp105_set8(i2c, TMP105_TEST_ADDR, TMP105_REG_CONFIG, 0);
+    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
+    g_assert_cmphex(value, ==, 0);
+
+    qmp_tmp105_set_temperature(TMP105_TEST_ID, 20000);
+    value = qmp_tmp105_get_temperature(TMP105_TEST_ID);
+    g_assert_cmpuint(value, ==, 20000);
+
+    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
+    g_assert_cmphex(value, ==, 0x1400);
+
+    qmp_tmp105_set_temperature(TMP105_TEST_ID, 20938); /* 20 + 15/16 */
+    value = qmp_tmp105_get_temperature(TMP105_TEST_ID);
+    g_assert_cmpuint(value, >=, 20938 - TMP105_PRECISION/2);
+    g_assert_cmpuint(value, <, 20938 + TMP105_PRECISION/2);
+
+    /* Set config */
+    tmp105_set8(i2c, TMP105_TEST_ADDR, TMP105_REG_CONFIG, 0x60);
+    value = tmp105_get8(i2c, TMP105_TEST_ADDR, TMP105_REG_CONFIG);
+    g_assert_cmphex(value, ==, 0x60);
+
+    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
+    g_assert_cmphex(value, ==, 0x14f0);
+
+    /* Set precision to 9, 10, 11 bits.  */
+    tmp105_set8(i2c, TMP105_TEST_ADDR, TMP105_REG_CONFIG, 0x00);
+    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
+    g_assert_cmphex(value, ==, 0x1480);
+
+    tmp105_set8(i2c, TMP105_TEST_ADDR, TMP105_REG_CONFIG, 0x20);
+    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
+    g_assert_cmphex(value, ==, 0x14c0);
+
+    tmp105_set8(i2c, TMP105_TEST_ADDR, TMP105_REG_CONFIG, 0x40);
+    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
+    g_assert_cmphex(value, ==, 0x14e0);
+
+    /* stored precision remains the same */
+    value = qmp_tmp105_get_temperature(TMP105_TEST_ID);
+    g_assert_cmpuint(value, >=, 20938 - TMP105_PRECISION/2);
+    g_assert_cmpuint(value, <, 20938 + TMP105_PRECISION/2);
+
+    tmp105_set8(i2c, TMP105_TEST_ADDR, TMP105_REG_CONFIG, 0x60);
+    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
+    g_assert_cmphex(value, ==, 0x14f0);
 
     tmp105_set16(i2c, TMP105_TEST_ADDR, TMP105_REG_T_LOW, 0x1234);
     tmp105_set16(i2c, TMP105_TEST_ADDR, TMP105_REG_T_HIGH, 0x4231);
-- 
1.9.0

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

* Re: [Qemu-devel] [PATCH for-2.0 6/7] tmp105-test: add a second sensor and test that one
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 6/7] tmp105-test: add a second sensor and test that one Paolo Bonzini
@ 2014-03-31 21:01   ` Andreas Färber
  0 siblings, 0 replies; 17+ messages in thread
From: Andreas Färber @ 2014-03-31 21:01 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: peter.maydell

Am 31.03.2014 18:26, schrieb Paolo Bonzini:
> This will make it easier to reach the device under test via QOM.
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  tests/tmp105-test.c | 17 +++++++++--------
>  5 files changed, 13 insertions(+), 12 deletions(-)
> 
> diff --git a/tests/tmp105-test.c b/tests/tmp105-test.c
> index 20a1894..4e640b4 100644
> --- a/tests/tmp105-test.c
> +++ b/tests/tmp105-test.c
> @@ -15,10 +15,10 @@
>  
>  #define OMAP2_I2C_1_BASE 0x48070000
>  
> -#define N8X0_ADDR 0x48
> +#define TMP105_TEST_ID   "tmp105-test"
> +#define TMP105_TEST_ADDR 0x49
>  
>  static I2CAdapter *i2c;
> -static uint8_t addr;
>  
>  static uint16_t tmp105_get16(I2CAdapter *i2c, uint8_t addr, uint8_t reg)
>  {
> @@ -61,14 +61,14 @@ static void send_and_receive(void)
>  {
>      uint16_t value;
>  
> -    value = tmp105_get16(i2c, addr, TMP105_REG_TEMPERATURE);
> +    value = tmp105_get16(i2c, TMP105_TEST_ADDR, TMP105_REG_TEMPERATURE);
>      g_assert_cmpuint(value, ==, 0);
>  
>      /* reset */
> -    tmp105_set8(i2c, addr, TMP105_REG_CONFIG, 0);
> +    tmp105_set8(i2c, TMP105_TEST_ADDR, TMP105_REG_CONFIG, 0);
>  
> -    tmp105_set16(i2c, addr, TMP105_REG_T_LOW, 0x1234);
> -    tmp105_set16(i2c, addr, TMP105_REG_T_HIGH, 0x4231);
> +    tmp105_set16(i2c, TMP105_TEST_ADDR, TMP105_REG_T_LOW, 0x1234);
> +    tmp105_set16(i2c, TMP105_TEST_ADDR, TMP105_REG_T_HIGH, 0x4231);
>  }
>  
>  int main(int argc, char **argv)
> @@ -78,9 +78,10 @@ int main(int argc, char **argv)
>  
>      g_test_init(&argc, &argv, NULL);
>  
> -    s = qtest_start("-machine n800");
> +    s = qtest_start("-machine n800 "
> +                    "-device tmp105,bus=i2c-bus.0,id=" TMP105_TEST_ID
> +                    ",address=0x49");

Probably we could do some clever stringify() tricks here to reuse your
TMP105_TEST_ADDR constant, but I'll leave it as is for now.

Andreas

>      i2c = omap_i2c_create(OMAP2_I2C_1_BASE);
> -    addr = N8X0_ADDR;
>  
>      qtest_add_func("/tmp105/tx-rx", send_and_receive);
>  
> 


-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH for-2.0 1/7] smbus: allow returning an error from reads
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 1/7] smbus: allow returning an error from reads Paolo Bonzini
@ 2014-03-31 21:20   ` Andreas Färber
  0 siblings, 0 replies; 17+ messages in thread
From: Andreas Färber @ 2014-03-31 21:20 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: peter.maydell

Am 31.03.2014 18:26, schrieb Paolo Bonzini:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/i2c/smbus.c         | 6 +++---
>  include/hw/i2c/smbus.h | 6 +++---
>  2 files changed, 6 insertions(+), 6 deletions(-)

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH for-2.0 2/7] smbus: return -1 if nothing found at the given address
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 2/7] smbus: return -1 if nothing found at the given address Paolo Bonzini
@ 2014-03-31 21:29   ` Andreas Färber
  0 siblings, 0 replies; 17+ messages in thread
From: Andreas Färber @ 2014-03-31 21:29 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: peter.maydell

Am 31.03.2014 18:26, schrieb Paolo Bonzini:
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/i2c/smbus.c         | 62 +++++++++++++++++++++++++++++++++++---------------
>  include/hw/i2c/smbus.h | 12 +++++-----
>  2 files changed, 50 insertions(+), 24 deletions(-)
> 
> diff --git a/hw/i2c/smbus.c b/hw/i2c/smbus.c
> index 190f08e..6e27ae8 100644
> --- a/hw/i2c/smbus.c
> +++ b/hw/i2c/smbus.c
> @@ -208,34 +208,44 @@ static int smbus_device_init(I2CSlave *i2c)
>  }
>  
>  /* Master device commands.  */
> -void smbus_quick_command(I2CBus *bus, uint8_t addr, int read)
> +int smbus_quick_command(I2CBus *bus, uint8_t addr, int read)
>  {
> -    i2c_start_transfer(bus, addr, read);
> +    if (i2c_start_transfer(bus, addr, read)) {

For anyone else who wondered about this condition: i2c_start_transfer()
returns 1 if slave device is not found and 0 on success, so no normal
return codes interfering here.

> +        return -1;
> +    }
>      i2c_end_transfer(bus);
> +    return 0;
>  }
[snip]

Reviewed-by: Andreas Färber <afaerber@suse.de>

Might have mentioned also doing some adjacent Coding Style cleanups.

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH for-2.0 3/7] pm_smbus: correctly report unclaimed cycles
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 3/7] pm_smbus: correctly report unclaimed cycles Paolo Bonzini
@ 2014-03-31 21:38   ` Andreas Färber
  0 siblings, 0 replies; 17+ messages in thread
From: Andreas Färber @ 2014-03-31 21:38 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel; +Cc: peter.maydell

Am 31.03.2014 18:26, schrieb Paolo Bonzini:
> Without this patch, i2cdetect will report all addresses as present.
> With it, only 0x50..0x57 are present.
> 
> Before:
> 
>          0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
>     00:          03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f
>     10: 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f
>     20: 20 21 22 23 24 25 26 27 28 29 2a 2b 2c 2d 2e 2f
>     30: 30 31 32 33 34 35 36 37 38 39 3a 3b 3c 3d 3e 3f
>     40: 40 41 42 43 44 45 46 47 48 49 4a 4b 4c 4d 4e 4f
>     50: 50 51 52 53 54 55 56 57 58 59 5a 5b 5c 5d 5e 5f
>     60: 60 61 62 63 64 65 66 67 68 69 6a 6b 6c 6d 6e 6f
>     70: 70 71 72 73 74 75 76 77
> 
> After:
> 
>          0  1  2  3  4  5  6  7  8  9  a  b  c  d  e  f
>     00:          -- -- -- -- -- -- -- -- -- -- -- -- --
>     10: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>     20: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>     30: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>     40: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>     50: 50 51 52 53 54 55 56 57 -- -- -- -- -- -- -- --
>     60: -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --
>     70: -- -- -- -- -- -- -- --
> 
> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
> ---
>  hw/i2c/pm_smbus.c | 63 ++++++++++++++++++++++++++++++++++++-------------------
>  1 file changed, 41 insertions(+), 22 deletions(-)

The pure goto refactoring looks okay to me; don't have a datasheet to
check the changing error smb_stat behavior against though, so FWIW

Reviewed-by: Andreas Färber <afaerber@suse.de>

Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes
  2014-03-31 16:26 [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Paolo Bonzini
                   ` (6 preceding siblings ...)
  2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 7/7] tmp105-test: test QOM property and precision Paolo Bonzini
@ 2014-03-31 21:58 ` Andreas Färber
  2014-04-02 15:55   ` Michael S. Tsirkin
  7 siblings, 1 reply; 17+ messages in thread
From: Andreas Färber @ 2014-03-31 21:58 UTC (permalink / raw)
  To: Paolo Bonzini, qemu-devel, Michael S. Tsirkin; +Cc: peter.maydell

Hi,

Am 31.03.2014 18:26, schrieb Paolo Bonzini:
> This is a resend of the I2C patches I posted a while ago.
> Patches 1-3 are just a rebase.
> 
> Patch 4 is the same as before, patches 5-7 make the tmp105
> testcase more complete in order to test that change.
> 
> Paolo Bonzini (7):
>   smbus: allow returning an error from reads
>   smbus: return -1 if nothing found at the given address
>   pm_smbus: correctly report unclaimed cycles

I've reviewed these and they look sane and safe for 2.0.
mst, could you have a second look as PC maintainer and take them?

>   tmp105: read temperature in milli-celsius
>   tmp105-test: wrap simple building blocks for testing
>   tmp105-test: add a second sensor and test that one
>   tmp105-test: test QOM property and precision

Thanks, this is more than I would've done myself or asked for. I've
re-broken the text paragraphs of 4/7 to fit into 76 chars and filled in
the commit info in 7/7:
https://github.com/afaerber/qemu-cpu/commits/qom-next

And for the record, this demonstrates how pretty much any I2C device
(such as ds1338) can be tested for lack of other libqos drivers: Add it
via -device to n800 or n810 machine using a free address (such as 0x49
here) and give the device an ID for accessing it via
/machine/peripheral/<id> (just shorthand <id> here, I let that slip
through).

>  hw/i2c/pm_smbus.c      |  63 +++++++++++++++--------
>  hw/i2c/smbus.c         |  68 +++++++++++++++++--------
>  hw/misc/tmp105.c       |   8 +--
>  include/hw/i2c/smbus.h |  18 +++----
>  roms/SLOF              |   2 +-
>  roms/openbios          |   2 +-
>  roms/qemu-palcode      |   2 +-
>  roms/seabios           |   2 +-
>  tests/tmp105-test.c    | 136 +++++++++++++++++++++++++++++++++++++++++--------
>  9 files changed, 220 insertions(+), 81 deletions(-)

This diffstat luckily differs from the patches. Please double-check your
setup. :)

Regards,
Andreas

-- 
SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes
  2014-03-31 21:58 ` [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Andreas Färber
@ 2014-04-02 15:55   ` Michael S. Tsirkin
  2014-04-02 15:58     ` Paolo Bonzini
  2014-05-07  8:03     ` Paolo Bonzini
  0 siblings, 2 replies; 17+ messages in thread
From: Michael S. Tsirkin @ 2014-04-02 15:55 UTC (permalink / raw)
  To: Andreas Färber; +Cc: Paolo Bonzini, qemu-devel, peter.maydell

On Mon, Mar 31, 2014 at 11:58:57PM +0200, Andreas Färber wrote:
> Hi,
> 
> Am 31.03.2014 18:26, schrieb Paolo Bonzini:
> > This is a resend of the I2C patches I posted a while ago.
> > Patches 1-3 are just a rebase.
> > 
> > Patch 4 is the same as before, patches 5-7 make the tmp105
> > testcase more complete in order to test that change.
> > 
> > Paolo Bonzini (7):
> >   smbus: allow returning an error from reads
> >   smbus: return -1 if nothing found at the given address
> >   pm_smbus: correctly report unclaimed cycles
> 
> I've reviewed these and they look sane and safe for 2.0.
> mst, could you have a second look as PC maintainer and take them?

I'd rather delay to 2.1.
It's not a regression is it?

> >   tmp105: read temperature in milli-celsius
> >   tmp105-test: wrap simple building blocks for testing
> >   tmp105-test: add a second sensor and test that one
> >   tmp105-test: test QOM property and precision
> 
> Thanks, this is more than I would've done myself or asked for. I've
> re-broken the text paragraphs of 4/7 to fit into 76 chars and filled in
> the commit info in 7/7:
> https://github.com/afaerber/qemu-cpu/commits/qom-next
> 
> And for the record, this demonstrates how pretty much any I2C device
> (such as ds1338) can be tested for lack of other libqos drivers: Add it
> via -device to n800 or n810 machine using a free address (such as 0x49
> here) and give the device an ID for accessing it via
> /machine/peripheral/<id> (just shorthand <id> here, I let that slip
> through).
> 
> >  hw/i2c/pm_smbus.c      |  63 +++++++++++++++--------
> >  hw/i2c/smbus.c         |  68 +++++++++++++++++--------
> >  hw/misc/tmp105.c       |   8 +--
> >  include/hw/i2c/smbus.h |  18 +++----
> >  roms/SLOF              |   2 +-
> >  roms/openbios          |   2 +-
> >  roms/qemu-palcode      |   2 +-
> >  roms/seabios           |   2 +-
> >  tests/tmp105-test.c    | 136 +++++++++++++++++++++++++++++++++++++++++--------
> >  9 files changed, 220 insertions(+), 81 deletions(-)
> 
> This diffstat luckily differs from the patches. Please double-check your
> setup. :)
> 
> Regards,
> Andreas
> 
> -- 
> SUSE LINUX Products GmbH, Maxfeldstr. 5, 90409 Nürnberg, Germany
> GF: Jeff Hawn, Jennifer Guild, Felix Imendörffer; HRB 16746 AG Nürnberg

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

* Re: [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes
  2014-04-02 15:55   ` Michael S. Tsirkin
@ 2014-04-02 15:58     ` Paolo Bonzini
  2014-05-07  8:03     ` Paolo Bonzini
  1 sibling, 0 replies; 17+ messages in thread
From: Paolo Bonzini @ 2014-04-02 15:58 UTC (permalink / raw)
  To: Michael S. Tsirkin, Andreas Färber; +Cc: peter.maydell, qemu-devel

Il 02/04/2014 17:55, Michael S. Tsirkin ha scritto:
> > I've reviewed these and they look sane and safe for 2.0.
> > mst, could you have a second look as PC maintainer and take them?
>
> I'd rather delay to 2.1.
> It's not a regression is it?

No, I'm fine with 2.1 since I won't be around to fix mess.

Paolo

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

* Re: [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes
  2014-04-02 15:55   ` Michael S. Tsirkin
  2014-04-02 15:58     ` Paolo Bonzini
@ 2014-05-07  8:03     ` Paolo Bonzini
  2014-05-07  9:02       ` Michael S. Tsirkin
  1 sibling, 1 reply; 17+ messages in thread
From: Paolo Bonzini @ 2014-05-07  8:03 UTC (permalink / raw)
  To: Michael S. Tsirkin, Andreas Färber; +Cc: peter.maydell, qemu-devel

Il 02/04/2014 17:55, Michael S. Tsirkin ha scritto:
>>> > >   smbus: allow returning an error from reads
>>> > >   smbus: return -1 if nothing found at the given address
>>> > >   pm_smbus: correctly report unclaimed cycles
>> >
>> > I've reviewed these and they look sane and safe for 2.0.
>> > mst, could you have a second look as PC maintainer and take them?
> I'd rather delay to 2.1.
> It's not a regression is it?
>

Ping?

Paolo

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

* Re: [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes
  2014-05-07  8:03     ` Paolo Bonzini
@ 2014-05-07  9:02       ` Michael S. Tsirkin
  0 siblings, 0 replies; 17+ messages in thread
From: Michael S. Tsirkin @ 2014-05-07  9:02 UTC (permalink / raw)
  To: Paolo Bonzini; +Cc: peter.maydell, Andreas Färber, qemu-devel

On Wed, May 07, 2014 at 10:03:58AM +0200, Paolo Bonzini wrote:
> Il 02/04/2014 17:55, Michael S. Tsirkin ha scritto:
> >>>> >   smbus: allow returning an error from reads
> >>>> >   smbus: return -1 if nothing found at the given address
> >>>> >   pm_smbus: correctly report unclaimed cycles
> >>>
> >>> I've reviewed these and they look sane and safe for 2.0.
> >>> mst, could you have a second look as PC maintainer and take them?
> >I'd rather delay to 2.1.
> >It's not a regression is it?
> >
> 
> Ping?
> 
> Paolo

Applied, thanks!

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

end of thread, other threads:[~2014-05-07  9:03 UTC | newest]

Thread overview: 17+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2014-03-31 16:26 [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Paolo Bonzini
2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 1/7] smbus: allow returning an error from reads Paolo Bonzini
2014-03-31 21:20   ` Andreas Färber
2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 2/7] smbus: return -1 if nothing found at the given address Paolo Bonzini
2014-03-31 21:29   ` Andreas Färber
2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 3/7] pm_smbus: correctly report unclaimed cycles Paolo Bonzini
2014-03-31 21:38   ` Andreas Färber
2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 4/7] tmp105: read temperature in milli-celsius Paolo Bonzini
2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 5/7] tmp105-test: wrap simple building blocks for testing Paolo Bonzini
2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 6/7] tmp105-test: add a second sensor and test that one Paolo Bonzini
2014-03-31 21:01   ` Andreas Färber
2014-03-31 16:26 ` [Qemu-devel] [PATCH for-2.0 7/7] tmp105-test: test QOM property and precision Paolo Bonzini
2014-03-31 21:58 ` [Qemu-devel] [PATCH for-2.0 0/7] SMBus and tmp105 fixes Andreas Färber
2014-04-02 15:55   ` Michael S. Tsirkin
2014-04-02 15:58     ` Paolo Bonzini
2014-05-07  8:03     ` Paolo Bonzini
2014-05-07  9:02       ` Michael S. Tsirkin

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.