From patchwork Thu Aug 23 20:37:02 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 144974 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp539849ljw; Thu, 23 Aug 2018 13:37:16 -0700 (PDT) X-Google-Smtp-Source: ANB0VdZHJ77nsgXv17zMq/3n42u84AzC6MZU02PLpOmHc/MaKCylP8mJI3GM7U9JFTIHUY8boAZF X-Received: by 2002:a63:1e11:: with SMTP id e17-v6mr6728470pge.225.1535056636554; Thu, 23 Aug 2018 13:37:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535056636; cv=none; d=google.com; s=arc-20160816; b=y8HD6xoFgJZzrmAVXcKp3ZZ6rTkRdhxIaqEDgtVvBvu4+uyObGk6s28jf9luCZZVP2 zge17BwrtjoLE4zsD1iC8vFBG0gwA8fxfifQz+4AY5MsoqrRUJGgEhnaLpvvIt5wUp5w Hrwf4r0FqmL6c3BDjcWC66prriPSbPScoTtMe66dN6K7bxPLG7Rck2yia9R8gO0ZPFP8 a5dtbo9yK2tZnhtG6SUwWQvQCBd/oNnzl04oWkfARIyVYWPxsjoL3wnt5x4YGkRjbc59 rniF6w7oohiSaosMfKOPnLhhGoHSIwjiOkc5Hib0HBid1yoU5wcGNna4xhhpRcUeNec6 Hzhg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=B31Nrm4kl7TE48y9/D7bjQbbnioCA5XX0o+dTj6vI2s=; b=NUzWHtfbS+oG/ccHKkjgByBx74frt3xyh8N+jSlOzZhbX33MedIAkicLg7nVgFEcT+ kGiATlHFg24b7pNa26kOeWe71TpVjo3rT5dQxbPiigNGI52IigR82I/HQBHx8GqqP2rj 7wUDhwkCBMskvgieafRH0biCGZXVZmX0Nu3P3DW03x1YKWjqCpGbJUZR8skfLVeLAEPm ydV2vbix0ZyDf2SVhvD9j7mr8jEZtmcHrHrsQ5zQJbuKGEKvQf/S4kVXMCZ67S2YxJ69 rwzyiJXuOUIwFkdegFjB/5+ogcP5GMtvdIaALadBzJgqSIgMQrKzSa3uybCmmrZJaako 3evg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=BaM1Solc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x66-v6si5749822pfx.129.2018.08.23.13.37.16; Thu, 23 Aug 2018 13:37:16 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=BaM1Solc; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727419AbeHXAIg (ORCPT + 32 others); Thu, 23 Aug 2018 20:08:36 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:45755 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbeHXAIf (ORCPT ); Thu, 23 Aug 2018 20:08:35 -0400 Received: by mail-oi0-f65.google.com with SMTP id t68-v6so407127oie.12 for ; Thu, 23 Aug 2018 13:37:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=B31Nrm4kl7TE48y9/D7bjQbbnioCA5XX0o+dTj6vI2s=; b=BaM1Solc/CLF50tOYx+QrZu4jhCsVRFQHJfSOdHeUoPtUaOcTDXCYmwhtPMnqQOylH q5C0i+1n0zcuKcWXg4vomGNrzHzmtqmPb9m4qFGPoBq1ZalmQtO9jFEfap4VGYf+kXD5 7YoMkWDm3Vthm1dqgvakw2qpEST9Od/EbblQGRRm/S1L5Wsb9a/a03e91h4Z3KXIj7kT 2ChYow8WKhONM+JrD9LKLN8QCZa+0epKU+HPU8iYZN+uxj3Bj7J5SdiKb/QECvNeT1NN vYhsB6ztffXAW/vE0X/BHh9JzMxfiR5YRWCGQGKjCw3+c7xq6jPoE5/Msx4ZiFNGQRjn b+8A== 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:cc:subject:date:message-id :in-reply-to:references; bh=B31Nrm4kl7TE48y9/D7bjQbbnioCA5XX0o+dTj6vI2s=; b=s+kkynj+rly3DyUJrvGy8hsMPi8eR36VOGuPUlJJGHKl2DoxNAyY92mRzf/4/NEaRY tHV8ccmQOc90J6snBLiYJHUjhJ/YZK2Y0WZDuRUQvGg474nM6z5JMfSHIV7CkaaxSRuh y2wWGwiEhTRfmZBuQG5cW644ORdujbG3t6UI/FL3UhQwxhfWvYEUbRBg/kEISQhxGzeS TS4DRr1ckn9WN3x+hoZ6/Bo6noH/aVHQXLP4suRJKOlXHw6IYWIxz8tVKIKXLeZR5R3Z ogk9iaK4f7RTM0YdD+/1FjDo0xQwH2FZH0vdz91vzK6IqGYRDZgAI8Fq9jbucnzsH8+A 9UiQ== X-Gm-Message-State: APzg51DDzvX2YOsWYzXj9xPHKpNg+tsjm/UiqFynoxU7OHMAEw2dDIX5 N0g158pfova3NI//o8nZGA== X-Received: by 2002:aca:e504:: with SMTP id c4-v6mr9407910oih.246.1535056632904; Thu, 23 Aug 2018 13:37:12 -0700 (PDT) Received: from serve.minyard.net ([47.184.170.128]) by smtp.gmail.com with ESMTPSA id m11-v6sm3076562oif.27.2018.08.23.13.37.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 13:37:12 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 2EF25B9A; Thu, 23 Aug 2018 15:37:11 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id E81023000CF; Thu, 23 Aug 2018 15:37:09 -0500 (CDT) From: minyard@acm.org To: Andrew Banman Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, rja@hpe.com, frank.ramsay@hpe.com, justin.ernst@hpe.com, Corey Minyard Subject: [PATCH 1/2] ipmi: Move BT capabilities detection to the detect call Date: Thu, 23 Aug 2018 15:37:02 -0500 Message-Id: <1535056623-26634-2-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535056623-26634-1-git-send-email-minyard@acm.org> References: <1535056623-26634-1-git-send-email-minyard@acm.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corey Minyard The capabilities detection was being done as part of the normal state machine, but it was possible for it to be running while the upper layers of the IPMI driver were initializing the device, resulting in error and failure to initialize. Move the capabilities detection to the the detect function, so it's done before anything else runs on the device. This also simplifies the state machine and removes some code, as a bonus. Signed-off-by: Corey Minyard Reported-by: Andrew Banman --- drivers/char/ipmi/ipmi_bt_sm.c | 92 ++++++++++++++++++++++-------------------- 1 file changed, 48 insertions(+), 44 deletions(-) -- 2.7.4 Tested-by: Andrew Banman diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c index cbc6126..b4133832e 100644 --- a/drivers/char/ipmi/ipmi_bt_sm.c +++ b/drivers/char/ipmi/ipmi_bt_sm.c @@ -59,8 +59,6 @@ enum bt_states { BT_STATE_RESET3, BT_STATE_RESTART, BT_STATE_PRINTME, - BT_STATE_CAPABILITIES_BEGIN, - BT_STATE_CAPABILITIES_END, BT_STATE_LONG_BUSY /* BT doesn't get hosed :-) */ }; @@ -86,7 +84,6 @@ struct si_sm_data { int error_retries; /* end of "common" fields */ int nonzero_status; /* hung BMCs stay all 0 */ enum bt_states complete; /* to divert the state machine */ - int BT_CAP_outreqs; long BT_CAP_req2rsp; int BT_CAP_retries; /* Recommended retries */ }; @@ -137,8 +134,6 @@ static char *state2txt(unsigned char state) case BT_STATE_RESET3: return("RESET3"); case BT_STATE_RESTART: return("RESTART"); case BT_STATE_LONG_BUSY: return("LONG_BUSY"); - case BT_STATE_CAPABILITIES_BEGIN: return("CAP_BEGIN"); - case BT_STATE_CAPABILITIES_END: return("CAP_END"); } return("BAD STATE"); } @@ -185,7 +180,6 @@ static unsigned int bt_init_data(struct si_sm_data *bt, struct si_sm_io *io) bt->complete = BT_STATE_IDLE; /* end here */ bt->BT_CAP_req2rsp = BT_NORMAL_TIMEOUT * USEC_PER_SEC; bt->BT_CAP_retries = BT_NORMAL_RETRY_LIMIT; - /* BT_CAP_outreqs == zero is a flag to read BT Capabilities */ return 3; /* We claim 3 bytes of space; ought to check SPMI table */ } @@ -447,7 +441,7 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt, static enum si_sm_result bt_event(struct si_sm_data *bt, long time) { - unsigned char status, BT_CAP[8]; + unsigned char status; static enum bt_states last_printed = BT_STATE_PRINTME; int i; @@ -500,12 +494,6 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) if (status & BT_H_BUSY) /* clear a leftover H_BUSY */ BT_CONTROL(BT_H_BUSY); - bt->timeout = bt->BT_CAP_req2rsp; - - /* Read BT capabilities if it hasn't been done yet */ - if (!bt->BT_CAP_outreqs) - BT_STATE_CHANGE(BT_STATE_CAPABILITIES_BEGIN, - SI_SM_CALL_WITHOUT_DELAY); BT_SI_SM_RETURN(SI_SM_IDLE); case BT_STATE_XACTION_START: @@ -610,37 +598,6 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) BT_STATE_CHANGE(BT_STATE_XACTION_START, SI_SM_CALL_WITH_DELAY); - /* - * Get BT Capabilities, using timing of upper level state machine. - * Set outreqs to prevent infinite loop on timeout. - */ - case BT_STATE_CAPABILITIES_BEGIN: - bt->BT_CAP_outreqs = 1; - { - unsigned char GetBT_CAP[] = { 0x18, 0x36 }; - bt->state = BT_STATE_IDLE; - bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP)); - } - bt->complete = BT_STATE_CAPABILITIES_END; - BT_STATE_CHANGE(BT_STATE_XACTION_START, - SI_SM_CALL_WITH_DELAY); - - case BT_STATE_CAPABILITIES_END: - i = bt_get_result(bt, BT_CAP, sizeof(BT_CAP)); - bt_init_data(bt, bt->io); - if ((i == 8) && !BT_CAP[2]) { - bt->BT_CAP_outreqs = BT_CAP[3]; - bt->BT_CAP_req2rsp = BT_CAP[6] * USEC_PER_SEC; - bt->BT_CAP_retries = BT_CAP[7]; - } else - pr_warn("IPMI BT: using default values\n"); - if (!bt->BT_CAP_outreqs) - bt->BT_CAP_outreqs = 1; - pr_warn("IPMI BT: req2rsp=%ld secs retries=%d\n", - bt->BT_CAP_req2rsp / USEC_PER_SEC, bt->BT_CAP_retries); - bt->timeout = bt->BT_CAP_req2rsp; - return SI_SM_CALL_WITHOUT_DELAY; - default: /* should never occur */ return error_recovery(bt, status, @@ -651,6 +608,11 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) static int bt_detect(struct si_sm_data *bt) { + unsigned char GetBT_CAP[] = { 0x18, 0x36 }; + unsigned char BT_CAP[8]; + enum si_sm_result smi_result; + int rv; + /* * It's impossible for the BT status and interrupt registers to be * all 1's, (assuming a properly functioning, self-initialized BMC) @@ -661,6 +623,48 @@ static int bt_detect(struct si_sm_data *bt) if ((BT_STATUS == 0xFF) && (BT_INTMASK_R == 0xFF)) return 1; reset_flags(bt); + + /* + * Try getting the BT capabilities here. + */ + rv = bt_start_transaction(bt, GetBT_CAP, sizeof(GetBT_CAP)); + if (rv) { + dev_warn(bt->io->dev, + "Can't start capabilities transaction: %d\n", rv); + goto out_no_bt_cap; + } + + smi_result = SI_SM_CALL_WITHOUT_DELAY; + for (;;) { + if (smi_result == SI_SM_CALL_WITH_DELAY || + smi_result == SI_SM_CALL_WITH_TICK_DELAY) { + schedule_timeout_uninterruptible(1); + smi_result = bt_event(bt, jiffies_to_usecs(1)); + } else if (smi_result == SI_SM_CALL_WITHOUT_DELAY) { + smi_result = bt_event(bt, 0); + } else + break; + } + + rv = bt_get_result(bt, BT_CAP, sizeof(BT_CAP)); + bt_init_data(bt, bt->io); + if (rv < 8) { + dev_warn(bt->io->dev, "bt cap response too short: %d\n", rv); + goto out_no_bt_cap; + } + + if (BT_CAP[2]) { + dev_warn(bt->io->dev, "Error fetching bt cap: %x\n", BT_CAP[2]); +out_no_bt_cap: + dev_warn(bt->io->dev, "using default values\n"); + } else { + bt->BT_CAP_req2rsp = BT_CAP[6] * USEC_PER_SEC; + bt->BT_CAP_retries = BT_CAP[7]; + } + + dev_info(bt->io->dev, "req2rsp=%ld secs retries=%d\n", + bt->BT_CAP_req2rsp / USEC_PER_SEC, bt->BT_CAP_retries); + return 0; } From patchwork Thu Aug 23 20:37:03 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 144975 Delivered-To: patch@linaro.org Received: by 2002:a2e:1648:0:0:0:0:0 with SMTP id 8-v6csp540350ljw; Thu, 23 Aug 2018 13:37:51 -0700 (PDT) X-Google-Smtp-Source: ANB0Vda39GUv20n9j793SK25wBguvNvAiVYHkTK+7oKC3t0q8oD4Upf5a2AMFXxCiGLRR/N4PkUZ X-Received: by 2002:a17:902:e183:: with SMTP id cd3-v6mr6278381plb.305.1535056671646; Thu, 23 Aug 2018 13:37:51 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1535056671; cv=none; d=google.com; s=arc-20160816; b=Y2Es7vTYRjIrfEcFJ9giZ1MT/ttWw+weH82FKmLNnlrQQIYRsxraRIsm7+j8blKwS+ xLQwk4JjQsN/zFKhTphbh/TDXnYmEPr4B5Ut5Umf9nqbn+sitZLNK+DaGYJkFii+ppvi MyGSrnDXELIdlAZUOMmlJpAz/zrNyWsnFvlYF6+CAfOAVwPUEigSB1F5eVDfLlJlsyW6 Xfbrzs01etx0WKMKUowC0NlnvTxMUHyRk73yfrq6p1GCAY7B7iePu8yy78J5rAzKqETZ SujzuDD5keVYr18SREx/FBxN6t47Hvvfudj/tdJLFczmN/NcWfwk6a/MfY/3q9MWJBUd Mo6Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature:arc-authentication-results; bh=L0zlVb16/YCru7lcj24JRdh47dmzHr+1MUoUck31wRQ=; b=i+TcKeYh46qjciEgjzyp6cC+h5UK3aCewR9YlP/I+aZgzQpQK+tDXh53xL3C8hCDIm 3WtmGZ7IwEkUy9DtDqqcOndWif0BiTM7F4gGQGynSXYwFPT86wtr+lo2JRNC98THLImr BfDrM17MWekpTyrSdWH6bA9Y6L+lIIlchcVd4sKbWpKBQUg70TthFrKTnNY8+g2BeQPw qUFjWchJon3YNcKreA1W7yVz9QUiOqEyLkAYCauGlCB2igD1knslIsQ/73U/ZL8FsNJu jVNRezlRaAV6Y/8Dk+nweCQO97vq0d6AQ9/EAt/snpkwOK7GaXORZd+fiiv6tNzkH8XW 9W0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XAHRhUFa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id x32-v6si5008590pld.356.2018.08.23.13.37.51; Thu, 23 Aug 2018 13:37:51 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=XAHRhUFa; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727462AbeHXAJF (ORCPT + 32 others); Thu, 23 Aug 2018 20:09:05 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:33563 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726083AbeHXAJF (ORCPT ); Thu, 23 Aug 2018 20:09:05 -0400 Received: by mail-oi0-f67.google.com with SMTP id 8-v6so11673735oip.0 for ; Thu, 23 Aug 2018 13:37:43 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=L0zlVb16/YCru7lcj24JRdh47dmzHr+1MUoUck31wRQ=; b=XAHRhUFaYFUuKKaVq6s4b4A5OGD2kgL3kMi7p4BLpsiwIVxOHLgfJznLb9E+8cEuka +x25scK26j9+iGAFRMkRczXwPRQQvpV3+2jxwUfkQuhgeGGFabwPY06pdSFfzzMjFLxc amYbHuKZ4QT2c1fEOCWZNg53XIB6324Kb24a7ReZaR3iUSmDBUQ6/3vSNxGizOVfw0hh M6PK76UP+t0WW+SCiF7mI1N58+WCtx2dUDm/YWTOFZxjZ5aAVi56qtg2yFWry8aSrhHM bihNnKwJSG0X7mBGg7rsz0BMPcBFteHZPE+qJLhUF5Vcu7fQCLgtJj6QTkYBBdfu3u0R xFYw== 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:cc:subject:date:message-id :in-reply-to:references; bh=L0zlVb16/YCru7lcj24JRdh47dmzHr+1MUoUck31wRQ=; b=iwLkJrlHro2haLVk3VImnXlB2IzmsyLKLSe1ZEXNZfCVyCt+iObnuiXK+THhqfCzlB WRoJtnx+CfzQpShMKEM8HlwGFOGzLbMOmaKn1SNA8u2y6MRPVDqTx41avIyHri82IX6l kWzNHFgWCHaQblXsBPZ6T2fts9q+Uq4BN/ZvzKVZI7jJWZFEvUgW1SV5cSXkDlXaLAo7 Jeev/4F2CuoZRvuohokQLqwzHQMb67I5tpS8NHdXYU6hdx01FRC+C8G/sdRrfNKU1Oie sWuLVfkGEKFsvgRV8Fe+Jk4i146IjzDtzZ/0zTfa5gCpvcnz1sTFPkWpV2Y/0rAa0qAF 0AMw== X-Gm-Message-State: APzg51BLRSoz6J5OGM+lPr+d+G/qVsDHbGvWkagx2u/vb7kfW3AXGDmQ QXAuC+kKt4dQ5f+xMw6/qA== X-Received: by 2002:aca:338a:: with SMTP id z132-v6mr10694859oiz.184.1535056662940; Thu, 23 Aug 2018 13:37:42 -0700 (PDT) Received: from serve.minyard.net ([47.184.170.128]) by smtp.gmail.com with ESMTPSA id o9-v6sm1194517oia.21.2018.08.23.13.37.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 23 Aug 2018 13:37:42 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:a11a:38c7:7111:773f]) by serve.minyard.net (Postfix) with ESMTPA id 384291271; Thu, 23 Aug 2018 15:37:11 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id D59F230000A; Thu, 23 Aug 2018 15:37:09 -0500 (CDT) From: minyard@acm.org To: Andrew Banman Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, rja@hpe.com, frank.ramsay@hpe.com, justin.ernst@hpe.com, Corey Minyard Subject: [PATCH 2/2] ipmi: Convert pr_xxx() to dev_xxx() in the BT code Date: Thu, 23 Aug 2018 15:37:03 -0500 Message-Id: <1535056623-26634-3-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1535056623-26634-1-git-send-email-minyard@acm.org> References: <1535056623-26634-1-git-send-email-minyard@acm.org> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corey Minyard Cleanups, do the replacement and change the levels to the proper ones for the function they are serving, as many were wrong. Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_bt_sm.c | 38 ++++++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 16 deletions(-) -- 2.7.4 diff --git a/drivers/char/ipmi/ipmi_bt_sm.c b/drivers/char/ipmi/ipmi_bt_sm.c index b4133832e..f3f216c 100644 --- a/drivers/char/ipmi/ipmi_bt_sm.c +++ b/drivers/char/ipmi/ipmi_bt_sm.c @@ -8,6 +8,8 @@ * Author: Rocky Craig */ +#define DEBUG /* So dev_dbg() is always available. */ + #include /* For printk. */ #include #include @@ -215,8 +217,8 @@ static int bt_start_transaction(struct si_sm_data *bt, return IPMI_NOT_IN_MY_STATE_ERR; if (bt_debug & BT_DEBUG_MSG) { - pr_warn("BT: +++++++++++++++++ New command\n"); - pr_warn("BT: NetFn/LUN CMD [%d data]:", size - 2); + dev_dbg(bt->io->dev, "+++++++++++++++++ New command\n"); + dev_dbg(bt->io->dev, "NetFn/LUN CMD [%d data]:", size - 2); for (i = 0; i < size; i ++) pr_cont(" %02x", data[i]); pr_cont("\n"); @@ -260,7 +262,7 @@ static int bt_get_result(struct si_sm_data *bt, memcpy(data + 2, bt->read_data + 4, msg_len - 2); if (bt_debug & BT_DEBUG_MSG) { - pr_warn("BT: result %d bytes:", msg_len); + dev_dbg(bt->io->dev, "result %d bytes:", msg_len); for (i = 0; i < msg_len; i++) pr_cont(" %02x", data[i]); pr_cont("\n"); @@ -274,7 +276,7 @@ static int bt_get_result(struct si_sm_data *bt, static void reset_flags(struct si_sm_data *bt) { if (bt_debug) - pr_warn("IPMI BT: flag reset %s\n", status2txt(BT_STATUS)); + dev_dbg(bt->io->dev, "flag reset %s\n", status2txt(BT_STATUS)); if (BT_STATUS & BT_H_BUSY) BT_CONTROL(BT_H_BUSY); /* force clear */ BT_CONTROL(BT_CLR_WR_PTR); /* always reset */ @@ -300,7 +302,8 @@ static void drain_BMC2HOST(struct si_sm_data *bt) BT_CONTROL(BT_B2H_ATN); /* some BMCs are stubborn */ BT_CONTROL(BT_CLR_RD_PTR); /* always reset */ if (bt_debug) - pr_warn("IPMI BT: stale response %s; ", status2txt(BT_STATUS)); + dev_dbg(bt->io->dev, "stale response %s; ", + status2txt(BT_STATUS)); size = BMC2HOST; for (i = 0; i < size ; i++) BMC2HOST; @@ -314,7 +317,7 @@ static inline void write_all_bytes(struct si_sm_data *bt) int i; if (bt_debug & BT_DEBUG_MSG) { - pr_warn("BT: write %d bytes seq=0x%02X", + dev_dbg(bt->io->dev, "write %d bytes seq=0x%02X", bt->write_count, bt->seq); for (i = 0; i < bt->write_count; i++) pr_cont(" %02x", bt->write_data[i]); @@ -338,7 +341,8 @@ static inline int read_all_bytes(struct si_sm_data *bt) if (bt->read_count < 4 || bt->read_count >= IPMI_MAX_MSG_LENGTH) { if (bt_debug & BT_DEBUG_MSG) - pr_warn("BT: bad raw rsp len=%d\n", bt->read_count); + dev_dbg(bt->io->dev, + "bad raw rsp len=%d\n", bt->read_count); bt->truncated = 1; return 1; /* let next XACTION START clean it up */ } @@ -349,7 +353,8 @@ static inline int read_all_bytes(struct si_sm_data *bt) if (bt_debug & BT_DEBUG_MSG) { int max = bt->read_count; - pr_warn("BT: got %d bytes seq=0x%02X", max, bt->read_data[2]); + dev_dbg(bt->io->dev, + "got %d bytes seq=0x%02X", max, bt->read_data[2]); if (max > 16) max = 16; for (i = 0; i < max; i++) @@ -364,7 +369,8 @@ static inline int read_all_bytes(struct si_sm_data *bt) return 1; if (bt_debug & BT_DEBUG_MSG) - pr_warn("IPMI BT: bad packet: want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n", + dev_dbg(bt->io->dev, + "IPMI BT: bad packet: want 0x(%02X, %02X, %02X) got (%02X, %02X, %02X)\n", bt->write_data[1] | 0x04, bt->write_data[2], bt->write_data[3], bt->read_data[1], bt->read_data[2], bt->read_data[3]); @@ -390,8 +396,8 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt, break; } - pr_warn("IPMI BT: %s in %s %s ", /* open-ended line */ - reason, STATE2TXT, STATUS2TXT); + dev_warn(bt->io->dev, "IPMI BT: %s in %s %s ", /* open-ended line */ + reason, STATE2TXT, STATUS2TXT); /* * Per the IPMI spec, retries are based on the sequence number @@ -405,14 +411,14 @@ static enum si_sm_result error_recovery(struct si_sm_data *bt, return SI_SM_CALL_WITHOUT_DELAY; } - pr_warn("failed %d retries, sending error response\n", - bt->BT_CAP_retries); + dev_warn(bt->io->dev, "failed %d retries, sending error response\n", + bt->BT_CAP_retries); if (!bt->nonzero_status) - pr_err("IPMI BT: stuck, try power cycle\n"); + dev_err(bt->io->dev, "stuck, try power cycle\n"); /* this is most likely during insmod */ else if (bt->seq <= (unsigned char)(bt->BT_CAP_retries & 0xFF)) { - pr_warn("IPMI: BT reset (takes 5 secs)\n"); + dev_warn(bt->io->dev, "BT reset (takes 5 secs)\n"); bt->state = BT_STATE_RESET1; return SI_SM_CALL_WITHOUT_DELAY; } @@ -448,7 +454,7 @@ static enum si_sm_result bt_event(struct si_sm_data *bt, long time) status = BT_STATUS; bt->nonzero_status |= status; if ((bt_debug & BT_DEBUG_STATES) && (bt->state != last_printed)) { - pr_warn("BT: %s %s TO=%ld - %ld\n", + dev_dbg(bt->io->dev, "BT: %s %s TO=%ld - %ld\n", STATE2TXT, STATUS2TXT, bt->timeout,