From patchwork Mon Jun 3 17:10:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Paolo Bonzini X-Patchwork-Id: 1109412 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=nongnu.org (client-ip=209.51.188.17; helo=lists.gnu.org; envelope-from=qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=redhat.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="ARBcdiR+"; dkim-atps=neutral Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 45Hhlv0Pyzz9sNk for ; Tue, 4 Jun 2019 03:25:47 +1000 (AEST) Received: from localhost ([127.0.0.1]:38431 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXqiO-0001Lu-Vr for incoming@patchwork.ozlabs.org; Mon, 03 Jun 2019 13:25:45 -0400 Received: from eggs.gnu.org ([209.51.188.92]:43506) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hXqUV-0007Vf-5k for qemu-devel@nongnu.org; Mon, 03 Jun 2019 13:11:25 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hXqUT-0004dI-VE for qemu-devel@nongnu.org; Mon, 03 Jun 2019 13:11:23 -0400 Received: from mail-wr1-x444.google.com ([2a00:1450:4864:20::444]:36700) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1hXqUQ-00041K-7v for qemu-devel@nongnu.org; Mon, 03 Jun 2019 13:11:20 -0400 Received: by mail-wr1-x444.google.com with SMTP id n4so9858167wrs.3 for ; Mon, 03 Jun 2019 10:11:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:subject:date:message-id:in-reply-to:references; bh=vgPNCTWPR6hZCIfyU4XsAQRjfaEbN+8hR83G4zbsugU=; b=ARBcdiR+Vqg8Mr/QTvJ6DNif9W59CXbdwM7AsKmKe/77/zALmnEtgkx3NL92oV6cj2 avU14ne22GwBsqfG7kH1fH3bZz/I/vL8l4dMMDM1hpOS1NY/5WC+mY8rq3ZhGWwsOLCg RttDokmUvr13HtT13vd1B5Mdysjf69GyaFYhk8PDwNxW6iwhv+U8HgjNpEkRrJEd5/3H OiIJixXh2TX6LoaSqplvWOf25duwdyNeS80TcQhb9E8TlC8g/zNZxQybp6eOfn42CJne 1w/lCvInEIeCl1AxFTZBnM9DIz8Ipl0E1HmLMBTu86hfQUsxqMZFX5PUNE/zkfd6HpiA ZxaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:sender:from:to:subject:date:message-id :in-reply-to:references; bh=vgPNCTWPR6hZCIfyU4XsAQRjfaEbN+8hR83G4zbsugU=; b=IpOUQBMxiVn2NTv5PEbAf6AuNwrJL8ZDb8Q3DPyYoXFlreO1rOMU8st6TSmjiMYFLM 5w6oUHiLmI4UQAX4DUFUg8AgYkvvDU/1uv692V5UfVs11kRpWlOs1/ALWuTcLqXSTklm Q62oLZxwELliJ3aQtqwRXjnx9qC3yRvioMri2DgqHX9uiaLtZhbfXtaMPDv8bgYiTJJc uK0dPOCPze9WdXdYxELbwr8ryck1SSGQy6nPKoB0LNigk6FRU548Fez4oxmWElwddQgx kJoY1OqIh4atVj2Jvmw+Bh6yKBm/4zuRKV9So8GtFlxAvf+i+5jW4hVkdcY5nNcbb/Mm tIzA== X-Gm-Message-State: APjAAAVsL21oEwTeBHJqhGK7MKo3bOPCCEqLGDp/nlHq2Ot1nY9oB/rF QFQV3IsO8gLjKA4gmhtyUNAJ0ZHB X-Google-Smtp-Source: APXvYqz5YXvvAhifupJE8LR96J/f/1waTbplqx6iaZBZNeNDNelYnaqS79+7ZeEZlo2Pxjjdtj1o6Q== X-Received: by 2002:adf:f544:: with SMTP id j4mr3421411wrp.150.1559581858567; Mon, 03 Jun 2019 10:10:58 -0700 (PDT) Received: from 640k.lan ([93.56.166.5]) by smtp.gmail.com with ESMTPSA id r131sm3325045wmf.4.2019.06.03.10.10.56 for (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 03 Jun 2019 10:10:57 -0700 (PDT) From: Paolo Bonzini To: qemu-devel@nongnu.org Date: Mon, 3 Jun 2019 19:10:31 +0200 Message-Id: <1559581843-3968-13-git-send-email-pbonzini@redhat.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1559581843-3968-1-git-send-email-pbonzini@redhat.com> References: <1559581843-3968-1-git-send-email-pbonzini@redhat.com> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2a00:1450:4864:20::444 Subject: [Qemu-devel] [PULL 12/24] libqos: fix omap-i2c receiving more than 4 bytes X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+incoming=patchwork.ozlabs.org@nongnu.org Sender: "Qemu-devel" If more than 4 bytes are received, the FIFO cannot host the entire contents of the transfer and STP will be nonzero before entering the transfer loop. Also, CNT will contain the number of bytes left to be transferred instead of the total number of bytes in the transfer. (Reverse engineered from the omap_i2c.c source code; no available datasheet). This will fix ds1338-test for omap-i2c. Signed-off-by: Paolo Bonzini --- tests/libqos/i2c-omap.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/tests/libqos/i2c-omap.c b/tests/libqos/i2c-omap.c index 1ef6e7b..bb65336 100644 --- a/tests/libqos/i2c-omap.c +++ b/tests/libqos/i2c-omap.c @@ -105,6 +105,7 @@ static void omap_i2c_recv(I2CAdapter *i2c, uint8_t addr, { OMAPI2C *s = (OMAPI2C *)i2c; uint16_t data, stat; + uint16_t orig_len = len; omap_i2c_set_slave_addr(s, addr); @@ -116,16 +117,24 @@ static void omap_i2c_recv(I2CAdapter *i2c, uint8_t addr, OMAP_I2C_CON_STT | OMAP_I2C_CON_STP; qtest_writew(i2c->qts, s->addr + OMAP_I2C_CON, data); - data = qtest_readw(i2c->qts, s->addr + OMAP_I2C_CON); - g_assert((data & OMAP_I2C_CON_STP) == 0); data = qtest_readw(i2c->qts, s->addr + OMAP_I2C_STAT); g_assert((data & OMAP_I2C_STAT_NACK) == 0); - data = qtest_readw(i2c->qts, s->addr + OMAP_I2C_CNT); - g_assert_cmpuint(data, ==, len); - while (len > 0) { + data = qtest_readw(i2c->qts, s->addr + OMAP_I2C_CON); + if (len <= 4) { + g_assert((data & OMAP_I2C_CON_STP) == 0); + + data = qtest_readw(i2c->qts, s->addr + OMAP_I2C_CNT); + g_assert_cmpuint(data, ==, orig_len); + } else { + g_assert((data & OMAP_I2C_CON_STP) != 0); + + data = qtest_readw(i2c->qts, s->addr + OMAP_I2C_CNT); + g_assert_cmpuint(data, ==, len - 4); + } + data = qtest_readw(i2c->qts, s->addr + OMAP_I2C_STAT); g_assert((data & OMAP_I2C_STAT_RRDY) != 0); g_assert((data & OMAP_I2C_STAT_ROVR) == 0);