Skip to content

Commit dae437d

Browse files
committed
Merge tag 'drm/tegra/for-6.3-rc1' of https://gitlab.freedesktop.org/drm/tegra into drm-next
drm/tegra: Changes for v6.3-rc1 This set of changes includes a rework of the custom syncpoint interrupt code to take better advantage of existing DRM/KMS infrastructure. There's also various bits of cleanup and fixes included. Signed-off-by: Dave Airlie <airlied@redhat.com> From: Thierry Reding <thierry.reding@gmail.com> Link: https://patchwork.freedesktop.org/patch/msgid/20230127170119.495943-1-thierry.reding@gmail.com
2 parents 54587d9 + 2abdd44 commit dae437d

26 files changed

Lines changed: 285 additions & 665 deletions

MAINTAINERS

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7040,7 +7040,7 @@ M: Thierry Reding <thierry.reding@gmail.com>
70407040
L: dri-devel@lists.freedesktop.org
70417041
L: linux-tegra@vger.kernel.org
70427042
S: Supported
7043-
T: git git://anongit.freedesktop.org/tegra/linux.git
7043+
T: git https://gitlab.freedesktop.org/drm/tegra.git
70447044
F: Documentation/devicetree/bindings/display/tegra/nvidia,tegra20-host1x.yaml
70457045
F: Documentation/devicetree/bindings/gpu/host1x/
70467046
F: drivers/gpu/drm/tegra/

drivers/gpu/drm/tegra/dpaux.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -598,7 +598,6 @@ static int tegra_dpaux_remove(struct platform_device *pdev)
598598
return 0;
599599
}
600600

601-
#ifdef CONFIG_PM
602601
static int tegra_dpaux_suspend(struct device *dev)
603602
{
604603
struct tegra_dpaux *dpaux = dev_get_drvdata(dev);
@@ -657,10 +656,9 @@ static int tegra_dpaux_resume(struct device *dev)
657656
clk_disable_unprepare(dpaux->clk);
658657
return err;
659658
}
660-
#endif
661659

662660
static const struct dev_pm_ops tegra_dpaux_pm_ops = {
663-
SET_RUNTIME_PM_OPS(tegra_dpaux_suspend, tegra_dpaux_resume, NULL)
661+
RUNTIME_PM_OPS(tegra_dpaux_suspend, tegra_dpaux_resume, NULL)
664662
};
665663

666664
static const struct tegra_dpaux_soc tegra124_dpaux_soc = {
@@ -694,7 +692,7 @@ struct platform_driver tegra_dpaux_driver = {
694692
.driver = {
695693
.name = "tegra-dpaux",
696694
.of_match_table = tegra_dpaux_of_match,
697-
.pm = &tegra_dpaux_pm_ops,
695+
.pm = pm_ptr(&tegra_dpaux_pm_ops),
698696
},
699697
.probe = tegra_dpaux_probe,
700698
.remove = tegra_dpaux_remove,

drivers/gpu/drm/tegra/firewall.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,9 @@ static int fw_check_regs_imm(struct tegra_drm_firewall *fw, u32 offset)
9797
{
9898
bool is_addr;
9999

100+
if (!fw->client->ops->is_addr_reg)
101+
return 0;
102+
100103
is_addr = fw->client->ops->is_addr_reg(fw->client->base.dev, fw->class,
101104
offset);
102105
if (is_addr)

drivers/gpu/drm/tegra/nvdec.c

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -67,26 +67,18 @@ static inline void nvdec_writel(struct nvdec *nvdec, u32 value,
6767

6868
static int nvdec_boot_falcon(struct nvdec *nvdec)
6969
{
70-
#ifdef CONFIG_IOMMU_API
71-
struct iommu_fwspec *spec = dev_iommu_fwspec_get(nvdec->dev);
72-
#endif
70+
u32 stream_id;
7371
int err;
7472

75-
#ifdef CONFIG_IOMMU_API
76-
if (nvdec->config->supports_sid && spec) {
73+
if (nvdec->config->supports_sid && tegra_dev_iommu_get_stream_id(nvdec->dev, &stream_id)) {
7774
u32 value;
7875

7976
value = TRANSCFG_ATT(1, TRANSCFG_SID_FALCON) | TRANSCFG_ATT(0, TRANSCFG_SID_HW);
8077
nvdec_writel(nvdec, value, NVDEC_TFBIF_TRANSCFG);
8178

82-
if (spec->num_ids > 0) {
83-
value = spec->ids[0] & 0xffff;
84-
85-
nvdec_writel(nvdec, value, VIC_THI_STREAMID0);
86-
nvdec_writel(nvdec, value, VIC_THI_STREAMID1);
87-
}
79+
nvdec_writel(nvdec, stream_id, VIC_THI_STREAMID0);
80+
nvdec_writel(nvdec, stream_id, VIC_THI_STREAMID1);
8881
}
89-
#endif
9082

9183
err = falcon_boot(&nvdec->falcon);
9284
if (err < 0)

drivers/gpu/drm/tegra/submit.c

Lines changed: 5 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -609,21 +609,13 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,
609609
host1x_memory_context_get(job->memory_context);
610610
}
611611
} else if (context->client->ops->get_streamid_offset) {
612-
#ifdef CONFIG_IOMMU_API
613-
struct iommu_fwspec *spec;
614-
615612
/*
616613
* Job submission will need to temporarily change stream ID,
617614
* so need to tell it what to change it back to.
618615
*/
619-
spec = dev_iommu_fwspec_get(context->client->base.dev);
620-
if (spec && spec->num_ids > 0)
621-
job->engine_fallback_streamid = spec->ids[0] & 0xffff;
622-
else
623-
job->engine_fallback_streamid = 0x7f;
624-
#else
625-
job->engine_fallback_streamid = 0x7f;
626-
#endif
616+
if (!tegra_dev_iommu_get_stream_id(context->client->base.dev,
617+
&job->engine_fallback_streamid))
618+
job->engine_fallback_streamid = TEGRA_STREAM_ID_BYPASS;
627619
}
628620

629621
/* Boot engine. */
@@ -654,7 +646,7 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,
654646
args->syncpt.value = job->syncpt_end;
655647

656648
if (syncobj) {
657-
struct dma_fence *fence = host1x_fence_create(job->syncpt, job->syncpt_end);
649+
struct dma_fence *fence = host1x_fence_create(job->syncpt, job->syncpt_end, true);
658650
if (IS_ERR(fence)) {
659651
err = PTR_ERR(fence);
660652
SUBMIT_ERR(context, "failed to create postfence: %d", err);
@@ -680,8 +672,7 @@ int tegra_drm_ioctl_channel_submit(struct drm_device *drm, void *data,
680672
kfree(job_data->used_mappings);
681673
}
682674

683-
if (job_data)
684-
kfree(job_data);
675+
kfree(job_data);
685676
put_bo:
686677
gather_bo_put(&bo->base);
687678
unlock:

drivers/gpu/drm/tegra/vic.c

Lines changed: 14 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -56,41 +56,30 @@ static void vic_writel(struct vic *vic, u32 value, unsigned int offset)
5656

5757
static int vic_boot(struct vic *vic)
5858
{
59-
#ifdef CONFIG_IOMMU_API
60-
struct iommu_fwspec *spec = dev_iommu_fwspec_get(vic->dev);
61-
#endif
62-
u32 fce_ucode_size, fce_bin_data_offset;
59+
u32 fce_ucode_size, fce_bin_data_offset, stream_id;
6360
void *hdr;
6461
int err = 0;
6562

66-
#ifdef CONFIG_IOMMU_API
67-
if (vic->config->supports_sid && spec) {
63+
if (vic->config->supports_sid && tegra_dev_iommu_get_stream_id(vic->dev, &stream_id)) {
6864
u32 value;
6965

7066
value = TRANSCFG_ATT(1, TRANSCFG_SID_FALCON) |
7167
TRANSCFG_ATT(0, TRANSCFG_SID_HW);
7268
vic_writel(vic, value, VIC_TFBIF_TRANSCFG);
7369

74-
if (spec->num_ids > 0) {
75-
value = spec->ids[0] & 0xffff;
76-
77-
/*
78-
* STREAMID0 is used for input/output buffers.
79-
* Initialize it to SID_VIC in case context isolation
80-
* is not enabled, and SID_VIC is used for both firmware
81-
* and data buffers.
82-
*
83-
* If context isolation is enabled, it will be
84-
* overridden by the SETSTREAMID opcode as part of
85-
* each job.
86-
*/
87-
vic_writel(vic, value, VIC_THI_STREAMID0);
88-
89-
/* STREAMID1 is used for firmware loading. */
90-
vic_writel(vic, value, VIC_THI_STREAMID1);
91-
}
70+
/*
71+
* STREAMID0 is used for input/output buffers. Initialize it to SID_VIC in case
72+
* context isolation is not enabled, and SID_VIC is used for both firmware and
73+
* data buffers.
74+
*
75+
* If context isolation is enabled, it will be overridden by the SETSTREAMID
76+
* opcode as part of each job.
77+
*/
78+
vic_writel(vic, stream_id, VIC_THI_STREAMID0);
79+
80+
/* STREAMID1 is used for firmware loading. */
81+
vic_writel(vic, stream_id, VIC_THI_STREAMID1);
9282
}
93-
#endif
9483

9584
/* setup clockgating registers */
9685
vic_writel(vic, CG_IDLE_CG_DLY_CNT(4) |

drivers/gpu/host1x/cdma.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -490,6 +490,15 @@ void host1x_cdma_update_sync_queue(struct host1x_cdma *cdma,
490490
host1x_hw_cdma_resume(host1x, cdma, restart_addr);
491491
}
492492

493+
static void cdma_update_work(struct work_struct *work)
494+
{
495+
struct host1x_cdma *cdma = container_of(work, struct host1x_cdma, update_work);
496+
497+
mutex_lock(&cdma->lock);
498+
update_cdma_locked(cdma);
499+
mutex_unlock(&cdma->lock);
500+
}
501+
493502
/*
494503
* Create a cdma
495504
*/
@@ -499,6 +508,7 @@ int host1x_cdma_init(struct host1x_cdma *cdma)
499508

500509
mutex_init(&cdma->lock);
501510
init_completion(&cdma->complete);
511+
INIT_WORK(&cdma->update_work, cdma_update_work);
502512

503513
INIT_LIST_HEAD(&cdma->sync_queue);
504514

@@ -679,7 +689,5 @@ void host1x_cdma_end(struct host1x_cdma *cdma,
679689
*/
680690
void host1x_cdma_update(struct host1x_cdma *cdma)
681691
{
682-
mutex_lock(&cdma->lock);
683-
update_cdma_locked(cdma);
684-
mutex_unlock(&cdma->lock);
692+
schedule_work(&cdma->update_work);
685693
}

drivers/gpu/host1x/cdma.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include <linux/sched.h>
1212
#include <linux/completion.h>
1313
#include <linux/list.h>
14+
#include <linux/workqueue.h>
1415

1516
struct host1x_syncpt;
1617
struct host1x_userctx_timeout;
@@ -69,6 +70,7 @@ struct host1x_cdma {
6970
struct buffer_timeout timeout; /* channel's timeout state/wq */
7071
bool running;
7172
bool torndown;
73+
struct work_struct update_work;
7274
};
7375

7476
#define cdma_to_channel(cdma) container_of(cdma, struct host1x_channel, cdma)

drivers/gpu/host1x/context.c

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,8 +35,6 @@ int host1x_memory_context_list_init(struct host1x *host1x)
3535
cdl->len = err / 4;
3636

3737
for (i = 0; i < cdl->len; i++) {
38-
struct iommu_fwspec *fwspec;
39-
4038
ctx = &cdl->devs[i];
4139

4240
ctx->host = host1x;
@@ -70,14 +68,12 @@ int host1x_memory_context_list_init(struct host1x *host1x)
7068
goto del_devices;
7169
}
7270

73-
fwspec = dev_iommu_fwspec_get(&ctx->dev);
74-
if (!fwspec || !device_iommu_mapped(&ctx->dev)) {
71+
if (!tegra_dev_iommu_get_stream_id(&ctx->dev, &ctx->stream_id) ||
72+
!device_iommu_mapped(&ctx->dev)) {
7573
dev_err(host1x->dev, "Context device %d has no IOMMU!\n", i);
7674
device_del(&ctx->dev);
7775
goto del_devices;
7876
}
79-
80-
ctx->stream_id = fwspec->ids[0] & 0xffff;
8177
}
8278

8379
return 0;

drivers/gpu/host1x/debug.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ static int show_channel(struct host1x_channel *ch, void *data, bool show_fifo)
7777

7878
static void show_syncpts(struct host1x *m, struct output *o, bool show_all)
7979
{
80+
unsigned long irqflags;
8081
struct list_head *pos;
8182
unsigned int i;
8283
int err;
@@ -92,10 +93,10 @@ static void show_syncpts(struct host1x *m, struct output *o, bool show_all)
9293
u32 min = host1x_syncpt_load(m->syncpt + i);
9394
unsigned int waiters = 0;
9495

95-
spin_lock(&m->syncpt[i].intr.lock);
96-
list_for_each(pos, &m->syncpt[i].intr.wait_head)
96+
spin_lock_irqsave(&m->syncpt[i].fences.lock, irqflags);
97+
list_for_each(pos, &m->syncpt[i].fences.list)
9798
waiters++;
98-
spin_unlock(&m->syncpt[i].intr.lock);
99+
spin_unlock_irqrestore(&m->syncpt[i].fences.lock, irqflags);
99100

100101
if (!kref_read(&m->syncpt[i].ref))
101102
continue;

0 commit comments

Comments
 (0)