devicetree.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Corey Minyard <tcminyard-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
To: "Cédric Le Goater" <clg-Bxea+6Xhats@public.gmane.org>,
	"Arnd Bergmann" <arnd-r2nGTMty4D4@public.gmane.org>,
	linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
Cc: Mark Rutland <mark.rutland-5wv7dgnIgG8@public.gmane.org>,
	devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	Corey Minyard <minyard-HInyCGIudOg@public.gmane.org>,
	Andrew Jeffery <andrew-zrmu5oMJ5Fs@public.gmane.org>,
	Alistair Popple
	<alistair-Y4h6yKqj69EXC2x5gXVKYQ@public.gmane.org>,
	Russell King <linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org>,
	Rob Herring <robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org>,
	Joel Stanley <joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>,
	Jeremy Kerr <jk-mnsaURCQ41sdnm+yROfE0A@public.gmane.org>
Subject: Re: [PATCH 1/3] misc: Add Aspeed BT IPMI host driver
Date: Mon, 12 Sep 2016 13:55:40 -0500	[thread overview]
Message-ID: <1ce6c4b4-5938-22fc-7467-d1efc220b772@gmail.com> (raw)
In-Reply-To: <c06a8afb-9143-6aef-3425-ad1e50cae35d-Bxea+6Xhats@public.gmane.org>

On 09/02/2016 08:22 AM, Cédric Le Goater wrote:
> Hello,
>
> Adding Corey in cc: . I guess I should have done that in the first place.

Yes, probably so.  I've been travelling and didn't see it on the mailing
lists until now.

There is already a BT driver in the kernel, in drivers/char/ipmi, why
won't that work?

-corey

>
> Arnd is suggesting to put this IPMI BT driver under drivers/char/ipmi
> which is indeed a better place than drivers/misc.
>
> Below some comments,
>
> On 08/31/2016 09:57 PM, Arnd Bergmann wrote:
>> On Wednesday, August 31, 2016 7:24:17 PM CEST Cédric Le Goater wrote:
>>> From: Alistair Popple <alistair-Y4h6yKqj69EXC2x5gXVKYQ@public.gmane.org>
>>>
>>> This patch adds a simple device driver to expose the iBT interface on
>>> Aspeed chips as a character device (/dev/bt).
>>>
>>> The iBT interface is used to perform in-band IPMI communication from a
>>> BMC to the host.
>>>
>>> Signed-off-by: Alistair Popple <alistair-Y4h6yKqj69EXC2x5gXVKYQ@public.gmane.org>
>>> Signed-off-by: Jeremy Kerr <jk-mnsaURCQ41sdnm+yROfE0A@public.gmane.org>
>>> Signed-off-by: Joel Stanley <joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org>
>>> [clg: checkpatch fixes
>>>        devicetree binding documentation]
>>> Signed-off-by: Cédric Le Goater <clg-Bxea+6Xhats@public.gmane.org>
>>> ---
>>>   .../devicetree/bindings/misc/aspeed,bt-host.txt    |  19 +
>>>   drivers/misc/Kconfig                               |   5 +
>>>   drivers/misc/Makefile                              |   1 +
>>>   drivers/misc/bt-host.c                             | 433 +++++++++++++++++++++
>>>   include/uapi/linux/Kbuild                          |   1 +
>>>   include/uapi/linux/bt-host.h                       |  18 +
>>>   6 files changed, 477 insertions(+)
>>>   create mode 100644 Documentation/devicetree/bindings/misc/aspeed,bt-host.txt
>>>   create mode 100644 drivers/misc/bt-host.c
>>>   create mode 100644 include/uapi/linux/bt-host.h
>>>
>>> diff --git a/Documentation/devicetree/bindings/misc/aspeed,bt-host.txt b/Documentation/devicetree/bindings/misc/aspeed,bt-host.txt
>>> new file mode 100644
>>> index 000000000000..938c5998c331
>>> --- /dev/null
>>> +++ b/Documentation/devicetree/bindings/misc/aspeed,bt-host.txt
>> "misc" seems like a bad category here. Does this fit nowhere else?
>>
>>> @@ -0,0 +1,19 @@
>>> +* Aspeed BT IPMI interface
>> What does "BT" stand for? IPMI is a more commonly known acronym,
>> but maybe list both with their full name as well.
> "Block Transfer" which is described in the IPMI specs.
>
> yes, I need to rephrase the commit log a bit and put some references
> to the specs.
>
>>> diff --git a/drivers/misc/Makefile b/drivers/misc/Makefile
>>> index 7410c6d9a34d..71a7b9feb0f0 100644
>>> --- a/drivers/misc/Makefile
>>> +++ b/drivers/misc/Makefile
>>> @@ -57,6 +57,7 @@ obj-$(CONFIG_ECHO)		+= echo/
>>>   obj-$(CONFIG_VEXPRESS_SYSCFG)	+= vexpress-syscfg.o
>>>   obj-$(CONFIG_CXL_BASE)		+= cxl/
>>>   obj-$(CONFIG_PANEL)             += panel.o
>>> +obj-$(CONFIG_ASPEED_BT_IPMI_HOST)	+= bt-host.o
>>>   
>>>   lkdtm-$(CONFIG_LKDTM)		+= lkdtm_core.o
>>>   lkdtm-$(CONFIG_LKDTM)		+= lkdtm_bugs.o
>> Maybe put this in a subdirectory of drivers/char/ipmi?
>> I understand that this is the other end of the protocol,
>> but they are closely related after all.
> I agree. There are also some definitions we could make common.
>
> Let's see what Corey thinks about it.
>
>>> +#define DEVICE_NAME	"bt-host"
>> here maybe "ipmi/bt-host" or "ipmi-bt-host"?
> yes. a name containing 'ipmi' is certainly wanted.
>    
>>> +static ssize_t bt_host_read(struct file *file, char __user *buf,
>>> +				size_t count, loff_t *ppos)
>>> +{
>>> +	struct bt_host *bt_host = file_bt_host(file);
>>> +	char __user *p = buf;
>>> +	u8 len;
>>> +
>>> +	if (!access_ok(VERIFY_WRITE, buf, count))
>>> +		return -EFAULT;
>>> +
>>> +	WARN_ON(*ppos);
>>> +
>>> +	if (wait_event_interruptible(bt_host->queue,
>>> +				bt_inb(bt_host, BT_CTRL) & BT_CTRL_H2B_ATN))
>>> +		return -ERESTARTSYS;
>>> +
>>> +	set_b_busy(bt_host);
>>> +	clr_h2b_atn(bt_host);
>>> +	clr_rd_ptr(bt_host);
>>> +
>>> +	len = bt_read(bt_host);
>>> +	__put_user(len, p++);
>>> +
>>> +	/* We pass the length back as well */
>>> +	if (len + 1 > count)
>>> +		len = count - 1;
>>> +
>>> +	while (len) {
>>> +		if (__put_user(bt_read(bt_host), p))
>>> +			return -EFAULT;
>>> +		len--; p++;
>>> +	}
>> If there are larger chunks of data to be transferred,
>> using a temporary buffer with copy_from_user/copy_to_user
>> would be more efficient. Since the size appears to
>> be limited to 256 bytes anyway, that easily fits on the stack.
> ok. I will change that.
>
>>> +
>>> +	clr_b_busy(bt_host);
>>> +
>>> +	return p - buf;
>>> +}
>> What is the motivation for only allowing complete messages
>> to be transferred or truncated for short buffers?
>>
>> Have you considered reading the message into a device specific
>> buffer and allowing continued reads?
>>
>> I don't see an obvious reason one way or another, and I suppose
>> you had an idea of what you were doing, so maybe explain it
>> in a comment.
> The interface is not byte oriented. It is called 'Block Transfer'
> because an entire message is buffered and then the host or the bmc
> is notified that there is data to be read.
>
> I will add a comment on that.
>
>>> +static long bt_host_ioctl(struct file *file, unsigned int cmd,
>>> +		unsigned long param)
>>> +{
>>> +	struct bt_host *bt_host = file_bt_host(file);
>>> +
>>> +	switch (cmd) {
>>> +	case BT_HOST_IOCTL_SMS_ATN:
>>> +		set_sms_atn(bt_host);
>>> +		return 0;
>>> +	}
>>> +	return -EINVAL;
>>> +}
>> Is this ioctl interface defined in a way that makes sense on
>> any IPMI host hardware, or did you just do it like this because
>> it is the easiest way  on the hardware.
> This platform runs OpenBMC on which a dbus daemon acts as a proxy
> between the IPMI BT char device and the rest of the system. So yes,
> the ioctl is relatively easy to use.
>
>> I think it's important for the user interface to be extensible
>> to other implementations if we ever add any.
> I agree but I don't know of any other BMC side implementations.
> May be others ?
>
>>> +static int bt_host_config_irq(struct bt_host *bt_host,
>>> +		struct platform_device *pdev)
>>> +{
>>> +	struct device *dev = &pdev->dev;
>>> +	uint32_t reg;
>>> +	int rc;
>>> +
>>> +	bt_host->irq = irq_of_parse_and_map(dev->of_node, 0);
>>> +	if (!bt_host->irq)
>>> +		return -ENODEV;
>> I think platform_get_irq() is the preferred interface here.
> OK.
>
> Thanks,
>
> C.
>
>
> _______________________________________________
> linux-arm-kernel mailing list
> linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org
> http://lists.infradead.org/mailman/listinfo/linux-arm-kernel


--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

  parent reply	other threads:[~2016-09-12 18:55 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-08-31 17:24 [PATCH 0/3] ARM: aspeed: add support for the BT IPMI host device Cédric Le Goater
2016-08-31 17:24 ` [PATCH 1/3] misc: Add Aspeed BT IPMI host driver Cédric Le Goater
     [not found]   ` <1472664259-23933-2-git-send-email-clg-Bxea+6Xhats@public.gmane.org>
2016-08-31 19:57     ` Arnd Bergmann
2016-09-02 13:22       ` Cédric Le Goater
     [not found]         ` <c06a8afb-9143-6aef-3425-ad1e50cae35d-Bxea+6Xhats@public.gmane.org>
2016-09-12 18:55           ` Corey Minyard [this message]
     [not found]             ` <1ce6c4b4-5938-22fc-7467-d1efc220b772-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-12 19:15               ` Arnd Bergmann
2016-09-12 20:33                 ` Corey Minyard
     [not found]                   ` <7db5ada0-49ea-55eb-089e-d979941ceff5-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
2016-09-12 21:23                     ` Cédric Le Goater
     [not found]                       ` <b42f1b61-8b00-2412-d51d-6207da8afcd6-Bxea+6Xhats@public.gmane.org>
2016-09-12 22:06                         ` Corey Minyard
2016-09-15  6:51                   ` Cédric Le Goater
     [not found]                     ` <3e2658cc-7089-abd2-23b3-ffd468edbd11-Bxea+6Xhats@public.gmane.org>
2016-09-15 12:23                       ` Corey Minyard
2016-08-31 17:24 ` [PATCH 2/3] ARM: aspeed: Add defconfigs for CONFIG_ASPEED_BT_IPMI_HOST Cédric Le Goater
2016-08-31 17:24 ` [PATCH 3/3] ARM: dts: aspeed: Enable BT IPMI host device Cédric Le Goater

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=1ce6c4b4-5938-22fc-7467-d1efc220b772@gmail.com \
    --to=tcminyard-re5jqeeqqe8avxtiumwx3w@public.gmane.org \
    --cc=alistair-Y4h6yKqj69EXC2x5gXVKYQ@public.gmane.org \
    --cc=andrew-zrmu5oMJ5Fs@public.gmane.org \
    --cc=arnd-r2nGTMty4D4@public.gmane.org \
    --cc=clg-Bxea+6Xhats@public.gmane.org \
    --cc=devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org \
    --cc=jk-mnsaURCQ41sdnm+yROfE0A@public.gmane.org \
    --cc=joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org \
    --cc=linux-I+IVW8TIWO2tmTQ+vhA3Yw@public.gmane.org \
    --cc=linux-arm-kernel-IAPFreCvJWM7uuMidbF8XUB+6BGkLq7r@public.gmane.org \
    --cc=mark.rutland-5wv7dgnIgG8@public.gmane.org \
    --cc=minyard-HInyCGIudOg@public.gmane.org \
    --cc=robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).