From patchwork Fri Nov 17 06:04:11 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: 838859 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) (using TLSv1.2 with cipher ADH-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 3ydSHr2lXFz9s4q for ; Fri, 17 Nov 2017 17:04:40 +1100 (AEDT) Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SCncVoAH"; 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 3ydSHr0dvDzDrKD for ; Fri, 17 Nov 2017 17:04:40 +1100 (AEDT) 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="SCncVoAH"; dkim-atps=neutral X-Original-To: skiboot@lists.ozlabs.org Delivered-To: skiboot@lists.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:400e:c00::243; helo=mail-pf0-x243.google.com; envelope-from=oohall@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="SCncVoAH"; dkim-atps=neutral Received: from mail-pf0-x243.google.com (mail-pf0-x243.google.com [IPv6:2607:f8b0:400e:c00::243]) (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 3ydSHh1hcVzDrK3 for ; Fri, 17 Nov 2017 17:04:31 +1100 (AEDT) Received: by mail-pf0-x243.google.com with SMTP id m88so1188269pfi.9 for ; Thu, 16 Nov 2017 22:04:31 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id; bh=5nvAQ+NkCpvEMsmIvlDZY6fQ2+uDy7Ll/YPaXVqR1LQ=; b=SCncVoAHOGyIcJJZsm95/QoiXpWg7waXWoi8K5nLfZXoo5HVZDvIQXldrCNJv+JX0c 7rf8JhtlYYqIO4/+q8ZMnCocxNrUGEZ9p2MJoIqAdmE5s7vfRzI5zegb5eB0+woh5TvJ DtsIHovtJeSwq1EpLxgf9SCFRKVgXa7vWhsQ8ia+m2dakaXznu6UWj91aXq7Jt7tMQBj C/BZrqTdrbryF8Hip1445JLvN67tS7SBpypD/91xjHxr/1exyXXH/j9yFJB9qIfyoD8o YKSdMmeE3KO6nLuOQeD6MGjmZqeGOW27m27NhRAWEebe4RLzwFNldp9TXPsNq2EsaMLB b76g== 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=5nvAQ+NkCpvEMsmIvlDZY6fQ2+uDy7Ll/YPaXVqR1LQ=; b=Hi+SV6InzuMX/42SRWTu8zlTwHaWNvBKDW8c/kxfh+g78XkpxXg310Z9VEVg90095b gT++yKP75bPR1vaOA2fhMQ5dD3L4rLVFl/QER+7Wkanc4Pl4nY0R0En4QAdrphu1hwyN CJIPsSOo7wpLRipMXpSDPbVfoZRyr6UBEclh3Posr4w6sgyI+WeGkBpzvLASt6K4IRA0 CkV5/ae6RIQ1v+O9FmU+z22AoDhDpRmicmphiT2PCGanJkQCkSlvfI+ECH4nkcD6jEiF nyBr4nisifvVJ2y9dOA+4L4DtUEyTEuRjR61dMzMpYkMlsVtURkOkSBZutQg9n4IWYPY wgmg== X-Gm-Message-State: AJaThX7VnkywwJpIzc9p/vFKguQZ10aO0TEuwnerTQgJHJFWhT6r/oQb iYNN6S2T2Ok5OnBmp1tnNTR9nump X-Google-Smtp-Source: AGs4zMbd+hhRX8KbHhe8o8tPA1J1qaFNTtLiM1GpbygDTwEykGe/phmCPqS+6KqzcP2QPjazQPSjYQ== X-Received: by 10.99.126.11 with SMTP id z11mr4087019pgc.281.1510898669289; Thu, 16 Nov 2017 22:04:29 -0800 (PST) Received: from flat-canetoad.au.ibm.com ([120.18.64.145]) by smtp.gmail.com with ESMTPSA id j14sm1166228pfj.93.2017.11.16.22.04.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 16 Nov 2017 22:04:28 -0800 (PST) From: Oliver O'Halloran To: skiboot@lists.ozlabs.org Date: Fri, 17 Nov 2017 17:04:11 +1100 Message-Id: <20171117060411.18124-1-oohall@gmail.com> X-Mailer: git-send-email 2.9.5 Subject: [Skiboot] [PATCH] p8-i2c: Limit number of retry attempts X-BeenThere: skiboot@lists.ozlabs.org X-Mailman-Version: 2.1.24 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" Current we will attempt to start an I2C transaction until it succeeds. In the event that the OCC does not release the lock on an I2C bus this results in an async token being held forever and the kernel thread that started the transaction will block forever while waiting for an async completion message. Fix this by limiting the number of attempts to start the transaction. Signed-off-by: Oliver O'Halloran --- hw/p8-i2c.c | 12 ++++++++++-- include/i2c.h | 1 + 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/hw/p8-i2c.c b/hw/p8-i2c.c index ec2f7fc0b47c..d029854d5c54 100644 --- a/hw/p8-i2c.c +++ b/hw/p8-i2c.c @@ -1303,8 +1303,16 @@ static void p8_i2c_check_work(struct p8_i2c_master *master) while (master->state == state_idle && !list_empty(&master->req_list)) { req = list_top(&master->req_list, struct i2c_request, link); rc = p8_i2c_start_request(master, req); - if (rc && rc != OPAL_BUSY) - p8_i2c_complete_request(master, req, rc); + if (rc) { + /* + * If it didn't work the first three times then + * odds are it's not going to work on the 4th. + */ + if (rc && req->retries > 3) + p8_i2c_complete_request(master, req, rc); + else + req->retries++; + } } } diff --git a/include/i2c.h b/include/i2c.h index 669c30a2fcfb..28c762891b70 100644 --- a/include/i2c.h +++ b/include/i2c.h @@ -64,6 +64,7 @@ struct i2c_request { void (*completion)( /* Completion callback */ int rc, struct i2c_request *req); void *user_data; /* Client data */ + int retries; }; /* Generic i2c */