From patchwork Wed Apr 27 04:31:08 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 66768 Delivered-To: patch@linaro.org Received: by 10.140.93.198 with SMTP id d64csp1976015qge; Tue, 26 Apr 2016 21:31:37 -0700 (PDT) X-Received: by 10.98.34.82 with SMTP id i79mr3004904pfi.35.1461731497764; Tue, 26 Apr 2016 21:31:37 -0700 (PDT) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 21si1821601pfi.15.2016.04.26.21.31.37; Tue, 26 Apr 2016 21:31:37 -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; 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 S1752481AbcD0Ebb (ORCPT + 29 others); Wed, 27 Apr 2016 00:31:31 -0400 Received: from mail-pf0-f196.google.com ([209.85.192.196]:35891 "EHLO mail-pf0-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751266AbcD0Eb3 (ORCPT ); Wed, 27 Apr 2016 00:31:29 -0400 Received: by mail-pf0-f196.google.com with SMTP id p185so3793472pfb.3 for ; Tue, 26 Apr 2016 21:31:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:in-reply-to:references; bh=Ljw8V2GpzpmCdPiTEFoa/JDwhSr29Ne9V7N+rI2XNZI=; b=fKt0qEy50gk4juMc27G/YNQA1dmvSYg7Tc7nqUgKbpsNkdzvDdOadjU8pBZepiWUAH lvjjT8scgAiPCjmU9jpsU+0fU0NOzht2h1eLORttKeQX223JL+wJlIj9lxjLbivCRFn0 CNg7m4hr062eIrca537xCzCu4+3GN4rBtFtWSqrMOMPFJ2upj1ckUPgyofPFVYc+bDMt G4oi5w3dAw+A33oGnfG1rnVzEmNKLp2DMsxlu9ICAFKicwlrlNw/mrOx1U0WBlQ23WN2 397/k0d0ifKCXaaF+ti8krBZv/M66shdfHbqNfkMgZ7fe/DcHm3LdKU0qkOHrv6e95/U Pb8g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:sender:from:to:cc:subject:date:message-id :in-reply-to:references; bh=Ljw8V2GpzpmCdPiTEFoa/JDwhSr29Ne9V7N+rI2XNZI=; b=HQPPZTEG6iGnowynfgrs0Py1VrjqNTtGT0+s1CZjvW8lhF2ynN6TjDWcXgwf2H1jEy ruOrCntmCDE60GOPKPevjxv9LBxhetzEZktZLZKs6OccIrHrzq+uGnWRoz5vcfqQZ5sj il1E92hjg8qjq0AgY1/BxsYjQwDwJEhiqbe7fIG/+D5VsSLNJCURYDeI/kLoy2tSZqzg ZAS+S2oqZqISUPp88gaYEYapxtasz59iWALFRiILdE2wwykkJjdrkMmRaAOjFA9DXa+l E3hx+y4ESkj/VTyYTrLTgpSSR2+UL27eqWh8CIjFBU+d5RselJOkrsPH6c+f7eNxvtIY bqig== X-Gm-Message-State: AOPr4FWyKeOXICn549pG0HtfcSICX8pozHCXZpDKiFiFneDu919hgc8wk2WWUcAeExMwOw== X-Received: by 10.98.78.199 with SMTP id c190mr8778086pfb.7.1461731488343; Tue, 26 Apr 2016 21:31:28 -0700 (PDT) Received: from serve.minyard.net ([173.71.13.195]) by smtp.gmail.com with ESMTPSA id 87sm2134154pfq.93.2016.04.26.21.31.27 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 26 Apr 2016 21:31:27 -0700 (PDT) Received: from t430.minyard.net (unknown [IPv6:2001:470:b8f6:1b:3c36:6e8c:c70a:c6bd]) by serve.minyard.net (Postfix) with ESMTPA id ED9F0318; Tue, 26 Apr 2016 23:31:25 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 44E6B30052C; Tue, 26 Apr 2016 23:31:25 -0500 (CDT) From: minyard@acm.org To: Mark Salter Cc: Corey Minyard , openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Corey Minyard Subject: [PATCH] IPMI: reserve memio regions separately Date: Tue, 26 Apr 2016 23:31:08 -0500 Message-Id: <1461731468-10585-1-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1461600515-26617-1-git-send-email-msalter@redhat.com> References: <1461600515-26617-1-git-send-email-msalter@redhat.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Corey Minyard Commit d61a3ead2680 ("[PATCH] IPMI: reserve I/O ports separately") changed the way I/O ports were reserved and includes this comment in log: Some BIOSes reserve disjoint I/O regions in their ACPI tables for the IPMI controller. This causes problems when trying to register the entire I/O region. Therefore we must register each I/O port separately. There is a similar problem with memio regions on an arm64 platform (AMD Seattle). Where I see: ipmi message handler version 39.2 ipmi_si AMDI0300:00: probing via device tree ipmi_si AMDI0300:00: ipmi_si: probing via ACPI ipmi_si AMDI0300:00: [mem 0xe0010000] regsize 1 spacing 4 irq 23 ipmi_si: Adding ACPI-specified kcs state machine IPMI System Interface driver. ipmi_si: Trying ACPI-specified kcs state machine at mem \ address 0xe0010000, slave address 0x0, irq 23 ipmi_si: Could not set up I/O space The problem is that the ACPI core registers disjoint regions for the platform device: e0010000-e0010000 : AMDI0300:00 e0010004-e0010004 : AMDI0300:00 and the ipmi_si driver tries to register one region e0010000-e0010004. Based on a patch from Mark Salter Signed-off-by: Corey Minyard --- drivers/char/ipmi/ipmi_si_intf.c | 40 +++++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 13 deletions(-) -- 2.7.4 Tested-by: Mark Salter diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index 6ecf9af..a815044 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -1637,25 +1637,28 @@ static void mem_outq(const struct si_sm_io *io, unsigned int offset, } #endif -static void mem_cleanup(struct smi_info *info) +static void mem_region_cleanup(struct smi_info *info, int num) { unsigned long addr = info->io.addr_data; - int mapsize; + int idx; + + for (idx = 0; idx < num; idx++) + release_mem_region(addr + idx * info->io.regspacing, + info->io.regsize); +} +static void mem_cleanup(struct smi_info *info) +{ if (info->io.addr) { iounmap(info->io.addr); - - mapsize = ((info->io_size * info->io.regspacing) - - (info->io.regspacing - info->io.regsize)); - - release_mem_region(addr, mapsize); + mem_region_cleanup(info, info->io_size); } } static int mem_setup(struct smi_info *info) { unsigned long addr = info->io.addr_data; - int mapsize; + int mapsize, idx; if (!addr) return -ENODEV; @@ -1692,6 +1695,21 @@ static int mem_setup(struct smi_info *info) } /* + * Some BIOSes reserve disjoint memory regions in their ACPI + * tables. This causes problems when trying to request the + * entire region. Therefore we must request each register + * separately. + */ + for (idx = 0; idx < info->io_size; idx++) { + if (request_mem_region(addr + idx * info->io.regspacing, + info->io.regsize, DEVICE_NAME) == NULL) { + /* Undo allocations */ + mem_region_cleanup(info, idx); + return -EIO; + } + } + + /* * Calculate the total amount of memory to claim. This is an * unusual looking calculation, but it avoids claiming any * more memory than it has to. It will claim everything @@ -1700,13 +1718,9 @@ static int mem_setup(struct smi_info *info) */ mapsize = ((info->io_size * info->io.regspacing) - (info->io.regspacing - info->io.regsize)); - - if (request_mem_region(addr, mapsize, DEVICE_NAME) == NULL) - return -EIO; - info->io.addr = ioremap(addr, mapsize); if (info->io.addr == NULL) { - release_mem_region(addr, mapsize); + mem_region_cleanup(info, info->io_size); return -EIO; } return 0;