From patchwork Wed May 17 19:56:20 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 100007 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp392122qge; Wed, 17 May 2017 12:56:58 -0700 (PDT) X-Received: by 10.99.97.83 with SMTP id v80mr546507pgb.94.1495051018782; Wed, 17 May 2017 12:56:58 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495051018; cv=none; d=google.com; s=arc-20160816; b=VW8i3KCk6jfUdh8o1tiABO+hdoujRmrQcBXbt3WIsY7JSkQtkp6EKQnAeaXaTjH5YG Mo4QpLlew3CZiPQeo7OfT4FvjAuZmrCUlgeu4rz1pm1xY111G0QD77fTGyExM5zmKADJ WW9E720j2Utc5veqeYR3CcHXMARcBE6uJQYzirQdrafBp7mZMdVI7t+LQx8KOZkYXVEp PCXYhFaW5+mnNxAU7uuX+tJ7riTASsDsmsOAbpyLArdgfO+DLvDyj2GwhUjvXvP8ULJt aGQdd5jqQBSfzNDjlIMb4RIjoWRW3qie5F752yaaOgSLD0nRTMIIrM48/lMnHA0Rk71q 8EtA== 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=sBn2QevA4zZeVsUHPTFoWz3VrKfWoWAwZ33IIgnZTZo=; b=D4Xxi/3ybXrns0a2qjZdH+iaFBIT9ieuTVuCUQ20D24d5sFi9dmlJYAo4UxiVpJeD5 VffW9B1BSPnIqOkIlbRlUWPNR6/h/RkgXMq70FmHbGiXWotH3hGR8tyICgDcs0BePqTu AViB7dyIuGpMXcsg/Yi783s9Cbiw63Wy1P3tMJuocU+rSKhjfJrm+w+flvRsxOVHV+Cz 6DrY1SJQF94rR2k032wOo/CUNd3QkQA86gtF8jAYLBX6Sn4TDowlLGnJrEAeWQgT5OMD eiLoLIeQLEH+TN4U0awIEkPhj0sv5Hdqk7HSHFIrtIT8Ivp1HschKpY0Z5qnvem3K0MV sE+A== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10si2972162pln.71.2017.05.17.12.56.58; Wed, 17 May 2017 12:56:58 -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 S1753433AbdEQT4f (ORCPT + 25 others); Wed, 17 May 2017 15:56:35 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:34104 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752921AbdEQT4d (ORCPT ); Wed, 17 May 2017 15:56:33 -0400 Received: by mail-oi0-f65.google.com with SMTP id w10so3904214oif.1 for ; Wed, 17 May 2017 12:56:33 -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=sBn2QevA4zZeVsUHPTFoWz3VrKfWoWAwZ33IIgnZTZo=; b=crFSMp+z5Xl+Lvj3YosdQEOrVSrZQZJdhuPNWNMUNz6LNMbKWMo+1W98M5sexgySQe rQWH/uBrxV3YaNe8FtYFaUHsP1kCzqqgUfyPvamJheYMLpmbVReLuUPtsMECVrI324xk Dhps8sLun7yAqs51u2Vxxtn3HkTbxhGQQxkjWwI7lbjFk3N/B2/VwzuvpJtp0PTq7+wa LNchRFvItgR41YyTHihZty6GmWmE+IkxhSuYExK/l2My7bwdhYsBfIb0oo8Qi1P4xgCu dXgR10Jxewdosj0Nwnpda5B/G9qFSsQFwsIwpyjWUSFg9kSisXe4mrTZ8DZdMw+VV1aJ 1d3A== 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=sBn2QevA4zZeVsUHPTFoWz3VrKfWoWAwZ33IIgnZTZo=; b=T6PLCB3wKLObML13U3oHqIWz1gZzSyRV49ohQbOBjHCTnBhqSFzjHXKfLs7C2wfmXu JPrSmqx4O5h5p1/DoLufEyz6DlPRu2sTQkuRayFpl+plsM5NhT88ow8U9k01LskCc8V7 pm9uLOGCd0P4J4OFJIQKAeiXOjNMpvOU7WrzQNdgo3qmLyBiRCN9uSpGCra/4e4q0xLJ EmzQx7NtRZRRZyXfZL69ScnsfgZ4uJEaW8lv1p9HccxRl5rT45bhzLtOhZdXRJDbM1tY I3Y5+/bIi03hgzu03fQem38feaaJPXM9+eqAZrGzY64PdRGSlhWlkQezQ+7DYcdyBPyt 9H6A== X-Gm-Message-State: AODbwcBWTilPwJ4ffa0X92/OMX2flCIHEMmZbKaQkF1oanbzIjS8gugP 2XiIPG8LBjyM4A== X-Received: by 10.202.168.140 with SMTP id r134mr250129oie.57.1495050993071; Wed, 17 May 2017 12:56:33 -0700 (PDT) Received: from serve.minyard.net ([47.184.154.34]) by smtp.gmail.com with ESMTPSA id e46sm1504664otc.17.2017.05.17.12.56.31 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 12:56:31 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id D62231310; Wed, 17 May 2017 14:56:30 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id ED8BB3029B4; Wed, 17 May 2017 14:56:28 -0500 (CDT) From: minyard@acm.org To: Jean Delvare Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Andy Lutomirski , Corey Minyard Subject: [PATCH v5 1/5] dmi: remove const from return of dmi_find_device Date: Wed, 17 May 2017 14:56:20 -0500 Message-Id: <1495050984-5602-2-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495050984-5602-1-git-send-email-minyard@acm.org> References: <1495050984-5602-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 A fwnode_handle is being added to dmi_device, and that will need to be updated. So remove the const. Signed-off-by: Corey Minyard Cc: Jean Delvare Cc: Andy Lutomirski Tested-by: Andy Lutomirski --- drivers/firmware/dmi_scan.c | 11 +++++------ include/linux/dmi.h | 10 +++++----- 2 files changed, 10 insertions(+), 11 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 54be60e..a29e96a 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -896,14 +896,13 @@ EXPORT_SYMBOL(dmi_name_in_vendors); * A new search is initiated by passing %NULL as the @from argument. * If @from is not %NULL, searches continue from next device. */ -const struct dmi_device *dmi_find_device(int type, const char *name, - const struct dmi_device *from) +struct dmi_device *dmi_find_device(int type, const char *name, + const struct dmi_device *from) { - const struct list_head *head = from ? &from->list : &dmi_devices; - struct list_head *d; + struct list_head *d = from ? from->list.next : dmi_devices.next; - for (d = head->next; d != &dmi_devices; d = d->next) { - const struct dmi_device *dev = + for (; d != &dmi_devices; d = d->next) { + struct dmi_device *dev = list_entry(d, struct dmi_device, list); if (((type == DMI_DEV_TYPE_ANY) || (dev->type == type)) && diff --git a/include/linux/dmi.h b/include/linux/dmi.h index 5e9c74c..a930a4d 100644 --- a/include/linux/dmi.h +++ b/include/linux/dmi.h @@ -98,9 +98,9 @@ struct dmi_dev_onboard { extern struct kobject *dmi_kobj; extern int dmi_check_system(const struct dmi_system_id *list); const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list); -extern const char * dmi_get_system_info(int field); -extern const struct dmi_device * dmi_find_device(int type, const char *name, - const struct dmi_device *from); +extern const char *dmi_get_system_info(int field); +extern struct dmi_device *dmi_find_device(int type, const char *name, + const struct dmi_device *from); extern void dmi_scan_machine(void); extern void dmi_memdev_walk(void); extern void dmi_set_dump_stack_arch_desc(void); @@ -116,8 +116,8 @@ extern void dmi_memdev_name(u16 handle, const char **bank, const char **device); #else static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; } -static inline const char * dmi_get_system_info(int field) { return NULL; } -static inline const struct dmi_device * dmi_find_device(int type, const char *name, +static inline const char *dmi_get_system_info(int field) { return NULL; } +static inline struct dmi_device *dmi_find_device(int type, const char *name, const struct dmi_device *from) { return NULL; } static inline void dmi_scan_machine(void) { return; } static inline void dmi_memdev_walk(void) { } From patchwork Wed May 17 19:56:21 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 100011 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp392317qge; Wed, 17 May 2017 12:57:37 -0700 (PDT) X-Received: by 10.98.58.83 with SMTP id h80mr518606pfa.27.1495051057199; Wed, 17 May 2017 12:57:37 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495051057; cv=none; d=google.com; s=arc-20160816; b=asWjzxta4Tkqzp4btiPpBk0nkX4h1Yv2zxn1i2fJujYgcu31vRwX7ikeUGGgKoc2Px PTGk2Y4RvRg57LHWVjyqzO8JLbxKShv3RGL3VJZFFDAICz6fHZoWAzjWh16GDzDfvmb5 Qf0dd5CjAfe58O1MsvoqmueP7tGOuBI7S0Q86+51ApDNY5qY7xyvmTiwidR6OlnaqfOz WOb7lII0HjJTiISdoyVzHXoC3CXrvGH0FRoZiRu7hai4wsBwQIdM/ozOeD+aHFxFBvX1 No3XYOpRhMXxnnffgM+4s0ond6UT6lppZm5V0sVzZNHUz6hlW/dugLJrDzxWg/3a3Xli T7FQ== 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=lFgF2Pkt/zHwWh3/L5pLuh4VdJqZl28fszh+z/gx6JM=; b=jhzdHIb7d2aPIID/S9CtfloX744L1DboEt7D8fDv+FQptQBQv9z0DvT7CY0Jhjp+g7 sGsgBugbqBkGnqhi7mgGsx/WG2Y897IP/nkYzwG9FwMtVTAeyQnVbxduB6bwq++mQl7W QGsNsCNyJTUyOi2HNUJlXF7CJ6xYf6pYDBhAUba3MIe5Gf8pe1ES38N9zlLPYxQdXbQG bUg1fqh4saIsOps6j5+LpsCrB89Bg7LeamWKALg9b7KlQIb6Klbsc/dmMaLbXRXEV6iy Jgi6OrsF0cJmg8hlk9jNwFs0bJpAAHsE7o68ItW2BAziJasX5XgqbVGu+Ql7C+KQEaWk Kqcw== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m86si2941529pfi.202.2017.05.17.12.57.36; Wed, 17 May 2017 12:57: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 S1754164AbdEQT52 (ORCPT + 25 others); Wed, 17 May 2017 15:57:28 -0400 Received: from mail-oi0-f66.google.com ([209.85.218.66]:35399 "EHLO mail-oi0-f66.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1752921AbdEQT4f (ORCPT ); Wed, 17 May 2017 15:56:35 -0400 Received: by mail-oi0-f66.google.com with SMTP id m17so3900024oik.2 for ; Wed, 17 May 2017 12:56:35 -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=lFgF2Pkt/zHwWh3/L5pLuh4VdJqZl28fszh+z/gx6JM=; b=oeH4AIJkAuM1OQpiA4vM4ADsj6q/P6VV/0DYtvJJSFjENENqnFV+cYd6u0ryg6M6pK MJ5guKxS0pJBoPc91m32tUzbrR/vOqgRITcGIh2b/t5M8Lv7uHYm6yzc7beLlwRIOm38 /MA2jqsqPUWiAgLyvKFpjyUrX2tAxMJ9zVZdtsb1yEbZ8vNjTnJ/gCDDzf+f/Ee9Q1co fLdZCT7o01W7yhnnjiFYVgquKUZZ1SOZOcrwExayLcP7XUUEMgLGb0UDEbBrxoZMH4hP AJ/3PtfwFaHD/5bqImcoqHvkViVotWceRbzQk4kXL36aqI5hbu6AgfAomLOtB0Q722jn tFIg== 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=lFgF2Pkt/zHwWh3/L5pLuh4VdJqZl28fszh+z/gx6JM=; b=LBy+iq9spQP97154GvP3bdYTUfsf29Yg8RLBXrGpc0BjiAhberZigzRK33jX5FXkRx DHzTe1LElI5NYnWOTTrL/waQdfDQyK4NTbmyMJEzd0KO8tlWqh5/WPUDfYKBusKCnoWQ 89+q7YWl1RnaxgMSNZRyt9Vn5YS4DFiAS/8qNtlUMLw0UMbksnyvv4zndzAKTzcE9z4B qwnLtFN4u57hASCspQFkd13ux8hvYgijkjEPssUTwOUXflgXvX0VgItC3jC6jbw2Oehy +XQPujvJWqVZ5KMoWMzzjrGLBnKsBedxuDWd6rleiIt7sqwvw7LhvER1Cp501Qd2kcNz VYcg== X-Gm-Message-State: AODbwcDmG3Y7c6tfWSVDTQQ5bBYPACxE1mAJWZXj+IFW/HlSo+ceonTV KxKMSKqSeJ+0uA== X-Received: by 10.202.92.65 with SMTP id q62mr307925oib.28.1495050995109; Wed, 17 May 2017 12:56:35 -0700 (PDT) Received: from serve.minyard.net ([47.184.154.34]) by smtp.gmail.com with ESMTPSA id z74sm1510390oia.2.2017.05.17.12.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 12:56:33 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 4F739941; Wed, 17 May 2017 14:56:30 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 07F583029B0; Wed, 17 May 2017 14:56:28 -0500 (CDT) From: minyard@acm.org To: Jean Delvare Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Andy Lutomirski , Corey Minyard Subject: [PATCH v5 2/5] dmi: Add a DMI firmware node and handling Date: Wed, 17 May 2017 14:56:21 -0500 Message-Id: <1495050984-5602-3-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495050984-5602-1-git-send-email-minyard@acm.org> References: <1495050984-5602-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 This is so that an IPMI platform device can be created from a DMI firmware entry. Signed-off-by: Corey Minyard Cc: Jean Delvare Cc: Andy Lutomirski Tested-by: Andy Lutomirski --- drivers/firmware/dmi_scan.c | 16 ++++++++++------ include/linux/dmi.h | 14 ++++++++++++++ include/linux/fwnode.h | 3 ++- 3 files changed, 26 insertions(+), 7 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index a29e96a..78ef357 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -242,6 +242,12 @@ static void __init dmi_save_type(const struct dmi_header *dm, int slot, dmi_ident[slot] = s; } +static void __init dmi_devices_list_add(struct dmi_device *dev) +{ + dev->fwnode.type = FWNODE_DMI; + list_add(&dev->list, &dmi_devices); +} + static void __init dmi_save_one_device(int type, const char *name) { struct dmi_device *dev; @@ -257,8 +263,7 @@ static void __init dmi_save_one_device(int type, const char *name) dev->type = type; strcpy((char *)(dev + 1), name); dev->name = (char *)(dev + 1); - dev->device_data = NULL; - list_add(&dev->list, &dmi_devices); + dmi_devices_list_add(dev); } static void __init dmi_save_devices(const struct dmi_header *dm) @@ -293,9 +298,8 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm) dev->type = DMI_DEV_TYPE_OEM_STRING; dev->name = devname; - dev->device_data = NULL; - list_add(&dev->list, &dmi_devices); + dmi_devices_list_add(dev); } } @@ -318,7 +322,7 @@ static void __init dmi_save_ipmi_device(const struct dmi_header *dm) dev->name = "IPMI controller"; dev->device_data = data; - list_add_tail(&dev->list, &dmi_devices); + dmi_devices_list_add(dev); } static void __init dmi_save_dev_pciaddr(int instance, int segment, int bus, @@ -345,7 +349,7 @@ static void __init dmi_save_dev_pciaddr(int instance, int segment, int bus, dev->dev.name = (char *)&dev[1]; dev->dev.device_data = dev; - list_add(&dev->dev.list, &dmi_devices); + dmi_devices_list_add(&dev->dev); } static void __init dmi_save_extended_devices(const struct dmi_header *dm) diff --git a/include/linux/dmi.h b/include/linux/dmi.h index a930a4d..c8dd5b8 100644 --- a/include/linux/dmi.h +++ b/include/linux/dmi.h @@ -4,6 +4,7 @@ #include #include #include +#include /* enum dmi_field is in mod_devicetable.h */ @@ -80,6 +81,7 @@ struct dmi_header { struct dmi_device { struct list_head list; + struct fwnode_handle fwnode; int type; const char *name; void *device_data; /* Type specific data */ @@ -113,6 +115,18 @@ extern int dmi_walk(void (*decode)(const struct dmi_header *, void *), extern bool dmi_match(enum dmi_field f, const char *str); extern void dmi_memdev_name(u16 handle, const char **bank, const char **device); +static inline bool is_dmi_fwnode(struct fwnode_handle *fwnode) +{ + return fwnode && fwnode->type == FWNODE_DMI; +} + +static inline struct dmi_device *to_dmi_device(struct fwnode_handle *fwnode) +{ + if (is_dmi_fwnode(fwnode)) + return container_of(fwnode, struct dmi_device, fwnode); + return NULL; +} + #else static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; } diff --git a/include/linux/fwnode.h b/include/linux/fwnode.h index 3dff239..630c1ef 100644 --- a/include/linux/fwnode.h +++ b/include/linux/fwnode.h @@ -19,7 +19,8 @@ enum fwnode_type { FWNODE_ACPI_DATA, FWNODE_ACPI_STATIC, FWNODE_PDATA, - FWNODE_IRQCHIP + FWNODE_IRQCHIP, + FWNODE_DMI }; struct fwnode_handle { From patchwork Wed May 17 19:56:22 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 100009 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp392133qge; Wed, 17 May 2017 12:57:00 -0700 (PDT) X-Received: by 10.84.229.79 with SMTP id d15mr524696pln.93.1495051020151; Wed, 17 May 2017 12:57:00 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495051020; cv=none; d=google.com; s=arc-20160816; b=UY+WI+2IN/v/rGHpZgoXdtcVVfUZBek9q2oN53l+FehslWSMlrZABGQN96Vm8+HgDw UMsrdpCBSKduKlRHPrxqN+9cu8X1EhPC6fLu1pz0zleoLh+SzPPszb6QlhigrRhZPaDa 6aXPOZ9bWi4nbwubioCkj32Gj0MwVemjzq5+fnijrGm6QTuqm1Bm3V5Lh2Ma6ZARRbK8 T3jJIXqU3jSUtYqX8FMU7yr+6rkqOlaBP4u+qPcA1VYAje6PuVaXOAoU89gL5VsdcrqD 05UUFvv76hk0/UeAeg8HyLzSfXDGF2blRCC/N9waxbTbPBQ+nLFDgYZzNrCYN5cIdSif 10DA== 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=xePd590STj4cp0mnWlaPm/mO1y8q/iSqP3RS1JCOkOY=; b=EAWCj9TvkzM4LZ6NsJOsG6OKFKAXaW5GwilC91FW3dCLTNNgVr6vJv/nKYRN5JvGqE 8JO0MVxRsLFP3yIHW437XtnGK7QorYUNk7cxiJguWLOzy8o/S1bb/AXt/nbL+L60VfdQ L7ulCTVq1GxhXTcw2berXDMF4kkhMJaUbihOxnKd9N9IzjoLLucLrVOkQEuQN7Q89jKZ 7h17w//rb1Ys8k6zccoQxF22Sz1teBFi6g10u+vapzfwoc6hWkGH9N21Cl6+WfTwjqZU CI+I13aHzx9VRtJMfaeaIC+wM9oNQ88ZsrcoKec7TKlYmWDvBXwOIU3epP3ffDi5L6XS 6k4w== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10si2972162pln.71.2017.05.17.12.56.59; Wed, 17 May 2017 12:57:00 -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 S1753972AbdEQT4s (ORCPT + 25 others); Wed, 17 May 2017 15:56:48 -0400 Received: from mail-oi0-f67.google.com ([209.85.218.67]:36666 "EHLO mail-oi0-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753781AbdEQT4m (ORCPT ); Wed, 17 May 2017 15:56:42 -0400 Received: by mail-oi0-f67.google.com with SMTP id w138so3894616oiw.3 for ; Wed, 17 May 2017 12:56:42 -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=xePd590STj4cp0mnWlaPm/mO1y8q/iSqP3RS1JCOkOY=; b=Z++hEaNmZJuBOmGS9k54ViYFcsR8c/toKIoGoFqJ5s6EBM2nIKbaenBO4EkywfLICz QSY7XkAlJiE9K1Cu0XWnq3VEp8P5yCUToxBXkLeK5LtC/Do0HM3zm8tR35xE5UMhRX6/ ipBQIiFDwASh7n8xWwQHylJaiUCu1cHR1uGCsfEgJViRnrnqcxQ76KUAUwMevlwhkqn5 3siVEaLV3DWnH0Ib6zT0yaoT1ZmCztJxa9I3MdsjdBbB9ckIAZLxdjV8w26FGlA7l6nv RA2hEuRupE6esK0X4oO0PJAWej7gE0jKKXtM59pKczIYXjCQLcz8V+xr3FlVsH4T3RBC wqpA== 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=xePd590STj4cp0mnWlaPm/mO1y8q/iSqP3RS1JCOkOY=; b=SED9E8VwoICwYUo0l1hq6AxT1RWJNEwZQoYPvycgl3IOhYo3s/6UafiOhWO4lkP9Wg WBwLU8FtxgTxDZM1HZ4i8sf0MKwfGxVSFBD78jFabce/35HtvEIKwpwy6uZ5TSRtkNtO gtgG/YKn+vl5Z7jgWHoD13HEaIhXnYHhVD4b9TJdZKMgXKUiKKgDMcfhr83Fgs4bRPF4 tqpOr7SwH6trkolVdzuIfzsPjrBOUSlNBVhSv3rMOIDsczLBxbd9GbFa2DdioLpSIL+3 4CTkbiGCgMur5iaTNiC8EEs1ftM6zB3nyZbGVxEFQrfHrAVovMP8/AOJjRRZ/Z+ysnEi Q7kQ== X-Gm-Message-State: AODbwcBecMsGuDIZ/AuJ2E0MxepkBumx7ezSgXcD5oz9Hp6CTtFVG4ca NH/NX2+1AdbE+A== X-Received: by 10.157.40.238 with SMTP id s101mr356070ota.88.1495050996567; Wed, 17 May 2017 12:56:36 -0700 (PDT) Received: from serve.minyard.net ([47.184.154.34]) by smtp.gmail.com with ESMTPSA id p3sm1519479oia.24.2017.05.17.12.56.33 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 12:56:35 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id EFBE21370; Wed, 17 May 2017 14:56:30 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 246D33029B2; Wed, 17 May 2017 14:56:28 -0500 (CDT) From: minyard@acm.org To: Jean Delvare Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Andy Lutomirski , Corey Minyard Subject: [PATCH v5 3/5] dmi: Add IPMI DMI scanning to the DMI code Date: Wed, 17 May 2017 14:56:22 -0500 Message-Id: <1495050984-5602-4-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495050984-5602-1-git-send-email-minyard@acm.org> References: <1495050984-5602-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 It makes more sense to be there, and it's cleaner with the upcoming conversion of IPMI DMI to a platform device. Signed-off-by: Corey Minyard Cc: Jean Delvare Cc: Andy Lutomirski Tested-by: Andy Lutomirski --- drivers/firmware/dmi_scan.c | 108 ++++++++++++++++++++++++++++++++++++++++++-- include/linux/dmi.h | 26 +++++++++++ 2 files changed, 129 insertions(+), 5 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 78ef357..96c0743 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -303,9 +303,105 @@ static void __init dmi_save_oem_strings_devices(const struct dmi_header *dm) } } +#define DMI_IPMI_MIN_LENGTH 0x10 +#define DMI_IPMI_VER2_LENGTH 0x12 +#define DMI_IPMI_TYPE 4 +#define DMI_IPMI_SLAVEADDR 6 +#define DMI_IPMI_ADDR 8 +#define DMI_IPMI_ACCESS 0x10 +#define DMI_IPMI_IRQ 0x11 +#define DMI_IPMI_IO_MASK 0xfffe + +static void __init dmi_decode_ipmi(struct dmi_dev_ipmi *dev, + const struct dmi_header *dm) +{ + const u8 *data = (const u8 *) dm; + unsigned long base_addr; + u8 len = dm->length; + bool slave_addr_set; + + if (len < DMI_IPMI_MIN_LENGTH) + return; + + dev->type = data[DMI_IPMI_TYPE]; + + memcpy(&base_addr, data + DMI_IPMI_ADDR, sizeof(unsigned long)); + if (len >= DMI_IPMI_VER2_LENGTH) { + if (dev->type == IPMI_DMI_TYPE_SSIF) { + if ((data[DMI_IPMI_ADDR] >> 1) == 0) { + /* + * Some broken systems put the I2C address in + * the slave address field. We try to + * accommodate them here. + */ + dev->base_addr = data[DMI_IPMI_SLAVEADDR] >> 1; + dev->slave_addr = 0; + slave_addr_set = true; + } else { + dev->base_addr = data[DMI_IPMI_ADDR] >> 1; + } + } else { + if (base_addr & 1) { + /* I/O */ + base_addr &= DMI_IPMI_IO_MASK; + dev->is_io_space = 1; + } else { + /* Memory */ + dev->is_io_space = 0; + } + + /* + * If bit 4 of byte 0x10 is set, then the lsb + * for the address is odd. + */ + base_addr |= (data[DMI_IPMI_ACCESS] >> 4) & 1; + + dev->base_addr = base_addr; + dev->irq = data[DMI_IPMI_IRQ]; + + /* + * The top two bits of byte 0x10 hold the + * register spacing. + */ + switch ((data[DMI_IPMI_ACCESS] >> 6) & 3) { + case 0: /* Byte boundaries */ + dev->offset = 1; + break; + case 1: /* 32-bit boundaries */ + dev->offset = 4; + break; + case 2: /* 16-byte boundaries */ + dev->offset = 16; + break; + default: + /* Leave 0 for undefined. */ + return; + } + } + } else { + /* Old DMI spec. */ + /* + * Note that technically, the lower bit of the base + * address should be 1 if the address is I/O and 0 if + * the address is in memory. So many systems get that + * wrong (and all that I have seen are I/O) so we just + * ignore that bit and assume I/O. Systems that use + * memory should use the newer spec, anyway. + */ + dev->base_addr = base_addr & DMI_IPMI_IO_MASK; + dev->is_io_space = 1; + dev->offset = 1; + } + + if (!slave_addr_set) + dev->slave_addr = data[DMI_IPMI_SLAVEADDR]; + + dev->good_data = 1; +} + static void __init dmi_save_ipmi_device(const struct dmi_header *dm) { - struct dmi_device *dev; + struct dmi_dev_ipmi *dev; void *data; data = dmi_alloc(dm->length); @@ -318,11 +414,13 @@ static void __init dmi_save_ipmi_device(const struct dmi_header *dm) if (!dev) return; - dev->type = DMI_DEV_TYPE_IPMI; - dev->name = "IPMI controller"; - dev->device_data = data; + dev->dev.type = DMI_DEV_TYPE_IPMI; + dev->dev.name = "IPMI controller"; + dev->dev.device_data = data; - dmi_devices_list_add(dev); + dmi_decode_ipmi(dev, dm); + + dmi_devices_list_add(&dev->dev); } static void __init dmi_save_dev_pciaddr(int instance, int segment, int bus, diff --git a/include/linux/dmi.h b/include/linux/dmi.h index c8dd5b8..96dc644 100644 --- a/include/linux/dmi.h +++ b/include/linux/dmi.h @@ -97,6 +97,24 @@ struct dmi_dev_onboard { int devfn; }; +/* Device data for an IPMI entry. */ +struct dmi_dev_ipmi { + struct dmi_device dev; + u8 good_data; + u8 type; + u8 is_io_space; + u8 irq; + u8 offset; + u8 slave_addr; + unsigned long base_addr; +}; + +/* dmi_ipmi_data type field */ +#define IPMI_DMI_TYPE_KCS 0x01 +#define IPMI_DMI_TYPE_SMIC 0x02 +#define IPMI_DMI_TYPE_BT 0x03 +#define IPMI_DMI_TYPE_SSIF 0x04 + extern struct kobject *dmi_kobj; extern int dmi_check_system(const struct dmi_system_id *list); const struct dmi_system_id *dmi_first_match(const struct dmi_system_id *list); @@ -127,6 +145,14 @@ static inline struct dmi_device *to_dmi_device(struct fwnode_handle *fwnode) return NULL; } +static inline struct dmi_dev_ipmi *to_dmi_dev_ipmi(struct dmi_device *dev) +{ + if (!dev || dev->type != DMI_DEV_TYPE_IPMI) + return NULL; + + return container_of(dev, struct dmi_dev_ipmi, dev); +} + #else static inline int dmi_check_system(const struct dmi_system_id *list) { return 0; } From patchwork Wed May 17 19:56:23 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 100008 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp392131qge; Wed, 17 May 2017 12:56:59 -0700 (PDT) X-Received: by 10.99.109.9 with SMTP id i9mr523417pgc.56.1495051019747; Wed, 17 May 2017 12:56:59 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495051019; cv=none; d=google.com; s=arc-20160816; b=0ip9v5+SWzoJNK63iakJ3nUN1eaFlacsbObdrP9btJMTwK/jaRW4oMeWBQiPxC2VGl 4UIVgix4zUU3zzFGa2dVuJHbvip/c1Mrau2sfYmGUE4BiwFviaNJNW5l3m4mdPjLaqTx 4UzpMGXtvwOye3oJgjGtOM5fuDgVHkYLECtkbCR0isndk6e3dBfW71F4NY9ef6eocima /07JYF5r1ESM7zAbfD+yWz5fGFTyb3Ri72WkUdePxwQY5lRwoLiPYCcGYIx0e6PhRZSr Kk8uDwmXT+C05rya2/mhkiB3jHMaTcbmxXZCQuVRZtDKjJYGFndwh4cyQ+p6H3HxlFOU MhZg== 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=Us5Mui4B3DBZqB/EBuV1NrwqzYeKniGPrWDeK4I37Bk=; b=OPsc1wqOkS+qzyDWjgh/ec1X4Cf1+zUyoThEqCKkZQXuTprRfYLA8y6O7BO0a0YTOA wnMFTnpEh7jJgB53afFezXq0G1G8DBDL9OQjwfqXC66UoJ85CHqgplo2hlrGtc9f20CP +sJmhYFDQ6Xp4bLT1oJmDop5Dafq/xGRJQ2rr+P/Cwaetb+r9KDPP1Z1ni6Fz6MRRatY F0RbVg6rTXl7S3he1B2lH1cYGL+jyIZSDnNP09TcRDYODcCSl6jrkpZYUx+VWvODliPb 5F7QLIX0K4GRkcPM8ZbpgZmSCZHEdT42dxQ62qBQgiHokwEU+4r5idupLa0xa0nCJGte WNtA== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id l10si2972162pln.71.2017.05.17.12.56.59; Wed, 17 May 2017 12:56:59 -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 S1753763AbdEQT4k (ORCPT + 25 others); Wed, 17 May 2017 15:56:40 -0400 Received: from mail-oi0-f65.google.com ([209.85.218.65]:35393 "EHLO mail-oi0-f65.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753140AbdEQT4f (ORCPT ); Wed, 17 May 2017 15:56:35 -0400 Received: by mail-oi0-f65.google.com with SMTP id m17so3899974oik.2 for ; Wed, 17 May 2017 12:56:34 -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=Us5Mui4B3DBZqB/EBuV1NrwqzYeKniGPrWDeK4I37Bk=; b=Uatu+R5vTmEpz7b/qWB9/hdpKJybD0qmOKpCkKUAag5wiR6qlInwI6PmwEltqEnydk vDdQvaJV3cqvq0jZ4YzGlLzgOHaK13CGW7Sp1XwOyRdZSF8LVFGdHo7DH8ng9C/YTrJG rvFmGIKkm3rDdkeHdZJSopT6NUEY2Dl+JQOzIjyaJ0JhVPVjDwfDqipPPJ1nt4N+a1mZ QLqG6gWvZTgE8U1y1SPFnjd97pkS2nASSed+aoLjAWdcv7biSt9or1yV0ruBR3+kubDN ymJztRnNeZVK25zBs/HXM38bJTQadKGkmc+AwKC+PZE5rnN+RiWxRkjAhUbvONU9FRla HH4w== 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=Us5Mui4B3DBZqB/EBuV1NrwqzYeKniGPrWDeK4I37Bk=; b=T3UONZ5YLJn6BHrJt3OdnT82/8h08BuM6rGXIko5Dkv6aJEEZbQzJ3laaZu2TlaBQw YoBKhRjEDRX6xutZToYpFHqUXbovKuxjYB0T87ZG5xEKBJPA5G1+mXYC5UDvJFbzAOj/ +JSCdvMsAwiJP8Vxn2uD7GDr+3bt3DiBS8wrFMkOLh+tS39z7b1CCBxHF4OmR12oq0ZY XSclcFfxBjM4sYfO0T/3ndbxaZdtsuuj/bhpdj4TrJZF6kWzGdMsC0kwLTExbOz7Gbyg U7jIifo7m0/R1f8qWte71L1su3bgpWn4bHxdLLAqD+yRQB04GSIRoo3YttYmaUup35TY LMYw== X-Gm-Message-State: AODbwcC80BzC5vxMTkp1G44YsBbMIDOBh6akkWrCoNUdgHujV8MR3b5A L+GEi+ESQtI7hg== X-Received: by 10.157.11.34 with SMTP id a31mr355673ota.114.1495050994403; Wed, 17 May 2017 12:56:34 -0700 (PDT) Received: from serve.minyard.net ([47.184.154.34]) by smtp.gmail.com with ESMTPSA id p27sm1533935otp.57.2017.05.17.12.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 12:56:33 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id 8AADC130E; Wed, 17 May 2017 14:56:30 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id DF48B300037; Wed, 17 May 2017 14:56:28 -0500 (CDT) From: minyard@acm.org To: Jean Delvare Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Andy Lutomirski , Corey Minyard Subject: [PATCH v5 4/5] dmi: Add IPMI DMI devices as platform devices Date: Wed, 17 May 2017 14:56:23 -0500 Message-Id: <1495050984-5602-5-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495050984-5602-1-git-send-email-minyard@acm.org> References: <1495050984-5602-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 Have DMI create a platform device for every IPMI device it finds. Signed-off-by: Corey Minyard Cc: Jean Delvare Cc: Andy Lutomirski Tested-by: Andy Lutomirski --- drivers/firmware/dmi_scan.c | 55 +++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 53 insertions(+), 2 deletions(-) -- 2.7.4 diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c index 96c0743..211e111 100644 --- a/drivers/firmware/dmi_scan.c +++ b/drivers/firmware/dmi_scan.c @@ -7,6 +7,7 @@ #include #include #include +#include #include #include @@ -783,6 +784,52 @@ static ssize_t raw_table_read(struct file *file, struct kobject *kobj, return count; } +static void __init dmi_add_platform_ipmi(struct dmi_device *dev, int *nr) +{ + struct platform_device *pdev; + struct dmi_dev_ipmi *ipmi_dev = to_dmi_dev_ipmi(dev); + int rv; + + if (!ipmi_dev->good_data) { + pr_err("dmi: Invalid IPMI data, not creating platform device"); + return; + } + + if (ipmi_dev->type == IPMI_DMI_TYPE_SSIF) + pdev = platform_device_alloc("dmi-ipmi-ssif", *nr); + else + pdev = platform_device_alloc("dmi-ipmi-si", *nr); + if (!pdev) { + pr_err("dmi: Error allocation IPMI platform device"); + return; + } + if (ipmi_dev->type == IPMI_DMI_TYPE_SSIF) + pdev->driver_override = "ipmi_ssif"; + else + pdev->driver_override = "ipmi_si"; + + pdev->dev.fwnode = &dev->fwnode; + rv = platform_device_add(pdev); + if (rv) { + dev_err(&pdev->dev, "dmi: Unable to add device: %d\n", rv); + platform_device_del(pdev); + return; + } + + (*nr)++; +} + +static void __init dmi_add_platform_devices(void) +{ + struct dmi_device *dev; + int nr_ipmi = 0; + + list_for_each_entry(dev, &dmi_devices, list) { + if (dev->type == DMI_DEV_TYPE_IPMI) + dmi_add_platform_ipmi(dev, &nr_ipmi); + } +} + static BIN_ATTR(smbios_entry_point, S_IRUSR, raw_table_read, NULL, 0); static BIN_ATTR(DMI, S_IRUSR, raw_table_read, NULL, 0); @@ -823,9 +870,13 @@ static int __init dmi_init(void) bin_attr_DMI.size = dmi_len; bin_attr_DMI.private = dmi_table; ret = sysfs_create_bin_file(tables_kobj, &bin_attr_DMI); - if (!ret) - return 0; + if (ret) + goto out_remove_bin_file; + + dmi_add_platform_devices(); + return 0; + out_remove_bin_file: sysfs_remove_bin_file(tables_kobj, &bin_attr_smbios_entry_point); err_unmap: From patchwork Wed May 17 19:56:24 2017 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Corey Minyard X-Patchwork-Id: 100010 Delivered-To: patch@linaro.org Received: by 10.140.96.100 with SMTP id j91csp392316qge; Wed, 17 May 2017 12:57:36 -0700 (PDT) X-Received: by 10.99.113.75 with SMTP id b11mr482624pgn.173.1495051056831; Wed, 17 May 2017 12:57:36 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1495051056; cv=none; d=google.com; s=arc-20160816; b=dqiwq71Z5qV0sCUuZ+Eho2/e4DRoL9N8u4U+jMo3uSKJWi9gTpvffKNsHWk/bfFZYD i/F8cyw3Ul9FEmjr8AZJDfQkJAy1HAkWxg5StKwIB8wmO3Un7G6Jv91h/LZqyVMOZHn7 F453Y77a4lC4uGvpvhdGTsZzbUSKCKuWPxaqQUzNn3djwEWGA1zuAyLqYzIxyZBHgjwI BXjNQpWyjxJTR/MrTcjIGEY5aHl/dbC3rlt6rEqQSOv9J4NgjS4OwAbGh8GXCBQ2fpqL 1n3Xyga/DTzwTfPD9nprfjVSptpuFaAU3cnpSQDnDA5oQSBUxZxideWTMtf5t2/fhVC/ uY6g== 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=EYPCYK4LCUn+ub6ktkp7bGvxauAFbWrO0IYukr4qWNA=; b=yTn7wfJrZcfeB2UYPpeWBi51YHqbewylIfZF2WbIVg+2TiwigH6Tg1P7tNhtOAD9Ok J9JKzt++jKET1pC6tsckQTyFcyCBj1hv+TCGSKEUtXtaCOzzgkrHhaXZC+ylVpTL+Wpw CkhMbrXNl/Zs0bjB/cPdrGOIYpk0rdnVySVNi6agnJaAlzxeer61x8rg8mpilJHca2kL ywrbfxswO6oUtfvgWZ2/ZY+cv4m+ukncZf7XycbwzO+fiWtEyNaf8XxxuzFxZXOIIJRP 8srNQv488txcQLEqPdkIJZCc3u+uVmryNOltGNVlthXnaH2kJ5mihZPAvVAZQEArYtGt Wn9w== ARC-Authentication-Results: i=1; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id m86si2941529pfi.202.2017.05.17.12.57.36; Wed, 17 May 2017 12:57:36 -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 S1754085AbdEQT5M (ORCPT + 25 others); Wed, 17 May 2017 15:57:12 -0400 Received: from mail-oi0-f68.google.com ([209.85.218.68]:33284 "EHLO mail-oi0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753486AbdEQT4g (ORCPT ); Wed, 17 May 2017 15:56:36 -0400 Received: by mail-oi0-f68.google.com with SMTP id h4so3903132oib.0 for ; Wed, 17 May 2017 12:56:36 -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=EYPCYK4LCUn+ub6ktkp7bGvxauAFbWrO0IYukr4qWNA=; b=SVs4JBqBNkpAtdKgZNpmi8MdwdFHAY5dC9bFaBdI1zatmB+OFR28YYbl6mM55KtjKP ADQLIkRAp7TIgEcn18htt/aMaDF/JI5RWw+5wHKLsQgpmt2HOKGXypV2Vp/EQ6ltJUrw EAUoIBl4ogcyRjgjN/O7/ao2vTh9LOrMHnNkScwfTs4HKGntwfLnseCSGLAu9usC4u9g LFz/aV0eW3DFrkf0/r5wydtp1weH3G6iBDImHo3qx8DyKITQo5Ld+fHQpdzUWXS7Y+9I 2xMU8D7mNmb2uTw6gIhrq1rwP/MbXHGqu+LqxSjtkX+hmjQqrtbUwcEoxesiMiuelLGf nhLA== 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=EYPCYK4LCUn+ub6ktkp7bGvxauAFbWrO0IYukr4qWNA=; b=WVFFSW6vtoOZF1VP8YM087ZNYOOEz65p5YHkYi0n7BEanV6g+zT27iRHIFbMNEZ2Z9 I9JVaLQ7OxVa2S0h2H98URNa+X6NbUzCPxdL9onsp8YSgdxwhVDMR4wQ4fSs/bKIGoB7 QL6+85x7AzNRDky6FrKvCoI0DfRjMyzwagt1MQhT0MM4uQW9O1Yu+PcEdXwInGC76Ybk wTE12aojVPIGBKzEyafoxVitCB/nQovuXOqLspi/ayiXTZO6Hbw8/qTEAPZahHUPjjzi F5G6Lc0I5hPM+8JbTmrOVllvTEI2Wy7KevGMdIqIflRTxEMsQNh0U5FjF6XrPHAERoGX lDOw== X-Gm-Message-State: AODbwcBALcyJQ7sm1gagIp3iQbt9K/4v9doRW7l9sANDh7p91EG2U6i2 MyVl1PhmPTe3Hg== X-Received: by 10.202.98.68 with SMTP id w65mr287217oib.173.1495050995689; Wed, 17 May 2017 12:56:35 -0700 (PDT) Received: from serve.minyard.net ([47.184.154.34]) by smtp.gmail.com with ESMTPSA id w197sm1521590oie.8.2017.05.17.12.56.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 May 2017 12:56:33 -0700 (PDT) Received: from t430.minyard.net (t430m.minyard.net [192.168.27.3]) by serve.minyard.net (Postfix) with ESMTPA id E90831322; Wed, 17 May 2017 14:56:30 -0500 (CDT) Received: by t430.minyard.net (Postfix, from userid 1000) id 3536D3029B3; Wed, 17 May 2017 14:56:28 -0500 (CDT) From: minyard@acm.org To: Jean Delvare Cc: openipmi-developer@lists.sourceforge.net, linux-kernel@vger.kernel.org, Andy Lutomirski , Corey Minyard Subject: [PATCH v5 5/5] ipmi: Convert DMI handling over to a platform device Date: Wed, 17 May 2017 14:56:24 -0500 Message-Id: <1495050984-5602-6-git-send-email-minyard@acm.org> X-Mailer: git-send-email 2.7.4 In-Reply-To: <1495050984-5602-1-git-send-email-minyard@acm.org> References: <1495050984-5602-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 Now that the DMI code creates a platform device for IPMI devices in the firmware, use that instead of handling all the DMI work in the IPMI driver itself. Signed-off-by: Corey Minyard Tested-by: Andy Lutomirski --- drivers/char/ipmi/ipmi_si_intf.c | 137 ++++++++------------------------------- drivers/char/ipmi/ipmi_ssif.c | 119 ++++++++++++++++++++++------------ 2 files changed, 106 insertions(+), 150 deletions(-) -- 2.7.4 diff --git a/drivers/char/ipmi/ipmi_si_intf.c b/drivers/char/ipmi/ipmi_si_intf.c index b2b618f..17611a8 100644 --- a/drivers/char/ipmi/ipmi_si_intf.c +++ b/drivers/char/ipmi/ipmi_si_intf.c @@ -2274,121 +2274,45 @@ static void spmi_find_bmc(void) #endif #ifdef CONFIG_DMI -struct dmi_ipmi_data { - u8 type; - u8 addr_space; - unsigned long base_addr; - u8 irq; - u8 offset; - u8 slave_addr; -}; - -static int decode_dmi(const struct dmi_header *dm, - struct dmi_ipmi_data *dmi) -{ - const u8 *data = (const u8 *)dm; - unsigned long base_addr; - u8 reg_spacing; - u8 len = dm->length; - - dmi->type = data[4]; - - memcpy(&base_addr, data+8, sizeof(unsigned long)); - if (len >= 0x11) { - if (base_addr & 1) { - /* I/O */ - base_addr &= 0xFFFE; - dmi->addr_space = IPMI_IO_ADDR_SPACE; - } else - /* Memory */ - dmi->addr_space = IPMI_MEM_ADDR_SPACE; - - /* If bit 4 of byte 0x10 is set, then the lsb for the address - is odd. */ - dmi->base_addr = base_addr | ((data[0x10] & 0x10) >> 4); - - dmi->irq = data[0x11]; - - /* The top two bits of byte 0x10 hold the register spacing. */ - reg_spacing = (data[0x10] & 0xC0) >> 6; - switch (reg_spacing) { - case 0x00: /* Byte boundaries */ - dmi->offset = 1; - break; - case 0x01: /* 32-bit boundaries */ - dmi->offset = 4; - break; - case 0x02: /* 16-byte boundaries */ - dmi->offset = 16; - break; - default: - /* Some other interface, just ignore it. */ - return -EIO; - } - } else { - /* Old DMI spec. */ - /* - * Note that technically, the lower bit of the base - * address should be 1 if the address is I/O and 0 if - * the address is in memory. So many systems get that - * wrong (and all that I have seen are I/O) so we just - * ignore that bit and assume I/O. Systems that use - * memory should use the newer spec, anyway. - */ - dmi->base_addr = base_addr & 0xfffe; - dmi->addr_space = IPMI_IO_ADDR_SPACE; - dmi->offset = 1; - } - - dmi->slave_addr = data[6]; - - return 0; -} - -static void try_init_dmi(struct dmi_ipmi_data *ipmi_data) +static int dmi_ipmi_probe(struct platform_device *pdev) { + struct dmi_device *dmi_dev = to_dmi_device(pdev->dev.fwnode); + struct dmi_dev_ipmi *ipmi_data = to_dmi_dev_ipmi(dmi_dev); struct smi_info *info; + if (!si_trydmi || !ipmi_data) + return -ENODEV; + info = smi_info_alloc(); if (!info) { pr_err(PFX "Could not allocate SI data\n"); - return; + return -ENOMEM; } info->addr_source = SI_SMBIOS; pr_info(PFX "probing via SMBIOS\n"); switch (ipmi_data->type) { - case 0x01: /* KCS */ + case IPMI_DMI_TYPE_KCS: info->si_type = SI_KCS; break; - case 0x02: /* SMIC */ + case IPMI_DMI_TYPE_SMIC: info->si_type = SI_SMIC; break; - case 0x03: /* BT */ + case IPMI_DMI_TYPE_BT: info->si_type = SI_BT; break; default: kfree(info); - return; + return -EINVAL; } - switch (ipmi_data->addr_space) { - case IPMI_MEM_ADDR_SPACE: - info->io_setup = mem_setup; - info->io.addr_type = IPMI_MEM_ADDR_SPACE; - break; - - case IPMI_IO_ADDR_SPACE: + if (ipmi_data->is_io_space) { info->io_setup = port_setup; info->io.addr_type = IPMI_IO_ADDR_SPACE; - break; - - default: - kfree(info); - pr_warn(PFX "Unknown SMBIOS I/O Address type: %d\n", - ipmi_data->addr_space); - return; + } else { + info->io_setup = mem_setup; + info->io.addr_type = IPMI_MEM_ADDR_SPACE; } info->io.addr_data = ipmi_data->base_addr; @@ -2404,6 +2328,8 @@ static void try_init_dmi(struct dmi_ipmi_data *ipmi_data) if (info->irq) info->irq_setup = std_irq_setup; + info->dev = &pdev->dev; + pr_info("ipmi_si: SMBIOS: %s %#lx regsize %d spacing %d irq %d\n", (info->io.addr_type == IPMI_IO_ADDR_SPACE) ? "io" : "mem", info->io.addr_data, info->io.regsize, info->io.regspacing, @@ -2411,21 +2337,13 @@ static void try_init_dmi(struct dmi_ipmi_data *ipmi_data) if (add_smi(info)) kfree(info); -} -static void dmi_find_bmc(void) + return 0; +} +#else +static int dmi_ipmi_probe(struct platform_device *pdev) { - const struct dmi_device *dev = NULL; - struct dmi_ipmi_data data; - int rv; - - while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev))) { - memset(&data, 0, sizeof(data)); - rv = decode_dmi((const struct dmi_header *) dev->device_data, - &data); - if (!rv) - try_init_dmi(&data); - } + return -ENODEV; } #endif /* CONFIG_DMI */ @@ -2813,7 +2731,10 @@ static int ipmi_probe(struct platform_device *dev) if (of_ipmi_probe(dev) == 0) return 0; - return acpi_ipmi_probe(dev); + if (acpi_ipmi_probe(dev) == 0) + return 0; + + return dmi_ipmi_probe(dev); } static int ipmi_remove(struct platform_device *dev) @@ -3786,11 +3707,6 @@ static int init_ipmi_si(void) } #endif -#ifdef CONFIG_DMI - if (si_trydmi) - dmi_find_bmc(); -#endif - #ifdef CONFIG_ACPI if (si_tryacpi) spmi_find_bmc(); @@ -3938,6 +3854,7 @@ static void cleanup_ipmi_si(void) } module_exit(cleanup_ipmi_si); +MODULE_ALIAS("platform:dmi-ipmi-si"); MODULE_LICENSE("GPL"); MODULE_AUTHOR("Corey Minyard "); MODULE_DESCRIPTION("Interface to the IPMI driver for the KCS, SMIC, and BT" diff --git a/drivers/char/ipmi/ipmi_ssif.c b/drivers/char/ipmi/ipmi_ssif.c index 1d4fd84..109ca4e 100644 --- a/drivers/char/ipmi/ipmi_ssif.c +++ b/drivers/char/ipmi/ipmi_ssif.c @@ -180,6 +180,8 @@ struct ssif_addr_info { int slave_addr; enum ipmi_addr_src addr_src; union ipmi_smi_info_union addr_info; + struct device *dev; + struct i2c_client *client; struct mutex clients_mutex; struct list_head clients; @@ -1469,6 +1471,7 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id) ssif_info->addr_source = addr_info->addr_src; ssif_info->ssif_debug = addr_info->debug; ssif_info->addr_info = addr_info->addr_info; + addr_info->client = client; slave_addr = addr_info->slave_addr; } } @@ -1706,8 +1709,19 @@ static int ssif_probe(struct i2c_client *client, const struct i2c_device_id *id) } out: - if (rv) + if (rv) { + /* + * Note that if addr_info->client is assigned, we + * leave it. The i2c client hangs around even if we + * return a failure here, and the failure here is not + * propagated back to the i2c code. This seems to be + * design intent, strange as it may be. But if we + * don't leave it, ssif_platform_remove will not remove + * the client like it should. + */ + dev_err(&client->dev, "Unable to start IPMI SSIF: %d\n", rv); kfree(ssif_info); + } kfree(resp); return rv; @@ -1732,7 +1746,8 @@ static int ssif_adapter_handler(struct device *adev, void *opaque) static int new_ssif_client(int addr, char *adapter_name, int debug, int slave_addr, - enum ipmi_addr_src addr_src) + enum ipmi_addr_src addr_src, + struct device *dev) { struct ssif_addr_info *addr_info; int rv = 0; @@ -1762,9 +1777,14 @@ static int new_ssif_client(int addr, char *adapter_name, sizeof(addr_info->binfo.type)); addr_info->binfo.addr = addr; addr_info->binfo.platform_data = addr_info; + if (dev) + addr_info->binfo.fwnode = dev->fwnode; addr_info->debug = debug; addr_info->slave_addr = slave_addr; addr_info->addr_src = addr_src; + addr_info->dev = dev; + + dev_set_drvdata(dev, addr_info); list_add_tail(&addr_info->link, &ssif_infos); @@ -1903,7 +1923,7 @@ static int try_init_spmi(struct SPMITable *spmi) myaddr = spmi->addr.address & 0x7f; - return new_ssif_client(myaddr, NULL, 0, 0, SI_SPMI); + return new_ssif_client(myaddr, NULL, 0, 0, SI_SPMI, NULL); } static void spmi_find_bmc(void) @@ -1932,48 +1952,30 @@ static void spmi_find_bmc(void) { } #endif #ifdef CONFIG_DMI -static int decode_dmi(const struct dmi_device *dmi_dev) +static int dmi_ipmi_probe(struct platform_device *pdev) { - struct dmi_header *dm = dmi_dev->device_data; - u8 *data = (u8 *) dm; - u8 len = dm->length; - unsigned short myaddr; - int slave_addr; - - if (num_addrs >= MAX_SSIF_BMCS) - return -1; + struct dmi_device *dmi_dev = to_dmi_device(pdev->dev.fwnode); + struct dmi_dev_ipmi *ipmi_data = to_dmi_dev_ipmi(dmi_dev); - if (len < 9) - return -1; - - if (data[0x04] != 4) /* Not SSIF */ - return -1; + if (!ssif_trydmi || !ipmi_data) + return -ENODEV; - if ((data[8] >> 1) == 0) { - /* - * Some broken systems put the I2C address in - * the slave address field. We try to - * accommodate them here. - */ - myaddr = data[6] >> 1; - slave_addr = 0; - } else { - myaddr = data[8] >> 1; - slave_addr = data[6]; + if (!ipmi_data->good_data) { + pr_err(PFX "DMI data for this device was invalid.\n"); + return -EINVAL; } - return new_ssif_client(myaddr, NULL, 0, slave_addr, SI_SMBIOS); -} - -static void dmi_iterator(void) -{ - const struct dmi_device *dev = NULL; + if (ipmi_data->type != IPMI_DMI_TYPE_SSIF) + return -ENODEV; - while ((dev = dmi_find_device(DMI_DEV_TYPE_IPMI, NULL, dev))) - decode_dmi(dev); + return new_ssif_client(ipmi_data->base_addr, NULL, 0, + ipmi_data->slave_addr, SI_SMBIOS, &pdev->dev); } #else -static void dmi_iterator(void) { } +static int dmi_ipmi_probe(struct platform_device *pdev) +{ + return -ENODEV; +} #endif static const struct i2c_device_id ssif_id[] = { @@ -1994,6 +1996,36 @@ static struct i2c_driver ssif_i2c_driver = { .detect = ssif_detect }; +static int ssif_platform_probe(struct platform_device *dev) +{ + return dmi_ipmi_probe(dev); +} + +static int ssif_platform_remove(struct platform_device *dev) +{ + struct ssif_addr_info *addr_info = dev_get_drvdata(&dev->dev); + + if (!addr_info) + return 0; + + mutex_lock(&ssif_infos_mutex); + if (addr_info->client) + i2c_unregister_device(addr_info->client); + + list_del(&addr_info->link); + kfree(addr_info); + mutex_unlock(&ssif_infos_mutex); + return 0; +} + +static struct platform_driver ipmi_driver = { + .driver = { + .name = DEVICE_NAME, + }, + .probe = ssif_platform_probe, + .remove = ssif_platform_remove, +}; + static int init_ipmi_ssif(void) { int i; @@ -2008,7 +2040,7 @@ static int init_ipmi_ssif(void) for (i = 0; i < num_addrs; i++) { rv = new_ssif_client(addr[i], adapter_name[i], dbg[i], slave_addrs[i], - SI_HARDCODED); + SI_HARDCODED, NULL); if (rv) pr_err(PFX "Couldn't add hardcoded device at addr 0x%x\n", @@ -2018,8 +2050,7 @@ static int init_ipmi_ssif(void) if (ssif_tryacpi) ssif_i2c_driver.driver.acpi_match_table = ACPI_PTR(ssif_acpi_match); - if (ssif_trydmi) - dmi_iterator(); + if (ssif_tryacpi) spmi_find_bmc(); @@ -2029,6 +2060,11 @@ static int init_ipmi_ssif(void) if (!rv) initialized = true; + /* Wait until here so ACPI devices will start first. */ + rv = platform_driver_register(&ipmi_driver); + if (rv) + pr_err(PFX "Unable to register driver: %d\n", rv); + return rv; } module_init(init_ipmi_ssif); @@ -2040,12 +2076,15 @@ static void cleanup_ipmi_ssif(void) initialized = false; + platform_driver_unregister(&ipmi_driver); + i2c_del_driver(&ssif_i2c_driver); free_ssif_clients(); } module_exit(cleanup_ipmi_ssif); +MODULE_ALIAS("platform:dmi-ipmi-ssif"); MODULE_AUTHOR("Todd C Davis , Corey Minyard "); MODULE_DESCRIPTION("IPMI driver for management controllers on a SMBus"); MODULE_LICENSE("GPL");