All of lore.kernel.org
 help / color / mirror / Atom feed
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Vinod Koul <vinod.koul@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Jarkko Nikula <jarkko.nikula@linux.intel.com>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH v2 8/8] mfd: Add support for Intel Sunrisepoint LPSS devices
Date: Fri, 29 May 2015 13:03:15 +0300	[thread overview]
Message-ID: <1432893795.26331.21.camel@linux.intel.com> (raw)
In-Reply-To: <20150528131051.GR11677@x1>

On Thu, 2015-05-28 at 14:10 +0100, Lee Jones wrote:
> On Thu, 28 May 2015, Andy Shevchenko wrote:
> > On Wed, 2015-05-27 at 11:22 +0100, Lee Jones wrote:
> > > On Mon, 25 May 2015, Andy Shevchenko wrote:

[]

> > > > +	intel_lpss_ltr_expose(lpss);
> > > > +
> > > > +	ret = intel_lpss_debugfs_add(lpss);
> > > > +	if (ret)
> > > > +		dev_warn(lpss->dev, "Failed to create debugfs entries\n");
> > > > +
> > > > +	if (intel_lpss_has_idma(lpss)) {
> > > > +		/*
> > > > +		 * Ensure the DMA driver is loaded before the host
> > > > +		 * controller device appears, so that the host controller
> > > > +		 * driver can request its DMA channels as early as
> > > > +		 * possible.
> > > > +		 *
> > > > +		 * If the DMA module is not there that's OK as well.
> > > > +		 */
> > > > +		intel_lpss_request_dma_module(LPSS_IDMA_DRIVER_NAME);
> > > > +
> > > > +		ret = mfd_add_devices(dev, lpss->devid, lpss->devs, 2,
> > > > +				      info->mem, info->irq, NULL);
> > > > +	} else {
> > > > +		ret = mfd_add_devices(dev, lpss->devid, lpss->devs + 1, 1,
> > > > +				      info->mem, info->irq, NULL);
> > > > +	}
> > > 
> > > I'm still not happy with the mfd_cells being manipulated in this way,
> > > or with the duplication you have within them.  Why don't you place the
> > > IDMA device it its own mfd_cell, then:
> > > 
> > > > +	if (intel_lpss_has_idma(lpss)) {
> > > > +		intel_lpss_request_dma_module(LPSS_IDMA_DRIVER_NAME);
> > > > +
> > > > +		ret = mfd_add_devices(dev, TBC, idma_dev, ARRAY_SIZE(idma_dev),
> > > > +				      info->mem, info->irq, NULL);
> > > > +             /* Error check */
> > > > +	}
> > > > +
> > > > +	ret = mfd_add_devices(dev, TBC, proto_dev, ARRAY_SIZE(proto_dev),
> > > > +				      info->mem, info->irq, NULL);
> > 
> > Would be nicer to export mfd_add_device() in that case?
> 
> What do you mean by export?  What's wrong with using this code
> segment?

I took a closer look into this, indeed, we can call mfd_add_devices() as
many time as we want to add a new child device.

Will refactor this piece of code.

> > > > +#ifdef CONFIG_PM_SLEEP
> > > > +#define INTEL_LPSS_SLEEP_PM_OPS			\
> > > > +	.prepare = intel_lpss_prepare,		\
> > > > +	.suspend = intel_lpss_suspend,		\
> > > > +	.resume = intel_lpss_resume,		\
> > > > +	.freeze = intel_lpss_suspend,		\
> > > > +	.thaw = intel_lpss_resume,		\
> > > > +	.poweroff = intel_lpss_suspend,		\
> > > > +	.restore = intel_lpss_resume,
> > > > +#endif
> > > > +
> > > > +#define INTEL_LPSS_RUNTIME_PM_OPS		\
> > > > +	.runtime_suspend = intel_lpss_suspend,	\
> > > > +	.runtime_resume = intel_lpss_resume,
> > > > +
> > > > +#else /* !CONFIG_PM */
> > > > +#define INTEL_LPSS_SLEEP_PM_OPS
> > > > +#define INTEL_LPSS_RUNTIME_PM_OPS
> > > > +#endif /* CONFIG_PM */
> > > > +
> > > > +#define INTEL_LPSS_PM_OPS(name)			\
> > > > +const struct dev_pm_ops name = {		\
> > > > +	INTEL_LPSS_SLEEP_PM_OPS			\
> > > > +	INTEL_LPSS_RUNTIME_PM_OPS		\
> > 
> > > If you _really_ need .prepare, then it's likely that some other
> > > platform might too.  It will be the same amount of code to just make
> > > this generic, so do that instead please.
> > 
> > In 'linux/pm.h' ->prepare() is excluded since it's quite exotic to be 
> > in device drivers. That is my understanding why it makes not much sense
> > to provide a generic definition for that.
> > 
> > $ git grep -n '\.prepare[ \t]*=.*pm' drivers/ | wc -l
> > 33
> > $ git grep -n SET_SYSTEM_SLEEP_PM_OPS drivers/ | wc -l
> > 114
> > $ git grep -n UNIVERSAL_DEV_PM_OPS drivers/ | wc -l
> > 9
> > …and there are a lot of drivers (hundreds+) that do
> > not use mentioned macros, and has no ->prepare() callback defined.
> > 
> > I can try to summon up Rafael to clarify this.
> 
> Yes, let's do that, as I'd like a second opinion on this, thanks.

Rafael, it would be nice to have your input here.

-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy

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

WARNING: multiple messages have this Message-ID (diff)
From: Andy Shevchenko <andriy.shevchenko@linux.intel.com>
To: Lee Jones <lee.jones@linaro.org>
Cc: "Rafael J. Wysocki" <rjw@rjwysocki.net>,
	linux-acpi@vger.kernel.org, linux-pm@vger.kernel.org,
	Greg Kroah-Hartman <gregkh@linuxfoundation.org>,
	Vinod Koul <vinod.koul@intel.com>,
	Andrew Morton <akpm@linux-foundation.org>,
	Mika Westerberg <mika.westerberg@linux.intel.com>,
	linux-kernel@vger.kernel.org, dmaengine@vger.kernel.org,
	Heikki Krogerus <heikki.krogerus@linux.intel.com>,
	Jarkko Nikula <jarkko.nikula@linux.intel.com>,
	"Wysocki, Rafael J" <rafael.j.wysocki@intel.com>
Subject: Re: [PATCH v2 8/8] mfd: Add support for Intel Sunrisepoint LPSS devices
Date: Fri, 29 May 2015 13:03:15 +0300	[thread overview]
Message-ID: <1432893795.26331.21.camel@linux.intel.com> (raw)
In-Reply-To: <20150528131051.GR11677@x1>

On Thu, 2015-05-28 at 14:10 +0100, Lee Jones wrote:
> On Thu, 28 May 2015, Andy Shevchenko wrote:
> > On Wed, 2015-05-27 at 11:22 +0100, Lee Jones wrote:
> > > On Mon, 25 May 2015, Andy Shevchenko wrote:

[]

> > > > +	intel_lpss_ltr_expose(lpss);
> > > > +
> > > > +	ret = intel_lpss_debugfs_add(lpss);
> > > > +	if (ret)
> > > > +		dev_warn(lpss->dev, "Failed to create debugfs entries\n");
> > > > +
> > > > +	if (intel_lpss_has_idma(lpss)) {
> > > > +		/*
> > > > +		 * Ensure the DMA driver is loaded before the host
> > > > +		 * controller device appears, so that the host controller
> > > > +		 * driver can request its DMA channels as early as
> > > > +		 * possible.
> > > > +		 *
> > > > +		 * If the DMA module is not there that's OK as well.
> > > > +		 */
> > > > +		intel_lpss_request_dma_module(LPSS_IDMA_DRIVER_NAME);
> > > > +
> > > > +		ret = mfd_add_devices(dev, lpss->devid, lpss->devs, 2,
> > > > +				      info->mem, info->irq, NULL);
> > > > +	} else {
> > > > +		ret = mfd_add_devices(dev, lpss->devid, lpss->devs + 1, 1,
> > > > +				      info->mem, info->irq, NULL);
> > > > +	}
> > > 
> > > I'm still not happy with the mfd_cells being manipulated in this way,
> > > or with the duplication you have within them.  Why don't you place the
> > > IDMA device it its own mfd_cell, then:
> > > 
> > > > +	if (intel_lpss_has_idma(lpss)) {
> > > > +		intel_lpss_request_dma_module(LPSS_IDMA_DRIVER_NAME);
> > > > +
> > > > +		ret = mfd_add_devices(dev, TBC, idma_dev, ARRAY_SIZE(idma_dev),
> > > > +				      info->mem, info->irq, NULL);
> > > > +             /* Error check */
> > > > +	}
> > > > +
> > > > +	ret = mfd_add_devices(dev, TBC, proto_dev, ARRAY_SIZE(proto_dev),
> > > > +				      info->mem, info->irq, NULL);
> > 
> > Would be nicer to export mfd_add_device() in that case?
> 
> What do you mean by export?  What's wrong with using this code
> segment?

I took a closer look into this, indeed, we can call mfd_add_devices() as
many time as we want to add a new child device.

Will refactor this piece of code.

> > > > +#ifdef CONFIG_PM_SLEEP
> > > > +#define INTEL_LPSS_SLEEP_PM_OPS			\
> > > > +	.prepare = intel_lpss_prepare,		\
> > > > +	.suspend = intel_lpss_suspend,		\
> > > > +	.resume = intel_lpss_resume,		\
> > > > +	.freeze = intel_lpss_suspend,		\
> > > > +	.thaw = intel_lpss_resume,		\
> > > > +	.poweroff = intel_lpss_suspend,		\
> > > > +	.restore = intel_lpss_resume,
> > > > +#endif
> > > > +
> > > > +#define INTEL_LPSS_RUNTIME_PM_OPS		\
> > > > +	.runtime_suspend = intel_lpss_suspend,	\
> > > > +	.runtime_resume = intel_lpss_resume,
> > > > +
> > > > +#else /* !CONFIG_PM */
> > > > +#define INTEL_LPSS_SLEEP_PM_OPS
> > > > +#define INTEL_LPSS_RUNTIME_PM_OPS
> > > > +#endif /* CONFIG_PM */
> > > > +
> > > > +#define INTEL_LPSS_PM_OPS(name)			\
> > > > +const struct dev_pm_ops name = {		\
> > > > +	INTEL_LPSS_SLEEP_PM_OPS			\
> > > > +	INTEL_LPSS_RUNTIME_PM_OPS		\
> > 
> > > If you _really_ need .prepare, then it's likely that some other
> > > platform might too.  It will be the same amount of code to just make
> > > this generic, so do that instead please.
> > 
> > In 'linux/pm.h' ->prepare() is excluded since it's quite exotic to be 
> > in device drivers. That is my understanding why it makes not much sense
> > to provide a generic definition for that.
> > 
> > $ git grep -n '\.prepare[ \t]*=.*pm' drivers/ | wc -l
> > 33
> > $ git grep -n SET_SYSTEM_SLEEP_PM_OPS drivers/ | wc -l
> > 114
> > $ git grep -n UNIVERSAL_DEV_PM_OPS drivers/ | wc -l
> > 9
> > …and there are a lot of drivers (hundreds+) that do
> > not use mentioned macros, and has no ->prepare() callback defined.
> > 
> > I can try to summon up Rafael to clarify this.
> 
> Yes, let's do that, as I'd like a second opinion on this, thanks.

Rafael, it would be nice to have your input here.

-- 
Andy Shevchenko <andriy.shevchenko@intel.com>
Intel Finland Oy


  reply	other threads:[~2015-05-29 10:03 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-05-25 16:09 [PATCH v2 0/8] mfd: introduce a driver for LPSS devices on SPT Andy Shevchenko
2015-05-25 16:09 ` [PATCH v2 1/8] PM / QoS: Make it possible to expose device latency tolerance to userspace Andy Shevchenko
2015-05-25 16:09 ` [PATCH v2 2/8] ACPI / PM: Attach ACPI power domain only once Andy Shevchenko
2015-05-25 16:09 ` [PATCH v2 3/8] core: platform: wakeup the parent before trying any driver operations Andy Shevchenko
2015-05-25 17:36   ` Alan Stern
2015-05-25 17:36     ` Alan Stern
2015-05-26 13:28     ` Heikki Krogerus
2015-05-26  4:04   ` Vinod Koul
2015-05-25 16:09 ` [PATCH v2 4/8] klist: implement klist_prev() Andy Shevchenko
2015-06-01  1:21   ` Greg Kroah-Hartman
2015-05-25 16:09 ` [PATCH v2 5/8] driver core: implement device_for_each_child_reverse() Andy Shevchenko
2015-06-01  1:21   ` Greg Kroah-Hartman
2015-05-25 16:09 ` [PATCH v2 6/8] mfd: make mfd_remove_devices() iterate in reverse order Andy Shevchenko
2015-05-25 16:09 ` [PATCH v2 7/8] dmaengine: add a driver for Intel integrated DMA 64-bit Andy Shevchenko
2015-05-26  4:06   ` Vinod Koul
2015-05-26  6:49     ` Andy Shevchenko
2015-06-02 12:49       ` Vinod Koul
2015-05-25 16:09 ` [PATCH v2 8/8] mfd: Add support for Intel Sunrisepoint LPSS devices Andy Shevchenko
2015-05-27 10:22   ` Lee Jones
2015-05-27 10:22     ` Lee Jones
2015-05-27 10:41     ` Mika Westerberg
2015-05-28 11:17     ` Andy Shevchenko
2015-05-28 11:17       ` Andy Shevchenko
2015-05-28 13:10       ` Lee Jones
2015-05-29 10:03         ` Andy Shevchenko [this message]
2015-05-29 10:03           ` Andy Shevchenko
2015-05-26  3:51 ` [PATCH v2 0/8] mfd: introduce a driver for LPSS devices on SPT Vinod Koul
2015-05-26  6:51   ` Andy Shevchenko

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=1432893795.26331.21.camel@linux.intel.com \
    --to=andriy.shevchenko@linux.intel.com \
    --cc=akpm@linux-foundation.org \
    --cc=dmaengine@vger.kernel.org \
    --cc=gregkh@linuxfoundation.org \
    --cc=heikki.krogerus@linux.intel.com \
    --cc=jarkko.nikula@linux.intel.com \
    --cc=lee.jones@linaro.org \
    --cc=linux-acpi@vger.kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux-pm@vger.kernel.org \
    --cc=mika.westerberg@linux.intel.com \
    --cc=rafael.j.wysocki@intel.com \
    --cc=rjw@rjwysocki.net \
    --cc=vinod.koul@intel.com \
    /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.