All of lore.kernel.org
 help / color / mirror / Atom feed
From: Benjamin Herrenschmidt <benh@kernel.crashing.org>
To: Guenter Roeck <linux@roeck-us.net>, eajames.ibm@gmail.com
Cc: devicetree@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-hwmon@vger.kernel.org, linux-doc@vger.kernel.org,
	jdelvare@suse.com, corbet@lwn.net, mark.rutland@arm.com,
	robh+dt@kernel.org, wsa@the-dreams.de, andrew@aj.id.au,
	joel@jms.id.au, "Edward A. James" <eajames@us.ibm.com>
Subject: Re: [PATCH linux v3 3/6] hwmon: occ: Add I2C transport implementation for SCOM operations
Date: Sun, 22 Jan 2017 07:53:17 +1100	[thread overview]
Message-ID: <1485031997.2495.4.camel@kernel.crashing.org> (raw)
In-Reply-To: <b47e5359-5587-cc89-43e2-379eb9e95fc8@roeck-us.net>

On Sat, 2017-01-21 at 10:11 -0800, Guenter Roeck wrote:
> > +int occ_i2c_getscom(void *bus, u32 address, u64 *data)
> > +{
> > +     ssize_t rc;
> > +     u64 buf;
> > +     struct i2c_client *client = bus;
> > +
> > +     rc = i2c_master_send(client, (const char *)&address,
> > sizeof(u32));
> > +     if (rc < 0)
> > +             return rc;
> > +     else if (rc != sizeof(u32))
> > +             return -EIO;
> > +
> > +     rc = i2c_master_recv(client, (char *)&buf, sizeof(u64));
> > +     if (rc < 0)
> > +             return rc;
> > +     else if (rc != sizeof(u64))
> > +             return -EIO;
> > +
> > +     *data = be64_to_cpu(buf);
> > +
> > +     return 0;
> > +}
> > +EXPORT_SYMBOL(occ_i2c_getscom);

Additionally, this assumes that is is the only other user of that i2c
path to P8. Something interleaving will break it. pdbg for example.

Talk to Alistair, the right thing here would probably be to have
a separate driver that provides the XSCOM interface via i2c to both
in-kernel and userspace, with proper arbitration.

An expedient might be to instead have the address and data cycles
of the above be 2 i2c messages in one i2c request, thus being
serialized somewhat atomically with other transactions to that i2c
bus.

You may need to make sure the underlying i2c controller driver supports
dual messages, and if it doesn't fix it. This is rather classic 4-bytes 
subaddress style i2c, it shouldn't be too hard.

Cheers,
Ben.


WARNING: multiple messages have this Message-ID (diff)
From: Benjamin Herrenschmidt <benh-XVmvHMARGAS8U2dJNN8I7kB+6BGkLq7r@public.gmane.org>
To: Guenter Roeck <linux-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>,
	eajames.ibm-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org
Cc: devicetree-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-hwmon-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	linux-doc-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
	jdelvare-IBi9RG/b67k@public.gmane.org,
	corbet-T1hC0tSOHrs@public.gmane.org,
	mark.rutland-5wv7dgnIgG8@public.gmane.org,
	robh+dt-DgEjT+Ai2ygdnm+yROfE0A@public.gmane.org,
	wsa-z923LK4zBo2bacvFa/9K2g@public.gmane.org,
	andrew-zrmu5oMJ5Fs@public.gmane.org,
	joel-U3u1mxZcP9KHXe+LvDLADg@public.gmane.org,
	"Edward A. James"
	<eajames-r/Jw6+rmf7HQT0dZR+AlfA@public.gmane.org>
Subject: Re: [PATCH linux v3 3/6] hwmon: occ: Add I2C transport implementation for SCOM operations
Date: Sun, 22 Jan 2017 07:53:17 +1100	[thread overview]
Message-ID: <1485031997.2495.4.camel@kernel.crashing.org> (raw)
In-Reply-To: <b47e5359-5587-cc89-43e2-379eb9e95fc8-0h96xk9xTtrk1uMJSBkQmQ@public.gmane.org>

On Sat, 2017-01-21 at 10:11 -0800, Guenter Roeck wrote:
> > +int occ_i2c_getscom(void *bus, u32 address, u64 *data)
> > +{
> > +     ssize_t rc;
> > +     u64 buf;
> > +     struct i2c_client *client = bus;
> > +
> > +     rc = i2c_master_send(client, (const char *)&address,
> > sizeof(u32));
> > +     if (rc < 0)
> > +             return rc;
> > +     else if (rc != sizeof(u32))
> > +             return -EIO;
> > +
> > +     rc = i2c_master_recv(client, (char *)&buf, sizeof(u64));
> > +     if (rc < 0)
> > +             return rc;
> > +     else if (rc != sizeof(u64))
> > +             return -EIO;
> > +
> > +     *data = be64_to_cpu(buf);
> > +
> > +     return 0;
> > +}
> > +EXPORT_SYMBOL(occ_i2c_getscom);

Additionally, this assumes that is is the only other user of that i2c
path to P8. Something interleaving will break it. pdbg for example.

Talk to Alistair, the right thing here would probably be to have
a separate driver that provides the XSCOM interface via i2c to both
in-kernel and userspace, with proper arbitration.

An expedient might be to instead have the address and data cycles
of the above be 2 i2c messages in one i2c request, thus being
serialized somewhat atomically with other transactions to that i2c
bus.

You may need to make sure the underlying i2c controller driver supports
dual messages, and if it doesn't fix it. This is rather classic 4-bytes 
subaddress style i2c, it shouldn't be too hard.

Cheers,
Ben.

--
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

  reply	other threads:[~2017-01-21 20:54 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-16 21:13 [PATCH linux v3 0/6] drivers: hwmon: Add On-Chip Controller driver eajames.ibm
2017-01-16 21:13 ` [PATCH linux v3 1/6] hwmon: Add core On-Chip Controller support for POWER CPUs eajames.ibm
2017-01-16 21:13   ` eajames.ibm-Re5JQEeQqe8AvxtiuMwx3w
2017-01-21 17:49   ` Guenter Roeck
2017-01-23 19:28     ` Edward James
2017-01-23 20:21       ` Guenter Roeck
2017-01-23 20:58         ` Edward James
2017-01-16 21:13 ` [PATCH linux v3 2/6] hwmon: occ: Add sysfs interface eajames.ibm
2017-01-21 18:08   ` Guenter Roeck
2017-01-21 18:08     ` Guenter Roeck
2017-01-23 22:01     ` Edward James
2017-01-23 22:15       ` Guenter Roeck
2017-01-23 22:34         ` Edward James
2017-01-16 21:13 ` [PATCH linux v3 3/6] hwmon: occ: Add I2C transport implementation for SCOM operations eajames.ibm
2017-01-21 18:11   ` Guenter Roeck
2017-01-21 18:11     ` Guenter Roeck
2017-01-21 20:53     ` Benjamin Herrenschmidt [this message]
2017-01-21 20:53       ` Benjamin Herrenschmidt
2017-01-24  0:00       ` Edward James
2017-01-23 23:57     ` Edward James
2017-01-25 23:51     ` Edward James
2017-01-16 21:13 ` [PATCH linux v3 4/6] hwmon: occ: Add callbacks for parsing P8 OCC datastructures eajames.ibm
2017-01-21 18:18   ` Guenter Roeck
2017-01-23 23:48     ` Edward James
2017-01-16 21:13 ` [PATCH linux v3 5/6] hwmon: occ: Add hwmon implementation for the P8 OCC eajames.ibm
2017-01-19 17:12   ` Rob Herring
2017-01-29 19:28   ` kbuild test robot
2017-01-16 21:13 ` [PATCH linux v3 6/6] hwmon: occ: Add callbacks for parsing P9 OCC datastructures eajames.ibm

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=1485031997.2495.4.camel@kernel.crashing.org \
    --to=benh@kernel.crashing.org \
    --cc=andrew@aj.id.au \
    --cc=corbet@lwn.net \
    --cc=devicetree@vger.kernel.org \
    --cc=eajames.ibm@gmail.com \
    --cc=eajames@us.ibm.com \
    --cc=jdelvare@suse.com \
    --cc=joel@jms.id.au \
    --cc=linux-doc@vger.kernel.org \
    --cc=linux-hwmon@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@roeck-us.net \
    --cc=mark.rutland@arm.com \
    --cc=robh+dt@kernel.org \
    --cc=wsa@the-dreams.de \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.