From patchwork Wed Aug 30 12:36:06 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Oliver O'Halloran X-Patchwork-Id: 807621 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [103.22.144.68]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3xj4kV0Trdz9s7F for ; Wed, 30 Aug 2017 22:36:34 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vSR0MPk0"; dkim-atps=neutral Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 3xj4kT6GtZzDqXk for ; Wed, 30 Aug 2017 22:36:33 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vSR0MPk0"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Received: from mail-pf0-x244.google.com (mail-pf0-x244.google.com [IPv6:2607:f8b0:400e:c00::244]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 3xj4kH3bMdzDqMc for ; Wed, 30 Aug 2017 22:36:23 +1000 (AEST) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="vSR0MPk0"; dkim-atps=neutral Received: by mail-pf0-x244.google.com with SMTP id p69so4236469pfk.1 for ; Wed, 30 Aug 2017 05:36:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=Ye5hFwvUn090RKTH1AqsMrxt6+qg9lKBvqpsDvLUkDE=; b=vSR0MPk0Hhusfnh4WOBjcTxqICnuFJxFyyI/T6RAeyYoLsBcu7DzpHMvsfi3pO+Mer YHkBfcxzgDzCivSFTsnNqHLQoWmStcIggz0c8TsFhQFdyFhNozTPqbRC7GTQyjYX7gyP 7Yzh6dHdNTDr/1NZoO+s67pjHG0aSxALVAmW493nTxVBnF24pb9mv+MvU0/AoZDYf8X/ H9vWzTsBR5nnCXzz0w0H3AIfuZdMyMQyYj9gN9/mPYj1qCYWkq1OGgWr/WHdtR4lQNVP QdoCSEnj7KsxCpG0phKas1SdldowWqkDN7VQryz886qu2XnZeygFzpv2Zgmcp7i98SOU KBlA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=Ye5hFwvUn090RKTH1AqsMrxt6+qg9lKBvqpsDvLUkDE=; b=nJSJ7r1MWkHRykinuefIvh+lPufT3NRwChR7ferroptu0brIfdUo7yqBzq20xY8QI1 PU/kD9MfvmrQRTd/DVYpFnrXE/MfXFUORORgqVzfTJlyjG9E+Y/xmmDeoRxKwmMmhu3c 9OOACoimkazAKeXaXM3veegTSNXRuL0lW+Ccfqkpv86V0jd9nhW+yvC7zk6z06ULHRxr HNPXIo6o1ai2NPPvlOsPJ65DwT2er1aOIpIKE2C+RnyNN0XjztwToUS/G+wE6PH6mgBB n1TUWZjcW5aL2ddL89e7NTP87qnErub8qI9v++oCMEt/WF66cLhaFp1mtf6Emv1b4PEz TwDA== X-Gm-Message-State: AHYfb5hqyjURgShPRn44lEV2/9BPe8ZnnpVa/TcMdr0px8x7TdgyNfUu CaKcrKG9ARSz/S7O X-Received: by 10.84.160.226 with SMTP id v31mr1784293plg.35.1504096581486; Wed, 30 Aug 2017 05:36:21 -0700 (PDT) Received: from flat-canetoad.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id t125sm9529192pgc.49.2017.08.30.05.36.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 30 Aug 2017 05:36:20 -0700 (PDT) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Wed, 30 Aug 2017 22:36:06 +1000 Message-Id: <20170830123606.8490-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [Skiboot] [PATCH] p8-i2c: Fix random data corruption X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.23 Precedence: list List-Id: Mailing list for skiboot development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: skiboot-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot" While waiting for the OCC to signal that it has finished using the I2C master we put the master into the, poorly named, occache_dis state. While in this state the transaction hasn't been started, but p8_i2c_check_status() will only skip it's checks when the master is in the idle state. Any action that checks that cranks the I2C state machine (interrupt, poll, etc) will call p8_i2c_check_status() and since the master is not idle, it will check the status register, see the transaction complete flag set and complete the i2c request without actually doing anything. If the transaction was a I2C read, the resulting output will be a zeroed data buffer. Signed-off-by: Oliver O'Halloran --- hw/p8-i2c.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index a6274171debb..9cc016fe98a5 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -892,7 +892,7 @@ static void p8_i2c_check_status(struct p8_i2c_master *master) /* If we are idle, just return, we'll catch error conditions * when we next try to enqueue a request */ - if (master->state == state_idle) + if (master->state == state_idle || master->state == state_occache_dis) return; /* Read status register */