From: "Poosa, Karthik" <karthik.poosa@intel.com>
To: Rodrigo Vivi <rodrigo.vivi@intel.com>,
Alexander Usyskin <alexander.usyskin@intel.com>
Cc: "Miquel Raynal" <miquel.raynal@bootlin.com>,
"Richard Weinberger" <richard@nod.at>,
"Vignesh Raghavendra" <vigneshr@ti.com>,
"Lucas De Marchi" <lucas.demarchi@intel.com>,
"Thomas Hellström" <thomas.hellstrom@linux.intel.com>,
"Maarten Lankhorst" <maarten.lankhorst@linux.intel.com>,
"Maxime Ripard" <mripard@kernel.org>,
"Thomas Zimmermann" <tzimmermann@suse.de>,
"David Airlie" <airlied@gmail.com>,
"Simona Vetter" <simona@ffwll.ch>,
"Jani Nikula" <jani.nikula@linux.intel.com>,
"Joonas Lahtinen" <joonas.lahtinen@linux.intel.com>,
"Tvrtko Ursulin" <tursulin@ursulin.net>,
"Reuven Abliyev" <reuven.abliyev@intel.com>,
"Oren Weil" <oren.jer.weil@intel.com>,
linux-mtd@lists.infradead.org, dri-devel@lists.freedesktop.org,
intel-gfx@lists.freedesktop.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH v4 07/11] mtd: intel-dg: wake card on operations
Date: Tue, 11 Feb 2025 11:02:03 +0530 [thread overview]
Message-ID: <bc54d970-6ea6-4ed4-b39b-c75a49a9b705@intel.com> (raw)
In-Reply-To: <Z5qiyRzkdgwQ9kTP@intel.com>
On 30-01-2025 03:21, Rodrigo Vivi wrote:
> On Wed, Jan 01, 2025 at 05:39:21PM +0200, Alexander Usyskin wrote:
>> Enable runtime PM in mtd driver to notify graphics driver that
>> whole card should be kept awake while nvm operations are
>> performed through this driver.
>>
>> CC: Lucas De Marchi <lucas.demarchi@intel.com>
>> Acked-by: Miquel Raynal <miquel.raynal@bootlin.com>
>> Signed-off-by: Alexander Usyskin <alexander.usyskin@intel.com>
>> ---
>> drivers/mtd/devices/mtd-intel-dg.c | 79 +++++++++++++++++++++++++-----
>> 1 file changed, 67 insertions(+), 12 deletions(-)
>>
>> diff --git a/drivers/mtd/devices/mtd-intel-dg.c b/drivers/mtd/devices/mtd-intel-dg.c
>> index 230bf444b7fe..a84153812291 100644
>> --- a/drivers/mtd/devices/mtd-intel-dg.c
>> +++ b/drivers/mtd/devices/mtd-intel-dg.c
>> @@ -15,11 +15,14 @@
>> #include <linux/module.h>
>> #include <linux/mtd/mtd.h>
>> #include <linux/mtd/partitions.h>
>> +#include <linux/pm_runtime.h>
>> #include <linux/string.h>
>> #include <linux/slab.h>
>> #include <linux/sizes.h>
>> #include <linux/types.h>
>>
>> +#define INTEL_DG_NVM_RPM_TIMEOUT 500
>> +
>> struct intel_dg_nvm {
>> struct kref refcnt;
>> struct mtd_info mtd;
>> @@ -460,6 +463,7 @@ static int intel_dg_mtd_erase(struct mtd_info *mtd, struct erase_info *info)
>> loff_t from;
>> size_t len;
>> size_t total_len;
>> + int ret = 0;
>>
>> if (WARN_ON(!nvm))
>> return -EINVAL;
>> @@ -474,20 +478,28 @@ static int intel_dg_mtd_erase(struct mtd_info *mtd, struct erase_info *info)
>> total_len = info->len;
>> addr = info->addr;
>>
>> + ret = pm_runtime_resume_and_get(&mtd->dev);
> I'm glad we are not accessing the parent directly here anymore,
> but to me it is still strange.
> I feel that we should be using &aux_dev->dev; instead of mtd->dev.
>
> What am I missing?
>
>> + if (ret < 0) {
>> + dev_err(&mtd->dev, "rpm: get failed %d\n", ret);
>> + return ret;
>> + }
>> +
>> guard(mutex)(&nvm->lock);
>>
>> while (total_len > 0) {
>> if (!IS_ALIGNED(addr, SZ_4K) || !IS_ALIGNED(total_len, SZ_4K)) {
>> dev_err(&mtd->dev, "unaligned erase %llx %zx\n", addr, total_len);
>> info->fail_addr = addr;
>> - return -ERANGE;
>> + ret = -ERANGE;
>> + goto out;
>> }
>>
>> idx = idg_nvm_get_region(nvm, addr);
>> if (idx >= nvm->nregions) {
>> dev_err(&mtd->dev, "out of range");
>> info->fail_addr = MTD_FAIL_ADDR_UNKNOWN;
>> - return -ERANGE;
>> + ret = -ERANGE;
>> + goto out;
>> }
>>
>> from = addr - nvm->regions[idx].offset;
>> @@ -503,14 +515,18 @@ static int intel_dg_mtd_erase(struct mtd_info *mtd, struct erase_info *info)
>> if (bytes < 0) {
>> dev_dbg(&mtd->dev, "erase failed with %zd\n", bytes);
>> info->fail_addr += nvm->regions[idx].offset;
>> - return bytes;
>> + ret = bytes;
>> + goto out;
>> }
>>
>> addr += len;
>> total_len -= len;
>> }
>>
>> - return 0;
>> +out:
>> + pm_runtime_mark_last_busy(&mtd->dev);
>> + pm_runtime_put_autosuspend(&mtd->dev);
>> + return ret;
>> }
>>
>> static int intel_dg_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
>> @@ -539,17 +555,25 @@ static int intel_dg_mtd_read(struct mtd_info *mtd, loff_t from, size_t len,
>> if (len > nvm->regions[idx].size - from)
>> len = nvm->regions[idx].size - from;
>>
>> + ret = pm_runtime_resume_and_get(&mtd->dev);
>> + if (ret < 0) {
>> + dev_err(&mtd->dev, "rpm: get failed %zd\n", ret);
>> + return ret;
>> + }
>> +
>> guard(mutex)(&nvm->lock);
>>
>> ret = idg_read(nvm, region, from, len, buf);
>> if (ret < 0) {
>> dev_dbg(&mtd->dev, "read failed with %zd\n", ret);
>> - return ret;
>> + } else {
>> + *retlen = ret;
>> + ret = 0;
>> }
>>
>> - *retlen = ret;
>> -
>> - return 0;
>> + pm_runtime_mark_last_busy(&mtd->dev);
>> + pm_runtime_put_autosuspend(&mtd->dev);
>> + return ret;
>> }
>>
>> static int intel_dg_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
>> @@ -578,17 +602,25 @@ static int intel_dg_mtd_write(struct mtd_info *mtd, loff_t to, size_t len,
>> if (len > nvm->regions[idx].size - to)
>> len = nvm->regions[idx].size - to;
>>
>> + ret = pm_runtime_resume_and_get(&mtd->dev);
>> + if (ret < 0) {
>> + dev_err(&mtd->dev, "rpm: get failed %zd\n", ret);
>> + return ret;
>> + }
>> +
>> guard(mutex)(&nvm->lock);
>>
>> ret = idg_write(nvm, region, to, len, buf);
>> if (ret < 0) {
>> dev_dbg(&mtd->dev, "write failed with %zd\n", ret);
>> - return ret;
>> + } else {
>> + *retlen = ret;
>> + ret = 0;
>> }
>>
>> - *retlen = ret;
>> -
>> - return 0;
>> + pm_runtime_mark_last_busy(&mtd->dev);
>> + pm_runtime_put_autosuspend(&mtd->dev);
>> + return ret;
>> }
>>
>> static void intel_dg_nvm_release(struct kref *kref)
>> @@ -670,6 +702,15 @@ static int intel_dg_nvm_init_mtd(struct intel_dg_nvm *nvm, struct device *device
>>
>> kfree(parts);
>>
>> + if (ret)
>> + goto out;
>> +
>> + devm_pm_runtime_enable(&nvm->mtd.dev);
>> +
>> + pm_runtime_set_autosuspend_delay(&nvm->mtd.dev, INTEL_DG_NVM_RPM_TIMEOUT);
>> + pm_runtime_use_autosuspend(&nvm->mtd.dev);
>> +
>> +out:
>> return ret;
>> }
>>
>> @@ -720,6 +761,17 @@ static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev,
>> n++;
>> }
>>
>> + devm_pm_runtime_enable(device);
>> +
>> + pm_runtime_set_autosuspend_delay(device, INTEL_DG_NVM_RPM_TIMEOUT);
>> + pm_runtime_use_autosuspend(device);
>> +
>> + ret = pm_runtime_resume_and_get(device);
>> + if (ret < 0) {
>> + dev_err(device, "rpm: get failed %d\n", ret);
>> + goto err_norpm;
>> + }
>> +
>> nvm->base = devm_ioremap_resource(device, &invm->bar);
>> if (IS_ERR(nvm->base)) {
>> dev_err(device, "mmio not mapped\n");
>> @@ -742,9 +794,12 @@ static int intel_dg_mtd_probe(struct auxiliary_device *aux_dev,
>>
>> dev_set_drvdata(&aux_dev->dev, nvm);
>>
>> + pm_runtime_put(device);
>> return 0;
>>
>> err:
>> + pm_runtime_put(device);
>> +err_norpm:
>> kref_put(&nvm->refcnt, intel_dg_nvm_release);
>> return ret;
>> }
>> --
>> 2.43.0
Acked-by: Karthik Poosa <karthik.poosa@intel.com>
______________________________________________________
Linux MTD discussion mailing list
http://lists.infradead.org/mailman/listinfo/linux-mtd/
next prev parent reply other threads:[~2025-02-11 6:40 UTC|newest]
Thread overview: 31+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-01-01 15:39 [PATCH v4 00/11] mtd: add driver for Intel discrete graphics Alexander Usyskin
2025-01-01 15:39 ` [PATCH v4 01/11] mtd: core: always create master device Alexander Usyskin
2025-01-06 10:46 ` Miquel Raynal
2025-01-06 11:03 ` Usyskin, Alexander
2025-01-14 14:05 ` Usyskin, Alexander
2025-01-15 19:22 ` Miquel Raynal
2025-01-15 22:30 ` Richard Weinberger
2025-01-16 6:54 ` Usyskin, Alexander
2025-01-17 22:27 ` Richard Weinberger
2025-01-19 7:30 ` Usyskin, Alexander
2025-01-01 15:39 ` [PATCH v4 02/11] mtd: add driver for intel graphics non-volatile memory device Alexander Usyskin
2025-01-02 10:32 ` Christophe JAILLET
2025-01-02 13:20 ` Usyskin, Alexander
2025-01-01 15:39 ` [PATCH v4 03/11] mtd: intel-dg: implement region enumeration Alexander Usyskin
2025-01-02 10:37 ` Christophe JAILLET
2025-01-02 10:49 ` Usyskin, Alexander
2025-01-01 15:39 ` [PATCH v4 04/11] mtd: intel-dg: implement access functions Alexander Usyskin
2025-01-01 15:39 ` [PATCH v4 05/11] mtd: intel-dg: register with mtd Alexander Usyskin
2025-01-01 15:39 ` [PATCH v4 06/11] mtd: intel-dg: align 64bit read and write Alexander Usyskin
2025-01-01 16:41 ` David Laight
2025-01-01 21:16 ` David Laight
2025-01-02 13:56 ` Usyskin, Alexander
2025-01-01 15:39 ` [PATCH v4 07/11] mtd: intel-dg: wake card on operations Alexander Usyskin
2025-01-29 21:51 ` Rodrigo Vivi
2025-02-11 5:32 ` Poosa, Karthik [this message]
2025-02-12 14:15 ` Usyskin, Alexander
2025-01-01 15:39 ` [PATCH v4 08/11] drm/i915/nvm: add nvm device for discrete graphics Alexander Usyskin
2025-01-01 15:39 ` [PATCH v4 09/11] drm/i915/nvm: add support for access mode Alexander Usyskin
2025-01-01 15:39 ` [PATCH v4 10/11] drm/xe/nvm: add on-die non-volatile memory device Alexander Usyskin
2025-01-29 21:36 ` Rodrigo Vivi
2025-01-01 15:39 ` [PATCH v4 11/11] drm/xe/nvm: add support for access mode Alexander Usyskin
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=bc54d970-6ea6-4ed4-b39b-c75a49a9b705@intel.com \
--to=karthik.poosa@intel.com \
--cc=airlied@gmail.com \
--cc=alexander.usyskin@intel.com \
--cc=dri-devel@lists.freedesktop.org \
--cc=intel-gfx@lists.freedesktop.org \
--cc=jani.nikula@linux.intel.com \
--cc=joonas.lahtinen@linux.intel.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-mtd@lists.infradead.org \
--cc=lucas.demarchi@intel.com \
--cc=maarten.lankhorst@linux.intel.com \
--cc=miquel.raynal@bootlin.com \
--cc=mripard@kernel.org \
--cc=oren.jer.weil@intel.com \
--cc=reuven.abliyev@intel.com \
--cc=richard@nod.at \
--cc=rodrigo.vivi@intel.com \
--cc=simona@ffwll.ch \
--cc=thomas.hellstrom@linux.intel.com \
--cc=tursulin@ursulin.net \
--cc=tzimmermann@suse.de \
--cc=vigneshr@ti.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox