From patchwork Thu Dec 7 21:34:47 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 121086 Delivered-To: patch@linaro.org Received: by 10.140.22.227 with SMTP id 90csp8893744qgn; Thu, 7 Dec 2017 13:40:17 -0800 (PST) X-Google-Smtp-Source: AGs4zMaI5lTJ+E9e9JgtwoydXj367e90xt2xEO2fPSmsMm6LL2jPVOAlVOVf+JhLdzw0dWG/sqOz X-Received: by 10.129.75.22 with SMTP id y22mr19205502ywa.100.1512682817432; Thu, 07 Dec 2017 13:40:17 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1512682817; cv=none; d=google.com; s=arc-20160816; b=0qH2V2QkEUVGvwW4watx47NxV/82fmTaWhOnvLl0gAMifEzZeVEUEw7n5XWJVMs1Tu 2RcxQEl0e+COEilDIvrzjpyundKhAPQ7NV7R2tco9ubH9jwHJgIcfWeriv8R+Xd8sPNa LOcmJJgDUlGiS7qg88+Iev6erUgerBZ9RH2GzEwsFXQqeTEtEmHXHJr/ro2qfjgrTpxJ DVTYMUTWzAzflCK8LsEL/r9qPvfpYZGERWIGH7axbMyb9uRNEw8XjQph1HbEdtUawMa4 ZQ2tIF5e0qR9ejG93Q74xJ/JGWQSJwZ7T4pFgORY0yME2hPKylr1B7XFS66RTMmEGI6G Girg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:cc:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:subject:references:in-reply-to :message-id:date:to:from:dkim-signature:arc-authentication-results; bh=ba92l3LFx1+Ht8sl7OUzFvrBVOExWKkqYB6FsoZgV1c=; b=KuuNrdEtIJuX65bNeMzE+WEWK78wbAvOKJ6eCFUoZwb+xMuMjw2z82D9NQf1zTl4ZA euDPphXZqy4Dm+NlXXPg20R2hLtt05Ns7ZIttTOlOIL+nZEIAV9fpSuTqHv9UqWR8i40 SJ3uqaG1NmJ/fzqwKapm/4YGjNYZueYBB0g8/RQjpekLIu2nLFhBOPSzYq5I1SzX4WL+ K+9FbhVgUQECWLzQzfeDFuXactrr47U9VJJzOX97loKIsRCXd4RTD0LLQ2zFv0aEEy57 4z8GJywF64WEH4Ue3CnffUdGbKby/tD9jjpbySDxVLLh4kF3BqPQRNzp+vmejcSvfX/S 1F/A== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mzvmT0TV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [2001:4830:134:3::11]) by mx.google.com with ESMTPS id n20si1406278ywm.146.2017.12.07.13.40.17 for (version=TLS1 cipher=AES128-SHA bits=128/128); Thu, 07 Dec 2017 13:40:17 -0800 (PST) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) client-ip=2001:4830:134:3::11; Authentication-Results: mx.google.com; dkim=fail header.i=@gmail.com header.s=20161025 header.b=mzvmT0TV; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 2001:4830:134:3::11 as permitted sender) smtp.mailfrom=qemu-devel-bounces+patch=linaro.org@nongnu.org Received: from localhost ([::1]:34450 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN3tw-0006Y0-Uv for patch@linaro.org; Thu, 07 Dec 2017 16:40:16 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:46759) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1eN3ot-0001vx-Fd for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:35:04 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1eN3or-00054h-8x for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:35:03 -0500 Received: from mail-pg0-x242.google.com ([2607:f8b0:400e:c05::242]:42392) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1eN3or-00053r-0A for qemu-devel@nongnu.org; Thu, 07 Dec 2017 16:35:01 -0500 Received: by mail-pg0-x242.google.com with SMTP id e14so5366255pgr.9 for ; Thu, 07 Dec 2017 13:35:00 -0800 (PST) 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=ba92l3LFx1+Ht8sl7OUzFvrBVOExWKkqYB6FsoZgV1c=; b=mzvmT0TVMUmmrKZI6cEmEngWR0+kiAixsXXrIBiLZMxajzAR7zlkTKdw182FIP6Etw MHKuTmYbJdx6zdlxDY/vVppDq2iOnbsAqEfA96JFBmH5hIWEGPqoxVqnSrgSXUmfwdyU PwgRYyRMY5prb86Hr6iJ1khqxuNoNulNjcAALowSKyPE71aS2uuzLlN+RYgS9zxSNUvY Y321pDYSikLsTMIUStyKHb7qwcWrtAxj2hQX/TENQgEGwfb5gSeulPIaHkfkf9wfvIgF P70+C/iuXJCS0lhDymLlJ2XGSDzuqBUwluDF4/x0lMYkdftJqFk9tfLI4V+cOGMXAIs4 sT/w== 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=ba92l3LFx1+Ht8sl7OUzFvrBVOExWKkqYB6FsoZgV1c=; b=b5mcyGa7IAQO7p43QHVOqZb6vfUa1v08+sq9Wh7QT8znQwWysOThVyegdOfslGqsV1 EXHLH/9qn2qZ1K6d5qHxKOf9R9qOBJky2feW8HimBa8D0SR6M2UmeZ8VSkZpvSK9sILR MIvJhlwwEWUqgmIIpMxkzgJcecH2WUHIYqeHbwp31auHYLzZAs6ovm0qk241LQAzvLJc eds+o3YM9V59V7CWQ3msgnQLsrwZo+KyFIl2q0Ej096ZvjBBNJzJh999dXIck7yghjmQ fm/dg3auSKkzcCZz4Rmz6RYfBunRjt4Re80QMrzknva1U262vmj8YxQ4NIwImlYt1wjd ekTw== X-Gm-Message-State: AJaThX5S2T8zdF+DcMlMjN/PjjhpGj1e6/JghMPOAQEZdsKEoQXPlXVA A398hyWYBWJtggaVvy06mqhIrBA= X-Received: by 10.101.90.8 with SMTP id y8mr26733417pgs.21.1512682499863; Thu, 07 Dec 2017 13:34:59 -0800 (PST) Received: from serve.minyard.net ([47.184.168.85]) by smtp.gmail.com with ESMTPSA id s184sm1772017pfb.9.2017.12.07.13.34.56 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Thu, 07 Dec 2017 13:34:57 -0800 (PST) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id B33F4CF0; Thu, 7 Dec 2017 15:34:53 -0600 (CST) Received: by t430.minyard.net (Postfix, from userid 1000) id 3D42D30008F; Thu, 7 Dec 2017 15:34:52 -0600 (CST) From: minyard@acm.org To: qemu-devel@nongnu.org Date: Thu, 7 Dec 2017 15:34:47 -0600 Message-Id: <1512682489-4474-6-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1512682489-4474-1-git-send-email-minyard@acm.org> References: <1512682489-4474-1-git-send-email-minyard@acm.org> X-detected-operating-system: by eggs.gnu.org: Genre and OS details not recognized. X-Received-From: 2607:f8b0:400e:c05::242 Subject: [Qemu-devel] [PATCH 5/7] ipmi: Allow a size value to be passed for I/O space X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Corey Minyard Errors-To: qemu-devel-bounces+patch=linaro.org@nongnu.org Sender: "Qemu-devel" From: Corey Minyard PCI device I/O must be >= 8 bytes in length or they don't work. Allow the size to be passed in, the default size of 2 or 3 won't work. Signed-off-by: Corey Minyard --- hw/ipmi/ipmi_bt.c | 19 +++++++++++++++---- hw/ipmi/ipmi_kcs.c | 23 +++++++++++++++++++---- hw/ipmi/isa_ipmi_bt.c | 2 +- hw/ipmi/isa_ipmi_kcs.c | 2 +- include/hw/ipmi/ipmi.h | 7 ++++++- include/hw/ipmi/ipmi_bt.h | 1 + include/hw/ipmi/ipmi_kcs.h | 1 + 7 files changed, 44 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/hw/ipmi/ipmi_bt.c b/hw/ipmi/ipmi_bt.c index e07e10a..130ef24 100644 --- a/hw/ipmi/ipmi_bt.c +++ b/hw/ipmi/ipmi_bt.c @@ -187,7 +187,7 @@ static uint64_t ipmi_bt_ioport_read(void *opaque, hwaddr addr, unsigned size) IPMIBT *ib = iic->get_backend_data(ii); uint32_t ret = 0xff; - switch (addr & 3) { + switch (addr & ib->size_mask) { case 0: ret = ib->control_reg; break; @@ -206,6 +206,9 @@ static uint64_t ipmi_bt_ioport_read(void *opaque, hwaddr addr, unsigned size) case 2: ret = ib->mask_reg; break; + default: + ret = 0xff; + break; } return ret; } @@ -228,7 +231,7 @@ static void ipmi_bt_ioport_write(void *opaque, hwaddr addr, uint64_t val, IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii); IPMIBT *ib = iic->get_backend_data(ii); - switch (addr & 3) { + switch (addr & ib->size_mask) { case 0: if (IPMI_BT_GET_CLR_WR(val)) { ib->inlen = 0; @@ -283,6 +286,9 @@ static void ipmi_bt_ioport_write(void *opaque, hwaddr addr, uint64_t val, ipmi_bt_lower_irq(ib); } break; + default: + /* Ignore. */ + break; } } @@ -344,14 +350,19 @@ static void ipmi_bt_set_irq_enable(IPMIInterface *ii, int val) ib->irqs_enabled = val; } -static void ipmi_bt_init(IPMIInterface *ii, Error **errp) +static void ipmi_bt_init(IPMIInterface *ii, unsigned int min_size, Error **errp) { IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii); IPMIBT *ib = iic->get_backend_data(ii); + if (min_size == 0) { + min_size = 4; + } + ib->size_mask = min_size - 1; ib->io_length = 3; - memory_region_init_io(&ib->io, NULL, &ipmi_bt_io_ops, ii, "ipmi-bt", 3); + memory_region_init_io(&ib->io, NULL, &ipmi_bt_io_ops, ii, "ipmi-bt", + min_size); } const VMStateDescription vmstate_IPMIBT = { diff --git a/hw/ipmi/ipmi_kcs.c b/hw/ipmi/ipmi_kcs.c index cb22dee..ec6dc39 100644 --- a/hw/ipmi/ipmi_kcs.c +++ b/hw/ipmi/ipmi_kcs.c @@ -230,7 +230,7 @@ static uint64_t ipmi_kcs_ioport_read(void *opaque, hwaddr addr, unsigned size) IPMIKCS *ik = iic->get_backend_data(ii); uint32_t ret; - switch (addr & 1) { + switch (addr & ik->size_mask) { case 0: ret = ik->data_out_reg; IPMI_KCS_SET_OBF(ik->status_reg, 0); @@ -241,6 +241,7 @@ static uint64_t ipmi_kcs_ioport_read(void *opaque, hwaddr addr, unsigned size) } } break; + case 1: ret = ik->status_reg; if (ik->atn_irq_set) { @@ -250,6 +251,9 @@ static uint64_t ipmi_kcs_ioport_read(void *opaque, hwaddr addr, unsigned size) } } break; + + default: + ret = 0xff; } return ret; } @@ -265,7 +269,7 @@ static void ipmi_kcs_ioport_write(void *opaque, hwaddr addr, uint64_t val, return; } - switch (addr & 1) { + switch (addr & ik->size_mask) { case 0: ik->data_in_reg = val; break; @@ -273,6 +277,10 @@ static void ipmi_kcs_ioport_write(void *opaque, hwaddr addr, uint64_t val, case 1: ik->cmd_reg = val; break; + + default: + /* Ignore. */ + break; } IPMI_KCS_SET_IBF(ik->status_reg, 1); ipmi_kcs_signal(ik, ii); @@ -319,13 +327,20 @@ static void ipmi_kcs_set_irq_enable(IPMIInterface *ii, int val) ik->irqs_enabled = val; } -static void ipmi_kcs_init(IPMIInterface *ii, Error **errp) +/* min_size must be a power of 2. */ +static void ipmi_kcs_init(IPMIInterface *ii, unsigned int min_size, + Error **errp) { IPMIInterfaceClass *iic = IPMI_INTERFACE_GET_CLASS(ii); IPMIKCS *ik = iic->get_backend_data(ii); + if (min_size == 0) { + min_size = 2; + } + ik->size_mask = min_size - 1; ik->io_length = 2; - memory_region_init_io(&ik->io, NULL, &ipmi_kcs_io_ops, ii, "ipmi-kcs", 2); + memory_region_init_io(&ik->io, NULL, &ipmi_kcs_io_ops, ii, "ipmi-kcs", + min_size); } const VMStateDescription vmstate_IPMIKCS = { diff --git a/hw/ipmi/isa_ipmi_bt.c b/hw/ipmi/isa_ipmi_bt.c index b711eca..a98e0ea 100644 --- a/hw/ipmi/isa_ipmi_bt.c +++ b/hw/ipmi/isa_ipmi_bt.c @@ -80,7 +80,7 @@ static void isa_ipmi_bt_realize(DeviceState *dev, Error **errp) iib->bt.bmc->intf = ii; iib->bt.opaque = iib; - iic->init(ii, errp); + iic->init(ii, 0, errp); if (*errp) return; diff --git a/hw/ipmi/isa_ipmi_kcs.c b/hw/ipmi/isa_ipmi_kcs.c index d1a5956..ab6f62e 100644 --- a/hw/ipmi/isa_ipmi_kcs.c +++ b/hw/ipmi/isa_ipmi_kcs.c @@ -79,7 +79,7 @@ static void ipmi_isa_realize(DeviceState *dev, Error **errp) iik->kcs.bmc->intf = ii; iik->kcs.opaque = iik; - iic->init(ii, errp); + iic->init(ii, 0, errp); if (*errp) return; diff --git a/include/hw/ipmi/ipmi.h b/include/hw/ipmi/ipmi.h index 0affe5a..0f62ea3 100644 --- a/include/hw/ipmi/ipmi.h +++ b/include/hw/ipmi/ipmi.h @@ -121,7 +121,12 @@ typedef struct IPMIInterface { typedef struct IPMIInterfaceClass { InterfaceClass parent; - void (*init)(struct IPMIInterface *s, Error **errp); + /* + * min_size is the requested I/O size and must be a power of 2. + * This is so PCI (or other busses) can request a bigger range. + * Use 0 for the default. + */ + void (*init)(struct IPMIInterface *s, unsigned int min_size, Error **errp); /* * Perform various operations on the hardware. If checkonly is diff --git a/include/hw/ipmi/ipmi_bt.h b/include/hw/ipmi/ipmi_bt.h index 16066a7..d1e2abe 100644 --- a/include/hw/ipmi/ipmi_bt.h +++ b/include/hw/ipmi/ipmi_bt.h @@ -57,6 +57,7 @@ typedef struct IPMIBT { uint32_t io_base; unsigned long io_length; MemoryRegion io; + unsigned long size_mask; void (*raise_irq)(struct IPMIBT *ib); void (*lower_irq)(struct IPMIBT *ib); diff --git a/include/hw/ipmi/ipmi_kcs.h b/include/hw/ipmi/ipmi_kcs.h index af596be..8c75e86 100644 --- a/include/hw/ipmi/ipmi_kcs.h +++ b/include/hw/ipmi/ipmi_kcs.h @@ -60,6 +60,7 @@ typedef struct IPMIKCS { uint32_t io_base; unsigned long io_length; MemoryRegion io; + unsigned long size_mask; void (*raise_irq)(struct IPMIKCS *ik); void (*lower_irq)(struct IPMIKCS *ik);