From: Lijun Pan <lijun.pan@intel.com>
To: Rex Zhang <rex.zhang@intel.com>, <vkoul@kernel.org>,
<dmaengine@vger.kernel.org>
Cc: <dave.jiang@intel.com>, <fenghua.yu@intel.com>
Subject: Re: [PATCH] dmaengine: idxd: Move dma_free_coherent() out of spinlocked context
Date: Tue, 12 Dec 2023 09:37:33 -0600 [thread overview]
Message-ID: <2fdec011-695a-43fd-81d0-24aa7fee39da@intel.com> (raw)
In-Reply-To: <20231212022158.358619-1-rex.zhang@intel.com>
On 12/11/2023 8:21 PM, Rex Zhang wrote:
> Task may be rescheduled within dma_free_coherent(). So dma_free_coherent()
> can't be called between spin_lock() and spin_unlock() to avoid Call Trace:
> Call Trace:
> <TASK>
> dump_stack_lvl+0x37/0x50
> __might_resched+0x16a/0x1c0
> vunmap+0x2c/0x70
> __iommu_dma_free+0x96/0x100
> idxd_device_evl_free+0xd5/0x100 [idxd]
> device_release_driver_internal+0x197/0x200
> unbind_store+0xa1/0xb0
> kernfs_fop_write_iter+0x120/0x1c0
> vfs_write+0x2d3/0x400
> ksys_write+0x63/0xe0
> do_syscall_64+0x44/0xa0
> entry_SYSCALL_64_after_hwframe+0x6e/0xd8
> Move it out of the context.
>
> Fixes: 244da66cda35 ("dmaengine: idxd: setup event log configuration")
> Signed-off-by: Rex Zhang <rex.zhang@intel.com>
> Reviewed-by: Dave Jiang <dave.jiang@intel.com>
> Reviewed-by: Fenghua Yu <fenghua.yu@intel.com>
> ---
Reviewed-by: Lijun Pan <lijun.pan@intel.com>
> drivers/dma/idxd/device.c | 9 ++++++++-
> 1 file changed, 8 insertions(+), 1 deletion(-)
>
> diff --git a/drivers/dma/idxd/device.c b/drivers/dma/idxd/device.c
> index 8f754f922217..fa0f880beae6 100644
> --- a/drivers/dma/idxd/device.c
> +++ b/drivers/dma/idxd/device.c
> @@ -802,6 +802,9 @@ static int idxd_device_evl_setup(struct idxd_device *idxd)
>
> static void idxd_device_evl_free(struct idxd_device *idxd)
> {
> + void *evl_log;
> + unsigned int evl_log_size;
> + dma_addr_t evl_dma;
> union gencfg_reg gencfg;
> union genctrl_reg genctrl;
> struct device *dev = &idxd->pdev->dev;
> @@ -822,11 +825,15 @@ static void idxd_device_evl_free(struct idxd_device *idxd)
> iowrite64(0, idxd->reg_base + IDXD_EVLCFG_OFFSET);
> iowrite64(0, idxd->reg_base + IDXD_EVLCFG_OFFSET + 8);
>
> - dma_free_coherent(dev, evl->log_size, evl->log, evl->dma);
> bitmap_free(evl->bmap);
> + evl_log = evl->log;
> + evl_log_size = evl->log_size;
> + evl_dma = evl->dma;
> evl->log = NULL;
> evl->size = IDXD_EVL_SIZE_MIN;
> spin_unlock(&evl->lock);
> +
> + dma_free_coherent(dev, evl_log_size, evl_log, evl_dma);
> }
>
> static void idxd_group_config_write(struct idxd_group *group)
prev parent reply other threads:[~2023-12-12 15:37 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2023-12-12 2:21 [PATCH] dmaengine: idxd: Move dma_free_coherent() out of spinlocked context Rex Zhang
2023-12-12 2:21 ` Rex Zhang
2023-12-21 16:30 ` Vinod Koul
2023-12-12 15:37 ` Lijun Pan [this message]
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=2fdec011-695a-43fd-81d0-24aa7fee39da@intel.com \
--to=lijun.pan@intel.com \
--cc=dave.jiang@intel.com \
--cc=dmaengine@vger.kernel.org \
--cc=fenghua.yu@intel.com \
--cc=rex.zhang@intel.com \
--cc=vkoul@kernel.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