From patchwork Thu Aug 8 05:37:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jordan Niethe X-Patchwork-Id: 1143840 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from lists.ozlabs.org (lists.ozlabs.org [203.11.71.2]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 463yjV0HS2z9sN4 for ; Thu, 8 Aug 2019 16:13:18 +1000 (AEST) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=gmail.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="IHdQMLMu"; dkim-atps=neutral Received: from bilbo.ozlabs.org (lists.ozlabs.org [IPv6:2401:3900:2:1::3]) by lists.ozlabs.org (Postfix) with ESMTP id 463yjT58zVzDqW6 for ; Thu, 8 Aug 2019 16:13:17 +1000 (AEST) X-Original-To: skiboot-stable@lists.ozlabs.org Delivered-To: skiboot-stable@lists.ozlabs.org Authentication-Results: lists.ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=gmail.com (client-ip=2607:f8b0:4864:20::442; helo=mail-pf1-x442.google.com; envelope-from=jniethe5@gmail.com; receiver=) Authentication-Results: lists.ozlabs.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: lists.ozlabs.org; dkim=pass (2048-bit key; unprotected) header.d=gmail.com header.i=@gmail.com header.b="IHdQMLMu"; dkim-atps=neutral Received: from mail-pf1-x442.google.com (mail-pf1-x442.google.com [IPv6:2607:f8b0:4864:20::442]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by lists.ozlabs.org (Postfix) with ESMTPS id 463xwd4v1KzDqLW; Thu, 8 Aug 2019 15:37:53 +1000 (AEST) Received: by mail-pf1-x442.google.com with SMTP id m30so43440970pff.8; Wed, 07 Aug 2019 22:37:53 -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:mime-version :content-transfer-encoding; bh=+Y09F2lrqlk/RADHa9AYlo87O5hhMYDvoea3XuCzyIg=; b=IHdQMLMukpEvpo5TOohJmkbQZvERpkWvQibCzkVKOGZvHXreNmuTs6hDJP3q9i7qBK WSdigkbuffCqGYRWVEwSE33WHLcQIulr6N7cXPj4TKqcqzmiUZcy5mnpKz5mJ2EAuOKf QDNdAT3dzsFm4dBcISPUL8jP6wgMWbUCFt3Q1q/nmAxipqzps8m9dyKhNUjTc+w1moNb AkrPBp0zV4o+JLaoPftp0ZP+JijOXBCbu6569l8U3XnX1GVq9QPGxmQ9y7/i+g8UeWkb aQDJyAyQd2rJmgUQyQTc0OP6RH2L6pMyFLr/HQCPf/LVcl0YBS1dKMm2m4wqc08uUx+o ZPcA== 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:mime-version :content-transfer-encoding; bh=+Y09F2lrqlk/RADHa9AYlo87O5hhMYDvoea3XuCzyIg=; b=RhleN27rPPVjzc8t5Wy1ipUT/szEOA6+kWhbK284n1YJvYz+riaOVWlzw4Ei5hKMda SHeuNem2SDkNsbumzKruv/rTFTOyryOqF36TIg3TTod+IhlYaXznLZ/fBCzqe0j3Qors BsIEL/AE9Efhr76+QDcjLy3a4UIBLA0kRcrNyCw2cgXZwcYSH9wIumfc8Fu8pvdXNJDx Usp2PgZ6E93YqHhlHEL76XhHcgoSDJDWvTKeQJKIYczZpkZ7/7KvPOTuMWmaR5r44WKf QO3wkR8qC4BxxFqB4eTftAMzXvZoUHy3aJb+ZYekPaBW39l9jjvefaFTLekyV/t6C8yG mPzA== X-Gm-Message-State: APjAAAXJzHTsbRgNCi9Wu5lACh+ebdezC5nht+W2bpfeQvd5lO4I07Sd b9jOXVDeklardxuKA/MAM6Zr/IZ3olg= X-Google-Smtp-Source: APXvYqxmaA9pa2LlNoU6oH9mBDHASnmzbbAfdHyM5av5C3TypNe37MQoAomCBSaJqC9hTtH5niT9LQ== X-Received: by 2002:a17:90a:cb97:: with SMTP id a23mr2128466pju.67.1565242671308; Wed, 07 Aug 2019 22:37:51 -0700 (PDT) Received: from pasglop.ozlabs.ibm.com ([122.99.82.10]) by smtp.gmail.com with ESMTPSA id a1sm64234424pgh.61.2019.08.07.22.37.49 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Wed, 07 Aug 2019 22:37:50 -0700 (PDT) From: Jordan Niethe To: skiboot@lists.ozlabs.org, skiboot-stable@lists.ozlabs.org Date: Thu, 8 Aug 2019 15:37:32 +1000 Message-Id: <20190808053732.8413-1-jniethe5@gmail.com> X-Mailer: git-send-email 2.20.1 MIME-Version: 1.0 X-Mailman-Approved-At: Thu, 08 Aug 2019 16:13:15 +1000 Subject: [Skiboot-stable] [PATCH v2] hw/phb4: Use standard MIN/MAX macro definitions X-BeenThere: skiboot-stable@lists.ozlabs.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "Patches, review, and discussion for stable releases of skiboot" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Jordan Niethe Errors-To: skiboot-stable-bounces+incoming=patchwork.ozlabs.org@lists.ozlabs.org Sender: "Skiboot-stable" The max() macro definition incorrectly returns the minimum value. The max() macro is used to ensure that PERST has been asserted for 250ms and that we wait 100ms seconds for the ETU logic in the CRESET_START PHB4 PCI slot state. However, by returning the minimum value there is no guarantee that either of these requirements are met. Correct macro definitions for MIN and MAX are already provided in skiboot.h. Remove the redundant/incorrect versions here and switch to using the standard ones. Fixes: 70edcbb4b39d ("hw/phb4: Skip FRESET PERST when coming from CRESET") Signed-off-by: Jordan Niethe --- v2: Add Fixes tag and improve commit message hw/phb4.c | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/hw/phb4.c b/hw/phb4.c index 39d0151c9aa1..a8fbf817ad2c 100644 --- a/hw/phb4.c +++ b/hw/phb4.c @@ -2574,9 +2574,6 @@ static void phb4_lane_eq_change(struct phb4 *p, uint32_t vdid) p->lane_eq_en = !phb4_lane_eq_retry_whitelist(vdid); } -#define min(x,y) ((x) < (y) ? x : y) -#define max(x,y) ((x) < (y) ? x : y) - static bool phb4_link_optimal(struct pci_slot *slot, uint32_t *vdid) { struct phb4 *p = phb_to_phb4(slot->phb); @@ -2603,9 +2600,9 @@ static bool phb4_link_optimal(struct pci_slot *slot, uint32_t *vdid) phb4_get_info(slot->phb, bdfn, &dev_speed, &dev_width); /* Work out if we are optimally trained */ - target_speed = min(phb_speed, dev_speed); + target_speed = MIN(phb_speed, dev_speed); optimal_speed = (trained_speed >= target_speed); - target_width = min(phb_width, dev_width); + target_width = MIN(phb_width, dev_width); optimal_width = (trained_width >= target_width); optimal = optimal_width && optimal_speed; retry_enabled = (phb4_chip_retry_workaround() && @@ -3366,7 +3363,7 @@ static int64_t phb4_creset(struct pci_slot *slot) */ creset_time = tb_to_msecs(mftb() - p->creset_start_time); if (creset_time < 250) - wait_time = max(100, 250 - creset_time); + wait_time = MAX(100, 250 - creset_time); else wait_time = 100; PHBDBG(p, "CRESET: wait_time = %lld\n", wait_time);