[PATCH] drm/amd/display: Fix memory leaks in S3 resume

2020-11-09 Thread Stylon Wang
EDID parsing in S3 resume pushes new display modes
to probed_modes list but doesn't consolidate to actual
mode list. This creates a race condition when
amdgpu_dm_connector_ddc_get_modes() re-initializes the
list head without walking the list and results in  memory leak.

Signed-off-by: Stylon Wang 
---
 drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c 
b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
index 0b6adf23d316..715e0bd489f8 100644
--- a/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
+++ b/drivers/gpu/drm/amd/display/amdgpu_dm/amdgpu_dm.c
@@ -2337,7 +2337,8 @@ void amdgpu_dm_update_connector_after_detect(
 
drm_connector_update_edid_property(connector,
   aconnector->edid);
-   drm_add_edid_modes(connector, aconnector->edid);
+   aconnector->num_modes = drm_add_edid_modes(connector, 
aconnector->edid);
+   drm_connector_list_update(connector);
 
if (aconnector->dc_link->aux_mode)
drm_dp_cec_set_edid(>dm_dp_aux.aux,
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drm/ttm: fix missing NULL check in the new page pool

2020-11-09 Thread Martin Peres

On 09/11/2020 17:54, Alex Deucher wrote:

On Fri, Nov 6, 2020 at 9:10 AM Christian König
 wrote:


The pool parameter can be NULL if we free through the shrinker.

Signed-off-by: Christian König 


Does this fix:
https://gitlab.freedesktop.org/drm/amd/-/issues/1362


It does! So you can add my:

Tested-by: Martin Peres 
Acked-by: Martin Peres 

Thanks,
Martin



Acked-by: Alex Deucher 




---
  drivers/gpu/drm/ttm/ttm_pool.c | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/ttm/ttm_pool.c b/drivers/gpu/drm/ttm/ttm_pool.c
index 44ec41aa78d6..1b96780b4989 100644
--- a/drivers/gpu/drm/ttm/ttm_pool.c
+++ b/drivers/gpu/drm/ttm/ttm_pool.c
@@ -135,7 +135,7 @@ static void ttm_pool_free_page(struct ttm_pool *pool, enum 
ttm_caching caching,
 set_pages_wb(p, 1 << order);
  #endif

-   if (!pool->use_dma_alloc) {
+   if (!pool || !pool->use_dma_alloc) {
 __free_pages(p, order);
 return;
 }
--
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 15/20] drm/radeon/r600d: Move 'rc600_*' prototypes into shared header

2020-11-09 Thread Lee Jones
On Mon, 09 Nov 2020, Alex Deucher wrote:

> On Mon, Nov 9, 2020 at 4:19 PM Lee Jones  wrote:
> >
> > Fixes the following W=1 kernel build warning(s):
> >
> >  drivers/gpu/drm/radeon/r600_hdmi.c:177:6: warning: no previous prototype 
> > for ‘r600_hdmi_update_acr’ [-Wmissing-prototypes]
> >  177 | void r600_hdmi_update_acr(struct drm_encoder *encoder, long offset,
> >  | ^~~~
> >  drivers/gpu/drm/radeon/r600_hdmi.c:217:6: warning: no previous prototype 
> > for ‘r600_set_avi_packet’ [-Wmissing-prototypes]
> >  217 | void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
> >  | ^~~
> >  drivers/gpu/drm/radeon/r600_hdmi.c:314:6: warning: no previous prototype 
> > for ‘r600_hdmi_audio_set_dto’ [-Wmissing-prototypes]
> >  314 | void r600_hdmi_audio_set_dto(struct radeon_device *rdev,
> >  | ^~~
> >  drivers/gpu/drm/radeon/r600_hdmi.c:340:6: warning: no previous prototype 
> > for ‘r600_set_vbi_packet’ [-Wmissing-prototypes]
> >  340 | void r600_set_vbi_packet(struct drm_encoder *encoder, u32 offset)
> >  | ^~~
> >  drivers/gpu/drm/radeon/r600_hdmi.c:351:6: warning: no previous prototype 
> > for ‘r600_set_audio_packet’ [-Wmissing-prototypes]
> >  351 | void r600_set_audio_packet(struct drm_encoder *encoder, u32 offset)
> >  | ^
> >  drivers/gpu/drm/radeon/r600_hdmi.c:393:6: warning: no previous prototype 
> > for ‘r600_set_mute’ [-Wmissing-prototypes]
> >  393 | void r600_set_mute(struct drm_encoder *encoder, u32 offset, bool 
> > mute)
> >  | ^
> >  drivers/gpu/drm/radeon/r600_hdmi.c:469:6: warning: no previous prototype 
> > for ‘r600_hdmi_enable’ [-Wmissing-prototypes]
> >  469 | void r600_hdmi_enable(struct drm_encoder *encoder, bool enable)
> >  | ^~~~
> >
> > Cc: Alex Deucher 
> > Cc: "Christian König" 
> > Cc: David Airlie 
> > Cc: Daniel Vetter 
> > Cc: amd-...@lists.freedesktop.org
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Lee Jones 
> > ---
> >  drivers/gpu/drm/radeon/r600d.h| 14 ++
> >  drivers/gpu/drm/radeon/radeon_audio.c | 11 +--
> >  2 files changed, 15 insertions(+), 10 deletions(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
> > index 2e00a5287bd2d..db4bcc8bee4e5 100644
> > --- a/drivers/gpu/drm/radeon/r600d.h
> > +++ b/drivers/gpu/drm/radeon/r600d.h
> > @@ -27,6 +27,20 @@
> >  #ifndef R600D_H
> >  #define R600D_H
> >
> > +struct radeon_crtc;
> > +struct radeon_hdmi_acr;
> > +
> > +void r600_set_audio_packet(struct drm_encoder *encoder, u32 offset);
> > +void r600_set_mute(struct drm_encoder *encoder, u32 offset, bool mute);
> > +void r600_hdmi_audio_set_dto(struct radeon_device *rdev,
> > +   struct radeon_crtc *crtc, unsigned int clock);
> > +void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
> > +   unsigned char *buffer, size_t size);
> > +void r600_hdmi_update_acr(struct drm_encoder *encoder, long offset,
> > +   const struct radeon_hdmi_acr *acr);
> > +void r600_set_vbi_packet(struct drm_encoder *encoder, u32 offset);
> > +void r600_hdmi_enable(struct drm_encoder *encoder, bool enable);
> > +
> 
> the *d.h headers are supposed to just be hardware definitions.  I'd
> prefer to keep driver stuff out of them.

That's fine (I did wonder if that were the case).

I need an answer from you and Sam whether I can create new headers.

For me, it is the right thing to do.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 00/20] [Set 3] Rid W=1 warnings from GPU

2020-11-09 Thread Lee Jones
On Mon, 09 Nov 2020, Alex Deucher wrote:

> On Mon, Nov 9, 2020 at 4:19 PM Lee Jones  wrote:
> >
> > This set is part of a larger effort attempting to clean-up W=1
> > kernel builds, which are currently overwhelmingly riddled with
> > niggly little warnings.
> >
> > This set takes the running (decreasing) total from 5000 before
> > [Set 1] down to 2300.
> >
> > Lee Jones (20):
> >   drm/radeon/radeon_ttm: Place declaration of 'rdev' in same clause as
> > its use
> >   drm/radeon: Move radeon_ttm{init,fini} to shared location
> >   drm/radeon/radeon_fence: Demote some non-conformant kernel-doc headers
> > and fix another
> >   drm/radeon: Move 'radeon_add_legacy_encoder' prototype to shared
> > header
> >   drm/radeon: Move 'radeon_add_legacy_encoder's prototype to shared
> > location
> >   drm/radeon/radeon_connectors: Strip out set but unused variable 'ret'
> >   drm/radeon/radeon_display: Remove unused variable 'mod'
> >   drm/radeon/radeon_i2c: Remove pointless function header
> >   drm/radeon/radeon_irq_kms: Demote non-conformant kernel-doc fix
> > another
> >   drm/radeon/radeon_ring: Add missing function parameters 'rdev' and
> > 'data'
> >   drm/radeon/r600: Strip out set but unused 'tmp' variables
> >   drm/radeon/radeon_cs: Fix a bunch of doc-rot issues
> >   drm/radeon/evergreen: Move 'rv770_set_clk_bypass_mode' prototype to
> > shared location
> >   drm/radeon: Move 'radeon_pm_acpi_event_handler' prototype into shared
> > header
> >   drm/radeon/r600d: Move 'rc600_*' prototypes into shared header
> >   drm/radeon/radeon_audio: Move 'dce3_2_*' prototypes to shared location
> >   drm/radeon/evergreend: Move 'evergreen_*' and 'sumo_*' prototypes out
> > to shared location
> >   drm/radeon/radeon_display: Fix function doc formatting and missing
> > param issues
> >   drm/radeon/r600: Fix a misnamed parameter description and a formatting
> > issue
> >   drm/radeon/cik: Fix a bunch of function parameter descriptions
> >
> >  drivers/gpu/drm/radeon/cik.c   | 10 +++
> >  drivers/gpu/drm/radeon/evergreen.c |  1 -
> >  drivers/gpu/drm/radeon/ni.c| 16 --
> >  drivers/gpu/drm/radeon/r600.c  | 11 +++
> >  drivers/gpu/drm/radeon/r600d.h | 14 +
> >  drivers/gpu/drm/radeon/radeon.h| 34 ++
> >  drivers/gpu/drm/radeon/radeon_acpi.c   |  2 --
> >  drivers/gpu/drm/radeon/radeon_atombios.c   |  5 
> >  drivers/gpu/drm/radeon/radeon_audio.c  | 23 +--
> >  drivers/gpu/drm/radeon/radeon_audio.h  | 12 
> >  drivers/gpu/drm/radeon/radeon_combios.c|  5 
> >  drivers/gpu/drm/radeon/radeon_connectors.c |  4 +--
> >  drivers/gpu/drm/radeon/radeon_cs.c | 12 
> >  drivers/gpu/drm/radeon/radeon_display.c| 17 +--
> >  drivers/gpu/drm/radeon/radeon_encoders.c   |  3 --
> >  drivers/gpu/drm/radeon/radeon_fence.c  |  6 ++--
> >  drivers/gpu/drm/radeon/radeon_i2c.c|  4 ---
> >  drivers/gpu/drm/radeon/radeon_irq_kms.c|  6 ++--
> >  drivers/gpu/drm/radeon/radeon_object.c |  2 --
> >  drivers/gpu/drm/radeon/radeon_ring.c   |  3 ++
> >  drivers/gpu/drm/radeon/radeon_ttm.c|  8 ++---
> >  drivers/gpu/drm/radeon/si.c|  6 
> >  22 files changed, 96 insertions(+), 108 deletions(-)
> 
> Instead of just dumping everything in radeon.h, I think it would be
> cleaner to add new headers that match the .c files that define them.
> E.g., add evergreen.h and put all the stuff from evergreen.c in there.
> Add rv770.h and add all the stuff defined in rv770.c, etc.

This was my original solution, but Sam pushed back.

Please can you decide amongst yourselves what is the best way forward?

I will abide by whatever you decide.

> > Cc: Alex Deucher 
> > Cc: amd-...@lists.freedesktop.org
> > Cc: "Christian König" 
> > Cc: Daniel Vetter 
> > Cc: David Airlie 
> > Cc: dri-devel@lists.freedesktop.org
> > Cc: Jerome Glisse 
> > Cc: linaro-mm-...@lists.linaro.org
> > Cc: linux-me...@vger.kernel.org
> > Cc: report to 
> > Cc: Slava Grigorev 
> > Cc: Sumit Semwal 
> >
> > ___
> > dri-devel mailing list
> > dri-devel@lists.freedesktop.org
> > https://lists.freedesktop.org/mailman/listinfo/dri-devel

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] dt-bindings: display: panel-simple: Allow optional 'ports' property

2020-11-09 Thread Sam Ravnborg
Hi Liu Ying,
On Tue, Nov 10, 2020 at 10:37:27AM +0800, Liu Ying wrote:
> Hi Sam,
> 
> On Wed, 2020-11-04 at 11:47 +0100, Sam Ravnborg wrote:
> > Hi Liu Ying
> > 
> > On Wed, Nov 04, 2020 at 04:03:37PM +0800, Liu Ying wrote:
> > > Some simple panels have dual LVDS interfaces which receive even and
> > > odd
> > > pixels respectively, like 'nlt,nl192108ac18-02d' and
> > > 'koe,tx26d202vm0bwa'.
> > > So, let's allow optional 'ports' property so that pixel order can
> > > be got
> > > via drm_of_lvds_get_dual_link_pixel_order() if it's child nodes 
> > > 'port@0'
> > > and 'port@1' contain 'dual-lvds-even-pixels' and 'dual-lvds-odd-
> > > pixels'
> > > properties respectively.
> > 
> > A panel with dual LVDS interfaces is no longer in the "simple"
> > category.
> > The panel-simple binding shall be limited to the simple pnales only.
> > 
> > This is also why we have for example panel-simple-dsi binding.
> > 
> > Please consider either a binding dedicated for the dual port displays
> > or
> 
> Thanks for your review.
> 
> Does a new 'panel-simple-lvds-dual-ports.yaml' binding look ok?
> I assume it would inherit all properties of panel-simple.yaml and all
> existing compatibles of LVDS panels with dual ports in
> panel-simple.yaml can be moved to it.

Yes, that would be fine. If possible we shall have similar panels
described by the same binding.

Try to send out the binding for review early before starting to move too
much around - so we can get an early look at it at see if this is indeed
the right direction to go.

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/4] drm/ttm: add multihop infrastrucutre (v2)

2020-11-09 Thread Dave Airlie
On Tue, 10 Nov 2020 at 07:27, Ville Syrjälä
 wrote:
>
> On Mon, Nov 09, 2020 at 09:48:04PM +0100, Christian König wrote:
> > Am 09.11.20 um 17:43 schrieb Ville Syrjälä:
> > > On Mon, Nov 09, 2020 at 05:20:17PM +0100, Christian König wrote:
> > >> Am 09.11.20 um 17:18 schrieb Ville Syrjälä:
> > >>> On Mon, Nov 09, 2020 at 04:57:29PM +0100, Christian König wrote:
> >  Am 09.11.20 um 16:16 schrieb Ville Syrjälä:
> > > On Wed, Nov 11, 2020 at 06:13:02PM +0100, Christian König wrote:
> > >> Am 09.11.20 um 01:54 schrieb Dave Airlie:
> > >>> @@ -1432,15 +1479,18 @@ int ttm_bo_swapout(struct ttm_operation_ctx 
> > >>> *ctx)
> > >>>   if (bo->mem.mem_type != TTM_PL_SYSTEM) {
> > >>>   struct ttm_operation_ctx ctx = { false, false };
> > >>>   struct ttm_resource evict_mem;
> > >>> + struct ttm_place hop = {};
> > >> Please always use memset() if you want to zero initialize something 
> > >> in
> > >> the kernel, we had enough trouble with that.
> > > What trouble is that? I've not heard of anything, and we use
> > > ={} quite extensively in drm land.
> >  ={} initializes only named fields, not padding.
> > >>> Has that actually happened?
> > >> YES! Numerous times!
> > > You wouldn't happen to have links/etc. to the discussion?
> > > I'd like to check them out.
> >
> > Uff, that was years ago. Just google for something like "mesa memset
> > hash", there was recently (~ the last year) another discussion because
> > somebody ran into exactly that problem once more.
>
> Found this:
> https://gitlab.freedesktop.org/mesa/mesa/-/issues/2071
> which does suprise me a bit. Though I suspect ={} might
> behave differently since the compiler might treat it
> more like a memset().

It doesn't there's a bit of info out there on what happens, it really
only matters for structs we are passing to userspace, but it's
unlikely to matter here,
but I've changed this to memset in my local tree, because why not.

Dave
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH RFC PKS/PMEM 05/58] kmap: Introduce k[un]map_thread

2020-11-09 Thread Ira Weiny
On Tue, Nov 10, 2020 at 02:13:56AM +0100, Thomas Gleixner wrote:
> Ira,
> 
> On Fri, Oct 09 2020 at 12:49, ira weiny wrote:
> > From: Ira Weiny 
> >
> > To correctly support the semantics of kmap() with Kernel protection keys
> > (PKS), kmap() may be required to set the protections on multiple
> > processors (globally).  Enabling PKS globally can be very expensive
> > depending on the requested operation.  Furthermore, enabling a domain
> > globally reduces the protection afforded by PKS.
> >
> > Most kmap() (Aprox 209 of 229) callers use the map within a single thread 
> > and
> > have no need for the protection domain to be enabled globally.  However, the
> > remaining callers do not follow this pattern and, as best I can tell, expect
> > the mapping to be 'global' and available to any thread who may access the
> > mapping.[1]
> >
> > We don't anticipate global mappings to pmem, however in general there is a
> > danger in changing the semantics of kmap().  Effectively, this would cause 
> > an
> > unresolved page fault with little to no information about why the failure
> > occurred.
> >
> > To resolve this a number of options were considered.
> >
> > 1) Attempt to change all the thread local kmap() calls to kmap_atomic()[2]
> > 2) Introduce a flags parameter to kmap() to indicate if the mapping should 
> > be
> >global or not
> > 3) Change ~20 call sites to 'kmap_global()' to indicate that they require a
> >global enablement of the pages.
> > 4) Change ~209 call sites to 'kmap_thread()' to indicate that the mapping 
> > is to
> >be used within that thread of execution only
> >
> > Option 1 is simply not feasible.  Option 2 would require all of the call 
> > sites
> > of kmap() to change.  Option 3 seems like a good minimal change but there 
> > is a
> > danger that new code may miss the semantic change of kmap() and not get the
> > behavior the developer intended.  Therefore, #4 was chosen.
> 
> There is Option #5:

There is now yes.  :-D

> 
> Convert the thread local kmap() invocations to the proposed kmap_local()
> interface which is coming along [1].

I've been trying to follow that thread.

> 
> That solves a couple of issues:
> 
>  1) It relieves the current kmap_atomic() usage sites from the implict
> pagefault/preempt disable semantics which apply even when
> CONFIG_HIGHMEM is disabled. kmap_local() still can be invoked from
> atomic context.
> 
>  2) Due to #1 it allows to replace the conditional usage of kmap() and
> kmap_atomic() for purely thread local mappings.
> 
>  3) It puts the burden on the HIGHMEM inflicted systems
> 
>  4) It is actually more efficient for most of the pure thread local use
> cases on HIGHMEM inflicted systems because it avoids the overhead of
> the global lock and the potential kmap slot exhaustion. A potential
> preemption will be more expensive, but that's not really the case we
> want to optimize for.
> 
>  5) It solves the RT issue vs. kmap_atomic()
> 
> So instead of creating yet another variety of kmap() which is just
> scratching the particular PKRS itch, can we please consolidate all of
> that on the wider reaching kmap_local() approach?

Yes I agree.  We absolutely don't want more kmap*() calls and I was hoping to
dovetail into your kmap_local() work.[2]

I've pivoted away from this work a bit to clean up all the
kmap()/memcpy*()/kunmaps() as discussed elsewhere in the thread first.[3]  I
was hoping your work would land and then I could s/kmap_thread()/kmap_local()/
on all of these patches.

Also, we can convert the new memcpy_*_page() calls to kmap_local() as well.
[For now my patch just uses kmap_atomic().]

I've not looked at all of the patches in your latest version.  Have you
included converting any of the kmap() call sites?  I thought you were more
focused on converting the kmap_atomic() to kmap_local()?

Ira

> 
> Thanks,
> 
> tglx
>  
> [1] https://lore.kernel.org/lkml/20201103092712.714480...@linutronix.de/

[2] 
https://lore.kernel.org/lkml/20201012195354.gc2046...@iweiny-desk2.sc.intel.com/
[3] https://lore.kernel.org/lkml/20201009213434.GA839@sol.localdomain/
https://lore.kernel.org/lkml/20201013200149.gi3576...@zeniv.linux.org.uk/

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 4.9 05/12] drm/amdgpu: perform srbm soft reset always on SDMA resume

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 253475c455eb5f8da34faa1af92709e7bb414624 ]

This can address the random SDMA hang after pci config reset
seen on Hawaii.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c 
b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index cb952acc71339..2934443fbd4dc 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -1053,22 +1053,19 @@ static int cik_sdma_soft_reset(void *handle)
 {
u32 srbm_soft_reset = 0;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-   u32 tmp = RREG32(mmSRBM_STATUS2);
+   u32 tmp;
 
-   if (tmp & SRBM_STATUS2__SDMA_BUSY_MASK) {
-   /* sdma0 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
-   }
-   if (tmp & SRBM_STATUS2__SDMA1_BUSY_MASK) {
-   /* sdma1 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
-   }
+   /* sdma0 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
+
+   /* sdma1 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
 
if (srbm_soft_reset) {
tmp = RREG32(mmSRBM_SOFT_RESET);
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 4.4 04/10] drm/amdgpu: perform srbm soft reset always on SDMA resume

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 253475c455eb5f8da34faa1af92709e7bb414624 ]

This can address the random SDMA hang after pci config reset
seen on Hawaii.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c 
b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index c568293cb6c1a..f1745c5cdf7b3 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -1118,22 +1118,19 @@ static int cik_sdma_soft_reset(void *handle)
 {
u32 srbm_soft_reset = 0;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-   u32 tmp = RREG32(mmSRBM_STATUS2);
+   u32 tmp;
 
-   if (tmp & SRBM_STATUS2__SDMA_BUSY_MASK) {
-   /* sdma0 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
-   }
-   if (tmp & SRBM_STATUS2__SDMA1_BUSY_MASK) {
-   /* sdma1 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
-   }
+   /* sdma0 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
+
+   /* sdma1 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
 
if (srbm_soft_reset) {
cik_sdma_print_status((void *)adev);
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 4.14 06/14] drm/amdgpu: perform srbm soft reset always on SDMA resume

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 253475c455eb5f8da34faa1af92709e7bb414624 ]

This can address the random SDMA hang after pci config reset
seen on Hawaii.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c 
b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index 11beef7c595f2..d35e5d8e8a058 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -1098,22 +1098,19 @@ static int cik_sdma_soft_reset(void *handle)
 {
u32 srbm_soft_reset = 0;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-   u32 tmp = RREG32(mmSRBM_STATUS2);
+   u32 tmp;
 
-   if (tmp & SRBM_STATUS2__SDMA_BUSY_MASK) {
-   /* sdma0 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
-   }
-   if (tmp & SRBM_STATUS2__SDMA1_BUSY_MASK) {
-   /* sdma1 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
-   }
+   /* sdma0 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
+
+   /* sdma1 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
 
if (srbm_soft_reset) {
tmp = RREG32(mmSRBM_SOFT_RESET);
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 4.19 08/21] drm/amd/pm: perform SMC reset on suspend/hibernation

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 277b080f98803cb73a83fb234f0be83a10e63958 ]

So that the succeeding resume can be performed based on
a clean state.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c  |  4 
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h |  1 +
 drivers/gpu/drm/amd/powerplay/inc/smumgr.h|  2 ++
 .../gpu/drm/amd/powerplay/smumgr/ci_smumgr.c  | 24 +++
 drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c |  8 +++
 5 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 058898b321b8a..d8e624d64ae38 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -1531,6 +1531,10 @@ int smu7_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE((tmp_result == 0),
"Failed to reset to default!", result = tmp_result);
 
+   tmp_result = smum_stop_smc(hwmgr);
+   PP_ASSERT_WITH_CODE((tmp_result == 0),
+   "Failed to stop smc!", result = tmp_result);
+
tmp_result = smu7_force_switch_to_arbf0(hwmgr);
PP_ASSERT_WITH_CODE((tmp_result == 0),
"Failed to force to switch arbf0!", result = 
tmp_result);
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h 
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 6ee864455a12a..f59e1e737735f 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -216,6 +216,7 @@ struct pp_smumgr_func {
bool (*is_hw_avfs_present)(struct pp_hwmgr  *hwmgr);
int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void 
*profile_setting);
int (*smc_table_manager)(struct pp_hwmgr *hwmgr, uint8_t *table, 
uint16_t table_id, bool rw); /*rw: true for read, false for write */
+   int (*stop_smc)(struct pp_hwmgr *hwmgr);
 };
 
 struct pp_hwmgr_func {
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h 
b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
index 82550a8a3a3fc..ef4f2392e2e7d 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
@@ -113,4 +113,6 @@ extern int smum_update_dpm_settings(struct pp_hwmgr *hwmgr, 
void *profile_settin
 
 extern int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, 
uint16_t table_id, bool rw);
 
+extern int smum_stop_smc(struct pp_hwmgr *hwmgr);
+
 #endif
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
index db87cb8930d24..0d4dd607e85c8 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
@@ -2934,6 +2934,29 @@ static int ci_update_smc_table(struct pp_hwmgr *hwmgr, 
uint32_t type)
return 0;
 }
 
+static void ci_reset_smc(struct pp_hwmgr *hwmgr)
+{
+   PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
+ SMC_SYSCON_RESET_CNTL,
+ rst_reg, 1);
+}
+
+
+static void ci_stop_smc_clock(struct pp_hwmgr *hwmgr)
+{
+   PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
+ SMC_SYSCON_CLOCK_CNTL_0,
+ ck_disable, 1);
+}
+
+static int ci_stop_smc(struct pp_hwmgr *hwmgr)
+{
+   ci_reset_smc(hwmgr);
+   ci_stop_smc_clock(hwmgr);
+
+   return 0;
+}
+
 const struct pp_smumgr_func ci_smu_funcs = {
.smu_init = ci_smu_init,
.smu_fini = ci_smu_fini,
@@ -2957,4 +2980,5 @@ const struct pp_smumgr_func ci_smu_funcs = {
.is_dpm_running = ci_is_dpm_running,
.update_dpm_settings = ci_update_dpm_settings,
.update_smc_table = ci_update_smc_table,
+   .stop_smc = ci_stop_smc,
 };
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
index a6edd5df33b0f..20ecf994d47f3 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
@@ -213,3 +213,11 @@ int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t 
*table, uint16_t tabl
 
return -EINVAL;
 }
+
+int smum_stop_smc(struct pp_hwmgr *hwmgr)
+{
+   if (hwmgr->smumgr_funcs->stop_smc)
+   return hwmgr->smumgr_funcs->stop_smc(hwmgr);
+
+   return 0;
+}
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 4.19 09/21] drm/amd/pm: do not use ixFEATURE_STATUS for checking smc running

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 786436b453001dafe81025389f96bf9dac1e9690 ]

This reverts commit f87812284172a9809820d10143b573d833cd3f75 ("drm/amdgpu:
Fix bug where DPM is not enabled after hibernate and resume").
It was intended to fix Hawaii S4(hibernation) issue but break S3. As
ixFEATURE_STATUS is filled with garbage data on resume which can be
only cleared by reloading smc firmware(but that will involve many
changes). So, we will revert this S4 fix and seek a new way.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
index 0d4dd607e85c8..c05bec5effb2e 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
@@ -2723,10 +2723,7 @@ static int ci_initialize_mc_reg_table(struct pp_hwmgr 
*hwmgr)
 
 static bool ci_is_dpm_running(struct pp_hwmgr *hwmgr)
 {
-   return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
-CGS_IND_REG__SMC, FEATURE_STATUS,
-VOLTAGE_CONTROLLER_ON))
-   ? true : false;
+   return ci_is_smc_ram_running(hwmgr);
 }
 
 static int ci_smu_init(struct pp_hwmgr *hwmgr)
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.4 39/42] i2c: sh_mobile: implement atomic transfers

2020-11-09 Thread Sasha Levin
From: Ulrich Hecht 

[ Upstream commit a49cc1fe9d64a2dc4e19b599204f403e5d25f44b ]

Implements atomic transfers to fix reboot/shutdown on r8a7790 Lager and
similar boards.

Signed-off-by: Ulrich Hecht 
Tested-by: Wolfram Sang 
Tested-by: Geert Uytterhoeven 
[wsa: some whitespace fixing]
Signed-off-by: Wolfram Sang 
Signed-off-by: Sasha Levin 
---
 drivers/i2c/busses/i2c-sh_mobile.c | 86 +++---
 1 file changed, 66 insertions(+), 20 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sh_mobile.c 
b/drivers/i2c/busses/i2c-sh_mobile.c
index 8777af4c695e9..d5dd58c27ce5f 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -129,6 +129,7 @@ struct sh_mobile_i2c_data {
int sr;
bool send_stop;
bool stop_after_dma;
+   bool atomic_xfer;
 
struct resource *res;
struct dma_chan *dma_tx;
@@ -333,13 +334,15 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data 
*pd, enum sh_mobile_i2c_op
ret = iic_rd(pd, ICDR);
break;
case OP_RX_STOP: /* enable DTE interrupt, issue stop */
-   iic_wr(pd, ICIC,
-  ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
+   if (!pd->atomic_xfer)
+   iic_wr(pd, ICIC,
+  ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK);
break;
case OP_RX_STOP_DATA: /* enable DTE interrupt, read data, issue stop */
-   iic_wr(pd, ICIC,
-  ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
+   if (!pd->atomic_xfer)
+   iic_wr(pd, ICIC,
+  ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
ret = iic_rd(pd, ICDR);
iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK);
break;
@@ -435,7 +438,8 @@ static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id)
 
if (wakeup) {
pd->sr |= SW_DONE;
-   wake_up(>wait);
+   if (!pd->atomic_xfer)
+   wake_up(>wait);
}
 
/* defeat write posting to avoid spurious WAIT interrupts */
@@ -587,6 +591,9 @@ static void start_ch(struct sh_mobile_i2c_data *pd, struct 
i2c_msg *usr_msg,
pd->pos = -1;
pd->sr = 0;
 
+   if (pd->atomic_xfer)
+   return;
+
pd->dma_buf = i2c_get_dma_safe_msg_buf(pd->msg, 8);
if (pd->dma_buf)
sh_mobile_i2c_xfer_dma(pd);
@@ -643,15 +650,13 @@ static int poll_busy(struct sh_mobile_i2c_data *pd)
return i ? 0 : -ETIMEDOUT;
 }
 
-static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
- struct i2c_msg *msgs,
- int num)
+static int sh_mobile_xfer(struct sh_mobile_i2c_data *pd,
+struct i2c_msg *msgs, int num)
 {
-   struct sh_mobile_i2c_data *pd = i2c_get_adapdata(adapter);
struct i2c_msg  *msg;
int err = 0;
int i;
-   long timeout;
+   long time_left;
 
/* Wake up device and enable clock */
pm_runtime_get_sync(pd->dev);
@@ -668,15 +673,35 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
if (do_start)
i2c_op(pd, OP_START);
 
-   /* The interrupt handler takes care of the rest... */
-   timeout = wait_event_timeout(pd->wait,
-  pd->sr & (ICSR_TACK | SW_DONE),
-  adapter->timeout);
-
-   /* 'stop_after_dma' tells if DMA transfer was complete */
-   i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg, 
pd->stop_after_dma);
+   if (pd->atomic_xfer) {
+   unsigned long j = jiffies + pd->adap.timeout;
+
+   time_left = time_before_eq(jiffies, j);
+   while (time_left &&
+  !(pd->sr & (ICSR_TACK | SW_DONE))) {
+   unsigned char sr = iic_rd(pd, ICSR);
+
+   if (sr & (ICSR_AL   | ICSR_TACK |
+ ICSR_WAIT | ICSR_DTE)) {
+   sh_mobile_i2c_isr(0, pd);
+   udelay(150);
+   } else {
+   cpu_relax();
+   }
+   time_left = time_before_eq(jiffies, j);
+   }
+   } else {
+   /* The interrupt handler takes care of the rest... */
+   time_left = wait_event_timeout(pd->wait,
+   pd->sr & (ICSR_TACK | SW_DONE),
+   pd->adap.timeout);
+
+   /* 'stop_after_dma' tells if DMA 

[PATCH AUTOSEL 5.4 35/42] amd/amdgpu: Disable VCN DPG mode for Picasso

2020-11-09 Thread Sasha Levin
From: Veerabadhran Gopalakrishnan 

[ Upstream commit c6d2b0fbb893d5c7dda405aa0e7bcbecf1c75f98 ]

Concurrent operation of VCN and JPEG decoder in DPG mode is
causing ring timeout due to power state.

Signed-off-by: Veerabadhran Gopalakrishnan 
Reviewed-by: Leo Liu 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c 
b/drivers/gpu/drm/amd/amdgpu/soc15.c
index c086262cc181d..317aa257c06bb 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -1144,8 +1144,7 @@ static int soc15_common_early_init(void *handle)
 
adev->pg_flags = AMD_PG_SUPPORT_SDMA |
AMD_PG_SUPPORT_MMHUB |
-   AMD_PG_SUPPORT_VCN |
-   AMD_PG_SUPPORT_VCN_DPG;
+   AMD_PG_SUPPORT_VCN;
} else {
adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
AMD_CG_SUPPORT_GFX_MGLS |
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 4.19 07/21] drm/amdgpu: perform srbm soft reset always on SDMA resume

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 253475c455eb5f8da34faa1af92709e7bb414624 ]

This can address the random SDMA hang after pci config reset
seen on Hawaii.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c 
b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index d0fa2aac23888..ca66c2f797584 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -1086,22 +1086,19 @@ static int cik_sdma_soft_reset(void *handle)
 {
u32 srbm_soft_reset = 0;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-   u32 tmp = RREG32(mmSRBM_STATUS2);
+   u32 tmp;
 
-   if (tmp & SRBM_STATUS2__SDMA_BUSY_MASK) {
-   /* sdma0 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
-   }
-   if (tmp & SRBM_STATUS2__SDMA1_BUSY_MASK) {
-   /* sdma1 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
-   }
+   /* sdma0 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
+
+   /* sdma1 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
 
if (srbm_soft_reset) {
tmp = RREG32(mmSRBM_SOFT_RESET);
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.4 14/42] drm/amdgpu: perform srbm soft reset always on SDMA resume

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 253475c455eb5f8da34faa1af92709e7bb414624 ]

This can address the random SDMA hang after pci config reset
seen on Hawaii.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c 
b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index 4af9acc2dc4f9..450ad7d5e21a0 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -1071,22 +1071,19 @@ static int cik_sdma_soft_reset(void *handle)
 {
u32 srbm_soft_reset = 0;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-   u32 tmp = RREG32(mmSRBM_STATUS2);
+   u32 tmp;
 
-   if (tmp & SRBM_STATUS2__SDMA_BUSY_MASK) {
-   /* sdma0 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
-   }
-   if (tmp & SRBM_STATUS2__SDMA1_BUSY_MASK) {
-   /* sdma1 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
-   }
+   /* sdma0 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
+
+   /* sdma1 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
 
if (srbm_soft_reset) {
tmp = RREG32(mmSRBM_SOFT_RESET);
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.4 16/42] drm/amd/pm: do not use ixFEATURE_STATUS for checking smc running

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 786436b453001dafe81025389f96bf9dac1e9690 ]

This reverts commit f87812284172a9809820d10143b573d833cd3f75 ("drm/amdgpu:
Fix bug where DPM is not enabled after hibernate and resume").
It was intended to fix Hawaii S4(hibernation) issue but break S3. As
ixFEATURE_STATUS is filled with garbage data on resume which can be
only cleared by reloading smc firmware(but that will involve many
changes). So, we will revert this S4 fix and seek a new way.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
index 0f4f27a89020d..42c8f8731a504 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
@@ -2725,10 +2725,7 @@ static int ci_initialize_mc_reg_table(struct pp_hwmgr 
*hwmgr)
 
 static bool ci_is_dpm_running(struct pp_hwmgr *hwmgr)
 {
-   return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
-CGS_IND_REG__SMC, FEATURE_STATUS,
-VOLTAGE_CONTROLLER_ON))
-   ? true : false;
+   return ci_is_smc_ram_running(hwmgr);
 }
 
 static int ci_smu_init(struct pp_hwmgr *hwmgr)
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.4 15/42] drm/amd/pm: perform SMC reset on suspend/hibernation

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 277b080f98803cb73a83fb234f0be83a10e63958 ]

So that the succeeding resume can be performed based on
a clean state.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c  |  4 
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h |  1 +
 drivers/gpu/drm/amd/powerplay/inc/smumgr.h|  2 ++
 .../gpu/drm/amd/powerplay/smumgr/ci_smumgr.c  | 24 +++
 drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c |  8 +++
 5 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index 35e6cbe805eb4..7cde55854b65c 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -1533,6 +1533,10 @@ int smu7_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE((tmp_result == 0),
"Failed to reset to default!", result = tmp_result);
 
+   tmp_result = smum_stop_smc(hwmgr);
+   PP_ASSERT_WITH_CODE((tmp_result == 0),
+   "Failed to stop smc!", result = tmp_result);
+
tmp_result = smu7_force_switch_to_arbf0(hwmgr);
PP_ASSERT_WITH_CODE((tmp_result == 0),
"Failed to force to switch arbf0!", result = 
tmp_result);
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h 
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 7bf9a14bfa0be..f6490a1284384 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -229,6 +229,7 @@ struct pp_smumgr_func {
bool (*is_hw_avfs_present)(struct pp_hwmgr  *hwmgr);
int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void 
*profile_setting);
int (*smc_table_manager)(struct pp_hwmgr *hwmgr, uint8_t *table, 
uint16_t table_id, bool rw); /*rw: true for read, false for write */
+   int (*stop_smc)(struct pp_hwmgr *hwmgr);
 };
 
 struct pp_hwmgr_func {
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h 
b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
index c5288831aa15c..05a55e850b5e0 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
@@ -114,4 +114,6 @@ extern int smum_update_dpm_settings(struct pp_hwmgr *hwmgr, 
void *profile_settin
 
 extern int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, 
uint16_t table_id, bool rw);
 
+extern int smum_stop_smc(struct pp_hwmgr *hwmgr);
+
 #endif
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
index 09a3d8ae44491..0f4f27a89020d 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
@@ -2936,6 +2936,29 @@ static int ci_update_smc_table(struct pp_hwmgr *hwmgr, 
uint32_t type)
return 0;
 }
 
+static void ci_reset_smc(struct pp_hwmgr *hwmgr)
+{
+   PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
+ SMC_SYSCON_RESET_CNTL,
+ rst_reg, 1);
+}
+
+
+static void ci_stop_smc_clock(struct pp_hwmgr *hwmgr)
+{
+   PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
+ SMC_SYSCON_CLOCK_CNTL_0,
+ ck_disable, 1);
+}
+
+static int ci_stop_smc(struct pp_hwmgr *hwmgr)
+{
+   ci_reset_smc(hwmgr);
+   ci_stop_smc_clock(hwmgr);
+
+   return 0;
+}
+
 const struct pp_smumgr_func ci_smu_funcs = {
.name = "ci_smu",
.smu_init = ci_smu_init,
@@ -2960,4 +2983,5 @@ const struct pp_smumgr_func ci_smu_funcs = {
.is_dpm_running = ci_is_dpm_running,
.update_dpm_settings = ci_update_dpm_settings,
.update_smc_table = ci_update_smc_table,
+   .stop_smc = ci_stop_smc,
 };
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
index 4240aeec9000e..83d06f8e99ec2 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
@@ -217,3 +217,11 @@ int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t 
*table, uint16_t tabl
 
return -EINVAL;
 }
+
+int smum_stop_smc(struct pp_hwmgr *hwmgr)
+{
+   if (hwmgr->smumgr_funcs->stop_smc)
+   return hwmgr->smumgr_funcs->stop_smc(hwmgr);
+
+   return 0;
+}
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.9 43/55] amd/amdgpu: Disable VCN DPG mode for Picasso

2020-11-09 Thread Sasha Levin
From: Veerabadhran Gopalakrishnan 

[ Upstream commit c6d2b0fbb893d5c7dda405aa0e7bcbecf1c75f98 ]

Concurrent operation of VCN and JPEG decoder in DPG mode is
causing ring timeout due to power state.

Signed-off-by: Veerabadhran Gopalakrishnan 
Reviewed-by: Leo Liu 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/soc15.c | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/soc15.c 
b/drivers/gpu/drm/amd/amdgpu/soc15.c
index c28ebf41530aa..254ab2ada70a0 100644
--- a/drivers/gpu/drm/amd/amdgpu/soc15.c
+++ b/drivers/gpu/drm/amd/amdgpu/soc15.c
@@ -1220,8 +1220,7 @@ static int soc15_common_early_init(void *handle)
 
adev->pg_flags = AMD_PG_SUPPORT_SDMA |
AMD_PG_SUPPORT_MMHUB |
-   AMD_PG_SUPPORT_VCN |
-   AMD_PG_SUPPORT_VCN_DPG;
+   AMD_PG_SUPPORT_VCN;
} else {
adev->cg_flags = AMD_CG_SUPPORT_GFX_MGCG |
AMD_CG_SUPPORT_GFX_MGLS |
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.9 49/55] i2c: sh_mobile: implement atomic transfers

2020-11-09 Thread Sasha Levin
From: Ulrich Hecht 

[ Upstream commit a49cc1fe9d64a2dc4e19b599204f403e5d25f44b ]

Implements atomic transfers to fix reboot/shutdown on r8a7790 Lager and
similar boards.

Signed-off-by: Ulrich Hecht 
Tested-by: Wolfram Sang 
Tested-by: Geert Uytterhoeven 
[wsa: some whitespace fixing]
Signed-off-by: Wolfram Sang 
Signed-off-by: Sasha Levin 
---
 drivers/i2c/busses/i2c-sh_mobile.c | 86 +++---
 1 file changed, 66 insertions(+), 20 deletions(-)

diff --git a/drivers/i2c/busses/i2c-sh_mobile.c 
b/drivers/i2c/busses/i2c-sh_mobile.c
index cab725551..bdd60770779ad 100644
--- a/drivers/i2c/busses/i2c-sh_mobile.c
+++ b/drivers/i2c/busses/i2c-sh_mobile.c
@@ -129,6 +129,7 @@ struct sh_mobile_i2c_data {
int sr;
bool send_stop;
bool stop_after_dma;
+   bool atomic_xfer;
 
struct resource *res;
struct dma_chan *dma_tx;
@@ -330,13 +331,15 @@ static unsigned char i2c_op(struct sh_mobile_i2c_data 
*pd, enum sh_mobile_i2c_op
ret = iic_rd(pd, ICDR);
break;
case OP_RX_STOP: /* enable DTE interrupt, issue stop */
-   iic_wr(pd, ICIC,
-  ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
+   if (!pd->atomic_xfer)
+   iic_wr(pd, ICIC,
+  ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK);
break;
case OP_RX_STOP_DATA: /* enable DTE interrupt, read data, issue stop */
-   iic_wr(pd, ICIC,
-  ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
+   if (!pd->atomic_xfer)
+   iic_wr(pd, ICIC,
+  ICIC_DTEE | ICIC_WAITE | ICIC_ALE | ICIC_TACKE);
ret = iic_rd(pd, ICDR);
iic_wr(pd, ICCR, ICCR_ICE | ICCR_RACK);
break;
@@ -429,7 +432,8 @@ static irqreturn_t sh_mobile_i2c_isr(int irq, void *dev_id)
 
if (wakeup) {
pd->sr |= SW_DONE;
-   wake_up(>wait);
+   if (!pd->atomic_xfer)
+   wake_up(>wait);
}
 
/* defeat write posting to avoid spurious WAIT interrupts */
@@ -581,6 +585,9 @@ static void start_ch(struct sh_mobile_i2c_data *pd, struct 
i2c_msg *usr_msg,
pd->pos = -1;
pd->sr = 0;
 
+   if (pd->atomic_xfer)
+   return;
+
pd->dma_buf = i2c_get_dma_safe_msg_buf(pd->msg, 8);
if (pd->dma_buf)
sh_mobile_i2c_xfer_dma(pd);
@@ -637,15 +644,13 @@ static int poll_busy(struct sh_mobile_i2c_data *pd)
return i ? 0 : -ETIMEDOUT;
 }
 
-static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
- struct i2c_msg *msgs,
- int num)
+static int sh_mobile_xfer(struct sh_mobile_i2c_data *pd,
+struct i2c_msg *msgs, int num)
 {
-   struct sh_mobile_i2c_data *pd = i2c_get_adapdata(adapter);
struct i2c_msg  *msg;
int err = 0;
int i;
-   long timeout;
+   long time_left;
 
/* Wake up device and enable clock */
pm_runtime_get_sync(pd->dev);
@@ -662,15 +667,35 @@ static int sh_mobile_i2c_xfer(struct i2c_adapter *adapter,
if (do_start)
i2c_op(pd, OP_START);
 
-   /* The interrupt handler takes care of the rest... */
-   timeout = wait_event_timeout(pd->wait,
-  pd->sr & (ICSR_TACK | SW_DONE),
-  adapter->timeout);
-
-   /* 'stop_after_dma' tells if DMA transfer was complete */
-   i2c_put_dma_safe_msg_buf(pd->dma_buf, pd->msg, 
pd->stop_after_dma);
+   if (pd->atomic_xfer) {
+   unsigned long j = jiffies + pd->adap.timeout;
+
+   time_left = time_before_eq(jiffies, j);
+   while (time_left &&
+  !(pd->sr & (ICSR_TACK | SW_DONE))) {
+   unsigned char sr = iic_rd(pd, ICSR);
+
+   if (sr & (ICSR_AL   | ICSR_TACK |
+ ICSR_WAIT | ICSR_DTE)) {
+   sh_mobile_i2c_isr(0, pd);
+   udelay(150);
+   } else {
+   cpu_relax();
+   }
+   time_left = time_before_eq(jiffies, j);
+   }
+   } else {
+   /* The interrupt handler takes care of the rest... */
+   time_left = wait_event_timeout(pd->wait,
+   pd->sr & (ICSR_TACK | SW_DONE),
+   pd->adap.timeout);
+
+   /* 'stop_after_dma' tells if DMA 

[PATCH AUTOSEL 5.9 21/55] drm/amd/pm: do not use ixFEATURE_STATUS for checking smc running

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 786436b453001dafe81025389f96bf9dac1e9690 ]

This reverts commit f87812284172a9809820d10143b573d833cd3f75 ("drm/amdgpu:
Fix bug where DPM is not enabled after hibernate and resume").
It was intended to fix Hawaii S4(hibernation) issue but break S3. As
ixFEATURE_STATUS is filled with garbage data on resume which can be
only cleared by reloading smc firmware(but that will involve many
changes). So, we will revert this S4 fix and seek a new way.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c | 5 +
 1 file changed, 1 insertion(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
index 09128122b4932..329bf4d44bbce 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
@@ -2726,10 +2726,7 @@ static int ci_initialize_mc_reg_table(struct pp_hwmgr 
*hwmgr)
 
 static bool ci_is_dpm_running(struct pp_hwmgr *hwmgr)
 {
-   return (1 == PHM_READ_INDIRECT_FIELD(hwmgr->device,
-CGS_IND_REG__SMC, FEATURE_STATUS,
-VOLTAGE_CONTROLLER_ON))
-   ? true : false;
+   return ci_is_smc_ram_running(hwmgr);
 }
 
 static int ci_smu_init(struct pp_hwmgr *hwmgr)
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.9 18/55] drm/amdgpu: perform srbm soft reset always on SDMA resume

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 253475c455eb5f8da34faa1af92709e7bb414624 ]

This can address the random SDMA hang after pci config reset
seen on Hawaii.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/amdgpu/cik_sdma.c | 27 ---
 1 file changed, 12 insertions(+), 15 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c 
b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
index 20f108818b2b9..a3c3fe96515f2 100644
--- a/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
+++ b/drivers/gpu/drm/amd/amdgpu/cik_sdma.c
@@ -1071,22 +1071,19 @@ static int cik_sdma_soft_reset(void *handle)
 {
u32 srbm_soft_reset = 0;
struct amdgpu_device *adev = (struct amdgpu_device *)handle;
-   u32 tmp = RREG32(mmSRBM_STATUS2);
+   u32 tmp;
 
-   if (tmp & SRBM_STATUS2__SDMA_BUSY_MASK) {
-   /* sdma0 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
-   }
-   if (tmp & SRBM_STATUS2__SDMA1_BUSY_MASK) {
-   /* sdma1 */
-   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
-   tmp |= SDMA0_F32_CNTL__HALT_MASK;
-   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
-   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
-   }
+   /* sdma0 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA0_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA_MASK;
+
+   /* sdma1 */
+   tmp = RREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET);
+   tmp |= SDMA0_F32_CNTL__HALT_MASK;
+   WREG32(mmSDMA0_F32_CNTL + SDMA1_REGISTER_OFFSET, tmp);
+   srbm_soft_reset |= SRBM_SOFT_RESET__SOFT_RESET_SDMA1_MASK;
 
if (srbm_soft_reset) {
tmp = RREG32(mmSRBM_SOFT_RESET);
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.9 20/55] drm/amd/pm: perform SMC reset on suspend/hibernation

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit 277b080f98803cb73a83fb234f0be83a10e63958 ]

So that the succeeding resume can be performed based on
a clean state.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 .../gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c  |  4 
 drivers/gpu/drm/amd/powerplay/inc/hwmgr.h |  1 +
 drivers/gpu/drm/amd/powerplay/inc/smumgr.h|  2 ++
 .../gpu/drm/amd/powerplay/smumgr/ci_smumgr.c  | 24 +++
 drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c |  8 +++
 5 files changed, 39 insertions(+)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
index fc63d9e32e1f8..c8ee931075e52 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/smu7_hwmgr.c
@@ -1541,6 +1541,10 @@ static int smu7_disable_dpm_tasks(struct pp_hwmgr *hwmgr)
PP_ASSERT_WITH_CODE((tmp_result == 0),
"Failed to reset to default!", result = tmp_result);
 
+   tmp_result = smum_stop_smc(hwmgr);
+   PP_ASSERT_WITH_CODE((tmp_result == 0),
+   "Failed to stop smc!", result = tmp_result);
+
tmp_result = smu7_force_switch_to_arbf0(hwmgr);
PP_ASSERT_WITH_CODE((tmp_result == 0),
"Failed to force to switch arbf0!", result = 
tmp_result);
diff --git a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h 
b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
index 15ed6cbdf3660..91cdc53472f01 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/hwmgr.h
@@ -229,6 +229,7 @@ struct pp_smumgr_func {
bool (*is_hw_avfs_present)(struct pp_hwmgr  *hwmgr);
int (*update_dpm_settings)(struct pp_hwmgr *hwmgr, void 
*profile_setting);
int (*smc_table_manager)(struct pp_hwmgr *hwmgr, uint8_t *table, 
uint16_t table_id, bool rw); /*rw: true for read, false for write */
+   int (*stop_smc)(struct pp_hwmgr *hwmgr);
 };
 
 struct pp_hwmgr_func {
diff --git a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h 
b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
index ad100b533d049..5f46f1a4f38ef 100644
--- a/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
+++ b/drivers/gpu/drm/amd/powerplay/inc/smumgr.h
@@ -113,4 +113,6 @@ extern int smum_update_dpm_settings(struct pp_hwmgr *hwmgr, 
void *profile_settin
 
 extern int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t *table, 
uint16_t table_id, bool rw);
 
+extern int smum_stop_smc(struct pp_hwmgr *hwmgr);
+
 #endif
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
index e4d1f3d66ef48..09128122b4932 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/ci_smumgr.c
@@ -2939,6 +2939,29 @@ static int ci_update_smc_table(struct pp_hwmgr *hwmgr, 
uint32_t type)
return 0;
 }
 
+static void ci_reset_smc(struct pp_hwmgr *hwmgr)
+{
+   PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
+ SMC_SYSCON_RESET_CNTL,
+ rst_reg, 1);
+}
+
+
+static void ci_stop_smc_clock(struct pp_hwmgr *hwmgr)
+{
+   PHM_WRITE_INDIRECT_FIELD(hwmgr->device, CGS_IND_REG__SMC,
+ SMC_SYSCON_CLOCK_CNTL_0,
+ ck_disable, 1);
+}
+
+static int ci_stop_smc(struct pp_hwmgr *hwmgr)
+{
+   ci_reset_smc(hwmgr);
+   ci_stop_smc_clock(hwmgr);
+
+   return 0;
+}
+
 const struct pp_smumgr_func ci_smu_funcs = {
.name = "ci_smu",
.smu_init = ci_smu_init,
@@ -2964,4 +2987,5 @@ const struct pp_smumgr_func ci_smu_funcs = {
.is_dpm_running = ci_is_dpm_running,
.update_dpm_settings = ci_update_dpm_settings,
.update_smc_table = ci_update_smc_table,
+   .stop_smc = ci_stop_smc,
 };
diff --git a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c 
b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
index b6fb480668416..b6921db3c1305 100644
--- a/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
+++ b/drivers/gpu/drm/amd/powerplay/smumgr/smumgr.c
@@ -245,3 +245,11 @@ int smum_smc_table_manager(struct pp_hwmgr *hwmgr, uint8_t 
*table, uint16_t tabl
 
return -EINVAL;
 }
+
+int smum_stop_smc(struct pp_hwmgr *hwmgr)
+{
+   if (hwmgr->smumgr_funcs->stop_smc)
+   return hwmgr->smumgr_funcs->stop_smc(hwmgr);
+
+   return 0;
+}
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH AUTOSEL 5.9 19/55] drm/amd/pm: correct the baco reset sequence for CI ASICs

2020-11-09 Thread Sasha Levin
From: Evan Quan 

[ Upstream commit c108725ef589af462be6b957f63c7925e38213eb ]

Correct some registers bitmasks and add mmBIOS_SCRATCH_7
reset.

Signed-off-by: Evan Quan 
Tested-by: Sandeep Raghuraman 
Reviewed-by: Alex Deucher 
Signed-off-by: Alex Deucher 
Signed-off-by: Sasha Levin 
---
 drivers/gpu/drm/amd/powerplay/hwmgr/ci_baco.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/powerplay/hwmgr/ci_baco.c 
b/drivers/gpu/drm/amd/powerplay/hwmgr/ci_baco.c
index 3be40114e63d2..45f608838f6eb 100644
--- a/drivers/gpu/drm/amd/powerplay/hwmgr/ci_baco.c
+++ b/drivers/gpu/drm/amd/powerplay/hwmgr/ci_baco.c
@@ -142,12 +142,12 @@ static const struct baco_cmd_entry exit_baco_tbl[] =
{ CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_BCLK_OFF_MASK,  
 BACO_CNTL__BACO_BCLK_OFF__SHIFT, 0, 0x00 },
{ CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_POWER_OFF_MASK, 
 BACO_CNTL__BACO_POWER_OFF__SHIFT, 0, 0x00 },
{ CMD_DELAY_MS, 0, 0, 0, 20, 0 },
-   { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__PWRGOOD_BF_MASK, 0, 0x, 
0x20 },
+   { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__PWRGOOD_BF_MASK, 0, 0x, 
0x200 },
{ CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_ISO_DIS_MASK, 
BACO_CNTL__BACO_ISO_DIS__SHIFT, 0, 0x01 },
-   { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__PWRGOOD_MASK, 0, 5, 0x1c },
+   { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__PWRGOOD_MASK, 0, 5, 0x1c00 },
{ CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_ANA_ISO_DIS_MASK, 
BACO_CNTL__BACO_ANA_ISO_DIS__SHIFT, 0, 0x01 },
{ CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_RESET_EN_MASK, 
BACO_CNTL__BACO_RESET_EN__SHIFT, 0, 0x00 },
-   { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__RCU_BIF_CONFIG_DONE_MASK, 0, 5, 
0x10 },
+   { CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__RCU_BIF_CONFIG_DONE_MASK, 0, 5, 
0x100 },
{ CMD_READMODIFYWRITE, mmBACO_CNTL, BACO_CNTL__BACO_EN_MASK, 
BACO_CNTL__BACO_EN__SHIFT, 0, 0x00 },
{ CMD_WAITFOR, mmBACO_CNTL, BACO_CNTL__BACO_MODE_MASK, 0, 0x, 
0x00 }
 };
@@ -155,6 +155,7 @@ static const struct baco_cmd_entry exit_baco_tbl[] =
 static const struct baco_cmd_entry clean_baco_tbl[] =
 {
{ CMD_WRITE, mmBIOS_SCRATCH_6, 0, 0, 0, 0 },
+   { CMD_WRITE, mmBIOS_SCRATCH_7, 0, 0, 0, 0 },
{ CMD_WRITE, mmCP_PFP_UCODE_ADDR, 0, 0, 0, 0 }
 };
 
-- 
2.27.0

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v5 4/7] dma-buf: heaps: Skip sync if not mapped

2020-11-09 Thread John Stultz
This patch is basically a port of Ørjan Eide's similar patch for ION
 https://lore.kernel.org/lkml/20200414134629.54567-1-orjan.e...@arm.com/

Only sync the sg-list of dma-buf heap attachment when the attachment
is actually mapped on the device.

dma-bufs may be synced at any time. It can be reached from user space
via DMA_BUF_IOCTL_SYNC, so there are no guarantees from callers on when
syncs may be attempted, and dma_buf_end_cpu_access() and
dma_buf_begin_cpu_access() may not be paired.

Since the sg_list's dma_address isn't set up until the buffer is used
on the device, and dma_map_sg() is called on it, the dma_address will be
NULL if sync is attempted on the dma-buf before it's mapped on a device.

Before v5.0 (commit 55897af63091 ("dma-direct: merge swiotlb_dma_ops
into the dma_direct code")) this was a problem as the dma-api (at least
the swiotlb_dma_ops on arm64) would use the potentially invalid
dma_address. How that failed depended on how the device handled physical
address 0. If 0 was a valid address to physical ram, that page would get
flushed a lot, while the actual pages in the buffer would not get synced
correctly. While if 0 is an invalid physical address it may cause a
fault and trigger a crash.

In v5.0 this was incidentally fixed by commit 55897af63091 ("dma-direct:
merge swiotlb_dma_ops into the dma_direct code"), as this moved the
dma-api to use the page pointer in the sg_list, and (for Ion buffers at
least) this will always be valid if the sg_list exists at all.

But, this issue is re-introduced in v5.3 with
commit 449fa54d6815 ("dma-direct: correct the physical addr in
dma_direct_sync_sg_for_cpu/device") moves the dma-api back to the old
behaviour and picks the dma_address that may be invalid.

dma-buf core doesn't ensure that the buffer is mapped on the device, and
thus have a valid sg_list, before calling the exporter's
begin_cpu_access.

Logic and commit message originally by: Ørjan Eide 

Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Laura Abbott 
Cc: Brian Starkey 
Cc: Hridya Valsaraju 
Cc: Suren Baghdasaryan 
Cc: Sandeep Patil 
Cc: Daniel Mentz 
Cc: Chris Goldsworthy 
Cc: Ørjan Eide 
Cc: Robin Murphy 
Cc: Ezequiel Garcia 
Cc: Simon Ser 
Cc: James Jones 
Cc: linux-me...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Brian Starkey 
Signed-off-by: John Stultz 
---
 drivers/dma-buf/heaps/cma_heap.c| 10 ++
 drivers/dma-buf/heaps/system_heap.c | 10 ++
 2 files changed, 20 insertions(+)

diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
index 5341e5e226d5..028f1e8d6041 100644
--- a/drivers/dma-buf/heaps/cma_heap.c
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -43,6 +43,7 @@ struct dma_heap_attachment {
struct device *dev;
struct sg_table table;
struct list_head list;
+   bool mapped;
 };
 
 static int cma_heap_attach(struct dma_buf *dmabuf,
@@ -67,6 +68,7 @@ static int cma_heap_attach(struct dma_buf *dmabuf,
 
a->dev = attachment->dev;
INIT_LIST_HEAD(>list);
+   a->mapped = false;
 
attachment->priv = a;
 
@@ -101,6 +103,7 @@ static struct sg_table *cma_heap_map_dma_buf(struct 
dma_buf_attachment *attachme
ret = dma_map_sgtable(attachment->dev, table, direction, 0);
if (ret)
return ERR_PTR(-ENOMEM);
+   a->mapped = true;
return table;
 }
 
@@ -108,6 +111,9 @@ static void cma_heap_unmap_dma_buf(struct 
dma_buf_attachment *attachment,
   struct sg_table *table,
   enum dma_data_direction direction)
 {
+   struct dma_heap_attachment *a = attachment->priv;
+
+   a->mapped = false;
dma_unmap_sgtable(attachment->dev, table, direction, 0);
 }
 
@@ -122,6 +128,8 @@ static int cma_heap_dma_buf_begin_cpu_access(struct dma_buf 
*dmabuf,
 
mutex_lock(>lock);
list_for_each_entry(a, >attachments, list) {
+   if (!a->mapped)
+   continue;
dma_sync_sgtable_for_cpu(a->dev, >table, direction);
}
mutex_unlock(>lock);
@@ -140,6 +148,8 @@ static int cma_heap_dma_buf_end_cpu_access(struct dma_buf 
*dmabuf,
 
mutex_lock(>lock);
list_for_each_entry(a, >attachments, list) {
+   if (!a->mapped)
+   continue;
dma_sync_sgtable_for_device(a->dev, >table, direction);
}
mutex_unlock(>lock);
diff --git a/drivers/dma-buf/heaps/system_heap.c 
b/drivers/dma-buf/heaps/system_heap.c
index 5c44f9c06807..15b36bc862b1 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -37,6 +37,7 @@ struct dma_heap_attachment {
struct device *dev;
struct sg_table *table;
struct list_head list;
+   bool mapped;
 };
 
 static struct sg_table *dup_sg_table(struct sg_table *table)
@@ -84,6 +85,7 @@ static int system_heap_attach(struct dma_buf *dmabuf,
a->table = table;

[PATCH v5 7/7] dma-buf: system_heap: Add a system-uncached heap re-using the system heap

2020-11-09 Thread John Stultz
This adds a heap that allocates non-contiguous buffers that are
marked as writecombined, so they are not cached by the CPU.

This is useful, as most graphics buffers are usually not touched
by the CPU or only written into once by the CPU. So when mapping
the buffer over and over between devices, we can skip the CPU
syncing, which saves a lot of cache management overhead, greatly
improving performance.

For folk using ION, there was a ION_FLAG_CACHED flag, which
signaled if the returned buffer should be CPU cacheable or not.
With DMA-BUF heaps, we do not yet have such a flag, and by default
the current heaps (system and cma) produce CPU cachable buffers.
So for folks transitioning from ION to DMA-BUF Heaps, this fills
in some of that missing functionality.

There has been a suggestion to make this functionality a flag
(DMAHEAP_FLAG_UNCACHED?) on the system heap, similar to how
ION used the ION_FLAG_CACHED. But I want to make sure an
_UNCACHED flag would truely be a generic attribute across all
heaps. So far that has been unclear, so having it as a separate
heap seemes better for now. (But I'm open to discussion on this
point!)

This is a rework of earlier efforts to add a uncached system heap,
done utilizing the exisitng system heap, adding just a bit of
logic to handle the uncached case.

Feedback would be very welcome!

Many thanks to Liam Mark for his help to get this working.

Pending opensource users of this code include:
* AOSP HiKey960 gralloc:
  - https://android-review.googlesource.com/c/device/linaro/hikey/+/1399519
  - Visibly improves performance over the system heap
* AOSP Codec2 (possibly, needs more review):
  - 
https://android-review.googlesource.com/c/platform/frameworks/av/+/1360640/17/media/codec2/vndk/C2DmaBufAllocator.cpp#325

Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Laura Abbott 
Cc: Brian Starkey 
Cc: Hridya Valsaraju 
Cc: Suren Baghdasaryan 
Cc: Sandeep Patil 
Cc: Daniel Mentz 
Cc: Chris Goldsworthy 
Cc: Ørjan Eide 
Cc: Robin Murphy 
Cc: Ezequiel Garcia 
Cc: Simon Ser 
Cc: James Jones 
Cc: linux-me...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Stultz 
---
v4:
* Make sys_uncached_heap static, as
Reported-by: kernel test robot 
* Fix wrong return value, caught by smatch
Reported-by: kernel test robot 
Reported-by: Dan Carpenter 
* Ensure we call flush/invalidate_kernel_vmap_range() in the
  uncached cases to try to address feedback about VIVT caches
  from Christoph
* Reorder a few lines as suggested by BrianS
* Avoid holding the initial mapping for the lifetime of the buffer
  as suggested by BrianS
* Fix a unlikely race between allocate and updating the dma_mask
  that BrianS noticed.
---
 drivers/dma-buf/heaps/system_heap.c | 111 
 1 file changed, 95 insertions(+), 16 deletions(-)

diff --git a/drivers/dma-buf/heaps/system_heap.c 
b/drivers/dma-buf/heaps/system_heap.c
index 55367266a47b..1fc5b38cbc59 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -22,6 +22,7 @@
 #include 
 
 static struct dma_heap *sys_heap;
+static struct dma_heap *sys_uncached_heap;
 
 struct system_heap_buffer {
struct dma_heap *heap;
@@ -31,6 +32,8 @@ struct system_heap_buffer {
struct sg_table sg_table;
int vmap_cnt;
void *vaddr;
+
+   bool uncached;
 };
 
 struct dma_heap_attachment {
@@ -38,6 +41,8 @@ struct dma_heap_attachment {
struct sg_table *table;
struct list_head list;
bool mapped;
+
+   bool uncached;
 };
 
 #define HIGH_ORDER_GFP  (((GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN \
@@ -100,7 +105,7 @@ static int system_heap_attach(struct dma_buf *dmabuf,
a->dev = attachment->dev;
INIT_LIST_HEAD(>list);
a->mapped = false;
-
+   a->uncached = buffer->uncached;
attachment->priv = a;
 
mutex_lock(>lock);
@@ -130,9 +135,13 @@ static struct sg_table *system_heap_map_dma_buf(struct 
dma_buf_attachment *attac
 {
struct dma_heap_attachment *a = attachment->priv;
struct sg_table *table = a->table;
+   int attr = 0;
int ret;
 
-   ret = dma_map_sgtable(attachment->dev, table, direction, 0);
+   if (a->uncached)
+   attr = DMA_ATTR_SKIP_CPU_SYNC;
+
+   ret = dma_map_sgtable(attachment->dev, table, direction, attr);
if (ret)
return ERR_PTR(ret);
 
@@ -145,9 +154,12 @@ static void system_heap_unmap_dma_buf(struct 
dma_buf_attachment *attachment,
  enum dma_data_direction direction)
 {
struct dma_heap_attachment *a = attachment->priv;
+   int attr = 0;
 
+   if (a->uncached)
+   attr = DMA_ATTR_SKIP_CPU_SYNC;
a->mapped = false;
-   dma_unmap_sgtable(attachment->dev, table, direction, 0);
+   dma_unmap_sgtable(attachment->dev, table, direction, attr);
 }
 
 static int system_heap_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
@@ -161,10 +173,12 @@ 

[PATCH v5 1/7] dma-buf: system_heap: Rework system heap to use sgtables instead of pagelists

2020-11-09 Thread John Stultz
In preparation for some patches to optmize the system
heap code, rework the dmabuf exporter to utilize sgtables rather
then pageslists for tracking the associated pages.

This will allow for large order page allocations, as well as
more efficient page pooling.

In doing so, the system heap stops using the heap-helpers logic
which sadly is not quite as generic as I was hoping it to be, so
this patch adds heap specific implementations of the dma_buf_ops
function handlers.

Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Laura Abbott 
Cc: Brian Starkey 
Cc: Hridya Valsaraju 
Cc: Suren Baghdasaryan 
Cc: Sandeep Patil 
Cc: Daniel Mentz 
Cc: Chris Goldsworthy 
Cc: Ørjan Eide 
Cc: Robin Murphy 
Cc: Ezequiel Garcia 
Cc: Simon Ser 
Cc: James Jones 
Cc: linux-me...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Brian Starkey 
Signed-off-by: John Stultz 
---
v2:
* Fix locking issue and an unused return value Reported-by:
 kernel test robot 
 Julia Lawall 
* Make system_heap_buf_ops static Reported-by:
 kernel test robot 
v3:
* Use the new sgtable mapping functions, as Suggested-by:
 Daniel Mentz 
v4:
* Make sys_heap static (indirectly) Reported-by:
 kernel test robot 
* Spelling fix suggested by BrianS
---
 drivers/dma-buf/heaps/system_heap.c | 344 
 1 file changed, 298 insertions(+), 46 deletions(-)

diff --git a/drivers/dma-buf/heaps/system_heap.c 
b/drivers/dma-buf/heaps/system_heap.c
index 0bf688e3c023..5c44f9c06807 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -3,7 +3,11 @@
  * DMABUF System heap exporter
  *
  * Copyright (C) 2011 Google, Inc.
- * Copyright (C) 2019 Linaro Ltd.
+ * Copyright (C) 2019, 2020 Linaro Ltd.
+ *
+ * Portions based off of Andrew Davis' SRAM heap:
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Andrew F. Davis 
  */
 
 #include 
@@ -15,72 +19,321 @@
 #include 
 #include 
 #include 
-#include 
-#include 
+#include 
+
+static struct dma_heap *sys_heap;
 
-#include "heap-helpers.h"
+struct system_heap_buffer {
+   struct dma_heap *heap;
+   struct list_head attachments;
+   struct mutex lock;
+   unsigned long len;
+   struct sg_table sg_table;
+   int vmap_cnt;
+   void *vaddr;
+};
 
-struct dma_heap *sys_heap;
+struct dma_heap_attachment {
+   struct device *dev;
+   struct sg_table *table;
+   struct list_head list;
+};
 
-static void system_heap_free(struct heap_helper_buffer *buffer)
+static struct sg_table *dup_sg_table(struct sg_table *table)
 {
-   pgoff_t pg;
+   struct sg_table *new_table;
+   int ret, i;
+   struct scatterlist *sg, *new_sg;
+
+   new_table = kzalloc(sizeof(*new_table), GFP_KERNEL);
+   if (!new_table)
+   return ERR_PTR(-ENOMEM);
+
+   ret = sg_alloc_table(new_table, table->orig_nents, GFP_KERNEL);
+   if (ret) {
+   kfree(new_table);
+   return ERR_PTR(-ENOMEM);
+   }
+
+   new_sg = new_table->sgl;
+   for_each_sgtable_sg(table, sg, i) {
+   sg_set_page(new_sg, sg_page(sg), sg->length, sg->offset);
+   new_sg = sg_next(new_sg);
+   }
+
+   return new_table;
+}
+
+static int system_heap_attach(struct dma_buf *dmabuf,
+ struct dma_buf_attachment *attachment)
+{
+   struct system_heap_buffer *buffer = dmabuf->priv;
+   struct dma_heap_attachment *a;
+   struct sg_table *table;
+
+   a = kzalloc(sizeof(*a), GFP_KERNEL);
+   if (!a)
+   return -ENOMEM;
+
+   table = dup_sg_table(>sg_table);
+   if (IS_ERR(table)) {
+   kfree(a);
+   return -ENOMEM;
+   }
+
+   a->table = table;
+   a->dev = attachment->dev;
+   INIT_LIST_HEAD(>list);
+
+   attachment->priv = a;
+
+   mutex_lock(>lock);
+   list_add(>list, >attachments);
+   mutex_unlock(>lock);
+
+   return 0;
+}
+
+static void system_heap_detach(struct dma_buf *dmabuf,
+  struct dma_buf_attachment *attachment)
+{
+   struct system_heap_buffer *buffer = dmabuf->priv;
+   struct dma_heap_attachment *a = attachment->priv;
+
+   mutex_lock(>lock);
+   list_del(>list);
+   mutex_unlock(>lock);
+
+   sg_free_table(a->table);
+   kfree(a->table);
+   kfree(a);
+}
 
-   for (pg = 0; pg < buffer->pagecount; pg++)
-   __free_page(buffer->pages[pg]);
-   kfree(buffer->pages);
+static struct sg_table *system_heap_map_dma_buf(struct dma_buf_attachment 
*attachment,
+   enum dma_data_direction 
direction)
+{
+   struct dma_heap_attachment *a = attachment->priv;
+   struct sg_table *table = a->table;
+   int ret;
+
+   ret = dma_map_sgtable(attachment->dev, table, direction, 0);
+   if (ret)
+   return ERR_PTR(ret);
+
+   return table;
+}
+
+static void 

[PATCH v5 2/7] dma-buf: heaps: Move heap-helper logic into the cma_heap implementation

2020-11-09 Thread John Stultz
Since the heap-helpers logic ended up not being as generic as
hoped, move the heap-helpers dma_buf_ops implementations into
the cma_heap directly.

This will allow us to remove the heap_helpers code in a following
patch.

Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Laura Abbott 
Cc: Brian Starkey 
Cc: Hridya Valsaraju 
Cc: Suren Baghdasaryan 
Cc: Sandeep Patil 
Cc: Daniel Mentz 
Cc: Chris Goldsworthy 
Cc: Ørjan Eide 
Cc: Robin Murphy 
Cc: Ezequiel Garcia 
Cc: Simon Ser 
Cc: James Jones 
Cc: linux-me...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Brian Starkey 
Signed-off-by: John Stultz 
---
v2:
* Fix unused return value and locking issue Reported-by:
kernel test robot 
Julia Lawall 
* Make cma_heap_buf_ops static suggested by
kernel test robot 
* Fix uninitialized return in cma Reported-by:
kernel test robot 
* Minor cleanups
v3:
* Use the new sgtable mapping functions, as Suggested-by:
 Daniel Mentz 
v4:
* Spelling fix suggested by BrianS
---
 drivers/dma-buf/heaps/cma_heap.c | 314 ++-
 1 file changed, 265 insertions(+), 49 deletions(-)

diff --git a/drivers/dma-buf/heaps/cma_heap.c b/drivers/dma-buf/heaps/cma_heap.c
index e55384dc115b..5341e5e226d5 100644
--- a/drivers/dma-buf/heaps/cma_heap.c
+++ b/drivers/dma-buf/heaps/cma_heap.c
@@ -2,76 +2,290 @@
 /*
  * DMABUF CMA heap exporter
  *
- * Copyright (C) 2012, 2019 Linaro Ltd.
+ * Copyright (C) 2012, 2019, 2020 Linaro Ltd.
  * Author:  for ST-Ericsson.
+ *
+ * Also utilizing parts of Andrew Davis' SRAM heap:
+ * Copyright (C) 2019 Texas Instruments Incorporated - http://www.ti.com/
+ * Andrew F. Davis 
  */
-
 #include 
-#include 
 #include 
 #include 
 #include 
 #include 
-#include 
 #include 
+#include 
+#include 
 #include 
-#include 
 #include 
-#include 
+#include 
 
-#include "heap-helpers.h"
 
 struct cma_heap {
struct dma_heap *heap;
struct cma *cma;
 };
 
-static void cma_heap_free(struct heap_helper_buffer *buffer)
+struct cma_heap_buffer {
+   struct cma_heap *heap;
+   struct list_head attachments;
+   struct mutex lock;
+   unsigned long len;
+   struct page *cma_pages;
+   struct page **pages;
+   pgoff_t pagecount;
+   int vmap_cnt;
+   void *vaddr;
+};
+
+struct dma_heap_attachment {
+   struct device *dev;
+   struct sg_table table;
+   struct list_head list;
+};
+
+static int cma_heap_attach(struct dma_buf *dmabuf,
+  struct dma_buf_attachment *attachment)
 {
-   struct cma_heap *cma_heap = dma_heap_get_drvdata(buffer->heap);
-   unsigned long nr_pages = buffer->pagecount;
-   struct page *cma_pages = buffer->priv_virt;
+   struct cma_heap_buffer *buffer = dmabuf->priv;
+   struct dma_heap_attachment *a;
+   int ret;
 
-   /* free page list */
-   kfree(buffer->pages);
-   /* release memory */
-   cma_release(cma_heap->cma, cma_pages, nr_pages);
+   a = kzalloc(sizeof(*a), GFP_KERNEL);
+   if (!a)
+   return -ENOMEM;
+
+   ret = sg_alloc_table_from_pages(>table, buffer->pages,
+   buffer->pagecount, 0,
+   buffer->pagecount << PAGE_SHIFT,
+   GFP_KERNEL);
+   if (ret) {
+   kfree(a);
+   return ret;
+   }
+
+   a->dev = attachment->dev;
+   INIT_LIST_HEAD(>list);
+
+   attachment->priv = a;
+
+   mutex_lock(>lock);
+   list_add(>list, >attachments);
+   mutex_unlock(>lock);
+
+   return 0;
+}
+
+static void cma_heap_detach(struct dma_buf *dmabuf,
+   struct dma_buf_attachment *attachment)
+{
+   struct cma_heap_buffer *buffer = dmabuf->priv;
+   struct dma_heap_attachment *a = attachment->priv;
+
+   mutex_lock(>lock);
+   list_del(>list);
+   mutex_unlock(>lock);
+
+   sg_free_table(>table);
+   kfree(a);
+}
+
+static struct sg_table *cma_heap_map_dma_buf(struct dma_buf_attachment 
*attachment,
+enum dma_data_direction direction)
+{
+   struct dma_heap_attachment *a = attachment->priv;
+   struct sg_table *table = >table;
+   int ret;
+
+   ret = dma_map_sgtable(attachment->dev, table, direction, 0);
+   if (ret)
+   return ERR_PTR(-ENOMEM);
+   return table;
+}
+
+static void cma_heap_unmap_dma_buf(struct dma_buf_attachment *attachment,
+  struct sg_table *table,
+  enum dma_data_direction direction)
+{
+   dma_unmap_sgtable(attachment->dev, table, direction, 0);
+}
+
+static int cma_heap_dma_buf_begin_cpu_access(struct dma_buf *dmabuf,
+enum dma_data_direction direction)
+{
+   struct cma_heap_buffer *buffer = dmabuf->priv;
+   struct dma_heap_attachment *a;
+
+   if (buffer->vmap_cnt)
+   

[PATCH v5 6/7] dma-buf: dma-heap: Keep track of the heap device struct

2020-11-09 Thread John Stultz
Keep track of the heap device struct.

This will be useful for special DMA allocations
and actions.

Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Laura Abbott 
Cc: Brian Starkey 
Cc: Hridya Valsaraju 
Cc: Suren Baghdasaryan 
Cc: Sandeep Patil 
Cc: Daniel Mentz 
Cc: Chris Goldsworthy 
Cc: Ørjan Eide 
Cc: Robin Murphy 
Cc: Ezequiel Garcia 
Cc: Simon Ser 
Cc: James Jones 
Cc: linux-me...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: John Stultz 
---
 drivers/dma-buf/dma-heap.c | 33 +
 include/linux/dma-heap.h   |  9 +
 2 files changed, 34 insertions(+), 8 deletions(-)

diff --git a/drivers/dma-buf/dma-heap.c b/drivers/dma-buf/dma-heap.c
index afd22c9dbdcf..72c746755d89 100644
--- a/drivers/dma-buf/dma-heap.c
+++ b/drivers/dma-buf/dma-heap.c
@@ -30,6 +30,7 @@
  * @heap_devt  heap device node
  * @list   list head connecting to list of heaps
  * @heap_cdev  heap char device
+ * @heap_dev   heap device struct
  *
  * Represents a heap of memory from which buffers can be made.
  */
@@ -40,6 +41,7 @@ struct dma_heap {
dev_t heap_devt;
struct list_head list;
struct cdev heap_cdev;
+   struct device *heap_dev;
 };
 
 static LIST_HEAD(heap_list);
@@ -190,10 +192,21 @@ void *dma_heap_get_drvdata(struct dma_heap *heap)
return heap->priv;
 }
 
+/**
+ * dma_heap_get_dev() - get device struct for the heap
+ * @heap: DMA-Heap to retrieve device struct from
+ *
+ * Returns:
+ * The device struct for the heap.
+ */
+struct device *dma_heap_get_dev(struct dma_heap *heap)
+{
+   return heap->heap_dev;
+}
+
 struct dma_heap *dma_heap_add(const struct dma_heap_export_info *exp_info)
 {
struct dma_heap *heap, *h, *err_ret;
-   struct device *dev_ret;
unsigned int minor;
int ret;
 
@@ -247,16 +260,20 @@ struct dma_heap *dma_heap_add(const struct 
dma_heap_export_info *exp_info)
goto err1;
}
 
-   dev_ret = device_create(dma_heap_class,
-   NULL,
-   heap->heap_devt,
-   NULL,
-   heap->name);
-   if (IS_ERR(dev_ret)) {
+   heap->heap_dev = device_create(dma_heap_class,
+  NULL,
+  heap->heap_devt,
+  NULL,
+  heap->name);
+   if (IS_ERR(heap->heap_dev)) {
pr_err("dma_heap: Unable to create device\n");
-   err_ret = ERR_CAST(dev_ret);
+   err_ret = ERR_CAST(heap->heap_dev);
goto err2;
}
+
+   /* Make sure it doesn't disappear on us */
+   heap->heap_dev = get_device(heap->heap_dev);
+
/* Add heap to the list */
mutex_lock(_list_lock);
list_add(>list, _list);
diff --git a/include/linux/dma-heap.h b/include/linux/dma-heap.h
index 454e354d1ffb..82857e096910 100644
--- a/include/linux/dma-heap.h
+++ b/include/linux/dma-heap.h
@@ -50,6 +50,15 @@ struct dma_heap_export_info {
  */
 void *dma_heap_get_drvdata(struct dma_heap *heap);
 
+/**
+ * dma_heap_get_dev() - get device struct for the heap
+ * @heap: DMA-Heap to retrieve device struct from
+ *
+ * Returns:
+ * The device struct for the heap.
+ */
+struct device *dma_heap_get_dev(struct dma_heap *heap);
+
 /**
  * dma_heap_add - adds a heap to dmabuf heaps
  * @exp_info:  information needed to register this heap
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v5 5/7] dma-buf: system_heap: Allocate higher order pages if available

2020-11-09 Thread John Stultz
While the system heap can return non-contiguous pages,
try to allocate larger order pages if possible.

This will allow slight performance gains and make implementing
page pooling easier.

Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Laura Abbott 
Cc: Brian Starkey 
Cc: Hridya Valsaraju 
Cc: Suren Baghdasaryan 
Cc: Sandeep Patil 
Cc: Daniel Mentz 
Cc: Chris Goldsworthy 
Cc: Ørjan Eide 
Cc: Robin Murphy 
Cc: Ezequiel Garcia 
Cc: Simon Ser 
Cc: James Jones 
Cc: linux-me...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Brian Starkey 
Signed-off-by: John Stultz 
---
v3:
* Use page_size() rather then opencoding it
v5:
* Add comment explaining order size rational
---
 drivers/dma-buf/heaps/system_heap.c | 89 +++--
 1 file changed, 71 insertions(+), 18 deletions(-)

diff --git a/drivers/dma-buf/heaps/system_heap.c 
b/drivers/dma-buf/heaps/system_heap.c
index 15b36bc862b1..55367266a47b 100644
--- a/drivers/dma-buf/heaps/system_heap.c
+++ b/drivers/dma-buf/heaps/system_heap.c
@@ -40,6 +40,20 @@ struct dma_heap_attachment {
bool mapped;
 };
 
+#define HIGH_ORDER_GFP  (((GFP_HIGHUSER | __GFP_ZERO | __GFP_NOWARN \
+   | __GFP_NORETRY) & ~__GFP_RECLAIM) \
+   | __GFP_COMP)
+#define LOW_ORDER_GFP (GFP_HIGHUSER | __GFP_ZERO | __GFP_COMP)
+static gfp_t order_flags[] = {HIGH_ORDER_GFP, LOW_ORDER_GFP, LOW_ORDER_GFP};
+/*
+ * The selection of the orders used for allocation (1MB, 64K, 4K) is designed
+ * to match with the sizes often found in IOMMUs. Using order 4 pages instead
+ * of order 0 pages can significantly improve the performance of many IOMMUs
+ * by reducing TLB pressure and time spent updating page tables.
+ */
+static const unsigned int orders[] = {8, 4, 0};
+#define NUM_ORDERS ARRAY_SIZE(orders)
+
 static struct sg_table *dup_sg_table(struct sg_table *table)
 {
struct sg_table *new_table;
@@ -270,8 +284,11 @@ static void system_heap_dma_buf_release(struct dma_buf 
*dmabuf)
int i;
 
table = >sg_table;
-   for_each_sgtable_sg(table, sg, i)
-   __free_page(sg_page(sg));
+   for_each_sg(table->sgl, sg, table->nents, i) {
+   struct page *page = sg_page(sg);
+
+   __free_pages(page, compound_order(page));
+   }
sg_free_table(table);
kfree(buffer);
 }
@@ -289,6 +306,26 @@ static const struct dma_buf_ops system_heap_buf_ops = {
.release = system_heap_dma_buf_release,
 };
 
+static struct page *alloc_largest_available(unsigned long size,
+   unsigned int max_order)
+{
+   struct page *page;
+   int i;
+
+   for (i = 0; i < NUM_ORDERS; i++) {
+   if (size <  (PAGE_SIZE << orders[i]))
+   continue;
+   if (max_order < orders[i])
+   continue;
+
+   page = alloc_pages(order_flags[i], orders[i]);
+   if (!page)
+   continue;
+   return page;
+   }
+   return NULL;
+}
+
 static int system_heap_allocate(struct dma_heap *heap,
unsigned long len,
unsigned long fd_flags,
@@ -296,11 +333,13 @@ static int system_heap_allocate(struct dma_heap *heap,
 {
struct system_heap_buffer *buffer;
DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
+   unsigned long size_remaining = len;
+   unsigned int max_order = orders[0];
struct dma_buf *dmabuf;
struct sg_table *table;
struct scatterlist *sg;
-   pgoff_t pagecount;
-   pgoff_t pg;
+   struct list_head pages;
+   struct page *page, *tmp_page;
int i, ret = -ENOMEM;
 
buffer = kzalloc(sizeof(*buffer), GFP_KERNEL);
@@ -312,25 +351,35 @@ static int system_heap_allocate(struct dma_heap *heap,
buffer->heap = heap;
buffer->len = len;
 
-   table = >sg_table;
-   pagecount = len / PAGE_SIZE;
-   if (sg_alloc_table(table, pagecount, GFP_KERNEL))
-   goto free_buffer;
-
-   sg = table->sgl;
-   for (pg = 0; pg < pagecount; pg++) {
-   struct page *page;
+   INIT_LIST_HEAD();
+   i = 0;
+   while (size_remaining > 0) {
/*
 * Avoid trying to allocate memory if the process
 * has been killed by SIGKILL
 */
if (fatal_signal_pending(current))
-   goto free_pages;
-   page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+   goto free_buffer;
+
+   page = alloc_largest_available(size_remaining, max_order);
if (!page)
-   goto free_pages;
+   goto free_buffer;
+
+   list_add_tail(>lru, );
+   size_remaining -= page_size(page);
+   max_order = compound_order(page);
+   i++;
+   }
+
+   table = 

[PATCH v5 3/7] dma-buf: heaps: Remove heap-helpers code

2020-11-09 Thread John Stultz
The heap-helpers code was not as generic as initially hoped
and it is now not being used, so remove it from the tree.

Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Laura Abbott 
Cc: Brian Starkey 
Cc: Hridya Valsaraju 
Cc: Suren Baghdasaryan 
Cc: Sandeep Patil 
Cc: Daniel Mentz 
Cc: Chris Goldsworthy 
Cc: Ørjan Eide 
Cc: Robin Murphy 
Cc: Ezequiel Garcia 
Cc: Simon Ser 
Cc: James Jones 
Cc: linux-me...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org
Reviewed-by: Brian Starkey 
Signed-off-by: John Stultz 
---
 drivers/dma-buf/heaps/Makefile   |   1 -
 drivers/dma-buf/heaps/heap-helpers.c | 270 ---
 drivers/dma-buf/heaps/heap-helpers.h |  53 --
 3 files changed, 324 deletions(-)
 delete mode 100644 drivers/dma-buf/heaps/heap-helpers.c
 delete mode 100644 drivers/dma-buf/heaps/heap-helpers.h

diff --git a/drivers/dma-buf/heaps/Makefile b/drivers/dma-buf/heaps/Makefile
index 6e54cdec3da0..974467791032 100644
--- a/drivers/dma-buf/heaps/Makefile
+++ b/drivers/dma-buf/heaps/Makefile
@@ -1,4 +1,3 @@
 # SPDX-License-Identifier: GPL-2.0
-obj-y  += heap-helpers.o
 obj-$(CONFIG_DMABUF_HEAPS_SYSTEM)  += system_heap.o
 obj-$(CONFIG_DMABUF_HEAPS_CMA) += cma_heap.o
diff --git a/drivers/dma-buf/heaps/heap-helpers.c 
b/drivers/dma-buf/heaps/heap-helpers.c
deleted file mode 100644
index d0696cf937af..
--- a/drivers/dma-buf/heaps/heap-helpers.c
+++ /dev/null
@@ -1,270 +0,0 @@
-// SPDX-License-Identifier: GPL-2.0
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-#include 
-
-#include "heap-helpers.h"
-
-void init_heap_helper_buffer(struct heap_helper_buffer *buffer,
-void (*free)(struct heap_helper_buffer *))
-{
-   buffer->priv_virt = NULL;
-   mutex_init(>lock);
-   buffer->vmap_cnt = 0;
-   buffer->vaddr = NULL;
-   buffer->pagecount = 0;
-   buffer->pages = NULL;
-   INIT_LIST_HEAD(>attachments);
-   buffer->free = free;
-}
-
-struct dma_buf *heap_helper_export_dmabuf(struct heap_helper_buffer *buffer,
- int fd_flags)
-{
-   DEFINE_DMA_BUF_EXPORT_INFO(exp_info);
-
-   exp_info.ops = _helper_ops;
-   exp_info.size = buffer->size;
-   exp_info.flags = fd_flags;
-   exp_info.priv = buffer;
-
-   return dma_buf_export(_info);
-}
-
-static void *dma_heap_map_kernel(struct heap_helper_buffer *buffer)
-{
-   void *vaddr;
-
-   vaddr = vmap(buffer->pages, buffer->pagecount, VM_MAP, PAGE_KERNEL);
-   if (!vaddr)
-   return ERR_PTR(-ENOMEM);
-
-   return vaddr;
-}
-
-static void dma_heap_buffer_destroy(struct heap_helper_buffer *buffer)
-{
-   if (buffer->vmap_cnt > 0) {
-   WARN(1, "%s: buffer still mapped in the kernel\n", __func__);
-   vunmap(buffer->vaddr);
-   }
-
-   buffer->free(buffer);
-}
-
-static void *dma_heap_buffer_vmap_get(struct heap_helper_buffer *buffer)
-{
-   void *vaddr;
-
-   if (buffer->vmap_cnt) {
-   buffer->vmap_cnt++;
-   return buffer->vaddr;
-   }
-   vaddr = dma_heap_map_kernel(buffer);
-   if (IS_ERR(vaddr))
-   return vaddr;
-   buffer->vaddr = vaddr;
-   buffer->vmap_cnt++;
-   return vaddr;
-}
-
-static void dma_heap_buffer_vmap_put(struct heap_helper_buffer *buffer)
-{
-   if (!--buffer->vmap_cnt) {
-   vunmap(buffer->vaddr);
-   buffer->vaddr = NULL;
-   }
-}
-
-struct dma_heaps_attachment {
-   struct device *dev;
-   struct sg_table table;
-   struct list_head list;
-};
-
-static int dma_heap_attach(struct dma_buf *dmabuf,
-  struct dma_buf_attachment *attachment)
-{
-   struct dma_heaps_attachment *a;
-   struct heap_helper_buffer *buffer = dmabuf->priv;
-   int ret;
-
-   a = kzalloc(sizeof(*a), GFP_KERNEL);
-   if (!a)
-   return -ENOMEM;
-
-   ret = sg_alloc_table_from_pages(>table, buffer->pages,
-   buffer->pagecount, 0,
-   buffer->pagecount << PAGE_SHIFT,
-   GFP_KERNEL);
-   if (ret) {
-   kfree(a);
-   return ret;
-   }
-
-   a->dev = attachment->dev;
-   INIT_LIST_HEAD(>list);
-
-   attachment->priv = a;
-
-   mutex_lock(>lock);
-   list_add(>list, >attachments);
-   mutex_unlock(>lock);
-
-   return 0;
-}
-
-static void dma_heap_detach(struct dma_buf *dmabuf,
-   struct dma_buf_attachment *attachment)
-{
-   struct dma_heaps_attachment *a = attachment->priv;
-   struct heap_helper_buffer *buffer = dmabuf->priv;
-
-   mutex_lock(>lock);
-   list_del(>list);
-   mutex_unlock(>lock);
-
-   sg_free_table(>table);
-   kfree(a);
-}
-
-static
-struct sg_table *dma_heap_map_dma_buf(struct 

[PATCH v5 0/7] dma-buf: Performance improvements for system heap & a system-uncached implementation

2020-11-09 Thread John Stultz
Hey All,
  So just wanted to send my last revision of my patch series
of performance optimizations to the dma-buf system heap.

This series reworks the system heap to use sgtables, and then
consolidates the pagelist method from the heap-helpers into the
CMA heap. After which the heap-helpers logic is removed (as it
is unused). I'd still like to find a better way to avoid some of
the logic duplication in implementing the entire dma_buf_ops
handlers per heap. But unfortunately that code is tied somewhat
to how the buffer's memory is tracked. As more heaps show up I
think we'll have a better idea how to best share code, so for
now I think this is ok.

After this, the series introduces an optimization that
Ørjan Eide implemented for ION that avoids calling sync on
attachments that don't have a mapping.

Next, an optimization to use larger order pages for the system
heap. This change brings us closer to the current performance
of the ION allocation code (though there still is a gap due
to ION using a mix of deferred-freeing and page pools, I'll be
looking at integrating those eventually).

Finally, a reworked version of my uncached system heap
implementation I was submitting a few weeks back. Since it
duplicated a lot of the now reworked system heap code, I
realized it would be much simpler to add the functionality to
the system_heap implementation itself.

While not improving the core allocation performance, the
uncached heap allocations do result in *much* improved
performance on HiKey960 as it avoids a lot of flushing and
invalidating buffers that the cpu doesn't touch often.

Feedback on these would be great!

thanks
-john

New in v5:
* Added a comment explaining why the order sizes are
  chosen as they are

Cc: Sumit Semwal 
Cc: Liam Mark 
Cc: Laura Abbott 
Cc: Brian Starkey 
Cc: Hridya Valsaraju 
Cc: Suren Baghdasaryan 
Cc: Sandeep Patil 
Cc: Daniel Mentz 
Cc: Chris Goldsworthy 
Cc: Ørjan Eide 
Cc: Robin Murphy 
Cc: Ezequiel Garcia 
Cc: Simon Ser 
Cc: James Jones 
Cc: linux-me...@vger.kernel.org
Cc: dri-devel@lists.freedesktop.org

John Stultz (7):
  dma-buf: system_heap: Rework system heap to use sgtables instead of
pagelists
  dma-buf: heaps: Move heap-helper logic into the cma_heap
implementation
  dma-buf: heaps: Remove heap-helpers code
  dma-buf: heaps: Skip sync if not mapped
  dma-buf: system_heap: Allocate higher order pages if available
  dma-buf: dma-heap: Keep track of the heap device struct
  dma-buf: system_heap: Add a system-uncached heap re-using the system
heap

 drivers/dma-buf/dma-heap.c   |  33 +-
 drivers/dma-buf/heaps/Makefile   |   1 -
 drivers/dma-buf/heaps/cma_heap.c | 324 +++---
 drivers/dma-buf/heaps/heap-helpers.c | 270 ---
 drivers/dma-buf/heaps/heap-helpers.h |  53 ---
 drivers/dma-buf/heaps/system_heap.c  | 494 ---
 include/linux/dma-heap.h |   9 +
 7 files changed, 753 insertions(+), 431 deletions(-)
 delete mode 100644 drivers/dma-buf/heaps/heap-helpers.c
 delete mode 100644 drivers/dma-buf/heaps/heap-helpers.h

-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [PATCH] drm/ast: Create chip AST2600

2020-11-09 Thread Kuo-Hsiang Chou
Hi, Thomas,

OK, I will describe the patch more precisely in the future. Thanks again!!!

Have a good day.
Kuo-Hsiang Chou

-Original Message-
From: Thomas Zimmermann [mailto:tzimmerm...@suse.de] 
Sent: Monday, November 09, 2020 6:26 PM
To: Kuo-Hsiang Chou ; 
dri-devel@lists.freedesktop.org; linux-ker...@vger.kernel.org
Cc: airl...@redhat.com; airl...@linux.ie; dan...@ffwll.ch; Jenmin Yuan 
; Arc Sung ; Tommy Huang 

Subject: Re: [PATCH] drm/ast: Create chip AST2600

Hi

Am 09.11.20 um 10:38 schrieb KuoHsiang Chou:
> [New] Support AST2600

A style issue: better write a nice sentence than these tags.  For the patch at 
hand, I'd preferred something like: "Only add an id for supporting AST2600. No 
functional changes are required."

I assume that there areno further changes required for AST2600.

> 
> Signed-off-by: KuoHsiang Chou 

Reviewed-by: Thomas Zimmermann 

I'll add the patch to drm-misc-next. Thanks!

Best regards
Thomas

> ---
>  drivers/gpu/drm/ast/ast_drv.h  | 1 +
>  drivers/gpu/drm/ast/ast_main.c | 5 -
>  2 files changed, 5 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/ast/ast_drv.h 
> b/drivers/gpu/drm/ast/ast_drv.h index 467049ca8430..6b9e3b94a712 
> 100644
> --- a/drivers/gpu/drm/ast/ast_drv.h
> +++ b/drivers/gpu/drm/ast/ast_drv.h
> @@ -63,6 +63,7 @@ enum ast_chip {
>   AST2300,
>   AST2400,
>   AST2500,
> + AST2600,
>  };
> 
>  enum ast_tx_chip {
> diff --git a/drivers/gpu/drm/ast/ast_main.c 
> b/drivers/gpu/drm/ast/ast_main.c index 77066bca8793..4ec6884f6c65 
> 100644
> --- a/drivers/gpu/drm/ast/ast_main.c
> +++ b/drivers/gpu/drm/ast/ast_main.c
> @@ -143,7 +143,10 @@ static int ast_detect_chip(struct drm_device *dev, bool 
> *need_post)
>   ast_detect_config_mode(dev, _rev);
> 
>   /* Identify chipset */
> - if (dev->pdev->revision >= 0x40) {
> + if (dev->pdev->revision >= 0x50) {
> + ast->chip = AST2600;
> + drm_info(dev, "AST 2600 detected\n");
> + } else if (dev->pdev->revision >= 0x40) {
>   ast->chip = AST2500;
>   drm_info(dev, "AST 2500 detected\n");
>   } else if (dev->pdev->revision >= 0x30) {
> --
> 2.18.4
> 

--
Thomas Zimmermann
Graphics Driver Developer
SUSE Software Solutions Germany GmbH
Maxfeldstr. 5, 90409 Nürnberg, Germany
(HRB 36809, AG Nürnberg)
Geschäftsführer: Felix Imendörffer
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: Subject: [RFC] clang tooling cleanups

2020-11-09 Thread Joe Perches
On Tue, 2020-10-27 at 09:42 -0700, t...@redhat.com wrote:
> This rfc will describe
> An upcoming treewide cleanup.
> How clang tooling was used to programatically do the clean up.
> Solicit opinions on how to generally use clang tooling.
> 
> The clang warning -Wextra-semi-stmt produces about 10k warnings.
> Reviewing these, a subset of semicolon after a switch looks safe to
> fix all the time.  An example problem
> 
> void foo(int a) {
>  switch(a) {
>  case 1:
>  ...
>  }; <--- extra semicolon
> }
> 
> Treewide, there are about 100 problems in 50 files for x86_64 allyesconfig.
> These fixes will be the upcoming cleanup.

coccinelle already does some of these.

For instance: scripts/coccinelle/misc/semicolon.cocci

Perhaps some tool coordination can be done here as
coccinelle/checkpatch/clang/Lindent call all be used
to do some facet or another of these cleanup issues.



___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v4 4/5] drm: panel: simple: Add BOE NV110WTM-N61

2020-11-09 Thread Doug Anderson
Hi,

On Mon, Nov 9, 2020 at 5:01 PM Douglas Anderson  wrote:
>
> Add support for the BOE NV110WTM-N61 panel.  The EDID lists two modes
> (one for 60 Hz refresh rate and one for 40 Hz), so we'll list both of
> them here.
>
> Note that the panel datasheet requires 80 ms between HPD asserting and
> the backlight power being turned on.  We'll use the new timing
> constraints structure to do this cleanly.  This assumes that the
> backlight will be enabled _after_ the panel enable finishes.  This is
> how it works today and seems a sane assumption.
>
> Signed-off-by: Douglas Anderson 
> ---
>
> Changes in v4:
> - Rebased atop changes in earlier patches.
>
> Changes in v2:
> - Adjust for shorter names in patch #1.
>
>  drivers/gpu/drm/panel/panel-simple.c | 46 
>  1 file changed, 46 insertions(+)
>
> diff --git a/drivers/gpu/drm/panel/panel-simple.c 
> b/drivers/gpu/drm/panel/panel-simple.c
> index a54f42cb3adc..9bb723696e94 100644
> --- a/drivers/gpu/drm/panel/panel-simple.c
> +++ b/drivers/gpu/drm/panel/panel-simple.c
> @@ -1396,6 +1396,49 @@ static const struct panel_desc boe_nv101wxmn51 = {
> },
>  };
>
> +static const struct drm_display_mode boe_nv110wtm_n61_modes[] = {
> +   {
> +   .clock = 207800,
> +   .hdisplay = 2160,
> +   .hsync_start = 2160 + 48,
> +   .hsync_end = 2160 + 48 + 32,
> +   .htotal = 2160 + 48 + 32 + 100,
> +   .vdisplay = 1440,
> +   .vsync_start = 1440 + 3,
> +   .vsync_end = 1440 + 3 + 6,
> +   .vtotal = 1440 + 3 + 6 + 31,
> +   },
> +   {
> +   .clock = 138500,
> +   .hdisplay = 2160,
> +   .hsync_start = 2160 + 48,
> +   .hsync_end = 2160 + 48 + 32,
> +   .htotal = 2160 + 48 + 32 + 100,
> +   .vdisplay = 1440,
> +   .vsync_start = 1440 + 3,
> +   .vsync_end = 1440 + 3 + 6,
> +   .vtotal = 1440 + 3 + 6 + 31,
> +   },

I can do it as a follow-up patch if there is no other reason to spin,
but I realized that I forgot to add:

.flags = DRM_MODE_FLAG_PHSYNC | DRM_MODE_FLAG_NVSYNC,

...to both the 40 and 60 Hz modes to make it match what's in the EDID.
I'm also OK w/ it getting added by a maintainer when this lands if
that makes sense.

-Doug
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


linux-next: build warning after merge of the drm-misc tree

2020-11-09 Thread Stephen Rothwell
Hi all,

After merging the drm-misc tree, today's linux-next build (arm
multi_v7_defconfig) produced this warning:

In file included from include/linux/kernel.h:14,
 from include/asm-generic/bug.h:20,
 from arch/arm/include/asm/bug.h:60,
 from include/linux/bug.h:5,
 from include/linux/io.h:11,
 from include/linux/dma-buf-map.h:9,
 from include/linux/dma-buf.h:16,
 from drivers/gpu/drm/drm_fb_helper.c:33:
drivers/gpu/drm/drm_fb_helper.c: In function 'fb_read_screen_base':
include/linux/minmax.h:18:28: warning: comparison of distinct pointer types 
lacks a cast
   18 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
  |^~
include/linux/minmax.h:32:4: note: in expansion of macro '__typecheck'
   32 |   (__typecheck(x, y) && __no_side_effects(x, y))
  |^~~
include/linux/minmax.h:42:24: note: in expansion of macro '__safe_cmp'
   42 |  __builtin_choose_expr(__safe_cmp(x, y), \
  |^~
include/linux/minmax.h:51:19: note: in expansion of macro '__careful_cmp'
   51 | #define min(x, y) __careful_cmp(x, y, <)
  |   ^
drivers/gpu/drm/drm_fb_helper.c:2041:22: note: in expansion of macro 'min'
 2041 |  size_t alloc_size = min(count, PAGE_SIZE);
  |  ^~~
drivers/gpu/drm/drm_fb_helper.c: In function 'fb_write_screen_base':
include/linux/minmax.h:18:28: warning: comparison of distinct pointer types 
lacks a cast
   18 |  (!!(sizeof((typeof(x) *)1 == (typeof(y) *)1)))
  |^~
include/linux/minmax.h:32:4: note: in expansion of macro '__typecheck'
   32 |   (__typecheck(x, y) && __no_side_effects(x, y))
  |^~~
include/linux/minmax.h:42:24: note: in expansion of macro '__safe_cmp'
   42 |  __builtin_choose_expr(__safe_cmp(x, y), \
  |^~
include/linux/minmax.h:51:19: note: in expansion of macro '__careful_cmp'
   51 | #define min(x, y) __careful_cmp(x, y, <)
  |   ^
drivers/gpu/drm/drm_fb_helper.c:2115:22: note: in expansion of macro 'min'
 2115 |  size_t alloc_size = min(count, PAGE_SIZE);
  |  ^~~

Introduced by commit

  222ec45f4c69 ("drm/fb_helper: Support framebuffers in I/O memory")

-- 
Cheers,
Stephen Rothwell


pgpAHqJrea9Rl.pgp
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


linux-next: build failure after merge of the drm-misc tree

2020-11-09 Thread Stephen Rothwell
Hi all,

After merging the drm-misc tree, today's linux-next build (arm
multi_v7_defconfig) failed like this:

drivers/gpu/drm/msm/msm_gem.c:1014:10: error: initialization of 'int (*)(struct 
drm_gem_object *, struct dma_buf_map *)' from incompatible pointer type 'void * 
(*)(struct drm_gem_object *)' [-Werror=incompatible-pointer-types]
 1014 |  .vmap = msm_gem_prime_vmap,
  |  ^~
drivers/gpu/drm/msm/msm_gem.c:1014:10: note: (near initialization for 
'msm_gem_object_funcs.vmap')
drivers/gpu/drm/msm/msm_gem.c:1015:12: error: initialization of 'void 
(*)(struct drm_gem_object *, struct dma_buf_map *)' from incompatible pointer 
type 'void (*)(struct drm_gem_object *, void *)' 
[-Werror=incompatible-pointer-types]
 1015 |  .vunmap = msm_gem_prime_vunmap,
  |^~~~

Caused by commit

  49a3f51dfeee ("drm/gem: Use struct dma_buf_map in GEM vmap ops and convert 
GEM backends")

interacting with commit

  3c9edd9c85f5 ("drm/msm: Introduce GEM object funcs")

from the drm tree.

I tried reverting commit 3c9edd9c85f5 (as 49a3f51dfeee does not revert
cleanly) but that just produced more errors, so I have disabled
CONFIG_DRM_MSM for now.
-- 
Cheers,
Stephen Rothwell


pgpOAE493ACtA.pgp
Description: OpenPGP digital signature
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 4/5] drm: panel: simple: Add BOE NV110WTM-N61

2020-11-09 Thread Douglas Anderson
Add support for the BOE NV110WTM-N61 panel.  The EDID lists two modes
(one for 60 Hz refresh rate and one for 40 Hz), so we'll list both of
them here.

Note that the panel datasheet requires 80 ms between HPD asserting and
the backlight power being turned on.  We'll use the new timing
constraints structure to do this cleanly.  This assumes that the
backlight will be enabled _after_ the panel enable finishes.  This is
how it works today and seems a sane assumption.

Signed-off-by: Douglas Anderson 
---

Changes in v4:
- Rebased atop changes in earlier patches.

Changes in v2:
- Adjust for shorter names in patch #1.

 drivers/gpu/drm/panel/panel-simple.c | 46 
 1 file changed, 46 insertions(+)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index a54f42cb3adc..9bb723696e94 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -1396,6 +1396,49 @@ static const struct panel_desc boe_nv101wxmn51 = {
},
 };
 
+static const struct drm_display_mode boe_nv110wtm_n61_modes[] = {
+   {
+   .clock = 207800,
+   .hdisplay = 2160,
+   .hsync_start = 2160 + 48,
+   .hsync_end = 2160 + 48 + 32,
+   .htotal = 2160 + 48 + 32 + 100,
+   .vdisplay = 1440,
+   .vsync_start = 1440 + 3,
+   .vsync_end = 1440 + 3 + 6,
+   .vtotal = 1440 + 3 + 6 + 31,
+   },
+   {
+   .clock = 138500,
+   .hdisplay = 2160,
+   .hsync_start = 2160 + 48,
+   .hsync_end = 2160 + 48 + 32,
+   .htotal = 2160 + 48 + 32 + 100,
+   .vdisplay = 1440,
+   .vsync_start = 1440 + 3,
+   .vsync_end = 1440 + 3 + 6,
+   .vtotal = 1440 + 3 + 6 + 31,
+   },
+};
+
+static const struct panel_desc boe_nv110wtm_n61 = {
+   .modes = boe_nv110wtm_n61_modes,
+   .num_modes = ARRAY_SIZE(boe_nv110wtm_n61_modes),
+   .bpc = 8,
+   .size = {
+   .width = 233,
+   .height = 155,
+   },
+   .delay = {
+   .hpd_absent_delay = 200,
+   .prepare_to_enable = 80,
+   .unprepare = 500,
+   },
+   .bus_format = MEDIA_BUS_FMT_RGB888_1X24,
+   .bus_flags = DRM_BUS_FLAG_DATA_MSB_TO_LSB,
+   .connector_type = DRM_MODE_CONNECTOR_eDP,
+};
+
 /* Also used for boe_nv133fhm_n62 */
 static const struct drm_display_mode boe_nv133fhm_n61_modes = {
.clock = 147840,
@@ -4086,6 +4129,9 @@ static const struct of_device_id platform_of_match[] = {
}, {
.compatible = "boe,nv101wxmn51",
.data = _nv101wxmn51,
+   }, {
+   .compatible = "boe,nv110wtm-n61",
+   .data = _nv110wtm_n61,
}, {
.compatible = "boe,nv133fhm-n61",
.data = _nv133fhm_n61,
-- 
2.29.2.222.g5d2a92d10f8-goog

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 2/5] drm: panel: simple: Defer unprepare delay till next prepare to shorten it

2020-11-09 Thread Douglas Anderson
It is believed that all of the current users of the "unprepare" delay
don't actually need to wait the amount of time specified directly in
the unprepare phase.  The purpose of the delay that's specified is to
allow the panel to fully power off so that we don't try to power it
back on before it's managed to full power down.

Let's use this observation to avoid the fixed delay that we currently
have.  Instead of delaying, we'll note the current time when the
unprepare happens.  If someone then tries to prepare the panel later
and not enough time has passed, we'll do the delay before starting the
prepare phase.

Signed-off-by: Douglas Anderson 
---

Changes in v4:
- Split ("Allow timing constraints, not fixed delays") into 2 patches.
- Reuse the existing "unprepare" and assume it means "unprepare_to_prepare".
- Shortened function name to panel_simple_wait().
- Change to fix kerneldoc is now patch #1 in the series.

 drivers/gpu/drm/panel/panel-simple.c | 27 ---
 1 file changed, 24 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 813c90274631..4bc61d71f068 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -115,6 +115,11 @@ struct panel_desc {
 *
 * The time (in milliseconds) that it takes for the panel
 * to power itself down completely.
+*
+* This time is used to prevent a future "prepare" from
+* starting until at least this many milliseconds has passed.
+* If at prepare time less time has passed since unprepare
+* finished, the driver waits for the remaining time.
 */
unsigned int unprepare;
} delay;
@@ -130,6 +135,8 @@ struct panel_simple {
bool enabled;
bool no_hpd;
 
+   ktime_t unprepared_time;
+
const struct panel_desc *desc;
 
struct regulator *supply;
@@ -257,6 +264,20 @@ static int panel_simple_get_non_edid_modes(struct 
panel_simple *panel,
return num;
 }
 
+static void panel_simple_wait(ktime_t start_ktime, unsigned int min_ms)
+{
+   ktime_t now_ktime, min_ktime;
+
+   if (!min_ms)
+   return;
+
+   min_ktime = ktime_add(start_ktime, ms_to_ktime(min_ms));
+   now_ktime = ktime_get();
+
+   if (ktime_before(now_ktime, min_ktime))
+   msleep(ktime_to_ms(ktime_sub(min_ktime, now_ktime)) + 1);
+}
+
 static int panel_simple_disable(struct drm_panel *panel)
 {
struct panel_simple *p = to_panel_simple(panel);
@@ -283,10 +304,8 @@ static int panel_simple_unprepare(struct drm_panel *panel)
 
regulator_disable(p->supply);
 
-   if (p->desc->delay.unprepare)
-   msleep(p->desc->delay.unprepare);
-
p->prepared = false;
+   p->unprepared_time = ktime_get();
 
return 0;
 }
@@ -326,6 +345,8 @@ static int panel_simple_prepare(struct drm_panel *panel)
if (p->prepared)
return 0;
 
+   panel_simple_wait(p->unprepared_time, p->desc->delay.unprepare);
+
err = regulator_enable(p->supply);
if (err < 0) {
dev_err(panel->dev, "failed to enable supply: %d\n", err);
-- 
2.29.2.222.g5d2a92d10f8-goog

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 5/5] dt-bindings: dt-bindings: display: simple: Add BOE NV110WTM-N61

2020-11-09 Thread Douglas Anderson
Add yet another eDP panel.

Signed-off-by: Douglas Anderson 
Acked-by: Rob Herring 
---

(no changes since v1)

 .../devicetree/bindings/display/panel/panel-simple.yaml | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml 
b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
index f9750b0b6708..994c19c357de 100644
--- a/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
+++ b/Documentation/devicetree/bindings/display/panel/panel-simple.yaml
@@ -76,6 +76,8 @@ properties:
 # BOE OPTOELECTRONICS TECHNOLOGY 10.1" WXGA TFT LCD panel
   - boe,nv101wxmn51
 # BOE NV133FHM-N61 13.3" FHD (1920x1080) TFT LCD Panel
+  - boe,nv110wtm-n61
+# BOE NV110WTM-N61 11.0" 2160x1440 TFT LCD Panel
   - boe,nv133fhm-n61
 # BOE NV133FHM-N62 13.3" FHD (1920x1080) TFT LCD Panel
   - boe,nv133fhm-n62
-- 
2.29.2.222.g5d2a92d10f8-goog

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 1/5] drm: panel: simple: Fixup the struct panel_desc kernel doc

2020-11-09 Thread Douglas Anderson
When I run:
  scripts/kernel-doc -rst drivers/gpu/drm/panel/panel-simple.c

I see that several of the kernel-doc entries aren't showing up because
they don't specify the full path down the hierarchy.  Let's fix that
and also move to inline kernel docs.

Signed-off-by: Douglas Anderson 
---

Changes in v4:
- ("drm: panel: simple: Fixup the struct panel_desc kernel doc") new for v4.

 drivers/gpu/drm/panel/panel-simple.c | 59 
 1 file changed, 42 insertions(+), 17 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 597f676a6591..813c90274631 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -64,33 +64,58 @@ struct panel_desc {
 
unsigned int bpc;
 
-   /**
-* @width: width (in millimeters) of the panel's active display area
-* @height: height (in millimeters) of the panel's active display area
-*/
struct {
+   /**
+* @size.width: Width (in mm) of the active display area.
+*/
unsigned int width;
+
+   /**
+* @size.height: Height (in mm) of the active display area.
+*/
unsigned int height;
} size;
 
-   /**
-* @prepare: the time (in milliseconds) that it takes for the panel to
-*   become ready and start receiving video data
-* @hpd_absent_delay: Add this to the prepare delay if we know Hot
-*Plug Detect isn't used.
-* @enable: the time (in milliseconds) that it takes for the panel to
-*  display the first valid frame after starting to receive
-*  video data
-* @disable: the time (in milliseconds) that it takes for the panel to
-*   turn the display off (no content is visible)
-* @unprepare: the time (in milliseconds) that it takes for the panel
-* to power itself down completely
-*/
struct {
+   /**
+* @delay.prepare: Time for the panel to become ready.
+*
+* The time (in milliseconds) that it takes for the panel to
+* become ready and start receiving video data
+*/
unsigned int prepare;
+
+   /**
+* @delay.hpd_absent_delay: Time to wait if HPD isn't hooked up.
+*
+* Add this to the prepare delay if we know Hot Plug Detect
+* isn't used.
+*/
unsigned int hpd_absent_delay;
+
+   /**
+* @delay.enable: Time for the panel to display a valid frame.
+*
+* The time (in milliseconds) that it takes for the panel to
+* display the first valid frame after starting to receive
+* video data.
+*/
unsigned int enable;
+
+   /**
+* @delay.disable: Time for the panel to turn the display off.
+*
+* The time (in milliseconds) that it takes for the panel to
+* turn the display off (no content is visible).
+*/
unsigned int disable;
+
+   /**
+* @delay.unprepare: Time to power down completely.
+*
+* The time (in milliseconds) that it takes for the panel
+* to power itself down completely.
+*/
unsigned int unprepare;
} delay;
 
-- 
2.29.2.222.g5d2a92d10f8-goog

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v4 3/5] drm: panel: simple: Allow specifying the delay from prepare to enable

2020-11-09 Thread Douglas Anderson
On the panel I'm looking at, there's an 80 ms minimum time between HPD
being asserted by the panel and setting the backlight enable GPIO.
While we could just add an 80 ms "enable" delay, this is not ideal.
Link training is allowed to happen in parallel with this delay so the
fixed 80 ms delay over-delays.

We'll support this by logging the time at the end of prepare and then
delaying in enable if enough time hasn't passed.

Signed-off-by: Douglas Anderson 
---

Changes in v4:
- Split ("Allow timing constraints, not fixed delays") into 2 patches.
- Fixed kerneldoc.

 drivers/gpu/drm/panel/panel-simple.c | 44 
 1 file changed, 38 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/panel/panel-simple.c 
b/drivers/gpu/drm/panel/panel-simple.c
index 4bc61d71f068..a54f42cb3adc 100644
--- a/drivers/gpu/drm/panel/panel-simple.c
+++ b/drivers/gpu/drm/panel/panel-simple.c
@@ -93,6 +93,36 @@ struct panel_desc {
 */
unsigned int hpd_absent_delay;
 
+   /**
+* @delay.prepare_to_enable: Time between prepare and enable.
+*
+* The minimum time, in milliseconds, that needs to have passed
+* between when prepare finished and enable may begin. If at
+* enable time less time has passed since prepare finished,
+* the driver waits for the remaining time.
+*
+* If a fixed enable delay is also specified, we'll start
+* counting before delaying for the fixed delay.
+*
+* If a fixed prepare delay is also specified, we won't start
+* counting until after the fixed delay. We can't overlap this
+* fixed delay with the min time because the fixed delay
+* doesn't happen at the end of the function if a HPD GPIO was
+* specified.
+*
+* In other words:
+*   prepare()
+* ...
+* // do fixed prepare delay
+* // wait for HPD GPIO if applicable
+* // start counting for prepare_to_enable
+*
+*   enable()
+* // do fixed enable delay
+* // enforce prepare_to_enable min time
+*/
+   unsigned int prepare_to_enable;
+
/**
 * @delay.enable: Time for the panel to display a valid frame.
 *
@@ -131,10 +161,10 @@ struct panel_desc {
 
 struct panel_simple {
struct drm_panel base;
-   bool prepared;
bool enabled;
bool no_hpd;
 
+   ktime_t prepared_time;
ktime_t unprepared_time;
 
const struct panel_desc *desc;
@@ -297,14 +327,14 @@ static int panel_simple_unprepare(struct drm_panel *panel)
 {
struct panel_simple *p = to_panel_simple(panel);
 
-   if (!p->prepared)
+   if (p->prepared_time == 0)
return 0;
 
gpiod_set_value_cansleep(p->enable_gpio, 0);
 
regulator_disable(p->supply);
 
-   p->prepared = false;
+   p->prepared_time = 0;
p->unprepared_time = ktime_get();
 
return 0;
@@ -342,7 +372,7 @@ static int panel_simple_prepare(struct drm_panel *panel)
int err;
int hpd_asserted;
 
-   if (p->prepared)
+   if (p->prepared_time != 0)
return 0;
 
panel_simple_wait(p->unprepared_time, p->desc->delay.unprepare);
@@ -381,7 +411,7 @@ static int panel_simple_prepare(struct drm_panel *panel)
}
}
 
-   p->prepared = true;
+   p->prepared_time = ktime_get();
 
return 0;
 }
@@ -396,6 +426,8 @@ static int panel_simple_enable(struct drm_panel *panel)
if (p->desc->delay.enable)
msleep(p->desc->delay.enable);
 
+   panel_simple_wait(p->prepared_time, p->desc->delay.prepare_to_enable);
+
p->enabled = true;
 
return 0;
@@ -562,7 +594,7 @@ static int panel_simple_probe(struct device *dev, const 
struct panel_desc *desc)
return -ENOMEM;
 
panel->enabled = false;
-   panel->prepared = false;
+   panel->prepared_time = 0;
panel->desc = desc;
 
panel->no_hpd = of_property_read_bool(dev->of_node, "no-hpd");
-- 
2.29.2.222.g5d2a92d10f8-goog

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 5/5] drm/mediatek: Add support for main DDP path on MT8167

2020-11-09 Thread Chun-Kuang Hu
Hi, Fabien:

Fabien Parent  於 2020年10月23日 週五 下午9:31寫道:
>
> Add the main (DSI) drm display path for MT8167.

Reviewed-by: Chun-Kuang Hu 

>
> Signed-off-by: Fabien Parent 
> ---
>
> Changelog:
>
> V2: No change
>
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 38 ++
>  1 file changed, 38 insertions(+)
>
> diff --git a/drivers/gpu/drm/mediatek/mtk_drm_drv.c 
> b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> index 59c85c63b7cc..3952435093fe 100644
> --- a/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> +++ b/drivers/gpu/drm/mediatek/mtk_drm_drv.c
> @@ -112,6 +112,17 @@ static const enum mtk_ddp_comp_id mt2712_mtk_ddp_third[] 
> = {
> DDP_COMPONENT_PWM2,
>  };
>
> +static enum mtk_ddp_comp_id mt8167_mtk_ddp_main[] = {
> +   DDP_COMPONENT_OVL0,
> +   DDP_COMPONENT_COLOR0,
> +   DDP_COMPONENT_CCORR,
> +   DDP_COMPONENT_AAL0,
> +   DDP_COMPONENT_GAMMA,
> +   DDP_COMPONENT_DITHER,
> +   DDP_COMPONENT_RDMA0,
> +   DDP_COMPONENT_DSI0,
> +};
> +
>  static const enum mtk_ddp_comp_id mt8173_mtk_ddp_main[] = {
> DDP_COMPONENT_OVL0,
> DDP_COMPONENT_COLOR0,
> @@ -163,6 +174,11 @@ static const struct mtk_mmsys_driver_data 
> mt8173_mmsys_driver_data = {
> .ext_len = ARRAY_SIZE(mt8173_mtk_ddp_ext),
>  };
>
> +static const struct mtk_mmsys_driver_data mt8167_mmsys_driver_data = {
> +   .main_path = mt8167_mtk_ddp_main,
> +   .main_len = ARRAY_SIZE(mt8167_mtk_ddp_main),
> +};
> +
>  static int mtk_drm_kms_init(struct drm_device *drm)
>  {
> struct mtk_drm_private *private = drm->dev_private;
> @@ -401,26 +417,42 @@ static const struct component_master_ops mtk_drm_ops = {
>  static const struct of_device_id mtk_ddp_comp_dt_ids[] = {
> { .compatible = "mediatek,mt2701-disp-ovl",
>   .data = (void *)MTK_DISP_OVL },
> +   { .compatible = "mediatek,mt8167-disp-ovl",
> + .data = (void *)MTK_DISP_OVL },
> { .compatible = "mediatek,mt8173-disp-ovl",
>   .data = (void *)MTK_DISP_OVL },
> { .compatible = "mediatek,mt2701-disp-rdma",
>   .data = (void *)MTK_DISP_RDMA },
> +   { .compatible = "mediatek,mt8167-disp-rdma",
> + .data = (void *)MTK_DISP_RDMA },
> { .compatible = "mediatek,mt8173-disp-rdma",
>   .data = (void *)MTK_DISP_RDMA },
> { .compatible = "mediatek,mt8173-disp-wdma",
>   .data = (void *)MTK_DISP_WDMA },
> +   { .compatible = "mediatek,mt8167-disp-ccorr",
> + .data = (void *)MTK_DISP_CCORR },
> { .compatible = "mediatek,mt2701-disp-color",
>   .data = (void *)MTK_DISP_COLOR },
> +   { .compatible = "mediatek,mt8167-disp-color",
> + .data = (void *)MTK_DISP_COLOR },
> { .compatible = "mediatek,mt8173-disp-color",
>   .data = (void *)MTK_DISP_COLOR },
> +   { .compatible = "mediatek,mt8167-disp-aal",
> + .data = (void *)MTK_DISP_AAL},
> { .compatible = "mediatek,mt8173-disp-aal",
>   .data = (void *)MTK_DISP_AAL},
> +   { .compatible = "mediatek,mt8167-disp-gamma",
> + .data = (void *)MTK_DISP_GAMMA, },
> { .compatible = "mediatek,mt8173-disp-gamma",
>   .data = (void *)MTK_DISP_GAMMA, },
> +   { .compatible = "mediatek,mt8167-disp-dither",
> + .data = (void *)MTK_DISP_DITHER },
> { .compatible = "mediatek,mt8173-disp-ufoe",
>   .data = (void *)MTK_DISP_UFOE },
> { .compatible = "mediatek,mt2701-dsi",
>   .data = (void *)MTK_DSI },
> +   { .compatible = "mediatek,mt8167-dsi",
> + .data = (void *)MTK_DSI },
> { .compatible = "mediatek,mt8173-dsi",
>   .data = (void *)MTK_DSI },
> { .compatible = "mediatek,mt2701-dpi",
> @@ -431,10 +463,14 @@ static const struct of_device_id mtk_ddp_comp_dt_ids[] 
> = {
>   .data = (void *)MTK_DISP_MUTEX },
> { .compatible = "mediatek,mt2712-disp-mutex",
>   .data = (void *)MTK_DISP_MUTEX },
> +   { .compatible = "mediatek,mt8167-disp-mutex",
> + .data = (void *)MTK_DISP_MUTEX },
> { .compatible = "mediatek,mt8173-disp-mutex",
>   .data = (void *)MTK_DISP_MUTEX },
> { .compatible = "mediatek,mt2701-disp-pwm",
>   .data = (void *)MTK_DISP_BLS },
> +   { .compatible = "mediatek,mt8167-disp-pwm",
> + .data = (void *)MTK_DISP_PWM },
> { .compatible = "mediatek,mt8173-disp-pwm",
>   .data = (void *)MTK_DISP_PWM },
> { .compatible = "mediatek,mt8173-disp-od",
> @@ -449,6 +485,8 @@ static const struct of_device_id mtk_drm_of_ids[] = {
>   .data = _mmsys_driver_data},
> { .compatible = "mediatek,mt2712-mmsys",
>   .data = _mmsys_driver_data},
> +   { .compatible = "mediatek,mt8167-mmsys",
> + .data = _mmsys_driver_data},
> { .compatible = "mediatek,mt8173-mmsys",
>   .data = _mmsys_driver_data},
> { }
> --
> 2.28.0
>

Re: [PATCH 0/3] Move Mediatek MIPI DSI PHY driver from DRM folder to PHY folder

2020-11-09 Thread Chun-Kuang Hu
Chun-Kuang Hu  於 2020年10月29日 週四 下午11:27寫道:
>
> mtk_mipi_dsi_phy is currently placed inside mediatek drm driver, but it's
> more suitable to place a phy driver into phy driver folder, so move
> mtk_mipi_dsi_phy driver into phy driver folder.

Applied the whole series into mediatek-drm-next [1].

[1] 
https://git.kernel.org/pub/scm/linux/kernel/git/chunkuang.hu/linux.git/log/?h=mediatek-drm-next

Regards,
Chun-Kuang.

>
> Chun-Kuang Hu (3):
>   drm/mediatek: Separate mtk_mipi_tx to an independent module
>   phy: mediatek: Move mtk_mipi_dsi_phy driver into drivers/phy/mediatek
> folder
>   MAINTAINERS: add files for Mediatek DRM drivers
>
>  MAINTAINERS| 1 +
>  drivers/gpu/drm/mediatek/Kconfig   | 1 +
>  drivers/gpu/drm/mediatek/Makefile  | 3 ---
>  drivers/gpu/drm/mediatek/mtk_drm_drv.c | 1 -
>  drivers/gpu/drm/mediatek/mtk_drm_drv.h | 1 -
>  drivers/phy/mediatek/Kconfig   | 7 +++
>  drivers/phy/mediatek/Makefile  | 5 +
>  .../mediatek/phy-mtk-mipi-dsi-mt8173.c}| 2 +-
>  .../mediatek/phy-mtk-mipi-dsi-mt8183.c}| 2 +-
>  .../mtk_mipi_tx.c => phy/mediatek/phy-mtk-mipi-dsi.c}  | 5 -
>  .../mtk_mipi_tx.h => phy/mediatek/phy-mtk-mipi-dsi.h}  | 0
>  11 files changed, 20 insertions(+), 8 deletions(-)
>  rename drivers/{gpu/drm/mediatek/mtk_mt8173_mipi_tx.c => 
> phy/mediatek/phy-mtk-mipi-dsi-mt8173.c} (99%)
>  rename drivers/{gpu/drm/mediatek/mtk_mt8183_mipi_tx.c => 
> phy/mediatek/phy-mtk-mipi-dsi-mt8183.c} (99%)
>  rename drivers/{gpu/drm/mediatek/mtk_mipi_tx.c => 
> phy/mediatek/phy-mtk-mipi-dsi.c} (97%)
>  rename drivers/{gpu/drm/mediatek/mtk_mipi_tx.h => 
> phy/mediatek/phy-mtk-mipi-dsi.h} (100%)
>
> --
> 2.17.1
>
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [RFC PATCH v1 3/3] drm/msm: Improve the a6xx page fault handler

2020-11-09 Thread Rob Clark
On Mon, Nov 9, 2020 at 2:23 PM Jordan Crouse  wrote:
>
> Use the new adreno-smmu-priv fault info function to get more SMMU
> debug registers and print the current TTBR0 to debug per-instance
> pagetables and figure out which GPU block generated the request.
>
> Signed-off-by: Jordan Crouse 
> ---
>
>  drivers/gpu/drm/msm/adreno/a5xx_gpu.c |  4 +-
>  drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 76 +--
>  drivers/gpu/drm/msm/msm_iommu.c   | 11 +++-
>  drivers/gpu/drm/msm/msm_mmu.h |  4 +-
>  4 files changed, 87 insertions(+), 8 deletions(-)
>
> diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
> b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> index d6804a802355..ed4cb81af874 100644
> --- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
> @@ -933,7 +933,7 @@ bool a5xx_idle(struct msm_gpu *gpu, struct msm_ringbuffer 
> *ring)
> return true;
>  }
>
> -static int a5xx_fault_handler(void *arg, unsigned long iova, int flags)
> +static int a5xx_fault_handler(void *arg, unsigned long iova, int flags, void 
> *data)
>  {
> struct msm_gpu *gpu = arg;
> pr_warn_ratelimited("*** gpu fault: iova=%08lx, flags=%d 
> (%u,%u,%u,%u)\n",
> @@ -943,7 +943,7 @@ static int a5xx_fault_handler(void *arg, unsigned long 
> iova, int flags)
> gpu_read(gpu, REG_A5XX_CP_SCRATCH_REG(6)),
> gpu_read(gpu, REG_A5XX_CP_SCRATCH_REG(7)));
>
> -   return -EFAULT;
> +   return 0;
>  }
>
>  static void a5xx_cp_err_irq(struct msm_gpu *gpu)
> diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
> b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> index 948f3656c20c..ac6e8cd5cf1a 100644
> --- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> +++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
> @@ -905,18 +905,88 @@ static void a6xx_recover(struct msm_gpu *gpu)
> msm_gpu_hw_init(gpu);
>  }
>
> -static int a6xx_fault_handler(void *arg, unsigned long iova, int flags)
> +static const char *a6xx_uche_fault_block(struct msm_gpu *gpu, u32 mid)
> +{
> +   static const char *uche_clients[7] = {
> +   "VFD", "SP", "VSC", "VPC", "HLSQ", "PC", "LRZ",
> +   };
> +   u32 val;
> +
> +   if (mid < 1 || mid > 3)
> +   return "UNKNOWN";
> +
> +   /*
> +* The source of the data depends on the mid ID read from FSYNR1.
> +* and the client ID read from the UCHE block
> +*/
> +   val = gpu_read(gpu, REG_A6XX_UCHE_CLIENT_PF);
> +
> +   /* mid = 3 is most precise and refers to only one block per client */
> +   if (mid == 3)
> +   return uche_clients[val & 7];
> +
> +   /* For mid=2 the source is TP or VFD except when the client id is 0 */
> +   if (mid == 2)
> +   return ((val & 7) == 0) ? "TP" : "TP|VFD";
> +
> +   /* For mid=1 just return "UCHE" as a catchall for everything else */
> +   return "UCHE";
> +}
> +
> +static const char *a6xx_fault_block(struct msm_gpu *gpu, u32 id)
> +{
> +   if (id == 0)
> +   return "CP";
> +   else if (id == 4)
> +   return "CCU";
> +   else if (id == 6)
> +   return "CDP Prefetch";
> +
> +   return a6xx_uche_fault_block(gpu, id);
> +}
> +
> +#define ARM_SMMU_FSR_TF BIT(1)
> +#define ARM_SMMU_FSR_PFBIT(3)
> +#define ARM_SMMU_FSR_EFBIT(4)
> +
> +static int a6xx_fault_handler(void *arg, unsigned long iova, int flags, void 
> *data)
>  {
> struct msm_gpu *gpu = arg;
> +   struct adreno_smmu_fault_info *info = data;
> +   const char *type = "UNKNOWN";
>
> -   pr_warn_ratelimited("*** gpu fault: iova=%08lx, flags=%d 
> (%u,%u,%u,%u)\n",
> +   /*
> +* Print a default message if we couldn't get the data from the
> +* adreno-smmu-priv
> +*/
> +   if (!info) {
> +   pr_warn_ratelimited("*** gpu fault: iova=%.16lx flags=%d 
> (%u,%u,%u,%u)\n",
> iova, flags,
> gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(4)),
> gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(5)),
> gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(6)),
> gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(7)));
>
> -   return -EFAULT;
> +   return 0;
> +   }
> +
> +   if (info->fsr & ARM_SMMU_FSR_TF)
> +   type = "TRANSLATION";
> +   else if (info->fsr & ARM_SMMU_FSR_PF)
> +   type = "PERMISSION";
> +   else if (info->fsr & ARM_SMMU_FSR_EF)
> +   type = "EXTERNAL";
> +
> +   pr_warn_ratelimited("*** gpu fault: ttbr0=%.16llx iova=%.16lx dir=%s 
> type=%s source=%s (%u,%u,%u,%u)\n",
> +   info->ttbr0, iova,
> +   flags & IOMMU_FAULT_WRITE ? "WRITE" : "READ", type,
> +   a6xx_fault_block(gpu, info->fsynr1 & 0xff),
> +   gpu_read(gpu, 

[RFC PATCH v1 0/3] iommu/arm-smmu: adreno-smmu page fault handling

2020-11-09 Thread Jordan Crouse
This is an RFC to add an Adreno GPU specific handler for pagefaults. The first
patch starts by wiring up report_iommu_fault for arm-smmu. The next patch adds
a adreno-smmu-priv function hook to capture a handful of important debugging
registers such as TTBR0, CONTEXTIDR, FSYNR0 and others. This is used by the
third patch to print more detailed information on page fault such as the TTBR0
for the pagetable that caused the fault and the source of the fault as
determined by a combination of the FSYNR1 register and an internal GPU
register.

This code provides a solid base that we can expand on later for even more
extensive GPU side page fault debugging capabilities.

Jordan Crouse (3):
  iommu/arm-smmu: Add support for driver IOMMU fault handlers
  drm/msm: Add an adreno-smmu-priv callback to get pagefault info
  drm/msm: Improve the a6xx page fault handler

 drivers/gpu/drm/msm/adreno/a5xx_gpu.c  |  4 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c  | 76 +-
 drivers/gpu/drm/msm/msm_iommu.c| 11 +++-
 drivers/gpu/drm/msm/msm_mmu.h  |  4 +-
 drivers/iommu/arm/arm-smmu/arm-smmu-qcom.c | 19 ++
 drivers/iommu/arm/arm-smmu/arm-smmu.c  | 16 -
 drivers/iommu/arm/arm-smmu/arm-smmu.h  |  2 +
 include/linux/adreno-smmu-priv.h   | 31 -
 8 files changed, 151 insertions(+), 12 deletions(-)

-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[RFC PATCH v1 3/3] drm/msm: Improve the a6xx page fault handler

2020-11-09 Thread Jordan Crouse
Use the new adreno-smmu-priv fault info function to get more SMMU
debug registers and print the current TTBR0 to debug per-instance
pagetables and figure out which GPU block generated the request.

Signed-off-by: Jordan Crouse 
---

 drivers/gpu/drm/msm/adreno/a5xx_gpu.c |  4 +-
 drivers/gpu/drm/msm/adreno/a6xx_gpu.c | 76 +--
 drivers/gpu/drm/msm/msm_iommu.c   | 11 +++-
 drivers/gpu/drm/msm/msm_mmu.h |  4 +-
 4 files changed, 87 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
index d6804a802355..ed4cb81af874 100644
--- a/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a5xx_gpu.c
@@ -933,7 +933,7 @@ bool a5xx_idle(struct msm_gpu *gpu, struct msm_ringbuffer 
*ring)
return true;
 }
 
-static int a5xx_fault_handler(void *arg, unsigned long iova, int flags)
+static int a5xx_fault_handler(void *arg, unsigned long iova, int flags, void 
*data)
 {
struct msm_gpu *gpu = arg;
pr_warn_ratelimited("*** gpu fault: iova=%08lx, flags=%d 
(%u,%u,%u,%u)\n",
@@ -943,7 +943,7 @@ static int a5xx_fault_handler(void *arg, unsigned long 
iova, int flags)
gpu_read(gpu, REG_A5XX_CP_SCRATCH_REG(6)),
gpu_read(gpu, REG_A5XX_CP_SCRATCH_REG(7)));
 
-   return -EFAULT;
+   return 0;
 }
 
 static void a5xx_cp_err_irq(struct msm_gpu *gpu)
diff --git a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c 
b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
index 948f3656c20c..ac6e8cd5cf1a 100644
--- a/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
+++ b/drivers/gpu/drm/msm/adreno/a6xx_gpu.c
@@ -905,18 +905,88 @@ static void a6xx_recover(struct msm_gpu *gpu)
msm_gpu_hw_init(gpu);
 }
 
-static int a6xx_fault_handler(void *arg, unsigned long iova, int flags)
+static const char *a6xx_uche_fault_block(struct msm_gpu *gpu, u32 mid)
+{
+   static const char *uche_clients[7] = {
+   "VFD", "SP", "VSC", "VPC", "HLSQ", "PC", "LRZ",
+   };
+   u32 val;
+
+   if (mid < 1 || mid > 3)
+   return "UNKNOWN";
+
+   /*
+* The source of the data depends on the mid ID read from FSYNR1.
+* and the client ID read from the UCHE block
+*/
+   val = gpu_read(gpu, REG_A6XX_UCHE_CLIENT_PF);
+
+   /* mid = 3 is most precise and refers to only one block per client */
+   if (mid == 3)
+   return uche_clients[val & 7];
+
+   /* For mid=2 the source is TP or VFD except when the client id is 0 */
+   if (mid == 2)
+   return ((val & 7) == 0) ? "TP" : "TP|VFD";
+
+   /* For mid=1 just return "UCHE" as a catchall for everything else */
+   return "UCHE";
+}
+
+static const char *a6xx_fault_block(struct msm_gpu *gpu, u32 id)
+{
+   if (id == 0)
+   return "CP";
+   else if (id == 4)
+   return "CCU";
+   else if (id == 6)
+   return "CDP Prefetch";
+
+   return a6xx_uche_fault_block(gpu, id);
+}
+
+#define ARM_SMMU_FSR_TF BIT(1)
+#define ARM_SMMU_FSR_PFBIT(3)
+#define ARM_SMMU_FSR_EFBIT(4)
+
+static int a6xx_fault_handler(void *arg, unsigned long iova, int flags, void 
*data)
 {
struct msm_gpu *gpu = arg;
+   struct adreno_smmu_fault_info *info = data;
+   const char *type = "UNKNOWN";
 
-   pr_warn_ratelimited("*** gpu fault: iova=%08lx, flags=%d 
(%u,%u,%u,%u)\n",
+   /*
+* Print a default message if we couldn't get the data from the
+* adreno-smmu-priv
+*/
+   if (!info) {
+   pr_warn_ratelimited("*** gpu fault: iova=%.16lx flags=%d 
(%u,%u,%u,%u)\n",
iova, flags,
gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(4)),
gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(5)),
gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(6)),
gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(7)));
 
-   return -EFAULT;
+   return 0;
+   }
+
+   if (info->fsr & ARM_SMMU_FSR_TF)
+   type = "TRANSLATION";
+   else if (info->fsr & ARM_SMMU_FSR_PF)
+   type = "PERMISSION";
+   else if (info->fsr & ARM_SMMU_FSR_EF)
+   type = "EXTERNAL";
+
+   pr_warn_ratelimited("*** gpu fault: ttbr0=%.16llx iova=%.16lx dir=%s 
type=%s source=%s (%u,%u,%u,%u)\n",
+   info->ttbr0, iova,
+   flags & IOMMU_FAULT_WRITE ? "WRITE" : "READ", type,
+   a6xx_fault_block(gpu, info->fsynr1 & 0xff),
+   gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(4)),
+   gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(5)),
+   gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(6)),
+   gpu_read(gpu, REG_A6XX_CP_SCRATCH_REG(7)));
+
+   return 0;
 }
 
 static void a6xx_cp_hw_err_irq(struct msm_gpu *gpu)

Re: [PATCH 00/20] [Set 3] Rid W=1 warnings from GPU

2020-11-09 Thread Alex Deucher
On Mon, Nov 9, 2020 at 4:19 PM Lee Jones  wrote:
>
> This set is part of a larger effort attempting to clean-up W=1
> kernel builds, which are currently overwhelmingly riddled with
> niggly little warnings.
>
> This set takes the running (decreasing) total from 5000 before
> [Set 1] down to 2300.
>
> Lee Jones (20):
>   drm/radeon/radeon_ttm: Place declaration of 'rdev' in same clause as
> its use
>   drm/radeon: Move radeon_ttm{init,fini} to shared location
>   drm/radeon/radeon_fence: Demote some non-conformant kernel-doc headers
> and fix another
>   drm/radeon: Move 'radeon_add_legacy_encoder' prototype to shared
> header
>   drm/radeon: Move 'radeon_add_legacy_encoder's prototype to shared
> location
>   drm/radeon/radeon_connectors: Strip out set but unused variable 'ret'
>   drm/radeon/radeon_display: Remove unused variable 'mod'
>   drm/radeon/radeon_i2c: Remove pointless function header
>   drm/radeon/radeon_irq_kms: Demote non-conformant kernel-doc fix
> another
>   drm/radeon/radeon_ring: Add missing function parameters 'rdev' and
> 'data'
>   drm/radeon/r600: Strip out set but unused 'tmp' variables
>   drm/radeon/radeon_cs: Fix a bunch of doc-rot issues
>   drm/radeon/evergreen: Move 'rv770_set_clk_bypass_mode' prototype to
> shared location
>   drm/radeon: Move 'radeon_pm_acpi_event_handler' prototype into shared
> header
>   drm/radeon/r600d: Move 'rc600_*' prototypes into shared header
>   drm/radeon/radeon_audio: Move 'dce3_2_*' prototypes to shared location
>   drm/radeon/evergreend: Move 'evergreen_*' and 'sumo_*' prototypes out
> to shared location
>   drm/radeon/radeon_display: Fix function doc formatting and missing
> param issues
>   drm/radeon/r600: Fix a misnamed parameter description and a formatting
> issue
>   drm/radeon/cik: Fix a bunch of function parameter descriptions
>
>  drivers/gpu/drm/radeon/cik.c   | 10 +++
>  drivers/gpu/drm/radeon/evergreen.c |  1 -
>  drivers/gpu/drm/radeon/ni.c| 16 --
>  drivers/gpu/drm/radeon/r600.c  | 11 +++
>  drivers/gpu/drm/radeon/r600d.h | 14 +
>  drivers/gpu/drm/radeon/radeon.h| 34 ++
>  drivers/gpu/drm/radeon/radeon_acpi.c   |  2 --
>  drivers/gpu/drm/radeon/radeon_atombios.c   |  5 
>  drivers/gpu/drm/radeon/radeon_audio.c  | 23 +--
>  drivers/gpu/drm/radeon/radeon_audio.h  | 12 
>  drivers/gpu/drm/radeon/radeon_combios.c|  5 
>  drivers/gpu/drm/radeon/radeon_connectors.c |  4 +--
>  drivers/gpu/drm/radeon/radeon_cs.c | 12 
>  drivers/gpu/drm/radeon/radeon_display.c| 17 +--
>  drivers/gpu/drm/radeon/radeon_encoders.c   |  3 --
>  drivers/gpu/drm/radeon/radeon_fence.c  |  6 ++--
>  drivers/gpu/drm/radeon/radeon_i2c.c|  4 ---
>  drivers/gpu/drm/radeon/radeon_irq_kms.c|  6 ++--
>  drivers/gpu/drm/radeon/radeon_object.c |  2 --
>  drivers/gpu/drm/radeon/radeon_ring.c   |  3 ++
>  drivers/gpu/drm/radeon/radeon_ttm.c|  8 ++---
>  drivers/gpu/drm/radeon/si.c|  6 
>  22 files changed, 96 insertions(+), 108 deletions(-)

Instead of just dumping everything in radeon.h, I think it would be
cleaner to add new headers that match the .c files that define them.
E.g., add evergreen.h and put all the stuff from evergreen.c in there.
Add rv770.h and add all the stuff defined in rv770.c, etc.

Alex

>
> Cc: Alex Deucher 
> Cc: amd-...@lists.freedesktop.org
> Cc: "Christian König" 
> Cc: Daniel Vetter 
> Cc: David Airlie 
> Cc: dri-devel@lists.freedesktop.org
> Cc: Jerome Glisse 
> Cc: linaro-mm-...@lists.linaro.org
> Cc: linux-me...@vger.kernel.org
> Cc: report to 
> Cc: Slava Grigorev 
> Cc: Sumit Semwal 
> --
> 2.25.1
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 15/20] drm/radeon/r600d: Move 'rc600_*' prototypes into shared header

2020-11-09 Thread Alex Deucher
On Mon, Nov 9, 2020 at 4:19 PM Lee Jones  wrote:
>
> Fixes the following W=1 kernel build warning(s):
>
>  drivers/gpu/drm/radeon/r600_hdmi.c:177:6: warning: no previous prototype for 
> ‘r600_hdmi_update_acr’ [-Wmissing-prototypes]
>  177 | void r600_hdmi_update_acr(struct drm_encoder *encoder, long offset,
>  | ^~~~
>  drivers/gpu/drm/radeon/r600_hdmi.c:217:6: warning: no previous prototype for 
> ‘r600_set_avi_packet’ [-Wmissing-prototypes]
>  217 | void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
>  | ^~~
>  drivers/gpu/drm/radeon/r600_hdmi.c:314:6: warning: no previous prototype for 
> ‘r600_hdmi_audio_set_dto’ [-Wmissing-prototypes]
>  314 | void r600_hdmi_audio_set_dto(struct radeon_device *rdev,
>  | ^~~
>  drivers/gpu/drm/radeon/r600_hdmi.c:340:6: warning: no previous prototype for 
> ‘r600_set_vbi_packet’ [-Wmissing-prototypes]
>  340 | void r600_set_vbi_packet(struct drm_encoder *encoder, u32 offset)
>  | ^~~
>  drivers/gpu/drm/radeon/r600_hdmi.c:351:6: warning: no previous prototype for 
> ‘r600_set_audio_packet’ [-Wmissing-prototypes]
>  351 | void r600_set_audio_packet(struct drm_encoder *encoder, u32 offset)
>  | ^
>  drivers/gpu/drm/radeon/r600_hdmi.c:393:6: warning: no previous prototype for 
> ‘r600_set_mute’ [-Wmissing-prototypes]
>  393 | void r600_set_mute(struct drm_encoder *encoder, u32 offset, bool mute)
>  | ^
>  drivers/gpu/drm/radeon/r600_hdmi.c:469:6: warning: no previous prototype for 
> ‘r600_hdmi_enable’ [-Wmissing-prototypes]
>  469 | void r600_hdmi_enable(struct drm_encoder *encoder, bool enable)
>  | ^~~~
>
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: amd-...@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Lee Jones 
> ---
>  drivers/gpu/drm/radeon/r600d.h| 14 ++
>  drivers/gpu/drm/radeon/radeon_audio.c | 11 +--
>  2 files changed, 15 insertions(+), 10 deletions(-)
>
> diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
> index 2e00a5287bd2d..db4bcc8bee4e5 100644
> --- a/drivers/gpu/drm/radeon/r600d.h
> +++ b/drivers/gpu/drm/radeon/r600d.h
> @@ -27,6 +27,20 @@
>  #ifndef R600D_H
>  #define R600D_H
>
> +struct radeon_crtc;
> +struct radeon_hdmi_acr;
> +
> +void r600_set_audio_packet(struct drm_encoder *encoder, u32 offset);
> +void r600_set_mute(struct drm_encoder *encoder, u32 offset, bool mute);
> +void r600_hdmi_audio_set_dto(struct radeon_device *rdev,
> +   struct radeon_crtc *crtc, unsigned int clock);
> +void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
> +   unsigned char *buffer, size_t size);
> +void r600_hdmi_update_acr(struct drm_encoder *encoder, long offset,
> +   const struct radeon_hdmi_acr *acr);
> +void r600_set_vbi_packet(struct drm_encoder *encoder, u32 offset);
> +void r600_hdmi_enable(struct drm_encoder *encoder, bool enable);
> +

the *d.h headers are supposed to just be hardware definitions.  I'd
prefer to keep driver stuff out of them.

Alex


>  #define CP_PACKET2 0x8000
>  #definePACKET2_PAD_SHIFT   0
>  #definePACKET2_PAD_MASK(0x3fff << 0)
> diff --git a/drivers/gpu/drm/radeon/radeon_audio.c 
> b/drivers/gpu/drm/radeon/radeon_audio.c
> index 8c63ccb8b6235..a2be60aa3cec4 100644
> --- a/drivers/gpu/drm/radeon/radeon_audio.c
> +++ b/drivers/gpu/drm/radeon/radeon_audio.c
> @@ -27,6 +27,7 @@
>  #include 
>  #include "radeon.h"
>  #include "atom.h"
> +#include "r600d.h"
>  #include "radeon_audio.h"
>
>  void r600_audio_enable(struct radeon_device *rdev, struct r600_audio_pin 
> *pin,
> @@ -63,8 +64,6 @@ void dce6_afmt_write_latency_fields(struct drm_encoder 
> *encoder,
>  struct r600_audio_pin* r600_audio_get_pin(struct radeon_device *rdev);
>  struct r600_audio_pin* dce6_audio_get_pin(struct radeon_device *rdev);
>  void dce6_afmt_select_pin(struct drm_encoder *encoder);
> -void r600_hdmi_audio_set_dto(struct radeon_device *rdev,
> -   struct radeon_crtc *crtc, unsigned int clock);
>  void dce3_2_audio_set_dto(struct radeon_device *rdev,
> struct radeon_crtc *crtc, unsigned int clock);
>  void dce4_hdmi_audio_set_dto(struct radeon_device *rdev,
> @@ -75,31 +74,23 @@ void dce6_hdmi_audio_set_dto(struct radeon_device *rdev,
> struct radeon_crtc *crtc, unsigned int clock);
>  void dce6_dp_audio_set_dto(struct radeon_device *rdev,
> struct radeon_crtc *crtc, unsigned int clock);
> -void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
> -   unsigned char *buffer, size_t size);
>  void evergreen_set_avi_packet(struct radeon_device *rdev, u32 offset,
> unsigned char *buffer, size_t size);
> -void r600_hdmi_update_acr(struct drm_encoder *encoder, long offset,
> -   const struct radeon_hdmi_acr *acr);
>  void dce3_2_hdmi_update_acr(struct 

Re: [PATCH 1/4] drm/ttm: add multihop infrastrucutre (v2)

2020-11-09 Thread Ville Syrjälä
On Mon, Nov 09, 2020 at 09:48:04PM +0100, Christian König wrote:
> Am 09.11.20 um 17:43 schrieb Ville Syrjälä:
> > On Mon, Nov 09, 2020 at 05:20:17PM +0100, Christian König wrote:
> >> Am 09.11.20 um 17:18 schrieb Ville Syrjälä:
> >>> On Mon, Nov 09, 2020 at 04:57:29PM +0100, Christian König wrote:
>  Am 09.11.20 um 16:16 schrieb Ville Syrjälä:
> > On Wed, Nov 11, 2020 at 06:13:02PM +0100, Christian König wrote:
> >> Am 09.11.20 um 01:54 schrieb Dave Airlie:
> >>> @@ -1432,15 +1479,18 @@ int ttm_bo_swapout(struct ttm_operation_ctx 
> >>> *ctx)
> >>>   if (bo->mem.mem_type != TTM_PL_SYSTEM) {
> >>>   struct ttm_operation_ctx ctx = { false, false };
> >>>   struct ttm_resource evict_mem;
> >>> + struct ttm_place hop = {};
> >> Please always use memset() if you want to zero initialize something in
> >> the kernel, we had enough trouble with that.
> > What trouble is that? I've not heard of anything, and we use
> > ={} quite extensively in drm land.
>  ={} initializes only named fields, not padding.
> >>> Has that actually happened?
> >> YES! Numerous times!
> > You wouldn't happen to have links/etc. to the discussion?
> > I'd like to check them out.
> 
> Uff, that was years ago. Just google for something like "mesa memset 
> hash", there was recently (~ the last year) another discussion because 
> somebody ran into exactly that problem once more.

Found this:
https://gitlab.freedesktop.org/mesa/mesa/-/issues/2071
which does suprise me a bit. Though I suspect ={} might
behave differently since the compiler might treat it
more like a memset().

Also makes me wonder about padding in general, because IIRC
the standard allows padding to be clobbered even after
initialization whenever any member is getting written. So
I think technically there is no guaranteed way to clear
the padding unless you never store anything into the struct.

-- 
Ville Syrjälä
Intel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drivers: amdgpu: amdgpu_display: Fixed the spelling of falg to flag

2020-11-09 Thread Alex Deucher
On Mon, Nov 9, 2020 at 4:16 PM Bhaskar Chowdhury  wrote:
>
> s/falg/flag/p
>
> Signed-off-by: Bhaskar Chowdhury 

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 2e8a8b57639f..9223502c1e5b 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -509,7 +509,7 @@ uint32_t amdgpu_display_supported_domains(struct 
> amdgpu_device *adev,
>  * to avoid hang caused by placement of scanout BO in GTT on certain
>  * APUs. So force the BO placement to VRAM in case this architecture
>  * will not allow USWC mappings.
> -* Also, don't allow GTT domain if the BO doens't have USWC falg set.
> +* Also, don't allow GTT domain if the BO doens't have USWC flag set.
>  */
> if ((bo_flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) &&
> amdgpu_bo_support_uswc(bo_flags) &&
> --
> 2.26.2
>
> ___
> amd-gfx mailing list
> amd-...@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/amd-gfx
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 20/20] drm/radeon/cik: Fix a bunch of function parameter descriptions

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/cik.c:1869:5: warning: no previous prototype for 
‘ci_mc_load_microcode’ [-Wmissing-prototypes]
 drivers/gpu/drm/radeon/cik.c: In function ‘cik_gpu_init’:
 drivers/gpu/drm/radeon/cik.c:3181:6: warning: variable ‘mc_shared_chmap’ set 
but not used [-Wunused-but-set-variable]
 drivers/gpu/drm/radeon/cik.c: At top level:
 drivers/gpu/drm/radeon/cik.c:4852:5: warning: no previous prototype for 
‘cik_gpu_check_soft_reset’ [-Wmissing-prototypes]
 drivers/gpu/drm/radeon/cik.c:5850:6: warning: no previous prototype for 
‘cik_enter_rlc_safe_mode’ [-Wmissing-prototypes]
 drivers/gpu/drm/radeon/cik.c:5871:6: warning: no previous prototype for 
‘cik_exit_rlc_safe_mode’ [-Wmissing-prototypes]
 drivers/gpu/drm/radeon/cik.c:6289:6: warning: no previous prototype for 
‘cik_update_cg’ [-Wmissing-prototypes]
 drivers/gpu/drm/radeon/cik.c:6421:6: warning: no previous prototype for 
‘cik_init_cp_pg_table’ [-Wmissing-prototypes]
 drivers/gpu/drm/radeon/cik.c:6678:5: warning: no previous prototype for 
‘cik_get_csb_size’ [-Wmissing-prototypes]
 drivers/gpu/drm/radeon/cik.c:6710:6: warning: no previous prototype for 
‘cik_get_csb_buffer’ [-Wmissing-prototypes]
 drivers/gpu/drm/radeon/cik.c:3084: warning: Function parameter or member 
'max_rb_num_per_se' not described in 'cik_get_rb_disabled'
 drivers/gpu/drm/radeon/cik.c:3084: warning: Excess function parameter 
'max_rb_num' description in 'cik_get_rb_disabled'
 drivers/gpu/drm/radeon/cik.c:3084: warning: Excess function parameter 'se_num' 
description in 'cik_get_rb_disabled'
 drivers/gpu/drm/radeon/cik.c:3114: warning: Function parameter or member 
'max_rb_num_per_se' not described in 'cik_setup_rb'
 drivers/gpu/drm/radeon/cik.c:3114: warning: Excess function parameter 
'max_rb_num' description in 'cik_setup_rb'
 drivers/gpu/drm/radeon/cik.c:5662: warning: Function parameter or member 
'mc_client' not described in 'cik_vm_decode_fault'
 drivers/gpu/drm/radeon/cik.c:5690: warning: Function parameter or member 
'ring' not described in 'cik_vm_flush'
 drivers/gpu/drm/radeon/cik.c:5690: warning: Function parameter or member 
'vm_id' not described in 'cik_vm_flush'
 drivers/gpu/drm/radeon/cik.c:5690: warning: Function parameter or member 
'pd_addr' not described in 'cik_vm_flush'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/cik.c | 10 --
 1 file changed, 4 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/cik.c b/drivers/gpu/drm/radeon/cik.c
index 5c42877fd6fbf..4494f9122fd91 100644
--- a/drivers/gpu/drm/radeon/cik.c
+++ b/drivers/gpu/drm/radeon/cik.c
@@ -3071,8 +3071,7 @@ static u32 cik_create_bitmask(u32 bit_width)
  * cik_get_rb_disabled - computes the mask of disabled RBs
  *
  * @rdev: radeon_device pointer
- * @max_rb_num: max RBs (render backends) for the asic
- * @se_num: number of SEs (shader engines) for the asic
+ * @max_rb_num_per_se: max RBs (render backends) for the asic
  * @sh_per_se: number of SH blocks per SE for the asic
  *
  * Calculates the bitmask of disabled RBs (CIK).
@@ -3104,7 +3103,7 @@ static u32 cik_get_rb_disabled(struct radeon_device *rdev,
  * @rdev: radeon_device pointer
  * @se_num: number of SEs (shader engines) for the asic
  * @sh_per_se: number of SH blocks per SE for the asic
- * @max_rb_num: max RBs (render backends) for the asic
+ * @max_rb_num_per_se: max RBs (render backends) for the asic
  *
  * Configures per-SE/SH RB registers (CIK).
  */
@@ -5654,6 +5653,7 @@ void cik_vm_fini(struct radeon_device *rdev)
  * @rdev: radeon_device pointer
  * @status: VM_CONTEXT1_PROTECTION_FAULT_STATUS register value
  * @addr: VM_CONTEXT1_PROTECTION_FAULT_ADDR register value
+ * @mc_client: VM_CONTEXT1_PROTECTION_FAULT_MCCLIENT register value
  *
  * Print human readable fault information (CIK).
  */
@@ -5677,11 +5677,9 @@ static void cik_vm_decode_fault(struct radeon_device 
*rdev,
   block, mc_client, mc_id);
 }
 
-/**
+/*
  * cik_vm_flush - cik vm flush using the CP
  *
- * @rdev: radeon_device pointer
- *
  * Update the page table base and flush the VM TLB
  * using the CP (CIK).
  */
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 18/20] drm/radeon/radeon_display: Fix function doc formatting and missing param issues

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_display.c:264: warning: Function parameter or 
member '__work' not described in 'radeon_unpin_work_func'
 drivers/gpu/drm/radeon/radeon_display.c:406: warning: Function parameter or 
member '__work' not described in 'radeon_flip_work_func'
 drivers/gpu/drm/radeon/radeon_display.c:956: warning: Function parameter or 
member 'freq' not described in 'radeon_compute_pll_avivo'
 drivers/gpu/drm/radeon/radeon_display.c:956: warning: Function parameter or 
member 'fb_div_p' not described in 'radeon_compute_pll_avivo'
 drivers/gpu/drm/radeon/radeon_display.c:956: warning: Function parameter or 
member 'frac_fb_div_p' not described in 'radeon_compute_pll_avivo'
 drivers/gpu/drm/radeon/radeon_display.c:956: warning: Function parameter or 
member 'ref_div_p' not described in 'radeon_compute_pll_avivo'
 drivers/gpu/drm/radeon/radeon_display.c:956: warning: Function parameter or 
member 'post_div_p' not described in 'radeon_compute_pll_avivo'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: report to 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_display.c | 13 +++--
 1 file changed, 7 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index 78fceedfd9255..eb0d4cb95f0a6 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -256,7 +256,7 @@ static void radeon_crtc_destroy(struct drm_crtc *crtc)
 /**
  * radeon_unpin_work_func - unpin old buffer object
  *
- * @__work - kernel work item
+ * @__work: kernel work item
  *
  * Unpin the old frame buffer object outside of the interrupt handler
  */
@@ -398,7 +398,7 @@ void radeon_crtc_handle_flip(struct radeon_device *rdev, 
int crtc_id)
 /**
  * radeon_flip_work_func - page flip framebuffer
  *
- * @work - kernel work item
+ * @__work: kernel work item
  *
  * Wait for the buffer object to become idle and do the actual page flip
  */
@@ -937,11 +937,12 @@ static void avivo_get_fb_ref_div(unsigned nom, unsigned 
den, unsigned post_div,
  * radeon_compute_pll_avivo - compute PLL paramaters
  *
  * @pll: information about the PLL
+ * @freq: target frequency
  * @dot_clock_p: resulting pixel clock
- * fb_div_p: resulting feedback divider
- * frac_fb_div_p: fractional part of the feedback divider
- * ref_div_p: resulting reference divider
- * post_div_p: resulting reference divider
+ * @fb_div_p: resulting feedback divider
+ * @frac_fb_div_p: fractional part of the feedback divider
+ * @ref_div_p: resulting reference divider
+ * @post_div_p: resulting reference divider
  *
  * Try to calculate the PLL parameters to generate the given frequency:
  * dot_clock = (ref_freq * feedback_div) / (ref_div * post_div)
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 08/20] drm/radeon/radeon_i2c: Remove pointless function header

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_i2c.c:46: warning: Function parameter or member 
'radeon_connector' not described in 'radeon_ddc_probe'
 drivers/gpu/drm/radeon/radeon_i2c.c:46: warning: Function parameter or member 
'use_aux' not described in 'radeon_ddc_probe'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_i2c.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_i2c.c 
b/drivers/gpu/drm/radeon/radeon_i2c.c
index 545e31e6cc3a9..aa61b3cb4049c 100644
--- a/drivers/gpu/drm/radeon/radeon_i2c.c
+++ b/drivers/gpu/drm/radeon/radeon_i2c.c
@@ -38,10 +38,6 @@ extern int radeon_atom_hw_i2c_xfer(struct i2c_adapter 
*i2c_adap,
   struct i2c_msg *msgs, int num);
 extern u32 radeon_atom_hw_i2c_func(struct i2c_adapter *adap);
 
-/**
- * radeon_ddc_probe
- *
- */
 bool radeon_ddc_probe(struct radeon_connector *radeon_connector, bool use_aux)
 {
u8 out = 0x0;
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 14/20] drm/radeon: Move 'radeon_pm_acpi_event_handler' prototype into shared header

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/rv770.c:1138:6: warning: no previous prototype for 
‘rv770_set_clk_bypass_mode’ [-Wmissing-prototypes]
 1138 | void rv770_set_clk_bypass_mode(struct radeon_device *rdev)
 | ^

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon.h  | 1 +
 drivers/gpu/drm/radeon/radeon_acpi.c | 2 --
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 32a2c894ee3ff..1cbbaff7cede2 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -291,6 +291,7 @@ void radeon_pm_fini(struct radeon_device *rdev);
 void radeon_pm_compute_clocks(struct radeon_device *rdev);
 void radeon_pm_suspend(struct radeon_device *rdev);
 void radeon_pm_resume(struct radeon_device *rdev);
+void radeon_pm_acpi_event_handler(struct radeon_device *rdev);
 void radeon_combios_get_power_modes(struct radeon_device *rdev);
 void radeon_atombios_get_power_modes(struct radeon_device *rdev);
 int radeon_atom_get_clock_dividers(struct radeon_device *rdev,
diff --git a/drivers/gpu/drm/radeon/radeon_acpi.c 
b/drivers/gpu/drm/radeon/radeon_acpi.c
index 6cf1645e7a1a8..0eb594b56af8c 100644
--- a/drivers/gpu/drm/radeon/radeon_acpi.c
+++ b/drivers/gpu/drm/radeon/radeon_acpi.c
@@ -45,8 +45,6 @@ static inline bool 
radeon_atpx_dgpu_req_power_for_displays(void) { return false;
 
 #define ACPI_AC_CLASS   "ac_adapter"
 
-extern void radeon_pm_acpi_event_handler(struct radeon_device *rdev);
-
 struct atif_verify_interface {
u16 size;   /* structure size in bytes (includes size 
field) */
u16 version;/* version */
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 13/20] drm/radeon/evergreen: Move 'rv770_set_clk_bypass_mode' prototype to shared location

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/rv770.c:1138:6: warning: no previous prototype for 
‘rv770_set_clk_bypass_mode’ [-Wmissing-prototypes]
 1138 | void rv770_set_clk_bypass_mode(struct radeon_device *rdev)
 | ^

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/evergreen.c | 1 -
 drivers/gpu/drm/radeon/r600.c  | 1 -
 drivers/gpu/drm/radeon/radeon.h| 2 ++
 3 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/evergreen.c 
b/drivers/gpu/drm/radeon/evergreen.c
index 14d90dc376e71..3541a9444be22 100644
--- a/drivers/gpu/drm/radeon/evergreen.c
+++ b/drivers/gpu/drm/radeon/evergreen.c
@@ -223,7 +223,6 @@ extern u32 si_get_csb_size(struct radeon_device *rdev);
 extern void si_get_csb_buffer(struct radeon_device *rdev, volatile u32 
*buffer);
 extern u32 cik_get_csb_size(struct radeon_device *rdev);
 extern void cik_get_csb_buffer(struct radeon_device *rdev, volatile u32 
*buffer);
-extern void rv770_set_clk_bypass_mode(struct radeon_device *rdev);
 
 static const u32 evergreen_golden_registers[] =
 {
diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 6e780b0109995..9587792503525 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -112,7 +112,6 @@ void r600_fini(struct radeon_device *rdev);
 void r600_irq_disable(struct radeon_device *rdev);
 static void r600_pcie_gen2_enable(struct radeon_device *rdev);
 extern int evergreen_rlc_resume(struct radeon_device *rdev);
-extern void rv770_set_clk_bypass_mode(struct radeon_device *rdev);
 
 /*
  * Indirect registers accessor
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 421f6b26512ed..32a2c894ee3ff 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -280,6 +280,8 @@ struct radeon_clock {
uint32_t vco_freq;
 };
 
+void rv770_set_clk_bypass_mode(struct radeon_device *rdev);
+
 /*
  * Power management
  */
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 07/20] drm/radeon/radeon_display: Remove unused variable 'mod'

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_display.c: In function ‘radeon_div’:
 drivers/gpu/drm/radeon/radeon_display.c:1094:11: warning: variable ‘mod’ set 
but not used [-Wunused-but-set-variable]

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: report to 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_display.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_display.c 
b/drivers/gpu/drm/radeon/radeon_display.c
index bd60f16fd0d78..78fceedfd9255 100644
--- a/drivers/gpu/drm/radeon/radeon_display.c
+++ b/drivers/gpu/drm/radeon/radeon_display.c
@@ -1091,11 +1091,9 @@ void radeon_compute_pll_avivo(struct radeon_pll *pll,
 /* pre-avivo */
 static inline uint32_t radeon_div(uint64_t n, uint32_t d)
 {
-   uint64_t mod;
-
n += d / 2;
 
-   mod = do_div(n, d);
+   do_div(n, d);
return n;
 }
 
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 19/20] drm/radeon/r600: Fix a misnamed parameter description and a formatting issue

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/r600.c:2965: warning: Function parameter or member 
'resv' not described in 'r600_copy_cpdma'
 drivers/gpu/drm/radeon/r600.c:2965: warning: Excess function parameter 'fence' 
description in 'r600_copy_cpdma'
 drivers/gpu/drm/radeon/r600.c:4382: warning: Function parameter or member 
'rdev' not described in 'r600_mmio_hdp_flush'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/r600.c | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index 9587792503525..0a085b85f559d 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -2952,7 +2952,7 @@ bool r600_semaphore_ring_emit(struct radeon_device *rdev,
  * @src_offset: src GPU address
  * @dst_offset: dst GPU address
  * @num_gpu_pages: number of GPU pages to xfer
- * @fence: radeon fence object
+ * @resv: DMA reservation object to manage fences
  *
  * Copy GPU paging using the CP DMA engine (r6xx+).
  * Used by the radeon ttm implementation to move pages if
@@ -4371,7 +4371,7 @@ int r600_debugfs_mc_info_init(struct radeon_device *rdev)
 
 /**
  * r600_mmio_hdp_flush - flush Host Data Path cache via MMIO
- * rdev: radeon device structure
+ * @rdev: radeon device structure
  *
  * Some R6XX/R7XX don't seem to take into account HDP flushes performed
  * through the ring buffer. This leads to corruption in rendering, see
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 10/20] drm/radeon/radeon_ring: Add missing function parameters 'rdev' and 'data'

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_ring.c:226: warning: Function parameter or 
member 'rdev' not described in 'radeon_ring_unlock_undo'
 drivers/gpu/drm/radeon/radeon_ring.c:240: warning: Function parameter or 
member 'rdev' not described in 'radeon_ring_lockup_update'
 drivers/gpu/drm/radeon/radeon_ring.c:283: warning: Function parameter or 
member 'data' not described in 'radeon_ring_backup'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_ring.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/drivers/gpu/drm/radeon/radeon_ring.c 
b/drivers/gpu/drm/radeon/radeon_ring.c
index 37093cea24c59..c3304c977a0a5 100644
--- a/drivers/gpu/drm/radeon/radeon_ring.c
+++ b/drivers/gpu/drm/radeon/radeon_ring.c
@@ -218,6 +218,7 @@ void radeon_ring_undo(struct radeon_ring *ring)
 /**
  * radeon_ring_unlock_undo - reset the wptr and unlock the ring
  *
+ * @rdev:   radeon device structure
  * @ring: radeon_ring structure holding ring information
  *
  * Call radeon_ring_undo() then unlock the ring (all asics).
@@ -231,6 +232,7 @@ void radeon_ring_unlock_undo(struct radeon_device *rdev, 
struct radeon_ring *rin
 /**
  * radeon_ring_lockup_update - update lockup variables
  *
+ * @rdev:   radeon device structure
  * @ring: radeon_ring structure holding ring information
  *
  * Update the last rptr value and timestamp (all asics).
@@ -275,6 +277,7 @@ bool radeon_ring_test_lockup(struct radeon_device *rdev, 
struct radeon_ring *rin
  *
  * @rdev: radeon_device pointer
  * @ring: the ring we want to back up
+ * @data: placeholder for returned commit data
  *
  * Saves all unprocessed commits from a ring, returns the number of dwords 
saved.
  */
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 17/20] drm/radeon/evergreend: Move 'evergreen_*' and 'sumo_*' prototypes out to shared location

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/evergreen.c:1281:6: warning: no previous prototype for 
‘evergreen_fix_pci_max_read_req_size’ [-Wmissing-prototypes]
 1281 | void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev)
 | ^~~
 drivers/gpu/drm/radeon/evergreen.c:2664:6: warning: no previous prototype for 
‘evergreen_mc_stop’ [-Wmissing-prototypes]
 2664 | void evergreen_mc_stop(struct radeon_device *rdev, struct 
evergreen_mc_save *save)
 | ^
 drivers/gpu/drm/radeon/evergreen.c:2762:6: warning: no previous prototype for 
‘evergreen_mc_resume’ [-Wmissing-prototypes]
 2762 | void evergreen_mc_resume(struct radeon_device *rdev, struct 
evergreen_mc_save *save)
 | ^~~
 drivers/gpu/drm/radeon/evergreen.c:2850:6: warning: no previous prototype for 
‘evergreen_mc_program’ [-Wmissing-prototypes]
 2850 | void evergreen_mc_program(struct radeon_device *rdev)
 | ^~~~
 drivers/gpu/drm/radeon/evergreen.c:3710:5: warning: no previous prototype for 
‘evergreen_mc_init’ [-Wmissing-prototypes]
 3710 | int evergreen_mc_init(struct radeon_device *rdev)
 | ^
 drivers/gpu/drm/radeon/evergreen.c:3769:6: warning: no previous prototype for 
‘evergreen_print_gpu_status_regs’ [-Wmissing-prototypes]
 3769 | void evergreen_print_gpu_status_regs(struct radeon_device *rdev)
 | ^~~
 drivers/gpu/drm/radeon/evergreen.c:3797:6: warning: no previous prototype for 
‘evergreen_is_display_hung’ [-Wmissing-prototypes]
 3797 | bool evergreen_is_display_hung(struct radeon_device *rdev)
 | ^
 drivers/gpu/drm/radeon/evergreen.c:4009:6: warning: no previous prototype for 
‘evergreen_gpu_pci_config_reset’ [-Wmissing-prototypes]
 4009 | void evergreen_gpu_pci_config_reset(struct radeon_device *rdev)
 | ^~
 drivers/gpu/drm/radeon/evergreen.c:4110:6: warning: no previous prototype for 
‘sumo_rlc_fini’ [-Wmissing-prototypes]
 4110 | void sumo_rlc_fini(struct radeon_device *rdev)
 | ^
 drivers/gpu/drm/radeon/evergreen.c:4153:5: warning: no previous prototype for 
‘sumo_rlc_init’ [-Wmissing-prototypes]
 4153 | int sumo_rlc_init(struct radeon_device *rdev)
 | ^
 drivers/gpu/drm/radeon/evergreen.c:4381:5: warning: no previous prototype for 
‘evergreen_rlc_resume’ [-Wmissing-prototypes]
 4381 | int evergreen_rlc_resume(struct radeon_device *rdev)
 | ^
 drivers/gpu/drm/radeon/evergreen.c:4670:6: warning: no previous prototype for 
‘evergreen_irq_suspend’ [-Wmissing-prototypes]
 4670 | void evergreen_irq_suspend(struct radeon_device *rdev)
 | ^

NB: Lots more of these - snipped for brevity

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/ni.c | 16 
 drivers/gpu/drm/radeon/radeon.h | 23 +++
 drivers/gpu/drm/radeon/si.c |  6 --
 3 files changed, 23 insertions(+), 22 deletions(-)

diff --git a/drivers/gpu/drm/radeon/ni.c b/drivers/gpu/drm/radeon/ni.c
index 02feb0801fd30..91bba473f2703 100644
--- a/drivers/gpu/drm/radeon/ni.c
+++ b/drivers/gpu/drm/radeon/ni.c
@@ -38,7 +38,6 @@
 #include "radeon_asic.h"
 #include "radeon_audio.h"
 #include "radeon_ucode.h"
-
 /*
  * Indirect registers accessor
  */
@@ -190,21 +189,6 @@ static const u32 tn_rlc_save_restore_register_list[] =
0x802c,
 };
 
-extern bool evergreen_is_display_hung(struct radeon_device *rdev);
-extern void evergreen_print_gpu_status_regs(struct radeon_device *rdev);
-extern void evergreen_mc_stop(struct radeon_device *rdev, struct 
evergreen_mc_save *save);
-extern void evergreen_mc_resume(struct radeon_device *rdev, struct 
evergreen_mc_save *save);
-extern int evergreen_mc_wait_for_idle(struct radeon_device *rdev);
-extern void evergreen_mc_program(struct radeon_device *rdev);
-extern void evergreen_irq_suspend(struct radeon_device *rdev);
-extern int evergreen_mc_init(struct radeon_device *rdev);
-extern void evergreen_fix_pci_max_read_req_size(struct radeon_device *rdev);
-extern void evergreen_pcie_gen2_enable(struct radeon_device *rdev);
-extern void evergreen_program_aspm(struct radeon_device *rdev);
-extern void sumo_rlc_fini(struct radeon_device *rdev);
-extern int sumo_rlc_init(struct radeon_device *rdev);
-extern void evergreen_gpu_pci_config_reset(struct radeon_device *rdev);
-
 /* Firmware Names */
 MODULE_FIRMWARE("radeon/BARTS_pfp.bin");
 MODULE_FIRMWARE("radeon/BARTS_me.bin");
diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 1cbbaff7cede2..3e53a9493ae92 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2951,6 +2951,29 @@ extern u32 r6xx_remap_render_backend(struct 
radeon_device *rdev,
 extern int ni_init_microcode(struct radeon_device 

[PATCH 06/20] drm/radeon/radeon_connectors: Strip out set but unused variable 'ret'

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_connectors.c: In function 
‘radeon_setup_mst_connector’:
 drivers/gpu/drm/radeon/radeon_connectors.c:2574:7: warning: variable ‘ret’ set 
but not used [-Wunused-but-set-variable]

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_connectors.c | 4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_connectors.c 
b/drivers/gpu/drm/radeon/radeon_connectors.c
index e308344344425..607ad5620bd99 100644
--- a/drivers/gpu/drm/radeon/radeon_connectors.c
+++ b/drivers/gpu/drm/radeon/radeon_connectors.c
@@ -2571,13 +2571,11 @@ void radeon_setup_mst_connector(struct drm_device *dev)
return;
 
list_for_each_entry(connector, >mode_config.connector_list, head) {
-   int ret;
-
radeon_connector = to_radeon_connector(connector);
 
if (connector->connector_type != DRM_MODE_CONNECTOR_DisplayPort)
continue;
 
-   ret = radeon_dp_mst_init(radeon_connector);
+   radeon_dp_mst_init(radeon_connector);
}
 }
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 12/20] drm/radeon/radeon_cs: Fix a bunch of doc-rot issues

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_cs.c:416: warning: Function parameter or member 
'backoff' not described in 'radeon_cs_parser_fini'
 drivers/gpu/drm/radeon/radeon_cs.c:735: warning: Function parameter or member 
'p' not described in 'radeon_cs_packet_parse'
 drivers/gpu/drm/radeon/radeon_cs.c:735: warning: Function parameter or member 
'idx' not described in 'radeon_cs_packet_parse'
 drivers/gpu/drm/radeon/radeon_cs.c:735: warning: Excess function parameter 
'parser' description in 'radeon_cs_packet_parse'
 drivers/gpu/drm/radeon/radeon_cs.c:844: warning: Function parameter or member 
'p' not described in 'radeon_cs_packet_next_reloc'
 drivers/gpu/drm/radeon/radeon_cs.c:844: warning: Function parameter or member 
'cs_reloc' not described in 'radeon_cs_packet_next_reloc'
 drivers/gpu/drm/radeon/radeon_cs.c:844: warning: Function parameter or member 
'nomm' not described in 'radeon_cs_packet_next_reloc'
 drivers/gpu/drm/radeon/radeon_cs.c:844: warning: Excess function parameter 
'parser' description in 'radeon_cs_packet_next_reloc'
 drivers/gpu/drm/radeon/radeon_cs.c:844: warning: Excess function parameter 
'data' description in 'radeon_cs_packet_next_reloc'
 drivers/gpu/drm/radeon/radeon_cs.c:844: warning: Excess function parameter 
'offset_start' description in 'radeon_cs_packet_next_reloc'
 drivers/gpu/drm/radeon/radeon_cs.c:844: warning: Excess function parameter 
'offset_mask' description in 'radeon_cs_packet_next_reloc'
 drivers/gpu/drm/radeon/radeon_cs.c:844: warning: Excess function parameter 
'reloc' description in 'radeon_cs_packet_next_reloc'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: Jerome Glisse 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_cs.c | 12 ++--
 1 file changed, 6 insertions(+), 6 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_cs.c 
b/drivers/gpu/drm/radeon/radeon_cs.c
index 21ce2f9502c09..729939df29cc5 100644
--- a/drivers/gpu/drm/radeon/radeon_cs.c
+++ b/drivers/gpu/drm/radeon/radeon_cs.c
@@ -408,6 +408,7 @@ static int cmp_size_smaller_first(void *priv, struct 
list_head *a,
  * cs_parser_fini() - clean parser states
  * @parser:parser structure holding parsing context.
  * @error: error number
+ * @backoff:   indicator to backoff the reservation
  *
  * If error is set than unvalidate buffer, otherwise just free memory
  * used by parsing context.
@@ -723,8 +724,9 @@ int radeon_cs_ioctl(struct drm_device *dev, void *data, 
struct drm_file *filp)
 
 /**
  * radeon_cs_packet_parse() - parse cp packet and point ib index to next packet
- * @parser:parser structure holding parsing context.
+ * @p: parser structure holding parsing context.
  * @pkt:   where to store packet information
+ * @idx:   packet index
  *
  * Assume that chunk_ib_index is properly set. Will return -EINVAL
  * if packet is bigger than remaining ib size. or if packets is unknown.
@@ -829,11 +831,9 @@ void radeon_cs_dump_packet(struct radeon_cs_parser *p,
 
 /**
  * radeon_cs_packet_next_reloc() - parse next (should be reloc) packet
- * @parser:parser structure holding parsing context.
- * @data:  pointer to relocation data
- * @offset_start:  starting offset
- * @offset_mask:   offset mask (to align start offset on)
- * @reloc: reloc informations
+ * @p: parser structure holding parsing context.
+ * @cs_reloc:  reloc informations
+ * @nomm:  never actually used
  *
  * Check if next packet is relocation packet3, do bo validation and compute
  * GPU offset using the provided start.
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 16/20] drm/radeon/radeon_audio: Move 'dce3_2_*' prototypes to shared location

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/dce3_1_afmt.c:30:6: warning: no previous prototype for 
‘dce3_2_afmt_hdmi_write_speaker_allocation’ [-Wmissing-prototypes]
 30 | void dce3_2_afmt_hdmi_write_speaker_allocation(struct drm_encoder 
*encoder,
 | ^
 drivers/gpu/drm/radeon/dce3_1_afmt.c:48:6: warning: no previous prototype for 
‘dce3_2_afmt_dp_write_speaker_allocation’ [-Wmissing-prototypes]
 48 | void dce3_2_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder,
 | ^~~
 drivers/gpu/drm/radeon/dce3_1_afmt.c:66:6: warning: no previous prototype for 
‘dce3_2_afmt_write_sad_regs’ [-Wmissing-prototypes]
 66 | void dce3_2_afmt_write_sad_regs(struct drm_encoder *encoder,
 | ^~
 drivers/gpu/drm/radeon/dce3_1_afmt.c:116:6: warning: no previous prototype for 
‘dce3_2_audio_set_dto’ [-Wmissing-prototypes]
 116 | void dce3_2_audio_set_dto(struct radeon_device *rdev,
 | ^~~~
 drivers/gpu/drm/radeon/dce3_1_afmt.c:170:6: warning: no previous prototype for 
‘dce3_2_hdmi_update_acr’ [-Wmissing-prototypes]
 170 | void dce3_2_hdmi_update_acr(struct drm_encoder *encoder, long offset,
 | ^~
 drivers/gpu/drm/radeon/dce3_1_afmt.c:202:6: warning: no previous prototype for 
‘dce3_2_set_audio_packet’ [-Wmissing-prototypes]
 202 | void dce3_2_set_audio_packet(struct drm_encoder *encoder, u32 offset)
 | ^~~
 drivers/gpu/drm/radeon/dce3_1_afmt.c:223:6: warning: no previous prototype for 
‘dce3_2_set_mute’ [-Wmissing-prototypes]
 223 | void dce3_2_set_mute(struct drm_encoder *encoder, u32 offset, bool mute)
 | ^~~

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Slava Grigorev 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_audio.c | 12 
 drivers/gpu/drm/radeon/radeon_audio.h | 12 
 2 files changed, 12 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_audio.c 
b/drivers/gpu/drm/radeon/radeon_audio.c
index a2be60aa3cec4..18228b366752e 100644
--- a/drivers/gpu/drm/radeon/radeon_audio.c
+++ b/drivers/gpu/drm/radeon/radeon_audio.c
@@ -39,16 +39,10 @@ void dce6_audio_enable(struct radeon_device *rdev, struct 
r600_audio_pin *pin,
 u32 dce6_endpoint_rreg(struct radeon_device *rdev, u32 offset, u32 reg);
 void dce6_endpoint_wreg(struct radeon_device *rdev,
u32 offset, u32 reg, u32 v);
-void dce3_2_afmt_write_sad_regs(struct drm_encoder *encoder,
-   struct cea_sad *sads, int sad_count);
 void evergreen_hdmi_write_sad_regs(struct drm_encoder *encoder,
struct cea_sad *sads, int sad_count);
 void dce6_afmt_write_sad_regs(struct drm_encoder *encoder,
struct cea_sad *sads, int sad_count);
-void dce3_2_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder,
-   u8 *sadb, int sad_count);
-void dce3_2_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder,
-   u8 *sadb, int sad_count);
 void dce4_afmt_hdmi_write_speaker_allocation(struct drm_encoder *encoder,
u8 *sadb, int sad_count);
 void dce4_afmt_dp_write_speaker_allocation(struct drm_encoder *encoder,
@@ -64,8 +58,6 @@ void dce6_afmt_write_latency_fields(struct drm_encoder 
*encoder,
 struct r600_audio_pin* r600_audio_get_pin(struct radeon_device *rdev);
 struct r600_audio_pin* dce6_audio_get_pin(struct radeon_device *rdev);
 void dce6_afmt_select_pin(struct drm_encoder *encoder);
-void dce3_2_audio_set_dto(struct radeon_device *rdev,
-   struct radeon_crtc *crtc, unsigned int clock);
 void dce4_hdmi_audio_set_dto(struct radeon_device *rdev,
struct radeon_crtc *crtc, unsigned int clock);
 void dce4_dp_audio_set_dto(struct radeon_device *rdev,
@@ -76,16 +68,12 @@ void dce6_dp_audio_set_dto(struct radeon_device *rdev,
struct radeon_crtc *crtc, unsigned int clock);
 void evergreen_set_avi_packet(struct radeon_device *rdev, u32 offset,
unsigned char *buffer, size_t size);
-void dce3_2_hdmi_update_acr(struct drm_encoder *encoder, long offset,
-   const struct radeon_hdmi_acr *acr);
 void evergreen_hdmi_update_acr(struct drm_encoder *encoder, long offset,
const struct radeon_hdmi_acr *acr);
 void dce4_set_vbi_packet(struct drm_encoder *encoder, u32 offset);
 void dce4_hdmi_set_color_depth(struct drm_encoder *encoder,
u32 offset, int bpc);
-void dce3_2_set_audio_packet(struct drm_encoder *encoder, u32 offset);
 void dce4_set_audio_packet(struct drm_encoder *encoder, u32 offset);
-void dce3_2_set_mute(struct drm_encoder *encoder, u32 offset, bool mute);
 void dce4_set_mute(struct drm_encoder *encoder, u32 offset, bool mute);
 static void radeon_audio_hdmi_mode_set(struct drm_encoder *encoder,
struct drm_display_mode *mode);
diff --git 

[PATCH 15/20] drm/radeon/r600d: Move 'rc600_*' prototypes into shared header

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/r600_hdmi.c:177:6: warning: no previous prototype for 
‘r600_hdmi_update_acr’ [-Wmissing-prototypes]
 177 | void r600_hdmi_update_acr(struct drm_encoder *encoder, long offset,
 | ^~~~
 drivers/gpu/drm/radeon/r600_hdmi.c:217:6: warning: no previous prototype for 
‘r600_set_avi_packet’ [-Wmissing-prototypes]
 217 | void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
 | ^~~
 drivers/gpu/drm/radeon/r600_hdmi.c:314:6: warning: no previous prototype for 
‘r600_hdmi_audio_set_dto’ [-Wmissing-prototypes]
 314 | void r600_hdmi_audio_set_dto(struct radeon_device *rdev,
 | ^~~
 drivers/gpu/drm/radeon/r600_hdmi.c:340:6: warning: no previous prototype for 
‘r600_set_vbi_packet’ [-Wmissing-prototypes]
 340 | void r600_set_vbi_packet(struct drm_encoder *encoder, u32 offset)
 | ^~~
 drivers/gpu/drm/radeon/r600_hdmi.c:351:6: warning: no previous prototype for 
‘r600_set_audio_packet’ [-Wmissing-prototypes]
 351 | void r600_set_audio_packet(struct drm_encoder *encoder, u32 offset)
 | ^
 drivers/gpu/drm/radeon/r600_hdmi.c:393:6: warning: no previous prototype for 
‘r600_set_mute’ [-Wmissing-prototypes]
 393 | void r600_set_mute(struct drm_encoder *encoder, u32 offset, bool mute)
 | ^
 drivers/gpu/drm/radeon/r600_hdmi.c:469:6: warning: no previous prototype for 
‘r600_hdmi_enable’ [-Wmissing-prototypes]
 469 | void r600_hdmi_enable(struct drm_encoder *encoder, bool enable)
 | ^~~~

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/r600d.h| 14 ++
 drivers/gpu/drm/radeon/radeon_audio.c | 11 +--
 2 files changed, 15 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r600d.h b/drivers/gpu/drm/radeon/r600d.h
index 2e00a5287bd2d..db4bcc8bee4e5 100644
--- a/drivers/gpu/drm/radeon/r600d.h
+++ b/drivers/gpu/drm/radeon/r600d.h
@@ -27,6 +27,20 @@
 #ifndef R600D_H
 #define R600D_H
 
+struct radeon_crtc;
+struct radeon_hdmi_acr;
+
+void r600_set_audio_packet(struct drm_encoder *encoder, u32 offset);
+void r600_set_mute(struct drm_encoder *encoder, u32 offset, bool mute);
+void r600_hdmi_audio_set_dto(struct radeon_device *rdev,
+   struct radeon_crtc *crtc, unsigned int clock);
+void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
+   unsigned char *buffer, size_t size);
+void r600_hdmi_update_acr(struct drm_encoder *encoder, long offset,
+   const struct radeon_hdmi_acr *acr);
+void r600_set_vbi_packet(struct drm_encoder *encoder, u32 offset);
+void r600_hdmi_enable(struct drm_encoder *encoder, bool enable);
+
 #define CP_PACKET2 0x8000
 #definePACKET2_PAD_SHIFT   0
 #definePACKET2_PAD_MASK(0x3fff << 0)
diff --git a/drivers/gpu/drm/radeon/radeon_audio.c 
b/drivers/gpu/drm/radeon/radeon_audio.c
index 8c63ccb8b6235..a2be60aa3cec4 100644
--- a/drivers/gpu/drm/radeon/radeon_audio.c
+++ b/drivers/gpu/drm/radeon/radeon_audio.c
@@ -27,6 +27,7 @@
 #include 
 #include "radeon.h"
 #include "atom.h"
+#include "r600d.h"
 #include "radeon_audio.h"
 
 void r600_audio_enable(struct radeon_device *rdev, struct r600_audio_pin *pin,
@@ -63,8 +64,6 @@ void dce6_afmt_write_latency_fields(struct drm_encoder 
*encoder,
 struct r600_audio_pin* r600_audio_get_pin(struct radeon_device *rdev);
 struct r600_audio_pin* dce6_audio_get_pin(struct radeon_device *rdev);
 void dce6_afmt_select_pin(struct drm_encoder *encoder);
-void r600_hdmi_audio_set_dto(struct radeon_device *rdev,
-   struct radeon_crtc *crtc, unsigned int clock);
 void dce3_2_audio_set_dto(struct radeon_device *rdev,
struct radeon_crtc *crtc, unsigned int clock);
 void dce4_hdmi_audio_set_dto(struct radeon_device *rdev,
@@ -75,31 +74,23 @@ void dce6_hdmi_audio_set_dto(struct radeon_device *rdev,
struct radeon_crtc *crtc, unsigned int clock);
 void dce6_dp_audio_set_dto(struct radeon_device *rdev,
struct radeon_crtc *crtc, unsigned int clock);
-void r600_set_avi_packet(struct radeon_device *rdev, u32 offset,
-   unsigned char *buffer, size_t size);
 void evergreen_set_avi_packet(struct radeon_device *rdev, u32 offset,
unsigned char *buffer, size_t size);
-void r600_hdmi_update_acr(struct drm_encoder *encoder, long offset,
-   const struct radeon_hdmi_acr *acr);
 void dce3_2_hdmi_update_acr(struct drm_encoder *encoder, long offset,
const struct radeon_hdmi_acr *acr);
 void evergreen_hdmi_update_acr(struct drm_encoder *encoder, long offset,
const struct radeon_hdmi_acr *acr);
-void r600_set_vbi_packet(struct drm_encoder *encoder, u32 offset);
 void dce4_set_vbi_packet(struct drm_encoder *encoder, u32 offset);
 void 

[PATCH 11/20] drm/radeon/r600: Strip out set but unused 'tmp' variables

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/r600.c: In function ‘r600_pcie_gart_tlb_flush’:
 drivers/gpu/drm/radeon/r600.c:1083:7: warning: variable ‘tmp’ set but not used 
[-Wunused-but-set-variable]
 drivers/gpu/drm/radeon/r600.c: At top level:
 drivers/gpu/drm/radeon/r600.c: In function ‘r600_mmio_hdp_flush’:
 drivers/gpu/drm/radeon/r600.c:4393:7: warning: variable ‘tmp’ set but not used 
[-Wunused-but-set-variable]

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/r600.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/r600.c b/drivers/gpu/drm/radeon/r600.c
index d9a33ca768f34..6e780b0109995 100644
--- a/drivers/gpu/drm/radeon/r600.c
+++ b/drivers/gpu/drm/radeon/r600.c
@@ -1080,7 +1080,6 @@ void r600_pcie_gart_tlb_flush(struct radeon_device *rdev)
if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740) &&
!(rdev->flags & RADEON_IS_AGP)) {
void __iomem *ptr = (void *)rdev->gart.ptr;
-   u32 tmp;
 
/* r7xx hw bug.  write to HDP_DEBUG1 followed by fb read
 * rather than write to HDP_REG_COHERENCY_FLUSH_CNTL
@@ -1088,7 +1087,7 @@ void r600_pcie_gart_tlb_flush(struct radeon_device *rdev)
 * method for them.
 */
WREG32(HDP_DEBUG1, 0);
-   tmp = readl((void __iomem *)ptr);
+   readl((void __iomem *)ptr);
} else
WREG32(R_005480_HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1);
 
@@ -4390,10 +4389,9 @@ void r600_mmio_hdp_flush(struct radeon_device *rdev)
if ((rdev->family >= CHIP_RV770) && (rdev->family <= CHIP_RV740) &&
rdev->vram_scratch.ptr && !(rdev->flags & RADEON_IS_AGP)) {
void __iomem *ptr = (void *)rdev->vram_scratch.ptr;
-   u32 tmp;
 
WREG32(HDP_DEBUG1, 0);
-   tmp = readl((void __iomem *)ptr);
+   readl((void __iomem *)ptr);
} else
WREG32(R_005480_HDP_MEM_COHERENCY_FLUSH_CNTL, 0x1);
 }
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 01/20] drm/radeon/radeon_ttm: Place declaration of 'rdev' in same clause as its use

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_ttm.c: In function ‘radeon_ttm_tt_create’:
 drivers/gpu/drm/radeon/radeon_ttm.c:611:24: warning: variable ‘rdev’ set but 
not used [-Wunused-but-set-variable]

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Jerome Glisse 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_ttm.c | 8 
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_ttm.c 
b/drivers/gpu/drm/radeon/radeon_ttm.c
index 95038ac3382e2..a8c915920070f 100644
--- a/drivers/gpu/drm/radeon/radeon_ttm.c
+++ b/drivers/gpu/drm/radeon/radeon_ttm.c
@@ -608,21 +608,21 @@ static void radeon_ttm_backend_destroy(struct 
ttm_bo_device *bdev, struct ttm_tt
 static struct ttm_tt *radeon_ttm_tt_create(struct ttm_buffer_object *bo,
   uint32_t page_flags)
 {
-   struct radeon_device *rdev;
struct radeon_ttm_tt *gtt;
enum ttm_caching caching;
struct radeon_bo *rbo;
-
-   rbo = container_of(bo, struct radeon_bo, tbo);
+#if IS_ENABLED(CONFIG_AGP)
+   struct radeon_device *rdev;
 
rdev = radeon_get_rdev(bo->bdev);
-#if IS_ENABLED(CONFIG_AGP)
if (rdev->flags & RADEON_IS_AGP) {
return ttm_agp_tt_create(bo, rdev->ddev->agp->bridge,
 page_flags);
}
 #endif
 
+   rbo = container_of(bo, struct radeon_bo, tbo);
+
gtt = kzalloc(sizeof(struct radeon_ttm_tt), GFP_KERNEL);
if (gtt == NULL) {
return NULL;
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 05/20] drm/radeon: Move 'radeon_add_legacy_encoder's prototype to shared location

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon.h  | 2 ++
 drivers/gpu/drm/radeon/radeon_atombios.c | 5 -
 drivers/gpu/drm/radeon/radeon_combios.c  | 5 -
 3 files changed, 2 insertions(+), 10 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 0cc8f081e113a..421f6b26512ed 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2819,6 +2819,8 @@ extern int radeon_cs_parser_init(struct radeon_cs_parser 
*p, void *data);
 extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int 
enable);
 extern void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
 struct drm_connector *drm_connector);
+extern void radeon_add_legacy_encoder(struct drm_device *dev, uint32_t 
encoder_enum,
+ uint32_t supported_device);
 extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int 
enable);
 extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 
domain);
 extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
diff --git a/drivers/gpu/drm/radeon/radeon_atombios.c 
b/drivers/gpu/drm/radeon/radeon_atombios.c
index 5d25917251892..557960e3b204f 100644
--- a/drivers/gpu/drm/radeon/radeon_atombios.c
+++ b/drivers/gpu/drm/radeon/radeon_atombios.c
@@ -39,11 +39,6 @@ extern void
 radeon_add_atom_encoder(struct drm_device *dev, uint32_t encoder_enum,
uint32_t supported_device, u16 caps);
 
-/* from radeon_legacy_encoder.c */
-extern void
-radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum,
- uint32_t supported_device);
-
 union atom_supported_devices {
struct _ATOM_SUPPORTED_DEVICES_INFO info;
struct _ATOM_SUPPORTED_DEVICES_INFO_2 info_2;
diff --git a/drivers/gpu/drm/radeon/radeon_combios.c 
b/drivers/gpu/drm/radeon/radeon_combios.c
index d3c04df7e75d7..b8cd37d76d8bf 100644
--- a/drivers/gpu/drm/radeon/radeon_combios.c
+++ b/drivers/gpu/drm/radeon/radeon_combios.c
@@ -40,11 +40,6 @@
 #include 
 #endif /* CONFIG_PPC_PMAC */
 
-/* from radeon_legacy_encoder.c */
-extern void
-radeon_add_legacy_encoder(struct drm_device *dev, uint32_t encoder_enum,
- uint32_t supported_device);
-
 /* old legacy ATI BIOS routines */
 
 /* COMBIOS table offsets */
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 09/20] drm/radeon/radeon_irq_kms: Demote non-conformant kernel-doc fix another

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_irq_kms.c:56: warning: Function parameter or 
member 'irq' not described in 'radeon_driver_irq_handler_kms'
 drivers/gpu/drm/radeon/radeon_irq_kms.c:56: warning: Function parameter or 
member 'arg' not described in 'radeon_driver_irq_handler_kms'
 drivers/gpu/drm/radeon/radeon_irq_kms.c:571: warning: Function parameter or 
member 'n' not described in 'radeon_irq_kms_set_irq_n_enabled'
 drivers/gpu/drm/radeon/radeon_irq_kms.c:571: warning: Excess function 
parameter 'num' description in 'radeon_irq_kms_set_irq_n_enabled'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_irq_kms.c | 6 ++
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_irq_kms.c 
b/drivers/gpu/drm/radeon/radeon_irq_kms.c
index b86bc88ad4308..3521084030d24 100644
--- a/drivers/gpu/drm/radeon/radeon_irq_kms.c
+++ b/drivers/gpu/drm/radeon/radeon_irq_kms.c
@@ -43,11 +43,9 @@
 
 #define RADEON_WAIT_IDLE_TIMEOUT 200
 
-/**
+/*
  * radeon_driver_irq_handler_kms - irq handler for KMS
  *
- * @int irq, void *arg: args
- *
  * This is the irq handler for the radeon KMS driver (all asics).
  * radeon_irq_process is a macro that points to the per-asic
  * irq handler callback.
@@ -556,7 +554,7 @@ void radeon_irq_kms_disable_hpd(struct radeon_device *rdev, 
unsigned hpd_mask)
  * @mask: the mask that enables the interrupts
  * @enable: whether to enable or disable the interrupt register
  * @name: the name of the interrupt register to print to the kernel log
- * @num: the number of the interrupt register to print to the kernel log
+ * @n: the number of the interrupt register to print to the kernel log
  *
  * Helper for updating the enable state of interrupt registers. Checks whether
  * or not the interrupt matches the enable state we want. If it doesn't, then
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 04/20] drm/radeon: Move 'radeon_add_legacy_encoder' prototype to shared header

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

  drivers/gpu/drm/radeon/radeon_legacy_encoders.c:1745:1: warning: no previous 
prototype for ‘radeon_add_legacy_encoder’ [-Wmissing-prototypes]
 1745 | radeon_add_legacy_encoder(struct drm_device *dev, uint32_t 
encoder_enum, uint32_t supported_device)
 | ^

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon.h  | 2 ++
 drivers/gpu/drm/radeon/radeon_encoders.c | 3 ---
 2 files changed, 2 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index a0c2497cd4cf4..0cc8f081e113a 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -2817,6 +2817,8 @@ extern void radeon_wb_disable(struct radeon_device *rdev);
 extern void radeon_surface_init(struct radeon_device *rdev);
 extern int radeon_cs_parser_init(struct radeon_cs_parser *p, void *data);
 extern void radeon_legacy_set_clock_gating(struct radeon_device *rdev, int 
enable);
+extern void radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
+struct drm_connector *drm_connector);
 extern void radeon_atom_set_clock_gating(struct radeon_device *rdev, int 
enable);
 extern void radeon_ttm_placement_from_domain(struct radeon_bo *rbo, u32 
domain);
 extern bool radeon_ttm_bo_is_radeon_bo(struct ttm_buffer_object *bo);
diff --git a/drivers/gpu/drm/radeon/radeon_encoders.c 
b/drivers/gpu/drm/radeon/radeon_encoders.c
index ced022fae19d7..3e342fd812ff4 100644
--- a/drivers/gpu/drm/radeon/radeon_encoders.c
+++ b/drivers/gpu/drm/radeon/radeon_encoders.c
@@ -33,9 +33,6 @@
 #include "radeon.h"
 #include "atom.h"
 
-extern void
-radeon_legacy_backlight_init(struct radeon_encoder *radeon_encoder,
-struct drm_connector *drm_connector);
 extern void
 radeon_atom_backlight_init(struct radeon_encoder *radeon_encoder,
   struct drm_connector *drm_connector);
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 03/20] drm/radeon/radeon_fence: Demote some non-conformant kernel-doc headers and fix another

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_fence.c:168: warning: Function parameter or 
member 'wait' not described in 'radeon_fence_check_signaled'
 drivers/gpu/drm/radeon/radeon_fence.c:168: warning: Function parameter or 
member 'mode' not described in 'radeon_fence_check_signaled'
 drivers/gpu/drm/radeon/radeon_fence.c:168: warning: Function parameter or 
member 'flags' not described in 'radeon_fence_check_signaled'
 drivers/gpu/drm/radeon/radeon_fence.c:168: warning: Function parameter or 
member 'key' not described in 'radeon_fence_check_signaled'
 drivers/gpu/drm/radeon/radeon_fence.c:393: warning: Function parameter or 
member 'f' not described in 'radeon_fence_enable_signaling'
 drivers/gpu/drm/radeon/radeon_fence.c:393: warning: Excess function parameter 
'fence' description in 'radeon_fence_enable_signaling'
 drivers/gpu/drm/radeon/radeon_fence.c:1010: warning: Function parameter or 
member 'm' not described in 'radeon_debugfs_gpu_reset'
 drivers/gpu/drm/radeon/radeon_fence.c:1010: warning: Function parameter or 
member 'data' not described in 'radeon_debugfs_gpu_reset'

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: Jerome Glisse 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon_fence.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon_fence.c 
b/drivers/gpu/drm/radeon/radeon_fence.c
index 8735bf2bb8b5c..9ee6e599ef83b 100644
--- a/drivers/gpu/drm/radeon/radeon_fence.c
+++ b/drivers/gpu/drm/radeon/radeon_fence.c
@@ -157,7 +157,7 @@ int radeon_fence_emit(struct radeon_device *rdev,
return 0;
 }
 
-/**
+/*
  * radeon_fence_check_signaled - callback from fence_queue
  *
  * this function is called with fence_queue lock held, which is also used
@@ -383,7 +383,7 @@ static bool radeon_fence_is_signaled(struct dma_fence *f)
 
 /**
  * radeon_fence_enable_signaling - enable signalling on fence
- * @fence: fence
+ * @f: fence
  *
  * This function is called with fence_queue lock held, and adds a callback
  * to fence_queue that checks if this fence is signaled, and if so it
@@ -1001,7 +1001,7 @@ static int radeon_debugfs_fence_info(struct seq_file *m, 
void *data)
return 0;
 }
 
-/**
+/*
  * radeon_debugfs_gpu_reset - manually trigger a gpu reset
  *
  * Manually trigger a gpu reset at the next fence wait.
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 02/20] drm/radeon: Move radeon_ttm{init, fini} to shared location

2020-11-09 Thread Lee Jones
Fixes the following W=1 kernel build warning(s):

 drivers/gpu/drm/radeon/radeon_ttm.c: At top level:
 drivers/gpu/drm/radeon/radeon_ttm.c:817:5: warning: no previous prototype for 
‘radeon_ttm_init’ [-Wmissing-prototypes]
 817 | int radeon_ttm_init(struct radeon_device *rdev)
 | ^~~
 drivers/gpu/drm/radeon/radeon_ttm.c:878:6: warning: no previous prototype for 
‘radeon_ttm_fini’ [-Wmissing-prototypes]
 878 | void radeon_ttm_fini(struct radeon_device *rdev)
 | ^~~

Cc: Alex Deucher 
Cc: "Christian König" 
Cc: David Airlie 
Cc: Daniel Vetter 
Cc: Sumit Semwal 
Cc: amd-...@lists.freedesktop.org
Cc: dri-devel@lists.freedesktop.org
Cc: linux-me...@vger.kernel.org
Cc: linaro-mm-...@lists.linaro.org
Signed-off-by: Lee Jones 
---
 drivers/gpu/drm/radeon/radeon.h| 4 
 drivers/gpu/drm/radeon/radeon_object.c | 2 --
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/radeon/radeon.h b/drivers/gpu/drm/radeon/radeon.h
index 53d9898e9871e..a0c2497cd4cf4 100644
--- a/drivers/gpu/drm/radeon/radeon.h
+++ b/drivers/gpu/drm/radeon/radeon.h
@@ -451,6 +451,10 @@ struct radeon_surface_reg {
 /*
  * TTM.
  */
+
+int radeon_ttm_init(struct radeon_device *rdev);
+void radeon_ttm_fini(struct radeon_device *rdev);
+
 struct radeon_mman {
struct ttm_bo_devicebdev;
boolinitialized;
diff --git a/drivers/gpu/drm/radeon/radeon_object.c 
b/drivers/gpu/drm/radeon/radeon_object.c
index ab81e35cb0606..048d83d0ca996 100644
--- a/drivers/gpu/drm/radeon/radeon_object.c
+++ b/drivers/gpu/drm/radeon/radeon_object.c
@@ -41,8 +41,6 @@
 #include "radeon.h"
 #include "radeon_trace.h"
 
-int radeon_ttm_init(struct radeon_device *rdev);
-void radeon_ttm_fini(struct radeon_device *rdev);
 static void radeon_bo_clear_surface_reg(struct radeon_bo *bo);
 
 /*
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH 00/20] [Set 3] Rid W=1 warnings from GPU

2020-11-09 Thread Lee Jones
This set is part of a larger effort attempting to clean-up W=1
kernel builds, which are currently overwhelmingly riddled with
niggly little warnings.

This set takes the running (decreasing) total from 5000 before
[Set 1] down to 2300.

Lee Jones (20):
  drm/radeon/radeon_ttm: Place declaration of 'rdev' in same clause as
its use
  drm/radeon: Move radeon_ttm{init,fini} to shared location
  drm/radeon/radeon_fence: Demote some non-conformant kernel-doc headers
and fix another
  drm/radeon: Move 'radeon_add_legacy_encoder' prototype to shared
header
  drm/radeon: Move 'radeon_add_legacy_encoder's prototype to shared
location
  drm/radeon/radeon_connectors: Strip out set but unused variable 'ret'
  drm/radeon/radeon_display: Remove unused variable 'mod'
  drm/radeon/radeon_i2c: Remove pointless function header
  drm/radeon/radeon_irq_kms: Demote non-conformant kernel-doc fix
another
  drm/radeon/radeon_ring: Add missing function parameters 'rdev' and
'data'
  drm/radeon/r600: Strip out set but unused 'tmp' variables
  drm/radeon/radeon_cs: Fix a bunch of doc-rot issues
  drm/radeon/evergreen: Move 'rv770_set_clk_bypass_mode' prototype to
shared location
  drm/radeon: Move 'radeon_pm_acpi_event_handler' prototype into shared
header
  drm/radeon/r600d: Move 'rc600_*' prototypes into shared header
  drm/radeon/radeon_audio: Move 'dce3_2_*' prototypes to shared location
  drm/radeon/evergreend: Move 'evergreen_*' and 'sumo_*' prototypes out
to shared location
  drm/radeon/radeon_display: Fix function doc formatting and missing
param issues
  drm/radeon/r600: Fix a misnamed parameter description and a formatting
issue
  drm/radeon/cik: Fix a bunch of function parameter descriptions

 drivers/gpu/drm/radeon/cik.c   | 10 +++
 drivers/gpu/drm/radeon/evergreen.c |  1 -
 drivers/gpu/drm/radeon/ni.c| 16 --
 drivers/gpu/drm/radeon/r600.c  | 11 +++
 drivers/gpu/drm/radeon/r600d.h | 14 +
 drivers/gpu/drm/radeon/radeon.h| 34 ++
 drivers/gpu/drm/radeon/radeon_acpi.c   |  2 --
 drivers/gpu/drm/radeon/radeon_atombios.c   |  5 
 drivers/gpu/drm/radeon/radeon_audio.c  | 23 +--
 drivers/gpu/drm/radeon/radeon_audio.h  | 12 
 drivers/gpu/drm/radeon/radeon_combios.c|  5 
 drivers/gpu/drm/radeon/radeon_connectors.c |  4 +--
 drivers/gpu/drm/radeon/radeon_cs.c | 12 
 drivers/gpu/drm/radeon/radeon_display.c| 17 +--
 drivers/gpu/drm/radeon/radeon_encoders.c   |  3 --
 drivers/gpu/drm/radeon/radeon_fence.c  |  6 ++--
 drivers/gpu/drm/radeon/radeon_i2c.c|  4 ---
 drivers/gpu/drm/radeon/radeon_irq_kms.c|  6 ++--
 drivers/gpu/drm/radeon/radeon_object.c |  2 --
 drivers/gpu/drm/radeon/radeon_ring.c   |  3 ++
 drivers/gpu/drm/radeon/radeon_ttm.c|  8 ++---
 drivers/gpu/drm/radeon/si.c|  6 
 22 files changed, 96 insertions(+), 108 deletions(-)

Cc: Alex Deucher 
Cc: amd-...@lists.freedesktop.org
Cc: "Christian König" 
Cc: Daniel Vetter 
Cc: David Airlie 
Cc: dri-devel@lists.freedesktop.org
Cc: Jerome Glisse 
Cc: linaro-mm-...@lists.linaro.org
Cc: linux-me...@vger.kernel.org
Cc: report to 
Cc: Slava Grigorev 
Cc: Sumit Semwal 
-- 
2.25.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 210123] drm:drm_atomic_helper_wait_for_dependencies [drm_kms_helper]] - flip_done time out with vmwgfx

2020-11-09 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=210123

--- Comment #1 from Stefan Mayr (stefan+ker...@mayr-stefan.de) ---
#208373 seems simliar but for us it started with an older kernel version

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 17/19] drm/radeon/radeon_kms: Fix misnaming of 'radeon_info_ioctl's dev param

2020-11-09 Thread Lee Jones
On Mon, 09 Nov 2020, Sam Ravnborg wrote:

> On Mon, Nov 09, 2020 at 08:10:13PM +, Lee Jones wrote:
> > On Mon, 09 Nov 2020, Sam Ravnborg wrote:
> > 
> > > Hi Alex,
> > > On Mon, Nov 09, 2020 at 02:50:35PM -0500, Alex Deucher wrote:
> > > > On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
> > > > >
> > > > > Fixes the following W=1 kernel build warning(s):
> > > > >
> > > > >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Function parameter 
> > > > > or member 'dev' not described in 'radeon_info_ioctl'
> > > > >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Excess function 
> > > > > parameter 'rdev' description in 'radeon_info_ioctl'
> > > > >
> > > > > Cc: Alex Deucher 
> > > > > Cc: "Christian König" 
> > > > > Cc: David Airlie 
> > > > > Cc: Daniel Vetter 
> > > > > Cc: amd-...@lists.freedesktop.org
> > > > > Cc: dri-devel@lists.freedesktop.org
> > > > > Signed-off-by: Lee Jones 
> > > > > ---
> > > > >  drivers/gpu/drm/radeon/radeon_kms.c | 2 +-
> > > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > > >
> > > > > diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
> > > > > b/drivers/gpu/drm/radeon/radeon_kms.c
> > > > > index 0d8fbabffcead..21c206795c364 100644
> > > > > --- a/drivers/gpu/drm/radeon/radeon_kms.c
> > > > > +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> > > > > @@ -213,7 +213,7 @@ static void radeon_set_filp_rights(struct 
> > > > > drm_device *dev,
> > > > >  /**
> > > > >   * radeon_info_ioctl - answer a device specific request.
> > > > >   *
> > > > > - * @rdev: radeon device pointer
> > > > > + * @dev: radeon device pointer
> > > > 
> > > > This should be:
> > > > + * @dev: drm device pointer
> > > 
> > > good spot. I am continuing the work on radeon and will post a patchset
> > > that contains only radeon fixes with Lee's patches and a few more by me.
> > > I will fix the above.
> > 
> > What do you mean by "continuing on"?
> > 
> > How will you prevent your work from conflicting with my current effort?
> 
> Quoting from previous mail in this thread:
> 
>   "
>   > > How would you like me to move forward?
>   >
>   > Fix the thousand of warnings in other places :-)
>   > I will take a look at radeon and post a new series based on your work
>   > with all W=1 warnings fixed.
> 
>   I'll drop this patch and carry on ploughing through the rest of them.
> "
> 
> Here I promised you to fix all warnings in the radeon driver.
> And despite this being more work than anticipated a promise is a
> promise. So therefore I started working on this.
> 
> If you want to do the rest of the radeon driver you are welcome and I
> will gladly drop this again. Just let me know your preference.

That was the plan.  To continue on and solve as many warnings as I can
before I start bumping into more serious issues like the one mentioned
above.  If you'd like to solve the radeon_init() issue right away;
however, that would be super helpful.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 6/6] drm/bridge: cdns-mhdp8546: Fix the interrupt enable/disable

2020-11-09 Thread Nikhil Devshatwar
When removing the tidss driver, there is a warning reported by
kernel about an unhandled interrupt for mhdp driver.

[   43.238895] irq 31: nobody cared (try booting with the "irqpoll" option)
... [snipped backtrace]
[   43.330735] handlers:
[   43.333020] [<5367c4f9>] irq_default_primary_handler threaded 
[<7e02b601>]
cdns_mhdp_irq_handler [cdns_mhdp8546]
[   43.344607] Disabling IRQ #31

This happens because as part of cdns_mhdp_bridge_hpd_disable, driver tries
to disable the interrupts. While disabling the SW_EVENT interrupts,
it accidentally enables the MBOX interrupts, which are not handled by
the driver.

Fix this with a read-modify-write to update only required bits.
Do the same for enabling interrupts as well.

Signed-off-by: Nikhil Devshatwar 
---
 drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c | 7 +--
 1 file changed, 5 insertions(+), 2 deletions(-)

diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c 
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index 2cd809eed827..6beccd2a408e 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -2146,7 +2146,8 @@ static void cdns_mhdp_bridge_hpd_enable(struct drm_bridge 
*bridge)
 
/* Enable SW event interrupts */
if (mhdp->bridge_attached)
-   writel(~(u32)CDNS_APB_INT_MASK_SW_EVENT_INT,
+   writel(readl(mhdp->regs + CDNS_APB_INT_MASK) &
+  ~CDNS_APB_INT_MASK_SW_EVENT_INT,
   mhdp->regs + CDNS_APB_INT_MASK);
 }
 
@@ -2154,7 +2155,9 @@ static void cdns_mhdp_bridge_hpd_disable(struct 
drm_bridge *bridge)
 {
struct cdns_mhdp_device *mhdp = bridge_to_mhdp(bridge);
 
-   writel(CDNS_APB_INT_MASK_SW_EVENT_INT, mhdp->regs + CDNS_APB_INT_MASK);
+   writel(readl(mhdp->regs + CDNS_APB_INT_MASK) |
+  CDNS_APB_INT_MASK_SW_EVENT_INT,
+  mhdp->regs + CDNS_APB_INT_MASK);
 }
 
 static const struct drm_bridge_funcs cdns_mhdp_bridge_funcs = {
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 1/6] drm: bridge: Propagate the bus flags from bridge->timings

2020-11-09 Thread Nikhil Devshatwar
bus_flags can be specified by a bridge in the timings.
If the bridge provides it, Override the bus_flags when propagating
from next bridge.

Signed-off-by: Nikhil Devshatwar 
---
 drivers/gpu/drm/drm_bridge.c | 8 
 1 file changed, 8 insertions(+)

diff --git a/drivers/gpu/drm/drm_bridge.c b/drivers/gpu/drm/drm_bridge.c
index 64f0effb52ac..2bbd6ffe82ce 100644
--- a/drivers/gpu/drm/drm_bridge.c
+++ b/drivers/gpu/drm/drm_bridge.c
@@ -975,6 +975,14 @@ drm_atomic_bridge_propagate_bus_flags(struct drm_bridge 
*bridge,
 * duplicate the "dummy propagation" logic.
 */
bridge_state->input_bus_cfg.flags = output_flags;
+
+   /*
+* If the bus flags are provided in timing, use those even if the next
+* bridge specifies something
+*/
+   if (bridge->timings && bridge->timings->input_bus_flags)
+   bridge_state->input_bus_cfg.flags =
+   bridge->timings->input_bus_flags;
 }
 
 /**
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 5/6] drm/tidss: Move to newer connector model

2020-11-09 Thread Nikhil Devshatwar
To be able to support connector operations across multiple
bridges, it is recommended that the connector should be
created by the SoC driver instead of the bridges.

Modify the tidss modesetting initialization sequence to
create the connector and attach bridges with flag
DRM_BRIDGE_ATTACH_NO_CONNECTOR

Signed-off-by: Nikhil Devshatwar 
---
 drivers/gpu/drm/tidss/tidss_drv.h |  3 +++
 drivers/gpu/drm/tidss/tidss_kms.c | 19 ++-
 2 files changed, 21 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/tidss/tidss_drv.h 
b/drivers/gpu/drm/tidss/tidss_drv.h
index 7de4bba52e6f..cfbf85a4d92b 100644
--- a/drivers/gpu/drm/tidss/tidss_drv.h
+++ b/drivers/gpu/drm/tidss/tidss_drv.h
@@ -27,6 +27,9 @@ struct tidss_device {
unsigned int num_planes;
struct drm_plane *planes[TIDSS_MAX_PLANES];
 
+   unsigned int num_connectors;
+   struct drm_connector *connectors[TIDSS_MAX_PORTS];
+
spinlock_t wait_lock;   /* protects the irq masks */
dispc_irq_t irq_mask;   /* enabled irqs in addition to wait_list */
 };
diff --git a/drivers/gpu/drm/tidss/tidss_kms.c 
b/drivers/gpu/drm/tidss/tidss_kms.c
index 09485c7f0d6f..1f5ae153b114 100644
--- a/drivers/gpu/drm/tidss/tidss_kms.c
+++ b/drivers/gpu/drm/tidss/tidss_kms.c
@@ -7,6 +7,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -192,6 +193,7 @@ static int tidss_dispc_modeset_init(struct tidss_device 
*tidss)
for (i = 0; i < num_pipes; ++i) {
struct tidss_plane *tplane;
struct tidss_crtc *tcrtc;
+   struct drm_connector *connector;
struct drm_encoder *enc;
u32 hw_plane_id = feat->vid_order[tidss->num_planes];
int ret;
@@ -222,11 +224,26 @@ static int tidss_dispc_modeset_init(struct tidss_device 
*tidss)
return PTR_ERR(enc);
}
 
-   ret = drm_bridge_attach(enc, pipes[i].bridge, NULL, 0);
+   ret = drm_bridge_attach(enc, pipes[i].bridge, NULL,
+   DRM_BRIDGE_ATTACH_NO_CONNECTOR);
if (ret) {
dev_err(tidss->dev, "bridge attach failed: %d\n", ret);
return ret;
}
+
+   connector = drm_bridge_connector_init(>ddev, enc);
+   if (IS_ERR(connector)) {
+   dev_err(tidss->dev, "bridge_connector create failed\n");
+   return PTR_ERR(connector);
+   }
+
+   tidss->connectors[tidss->num_connectors++] = connector;
+
+   ret = drm_connector_attach_encoder(connector, enc);
+   if (ret) {
+   dev_err(tidss->dev, "attaching encoder to connector 
failed\n");
+   return ret;
+   }
}
 
/* create overlay planes of the leftover planes */
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 4/6] drm/tidss: Set bus_format correctly from bridge/connector

2020-11-09 Thread Nikhil Devshatwar
When there is a chain of bridges attached to the encoder,
the bus_format should be ideally set from the input format of the
first bridge in the chain.

Use the bridge state to get the negotiated bus_format.
If the bridge does not support format negotiation, error out
and fail.

Signed-off-by: Nikhil Devshatwar 
---
 drivers/gpu/drm/tidss/tidss_encoder.c | 22 ++
 1 file changed, 14 insertions(+), 8 deletions(-)

diff --git a/drivers/gpu/drm/tidss/tidss_encoder.c 
b/drivers/gpu/drm/tidss/tidss_encoder.c
index e278a9c89476..ba5b6fccabe7 100644
--- a/drivers/gpu/drm/tidss/tidss_encoder.c
+++ b/drivers/gpu/drm/tidss/tidss_encoder.c
@@ -22,6 +22,7 @@ static int tidss_encoder_atomic_check(struct drm_encoder 
*encoder,
struct drm_device *ddev = encoder->dev;
struct tidss_crtc_state *tcrtc_state = to_tidss_crtc_state(crtc_state);
struct drm_display_info *di = _state->connector->display_info;
+   struct drm_bridge_state *bstate;
struct drm_bridge *bridge;
bool bus_flags_set = false;
 
@@ -41,17 +42,22 @@ static int tidss_encoder_atomic_check(struct drm_encoder 
*encoder,
break;
}
 
-   if (!di->bus_formats || di->num_bus_formats == 0)  {
-   dev_err(ddev->dev, "%s: No bus_formats in connected display\n",
-   __func__);
-   return -EINVAL;
-   }
-
-   // XXX any cleaner way to set bus format and flags?
-   tcrtc_state->bus_format = di->bus_formats[0];
if (!bus_flags_set)
tcrtc_state->bus_flags = di->bus_flags;
 
+   /* Copy the bus_format from the input_bus_format of first bridge */
+   bridge = drm_bridge_chain_get_first_bridge(encoder);
+   bstate = drm_atomic_get_new_bridge_state(crtc_state->state, bridge);
+   if (bstate)
+   tcrtc_state->bus_format = bstate->input_bus_cfg.format;
+
+   if (tcrtc_state->bus_format == 0 ||
+   tcrtc_state->bus_format == MEDIA_BUS_FMT_FIXED) {
+
+   dev_err(ddev->dev, "Bridge connected to the encoder did not 
specify media bus format\n");
+   return -EINVAL;
+   }
+
return 0;
 }
 
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 2/6] drm/bridge: tfp410: Support format negotiation hooks

2020-11-09 Thread Nikhil Devshatwar
With new connector model, tfp410 will not create the connector and
SoC driver will rely on format negotiation to setup the encoder format.

Support format negotiations hooks in the drm_bridge_funcs.
Use helper functions for state management.

Output format is expected to be MEDIA_BUS_FMT_FIXED
Input format is the one selected by the bridge from DT properties.

Signed-off-by: Nikhil Devshatwar 
---
 drivers/gpu/drm/bridge/ti-tfp410.c | 33 ++
 1 file changed, 33 insertions(+)

diff --git a/drivers/gpu/drm/bridge/ti-tfp410.c 
b/drivers/gpu/drm/bridge/ti-tfp410.c
index ba3fa2a9b8a4..f56dbe246e57 100644
--- a/drivers/gpu/drm/bridge/ti-tfp410.c
+++ b/drivers/gpu/drm/bridge/ti-tfp410.c
@@ -204,12 +204,45 @@ static enum drm_mode_status tfp410_mode_valid(struct 
drm_bridge *bridge,
return MODE_OK;
 }
 
+static u32 *tfp410_get_input_bus_fmts(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state,
+ u32 output_fmt,
+ unsigned int *num_input_fmts)
+{
+   struct tfp410 *dvi = drm_bridge_to_tfp410(bridge);
+   u32 *input_fmts;
+
+   *num_input_fmts = 0;
+
+   /*
+* Output of tfp410 is DVI, which is TMDS.
+* There is no media format defined for this
+* Using MEDIA_BUS_FMT_FIXED for now
+*/
+   if (output_fmt != MEDIA_BUS_FMT_FIXED)
+   return NULL;
+
+   input_fmts = kzalloc(sizeof(*input_fmts), GFP_KERNEL);
+   if (!input_fmts)
+   return NULL;
+
+   *num_input_fmts = 1;
+   input_fmts[0] = dvi->bus_format;
+   return input_fmts;
+}
+
 static const struct drm_bridge_funcs tfp410_bridge_funcs = {
.attach = tfp410_attach,
.detach = tfp410_detach,
.enable = tfp410_enable,
.disable= tfp410_disable,
.mode_valid = tfp410_mode_valid,
+   .atomic_reset = drm_atomic_helper_bridge_reset,
+   .atomic_duplicate_state = drm_atomic_helper_bridge_duplicate_state,
+   .atomic_destroy_state = drm_atomic_helper_bridge_destroy_state,
+   .atomic_get_input_bus_fmts = tfp410_get_input_bus_fmts,
 };
 
 static const struct drm_bridge_timings tfp410_default_timings = {
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 3/6] drm/bridge: mhdp8546: Add minimal format negotiation

2020-11-09 Thread Nikhil Devshatwar
With new connector model, mhdp bridge will not create the connector and
SoC driver will rely on format negotiation to setup the encoder format.

Support minimal format negotiations hooks in the drm_bridge_funcs.
Complete format negotiation can be added based on EDID data.
This patch adds the minimal required support to avoid failure
after moving to new connector model.

Signed-off-by: Nikhil Devshatwar 
---
 .../drm/bridge/cadence/cdns-mhdp8546-core.c   | 25 +++
 1 file changed, 25 insertions(+)

diff --git a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c 
b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
index d0c65610ebb5..2cd809eed827 100644
--- a/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
+++ b/drivers/gpu/drm/bridge/cadence/cdns-mhdp8546-core.c
@@ -2078,6 +2078,30 @@ cdns_mhdp_bridge_atomic_reset(struct drm_bridge *bridge)
return _mhdp_state->base;
 }
 
+static u32 *cdns_mhdp_get_input_bus_fmts(struct drm_bridge *bridge,
+ struct drm_bridge_state *bridge_state,
+ struct drm_crtc_state *crtc_state,
+ struct drm_connector_state *conn_state,
+ u32 output_fmt,
+ unsigned int *num_input_fmts)
+{
+   u32 *input_fmts;
+   u32 default_bus_format = MEDIA_BUS_FMT_RGB121212_1X36;
+
+   *num_input_fmts = 0;
+
+   if (output_fmt != MEDIA_BUS_FMT_FIXED)
+   return NULL;
+
+   input_fmts = kzalloc(sizeof(*input_fmts), GFP_KERNEL);
+   if (!input_fmts)
+   return NULL;
+
+   *num_input_fmts = 1;
+   input_fmts[0] = default_bus_format;
+   return input_fmts;
+}
+
 static int cdns_mhdp_atomic_check(struct drm_bridge *bridge,
  struct drm_bridge_state *bridge_state,
  struct drm_crtc_state *crtc_state,
@@ -2142,6 +2166,7 @@ static const struct drm_bridge_funcs 
cdns_mhdp_bridge_funcs = {
.atomic_duplicate_state = cdns_mhdp_bridge_atomic_duplicate_state,
.atomic_destroy_state = cdns_mhdp_bridge_atomic_destroy_state,
.atomic_reset = cdns_mhdp_bridge_atomic_reset,
+   .atomic_get_input_bus_fmts = cdns_mhdp_get_input_bus_fmts,
.detect = cdns_mhdp_bridge_detect,
.get_edid = cdns_mhdp_bridge_get_edid,
.hpd_enable = cdns_mhdp_bridge_hpd_enable,
-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v2 0/6] drm/tidss: Use new connector model for tidss

2020-11-09 Thread Nikhil Devshatwar
This series moves the tidss to using new connectoe model, where the 
SoC driver (tidss) creates the connector and all the bridges are 
attached with the flag DRM_BRIDGE_ATTACH_NO_CONNECTOR

Since the bridges do not create the connector, the bus format and
bus_flag is set after the format negotiation.
Support format negotiations in the tfp410 and mhdp bridge drivers
as a first step before moving the connector model.

Nikhil Devshatwar (6):
  drm: bridge: Propagate the bus flags from bridge->timings
  drm/bridge: tfp410: Support format negotiation hooks
  drm/bridge: mhdp8546: Add minimal format negotiation
  drm/tidss: Set bus_format correctly from bridge/connector
  drm/tidss: Move to newer connector model
  drm/bridge: cdns-mhdp8546: Fix the interrupt enable/disable

 .../drm/bridge/cadence/cdns-mhdp8546-core.c   | 32 --
 drivers/gpu/drm/bridge/ti-tfp410.c| 33 +++
 drivers/gpu/drm/drm_bridge.c  |  8 +
 drivers/gpu/drm/tidss/tidss_drv.h |  3 ++
 drivers/gpu/drm/tidss/tidss_encoder.c | 22 -
 drivers/gpu/drm/tidss/tidss_kms.c | 19 ++-
 6 files changed, 106 insertions(+), 11 deletions(-)

-- 
2.17.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[Bug 210123] New: drm:drm_atomic_helper_wait_for_dependencies [drm_kms_helper]] - flip_done time out with vmwgfx

2020-11-09 Thread bugzilla-daemon
https://bugzilla.kernel.org/show_bug.cgi?id=210123

Bug ID: 210123
   Summary: drm:drm_atomic_helper_wait_for_dependencies
[drm_kms_helper]] - flip_done time out with vmwgfx
   Product: Drivers
   Version: 2.5
Kernel Version: 5.3.18-24.9.1
  Hardware: x86-64
OS: Linux
  Tree: Mainline
Status: NEW
  Severity: normal
  Priority: P1
 Component: Video(DRI - non Intel)
  Assignee: drivers_video-...@kernel-bugs.osdl.org
  Reporter: stefan+ker...@mayr-stefan.de
Regression: No

Since we upgraded SUSE Linux Enterprise Server 15 from kernel 4.12.14-197.45.1
(SLES15 SP1) to 5.3.18-24.9.1 (SLES15 SP2) or later we see the following error
messages on some virtual machines:

[102215.857602] [drm:drm_atomic_helper_wait_for_dependencies [drm_kms_helper]]
*ERROR* [CRTC:38:crtc-0] flip_done timed out
[102226.097847] [drm:drm_atomic_helper_wait_for_dependencies [drm_kms_helper]]
*ERROR* [PLANE:34:plane-0] flip_done timed out

We were also provided some more current kernels from SUSE support:
- 5.3.18 with updated modules 
- 5.8.15
- 5.9.1

The issue stays the same. All affected machines are running in runlevel 3. The
only graphical "thing" is the boot screen and when this error appears in the
logs this screen is sitting at an empty login prompt.
All virtual machines are running in a VMware environment on ESXi-Hosts with
versions between 6.0.x and 6.7.x. We could not track it down to specific ESXi
versions, load on the ESXi host or even the virtual machine. This happens on
different versions, loaded and also on idle hosts and virtual machines.

The issue goes away when we add vmwgfx to the grub module_blacklist.

I know our kernel versions are somehow SUSE specific. But what changed between
4.12 and 5.3 and later that may cause this message between drm and vmwgfx?

-- 
You are receiving this mail because:
You are watching the assignee of the bug.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


RE: [PATCH v9 4/5] RDMA/mlx5: Support dma-buf based userspace memory region

2020-11-09 Thread Xiong, Jianxin
> -Original Message-
> From: Jason Gunthorpe 
> Sent: Monday, November 09, 2020 12:53 PM
> To: Xiong, Jianxin 
> Cc: linux-r...@vger.kernel.org; dri-devel@lists.freedesktop.org; Doug Ledford 
> ; Leon Romanovsky
> ; Sumit Semwal ; Christian Koenig 
> ; Vetter, Daniel
> 
> Subject: Re: [PATCH v9 4/5] RDMA/mlx5: Support dma-buf based userspace memory 
> region
> 
> On Mon, Nov 09, 2020 at 11:23:00AM -0800, Jianxin Xiong wrote:
> > @@ -1291,8 +1303,11 @@ static struct mlx5_ib_mr *reg_create(struct ib_mr 
> > *ibmr, struct ib_pd *pd,
> > int err;
> > bool pg_cap = !!(MLX5_CAP_GEN(dev->mdev, pg));
> >
> > -   page_size =
> > -   mlx5_umem_find_best_pgsz(umem, mkc, log_page_size, 0, iova);
> > +   if (umem->is_dmabuf)
> > +   page_size = ib_umem_find_best_pgsz(umem, PAGE_SIZE, iova);
> > +   else
> > +   page_size = mlx5_umem_find_best_pgsz(umem, mkc, log_page_size,
> > +0, iova);
> 
> Any place touching the sgl has to also hold the resv lock, and sgl might be 
> NULL since an invalidation could come in at any time, eg before
> we get here.
> 
> You can avoid those problems by ingoring the SGL and hard wiring PAGE_SIZE 
> here
> 
> > +static int pagefault_dmabuf_mr(struct mlx5_ib_mr *mr, size_t bcnt,
> > +  u32 *bytes_mapped, u32 flags) {
> > +   struct ib_umem_dmabuf *umem_dmabuf = to_ib_umem_dmabuf(mr->umem);
> > +   u32 xlt_flags = 0;
> > +   int err;
> > +
> > +   if (flags & MLX5_PF_FLAGS_ENABLE)
> > +   xlt_flags |= MLX5_IB_UPD_XLT_ENABLE;
> > +
> > +   dma_resv_lock(umem_dmabuf->attach->dmabuf->resv, NULL);
> > +   err = ib_umem_dmabuf_map_pages(umem_dmabuf);
> > +   if (!err)
> > +   err = mlx5_ib_update_mr_pas(mr, xlt_flags);
> 
> This still has to call mlx5_umem_find_best_pgsz() each time the sgl changes 
> to ensure it is still Ok. Just checking that
> 
>   mlx5_umem_find_best_pgsz() > PAGE_SIZE
> 
> and then throwing away the value is OK

ib_umem_find_best_pgsz() is already called inside ib_umem_dmabuf_map_pages(). 
Do we
still need to call mlx5_umem_find_best_pgsz() here?

> 
> Jason
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/8] drm: Add dummy page per device or GEM object

2020-11-09 Thread Andrey Grodzovsky


On 6/22/20 1:50 PM, Daniel Vetter wrote:

On Mon, Jun 22, 2020 at 7:45 PM Christian König
 wrote:

Am 22.06.20 um 16:32 schrieb Andrey Grodzovsky:

On 6/22/20 9:18 AM, Christian König wrote:

Am 21.06.20 um 08:03 schrieb Andrey Grodzovsky:

Will be used to reroute CPU mapped BO's page faults once
device is removed.

Signed-off-by: Andrey Grodzovsky 
---
   drivers/gpu/drm/drm_file.c  |  8 
   drivers/gpu/drm/drm_prime.c | 10 ++
   include/drm/drm_file.h  |  2 ++
   include/drm/drm_gem.h   |  2 ++
   4 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index c4c704e..67c0770 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -188,6 +188,12 @@ struct drm_file *drm_file_alloc(struct
drm_minor *minor)
   goto out_prime_destroy;
   }
   +file->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+if (!file->dummy_page) {
+ret = -ENOMEM;
+goto out_prime_destroy;
+}
+
   return file;
 out_prime_destroy:
@@ -284,6 +290,8 @@ void drm_file_free(struct drm_file *file)
   if (dev->driver->postclose)
   dev->driver->postclose(dev, file);
   +__free_page(file->dummy_page);
+
   drm_prime_destroy_file_private(>prime);
 WARN_ON(!list_empty(>event_list));
diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 1de2cde..c482e9c 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -335,6 +335,13 @@ int drm_gem_prime_fd_to_handle(struct
drm_device *dev,
 ret = drm_prime_add_buf_handle(_priv->prime,
   dma_buf, *handle);
+
+if (!ret) {
+obj->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+if (!obj->dummy_page)
+ret = -ENOMEM;
+}
+

While the per file case still looks acceptable this is a clear NAK
since it will massively increase the memory needed for a prime
exported object.

I think that this is quite overkill in the first place and for the
hot unplug case we can just use the global dummy page as well.

Christian.


Global dummy page is good for read access, what do you do on write
access ? My first approach was indeed to map at first global dummy
page as read only and mark the vma->vm_flags as !VM_SHARED assuming
that this would trigger Copy On Write flow in core mm
(https://nam11.safelinks.protection.outlook.com/?url=https%3A%2F%2Felixir.bootlin.com%2Flinux%2Fv5.7-rc7%2Fsource%2Fmm%2Fmemory.c%23L3977data=02%7C01%7CAndrey.Grodzovsky%40amd.com%7C3753451d037544e7495408d816d4c4ee%7C3dd8961fe4884e608e11a82d994e183d%7C0%7C0%7C637284450384586120sdata=ZpRaQgqA5K4jRfidOiedey0AleeYQ97WNUkGA29ERA0%3Dreserved=0)
on the next page fault to same address triggered by a write access but
then i realized a new COW page will be allocated for each such mapping
and this is much more wasteful then having a dedicated page per GEM
object.

Yeah, but this is only for a very very small corner cases. What we need
to prevent is increasing the memory usage during normal operation to much.

Using memory during the unplug is completely unproblematic because we
just released quite a bunch of it by releasing all those system memory
buffers.

And I'm pretty sure that COWed pages are correctly accounted towards the
used memory of a process.

So I think if that approach works as intended and the COW pages are
released again on unmapping it would be the perfect solution to the problem.

Daniel what do you think?

If COW works, sure sounds reasonable. And if we can make sure we
managed to drop all the system allocations (otherwise suddenly 2x
memory usage, worst case). But I have no idea whether we can
retroshoehorn that into an established vma, you might have fun stuff
like a mkwrite handler there (which I thought is the COW handler
thing, but really no idea).



Can you clarify your concern here ? I see no DRM driver besides vmwgfx
who installs a handler for vm_operations_struct.page_mkwrite and in any
case, since I will be turning off VM_SHARED flag for the faulting vm_area_struct
making it a COW, page_mkwrite will not be called on any subsequent vm fault.

Andrey




If we need to massively change stuff then I think rw dummy page,
allocated on first fault after hotunplug (maybe just make it one per
object, that's simplest) seems like the much safer option. Much less
code that can go wrong.
-Daniel


Regards,
Christian.


We can indeed optimize by allocating this dummy page on the first page
fault after device disconnect instead on GEM object creation.

Andrey



mutex_unlock(_priv->prime.lock);
   if (ret)
   goto fail;
@@ -1006,6 +1013,9 @@ void drm_prime_gem_destroy(struct
drm_gem_object *obj, struct sg_table *sg)
   dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL);
   dma_buf = attach->dmabuf;
   dma_buf_detach(attach->dmabuf, attach);
+
+__free_page(obj->dummy_page);
+
   /* remove the reference */
   dma_buf_put(dma_buf);
   }

Re: [PATCH 17/19] drm/radeon/radeon_kms: Fix misnaming of 'radeon_info_ioctl's dev param

2020-11-09 Thread Sam Ravnborg
On Mon, Nov 09, 2020 at 08:10:13PM +, Lee Jones wrote:
> On Mon, 09 Nov 2020, Sam Ravnborg wrote:
> 
> > Hi Alex,
> > On Mon, Nov 09, 2020 at 02:50:35PM -0500, Alex Deucher wrote:
> > > On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
> > > >
> > > > Fixes the following W=1 kernel build warning(s):
> > > >
> > > >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Function parameter 
> > > > or member 'dev' not described in 'radeon_info_ioctl'
> > > >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Excess function 
> > > > parameter 'rdev' description in 'radeon_info_ioctl'
> > > >
> > > > Cc: Alex Deucher 
> > > > Cc: "Christian König" 
> > > > Cc: David Airlie 
> > > > Cc: Daniel Vetter 
> > > > Cc: amd-...@lists.freedesktop.org
> > > > Cc: dri-devel@lists.freedesktop.org
> > > > Signed-off-by: Lee Jones 
> > > > ---
> > > >  drivers/gpu/drm/radeon/radeon_kms.c | 2 +-
> > > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > > >
> > > > diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
> > > > b/drivers/gpu/drm/radeon/radeon_kms.c
> > > > index 0d8fbabffcead..21c206795c364 100644
> > > > --- a/drivers/gpu/drm/radeon/radeon_kms.c
> > > > +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> > > > @@ -213,7 +213,7 @@ static void radeon_set_filp_rights(struct 
> > > > drm_device *dev,
> > > >  /**
> > > >   * radeon_info_ioctl - answer a device specific request.
> > > >   *
> > > > - * @rdev: radeon device pointer
> > > > + * @dev: radeon device pointer
> > > 
> > > This should be:
> > > + * @dev: drm device pointer
> > 
> > good spot. I am continuing the work on radeon and will post a patchset
> > that contains only radeon fixes with Lee's patches and a few more by me.
> > I will fix the above.
> 
> What do you mean by "continuing on"?
> 
> How will you prevent your work from conflicting with my current effort?

Quoting from previous mail in this thread:

  "
  > > How would you like me to move forward?
  >
  > Fix the thousand of warnings in other places :-)
  > I will take a look at radeon and post a new series based on your work
  > with all W=1 warnings fixed.

  I'll drop this patch and carry on ploughing through the rest of them.
"

Here I promised you to fix all warnings in the radeon driver.
And despite this being more work than anticipated a promise is a
promise. So therefore I started working on this.

If you want to do the rest of the radeon driver you are welcome and I
will gladly drop this again. Just let me know your preference.

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 1/4] drm/ttm: add multihop infrastrucutre (v2)

2020-11-09 Thread Christian König

Am 09.11.20 um 17:43 schrieb Ville Syrjälä:

On Mon, Nov 09, 2020 at 05:20:17PM +0100, Christian König wrote:

Am 09.11.20 um 17:18 schrieb Ville Syrjälä:

On Mon, Nov 09, 2020 at 04:57:29PM +0100, Christian König wrote:

Am 09.11.20 um 16:16 schrieb Ville Syrjälä:

On Wed, Nov 11, 2020 at 06:13:02PM +0100, Christian König wrote:

Am 09.11.20 um 01:54 schrieb Dave Airlie:

@@ -1432,15 +1479,18 @@ int ttm_bo_swapout(struct ttm_operation_ctx *ctx)
if (bo->mem.mem_type != TTM_PL_SYSTEM) {
struct ttm_operation_ctx ctx = { false, false };
struct ttm_resource evict_mem;
+   struct ttm_place hop = {};

Please always use memset() if you want to zero initialize something in
the kernel, we had enough trouble with that.

What trouble is that? I've not heard of anything, and we use
={} quite extensively in drm land.

={} initializes only named fields, not padding.

Has that actually happened?

YES! Numerous times!

You wouldn't happen to have links/etc. to the discussion?
I'd like to check them out.


Uff, that was years ago. Just google for something like "mesa memset 
hash", there was recently (~ the last year) another discussion because 
somebody ran into exactly that problem once more.


Christian.
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH v2 1/8] drm: Add dummy page per device or GEM object

2020-11-09 Thread Andrey Grodzovsky


On 6/22/20 5:35 AM, Daniel Vetter wrote:

On Sun, Jun 21, 2020 at 02:03:01AM -0400, Andrey Grodzovsky wrote:

Will be used to reroute CPU mapped BO's page faults once
device is removed.

Signed-off-by: Andrey Grodzovsky 
---
  drivers/gpu/drm/drm_file.c  |  8 
  drivers/gpu/drm/drm_prime.c | 10 ++
  include/drm/drm_file.h  |  2 ++
  include/drm/drm_gem.h   |  2 ++
  4 files changed, 22 insertions(+)

diff --git a/drivers/gpu/drm/drm_file.c b/drivers/gpu/drm/drm_file.c
index c4c704e..67c0770 100644
--- a/drivers/gpu/drm/drm_file.c
+++ b/drivers/gpu/drm/drm_file.c
@@ -188,6 +188,12 @@ struct drm_file *drm_file_alloc(struct drm_minor *minor)
goto out_prime_destroy;
}
  
+	file->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO);

+   if (!file->dummy_page) {
+   ret = -ENOMEM;
+   goto out_prime_destroy;
+   }
+
return file;
  
  out_prime_destroy:

@@ -284,6 +290,8 @@ void drm_file_free(struct drm_file *file)
if (dev->driver->postclose)
dev->driver->postclose(dev, file);
  
+	__free_page(file->dummy_page);

+
drm_prime_destroy_file_private(>prime);
  
  	WARN_ON(!list_empty(>event_list));

diff --git a/drivers/gpu/drm/drm_prime.c b/drivers/gpu/drm/drm_prime.c
index 1de2cde..c482e9c 100644
--- a/drivers/gpu/drm/drm_prime.c
+++ b/drivers/gpu/drm/drm_prime.c
@@ -335,6 +335,13 @@ int drm_gem_prime_fd_to_handle(struct drm_device *dev,
  
  	ret = drm_prime_add_buf_handle(_priv->prime,

dma_buf, *handle);
+
+   if (!ret) {
+   obj->dummy_page = alloc_page(GFP_KERNEL | __GFP_ZERO);
+   if (!obj->dummy_page)
+   ret = -ENOMEM;
+   }
+
mutex_unlock(_priv->prime.lock);
if (ret)
goto fail;
@@ -1006,6 +1013,9 @@ void drm_prime_gem_destroy(struct drm_gem_object *obj, 
struct sg_table *sg)
dma_buf_unmap_attachment(attach, sg, DMA_BIDIRECTIONAL);
dma_buf = attach->dmabuf;
dma_buf_detach(attach->dmabuf, attach);
+
+   __free_page(obj->dummy_page);
+
/* remove the reference */
dma_buf_put(dma_buf);
  }
diff --git a/include/drm/drm_file.h b/include/drm/drm_file.h
index 19df802..349a658 100644
--- a/include/drm/drm_file.h
+++ b/include/drm/drm_file.h
@@ -335,6 +335,8 @@ struct drm_file {
 */
struct drm_prime_file_private prime;
  

Kerneldoc for these please, including why we need them and when. E.g. the
one in gem_bo should say it's only for exported buffers, so that we're not
colliding security spaces.


+   struct page *dummy_page;
+
/* private: */
  #if IS_ENABLED(CONFIG_DRM_LEGACY)
unsigned long lock_count; /* DRI1 legacy lock count */
diff --git a/include/drm/drm_gem.h b/include/drm/drm_gem.h
index 0b37506..47460d1 100644
--- a/include/drm/drm_gem.h
+++ b/include/drm/drm_gem.h
@@ -310,6 +310,8 @@ struct drm_gem_object {
 *
 */
const struct drm_gem_object_funcs *funcs;
+
+   struct page *dummy_page;
  };

I think amdgpu doesn't care, but everyone else still might care somewhat
about flink. That also shares buffers, so also needs to allocate the
per-bo dummy page.



Hi, back to this topic after a long context switch for internal project.

I don't see why for FLINK we can't use same dummy page from struct 
drm_gem_object - looking
at drm_gem_flink_ioctl I see that the underlying object we look up is still of 
type drm_gem_object.

Why we need per BO (TTM BO  I assume?) dummy page for this ?

Andrey




I also wonder whether we shouldn't have a helper to look up the dummy
page, just to encode in core code how it's supposedo to cascade.
-Daniel

  
  /**

--
2.7.4


___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 17/19] drm/radeon/radeon_kms: Fix misnaming of 'radeon_info_ioctl's dev param

2020-11-09 Thread Lee Jones
On Mon, 09 Nov 2020, Sam Ravnborg wrote:

> Hi Alex,
> On Mon, Nov 09, 2020 at 02:50:35PM -0500, Alex Deucher wrote:
> > On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
> > >
> > > Fixes the following W=1 kernel build warning(s):
> > >
> > >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Function parameter or 
> > > member 'dev' not described in 'radeon_info_ioctl'
> > >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Excess function 
> > > parameter 'rdev' description in 'radeon_info_ioctl'
> > >
> > > Cc: Alex Deucher 
> > > Cc: "Christian König" 
> > > Cc: David Airlie 
> > > Cc: Daniel Vetter 
> > > Cc: amd-...@lists.freedesktop.org
> > > Cc: dri-devel@lists.freedesktop.org
> > > Signed-off-by: Lee Jones 
> > > ---
> > >  drivers/gpu/drm/radeon/radeon_kms.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
> > > b/drivers/gpu/drm/radeon/radeon_kms.c
> > > index 0d8fbabffcead..21c206795c364 100644
> > > --- a/drivers/gpu/drm/radeon/radeon_kms.c
> > > +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> > > @@ -213,7 +213,7 @@ static void radeon_set_filp_rights(struct drm_device 
> > > *dev,
> > >  /**
> > >   * radeon_info_ioctl - answer a device specific request.
> > >   *
> > > - * @rdev: radeon device pointer
> > > + * @dev: radeon device pointer
> > 
> > This should be:
> > + * @dev: drm device pointer
> 
> good spot. I am continuing the work on radeon and will post a patchset
> that contains only radeon fixes with Lee's patches and a few more by me.
> I will fix the above.

What do you mean by "continuing on"?

How will you prevent your work from conflicting with my current effort?

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 17/19] drm/radeon/radeon_kms: Fix misnaming of 'radeon_info_ioctl's dev param

2020-11-09 Thread Alex Deucher
On Mon, Nov 9, 2020 at 2:56 PM Sam Ravnborg  wrote:
>
> Hi Alex,
> On Mon, Nov 09, 2020 at 02:50:35PM -0500, Alex Deucher wrote:
> > On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
> > >
> > > Fixes the following W=1 kernel build warning(s):
> > >
> > >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Function parameter or 
> > > member 'dev' not described in 'radeon_info_ioctl'
> > >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Excess function 
> > > parameter 'rdev' description in 'radeon_info_ioctl'
> > >
> > > Cc: Alex Deucher 
> > > Cc: "Christian König" 
> > > Cc: David Airlie 
> > > Cc: Daniel Vetter 
> > > Cc: amd-...@lists.freedesktop.org
> > > Cc: dri-devel@lists.freedesktop.org
> > > Signed-off-by: Lee Jones 
> > > ---
> > >  drivers/gpu/drm/radeon/radeon_kms.c | 2 +-
> > >  1 file changed, 1 insertion(+), 1 deletion(-)
> > >
> > > diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
> > > b/drivers/gpu/drm/radeon/radeon_kms.c
> > > index 0d8fbabffcead..21c206795c364 100644
> > > --- a/drivers/gpu/drm/radeon/radeon_kms.c
> > > +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> > > @@ -213,7 +213,7 @@ static void radeon_set_filp_rights(struct drm_device 
> > > *dev,
> > >  /**
> > >   * radeon_info_ioctl - answer a device specific request.
> > >   *
> > > - * @rdev: radeon device pointer
> > > + * @dev: radeon device pointer
> >
> > This should be:
> > + * @dev: drm device pointer
>
> good spot. I am continuing the work on radeon and will post a patchset
> that contains only radeon fixes with Lee's patches and a few more by me.
> I will fix the above.

Awesome.  Thanks!

Alex
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 16/19] drm/amd/amdgpu/amdgpu_kms: Remove 'struct drm_amdgpu_info_device dev_info' from the stack

2020-11-09 Thread Alex Deucher
On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
>
> Place it on the heap instead.
>
> Fixes the following W=1 kernel build warning(s):
>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c: In function ‘amdgpu_info_ioctl’:
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c:979:1: warning: the frame size of 
> 1128 bytes is larger than 1024 bytes [-Wframe-larger-than=]
>
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: amd-...@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Lee Jones 

Applied.  Thanks!

Alex


> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c | 104 +---
>  1 file changed, 55 insertions(+), 49 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> index 918d4e9c6461a..ef6fa5007d135 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_kms.c
> @@ -721,38 +721,42 @@ static int amdgpu_info_ioctl(struct drm_device *dev, 
> void *data, struct drm_file
> return n ? -EFAULT : 0;
> }
> case AMDGPU_INFO_DEV_INFO: {
> -   struct drm_amdgpu_info_device dev_info;
> +   struct drm_amdgpu_info_device *dev_info;
> uint64_t vm_size;
> +   int ret;
> +
> +   dev_info = kzalloc(sizeof(*dev_info), GFP_KERNEL);
> +   if (!dev_info)
> +   return -ENOMEM;
>
> -   memset(_info, 0, sizeof(dev_info));
> -   dev_info.device_id = dev->pdev->device;
> -   dev_info.chip_rev = adev->rev_id;
> -   dev_info.external_rev = adev->external_rev_id;
> -   dev_info.pci_rev = dev->pdev->revision;
> -   dev_info.family = adev->family;
> -   dev_info.num_shader_engines = 
> adev->gfx.config.max_shader_engines;
> -   dev_info.num_shader_arrays_per_engine = 
> adev->gfx.config.max_sh_per_se;
> +   dev_info->device_id = dev->pdev->device;
> +   dev_info->chip_rev = adev->rev_id;
> +   dev_info->external_rev = adev->external_rev_id;
> +   dev_info->pci_rev = dev->pdev->revision;
> +   dev_info->family = adev->family;
> +   dev_info->num_shader_engines = 
> adev->gfx.config.max_shader_engines;
> +   dev_info->num_shader_arrays_per_engine = 
> adev->gfx.config.max_sh_per_se;
> /* return all clocks in KHz */
> -   dev_info.gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
> +   dev_info->gpu_counter_freq = amdgpu_asic_get_xclk(adev) * 10;
> if (adev->pm.dpm_enabled) {
> -   dev_info.max_engine_clock = amdgpu_dpm_get_sclk(adev, 
> false) * 10;
> -   dev_info.max_memory_clock = amdgpu_dpm_get_mclk(adev, 
> false) * 10;
> +   dev_info->max_engine_clock = 
> amdgpu_dpm_get_sclk(adev, false) * 10;
> +   dev_info->max_memory_clock = 
> amdgpu_dpm_get_mclk(adev, false) * 10;
> } else {
> -   dev_info.max_engine_clock = adev->clock.default_sclk 
> * 10;
> -   dev_info.max_memory_clock = adev->clock.default_mclk 
> * 10;
> +   dev_info->max_engine_clock = adev->clock.default_sclk 
> * 10;
> +   dev_info->max_memory_clock = adev->clock.default_mclk 
> * 10;
> }
> -   dev_info.enabled_rb_pipes_mask = 
> adev->gfx.config.backend_enable_mask;
> -   dev_info.num_rb_pipes = adev->gfx.config.max_backends_per_se *
> +   dev_info->enabled_rb_pipes_mask = 
> adev->gfx.config.backend_enable_mask;
> +   dev_info->num_rb_pipes = adev->gfx.config.max_backends_per_se 
> *
> adev->gfx.config.max_shader_engines;
> -   dev_info.num_hw_gfx_contexts = 
> adev->gfx.config.max_hw_contexts;
> -   dev_info._pad = 0;
> -   dev_info.ids_flags = 0;
> +   dev_info->num_hw_gfx_contexts = 
> adev->gfx.config.max_hw_contexts;
> +   dev_info->_pad = 0;
> +   dev_info->ids_flags = 0;
> if (adev->flags & AMD_IS_APU)
> -   dev_info.ids_flags |= AMDGPU_IDS_FLAGS_FUSION;
> +   dev_info->ids_flags |= AMDGPU_IDS_FLAGS_FUSION;
> if (amdgpu_mcbp || amdgpu_sriov_vf(adev))
> -   dev_info.ids_flags |= AMDGPU_IDS_FLAGS_PREEMPTION;
> +   dev_info->ids_flags |= AMDGPU_IDS_FLAGS_PREEMPTION;
> if (amdgpu_is_tmz(adev))
> -   dev_info.ids_flags |= AMDGPU_IDS_FLAGS_TMZ;
> +   dev_info->ids_flags |= AMDGPU_IDS_FLAGS_TMZ;
>
> vm_size = adev->vm_manager.max_pfn * AMDGPU_GPU_PAGE_SIZE;
> vm_size -= AMDGPU_VA_RESERVED_SIZE;
> @@ -762,45 

Re: [PATCH 17/19] drm/radeon/radeon_kms: Fix misnaming of 'radeon_info_ioctl's dev param

2020-11-09 Thread Lee Jones
On Mon, 09 Nov 2020, Alex Deucher wrote:

> On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
> >
> > Fixes the following W=1 kernel build warning(s):
> >
> >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Function parameter or 
> > member 'dev' not described in 'radeon_info_ioctl'
> >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Excess function 
> > parameter 'rdev' description in 'radeon_info_ioctl'
> >
> > Cc: Alex Deucher 
> > Cc: "Christian König" 
> > Cc: David Airlie 
> > Cc: Daniel Vetter 
> > Cc: amd-...@lists.freedesktop.org
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Lee Jones 
> > ---
> >  drivers/gpu/drm/radeon/radeon_kms.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
> > b/drivers/gpu/drm/radeon/radeon_kms.c
> > index 0d8fbabffcead..21c206795c364 100644
> > --- a/drivers/gpu/drm/radeon/radeon_kms.c
> > +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> > @@ -213,7 +213,7 @@ static void radeon_set_filp_rights(struct drm_device 
> > *dev,
> >  /**
> >   * radeon_info_ioctl - answer a device specific request.
> >   *
> > - * @rdev: radeon device pointer
> > + * @dev: radeon device pointer
> 
> This should be:
> + * @dev: drm device pointer

Makes sense.  If you don't fancy fixing this up, I'll send out a
fix-up in a few days.

-- 
Lee Jones [李琼斯]
Senior Technical Lead - Developer Services
Linaro.org │ Open source software for Arm SoCs
Follow Linaro: Facebook | Twitter | Blog
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 12/19] drm/amd/display/dc/basics/fixpt31_32: Move variables to where they're used

2020-11-09 Thread Alex Deucher
On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
>
> Also rid some unused ones.
>
> This patch solves 2000 warnings!
>
> Fixes the following W=1 kernel build warning(s):
>
>  In file included from drivers/gpu/drm/amd/amdgpu/../display/dc/dc_types.h:33,
>  from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services_types.h:30,
>  from drivers/gpu/drm/amd/amdgpu/../display/dc/dm_services.h:35,
>  from drivers/gpu/drm/amd/amdgpu/../display/amdgpu_dm/amdgpu_dm_helpers.c:35:
>  At top level:
>  drivers/gpu/drm/amd/amdgpu/../display/include/fixed31_32.h:76:32: warning: 
> ‘dc_fixpt_ln2_div_2’ defined but not used [-Wunused-const-variable=]
>  76 | static const struct fixed31_32 dc_fixpt_ln2_div_2 = { 1488522236LL };
>  | ^~
>  drivers/gpu/drm/amd/amdgpu/../display/include/fixed31_32.h:75:32: warning: 
> ‘dc_fixpt_ln2’ defined but not used [-Wunused-const-variable=]
>  75 | static const struct fixed31_32 dc_fixpt_ln2 = { 2977044471LL };
>  | ^~~~
>  drivers/gpu/drm/amd/amdgpu/../display/include/fixed31_32.h:74:32: warning: 
> ‘dc_fixpt_e’ defined but not used [-Wunused-const-variable=]
>  74 | static const struct fixed31_32 dc_fixpt_e = { 11674931555LL };
>  | ^~
>  drivers/gpu/drm/amd/amdgpu/../display/include/fixed31_32.h:73:32: warning: 
> ‘dc_fixpt_two_pi’ defined but not used [-Wunused-const-variable=]
>  73 | static const struct fixed31_32 dc_fixpt_two_pi = { 26986075409LL };
>  | ^~~
>  drivers/gpu/drm/amd/amdgpu/../display/include/fixed31_32.h:72:32: warning: 
> ‘dc_fixpt_pi’ defined but not used [-Wunused-const-variable=]
>  72 | static const struct fixed31_32 dc_fixpt_pi = { 13493037705LL };
>  | ^~~
>
> Cc: Harry Wentland 
> Cc: Leo Li 
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: amd-...@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Lee Jones 

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c | 5 +
>  drivers/gpu/drm/amd/display/include/fixed31_32.h   | 6 --
>  2 files changed, 5 insertions(+), 6 deletions(-)
>
> diff --git a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c 
> b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c
> index 1e9a2d3520684..59f37563704ad 100644
> --- a/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c
> +++ b/drivers/gpu/drm/amd/display/dc/basics/fixpt31_32.c
> @@ -26,6 +26,11 @@
>  #include "dm_services.h"
>  #include "include/fixed31_32.h"
>
> +static const struct fixed31_32 dc_fixpt_pi = { 13493037705LL };
> +static const struct fixed31_32 dc_fixpt_two_pi = { 26986075409LL };
> +static const struct fixed31_32 dc_fixpt_ln2 = { 2977044471LL };
> +static const struct fixed31_32 dc_fixpt_ln2_div_2 = { 1488522236LL };
> +
>  static inline unsigned long long abs_i64(
> long long arg)
>  {
> diff --git a/drivers/gpu/drm/amd/display/include/fixed31_32.h 
> b/drivers/gpu/drm/amd/display/include/fixed31_32.h
> index 16df2a485dd0d..22053d7ea6ced 100644
> --- a/drivers/gpu/drm/amd/display/include/fixed31_32.h
> +++ b/drivers/gpu/drm/amd/display/include/fixed31_32.h
> @@ -69,12 +69,6 @@ static const struct fixed31_32 dc_fixpt_epsilon = { 1LL };
>  static const struct fixed31_32 dc_fixpt_half = { 0x8000LL };
>  static const struct fixed31_32 dc_fixpt_one = { 0x1LL };
>
> -static const struct fixed31_32 dc_fixpt_pi = { 13493037705LL };
> -static const struct fixed31_32 dc_fixpt_two_pi = { 26986075409LL };
> -static const struct fixed31_32 dc_fixpt_e = { 11674931555LL };
> -static const struct fixed31_32 dc_fixpt_ln2 = { 2977044471LL };
> -static const struct fixed31_32 dc_fixpt_ln2_div_2 = { 1488522236LL };
> -
>  /*
>   * @brief
>   * Initialization routines
> --
> 2.25.1
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 17/19] drm/radeon/radeon_kms: Fix misnaming of 'radeon_info_ioctl's dev param

2020-11-09 Thread Sam Ravnborg
Hi Alex,
On Mon, Nov 09, 2020 at 02:50:35PM -0500, Alex Deucher wrote:
> On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
> >
> > Fixes the following W=1 kernel build warning(s):
> >
> >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Function parameter or 
> > member 'dev' not described in 'radeon_info_ioctl'
> >  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Excess function 
> > parameter 'rdev' description in 'radeon_info_ioctl'
> >
> > Cc: Alex Deucher 
> > Cc: "Christian König" 
> > Cc: David Airlie 
> > Cc: Daniel Vetter 
> > Cc: amd-...@lists.freedesktop.org
> > Cc: dri-devel@lists.freedesktop.org
> > Signed-off-by: Lee Jones 
> > ---
> >  drivers/gpu/drm/radeon/radeon_kms.c | 2 +-
> >  1 file changed, 1 insertion(+), 1 deletion(-)
> >
> > diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
> > b/drivers/gpu/drm/radeon/radeon_kms.c
> > index 0d8fbabffcead..21c206795c364 100644
> > --- a/drivers/gpu/drm/radeon/radeon_kms.c
> > +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> > @@ -213,7 +213,7 @@ static void radeon_set_filp_rights(struct drm_device 
> > *dev,
> >  /**
> >   * radeon_info_ioctl - answer a device specific request.
> >   *
> > - * @rdev: radeon device pointer
> > + * @dev: radeon device pointer
> 
> This should be:
> + * @dev: drm device pointer

good spot. I am continuing the work on radeon and will post a patchset
that contains only radeon fixes with Lee's patches and a few more by me.
I will fix the above.

Sam
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 14/19] drm/amd/amdgpu/amdgpu_device: Provide documentation for 'reg_addr' params

2020-11-09 Thread Alex Deucher
On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
>
> Fixes the following W=1 kernel build warning(s):
>
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:594: warning: Function parameter 
> or member 'reg_addr' not described in 'amdgpu_device_indirect_rreg'
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c:624: warning: Function parameter 
> or member 'reg_addr' not described in 'amdgpu_device_indirect_rreg64'
>
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: Sumit Semwal 
> Cc: amd-...@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Cc: linux-me...@vger.kernel.org
> Cc: linaro-mm-...@lists.linaro.org
> Signed-off-by: Lee Jones 

Applied.  Thanks!

Alex

> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_device.c | 2 ++
>  1 file changed, 2 insertions(+)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> index 300fcade4a2b1..63374d12e00fe 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_device.c
> @@ -585,6 +585,7 @@ void amdgpu_mm_wdoorbell64(struct amdgpu_device *adev, 
> u32 index, u64 v)
>   * @adev: amdgpu_device pointer
>   * @pcie_index: mmio register offset
>   * @pcie_data: mmio register offset
> + * @reg_addr: indirect register address to read from
>   *
>   * Returns the value of indirect register @reg_addr
>   */
> @@ -615,6 +616,7 @@ u32 amdgpu_device_indirect_rreg(struct amdgpu_device 
> *adev,
>   * @adev: amdgpu_device pointer
>   * @pcie_index: mmio register offset
>   * @pcie_data: mmio register offset
> + * @reg_addr: indirect register address to read from
>   *
>   * Returns the value of indirect register @reg_addr
>   */
> --
> 2.25.1
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 17/19] drm/radeon/radeon_kms: Fix misnaming of 'radeon_info_ioctl's dev param

2020-11-09 Thread Alex Deucher
On Fri, Nov 6, 2020 at 4:50 PM Lee Jones  wrote:
>
> Fixes the following W=1 kernel build warning(s):
>
>  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Function parameter or 
> member 'dev' not described in 'radeon_info_ioctl'
>  drivers/gpu/drm/radeon/radeon_kms.c:226: warning: Excess function parameter 
> 'rdev' description in 'radeon_info_ioctl'
>
> Cc: Alex Deucher 
> Cc: "Christian König" 
> Cc: David Airlie 
> Cc: Daniel Vetter 
> Cc: amd-...@lists.freedesktop.org
> Cc: dri-devel@lists.freedesktop.org
> Signed-off-by: Lee Jones 
> ---
>  drivers/gpu/drm/radeon/radeon_kms.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/radeon/radeon_kms.c 
> b/drivers/gpu/drm/radeon/radeon_kms.c
> index 0d8fbabffcead..21c206795c364 100644
> --- a/drivers/gpu/drm/radeon/radeon_kms.c
> +++ b/drivers/gpu/drm/radeon/radeon_kms.c
> @@ -213,7 +213,7 @@ static void radeon_set_filp_rights(struct drm_device *dev,
>  /**
>   * radeon_info_ioctl - answer a device specific request.
>   *
> - * @rdev: radeon device pointer
> + * @dev: radeon device pointer

This should be:
+ * @dev: drm device pointer

Alex

>   * @data: request object
>   * @filp: drm filp
>   *
> --
> 2.25.1
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH] drivers: amdgpu: amdgpu_display.c: Fix a spelling doens\'t to doesn\'t

2020-11-09 Thread Alex Deucher
On Mon, Nov 9, 2020 at 3:52 AM Bhaskar Chowdhury  wrote:
>
> s/doens't/doesn't/p
>
> Signed-off-by: Bhaskar Chowdhury 
> ---
>  drivers/gpu/drm/amd/amdgpu/amdgpu_display.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c 
> b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> index 7cc7af2a6822..a92cb137293a 100644
> --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_display.c
> @@ -512,7 +512,7 @@ uint32_t amdgpu_display_supported_domains(struct 
> amdgpu_device *adev,
>  * to avoid hang caused by placement of scanout BO in GTT on certain
>  * APUs. So force the BO placement to VRAM in case this architecture
>  * will not allow USWC mappings.
> -* Also, don't allow GTT domain if the BO doens't have USWC falg set.
> +* Also, don't allow GTT domain if the BO doesn't have USWC falg set.

Applied. Care to send a patch to also fix the spelling of "flag"?

Thanks,

Alex


>  */
> if ((bo_flags & AMDGPU_GEM_CREATE_CPU_GTT_USWC) &&
> amdgpu_bo_support_uswc(bo_flags) &&
> --
> 2.26.2
>
> ___
> dri-devel mailing list
> dri-devel@lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/dri-devel
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [git pull] drm next pull for 5.10-rc1

2020-11-09 Thread Lyude Paul
whoops, you can ignore this actually - I got this mixed up with an Intel issue I
was looking at, this is actually a nouveau issue and you guys don't need to look
at this :)

Kirill-I'll get to this asap, but I've got some other stuff on my plate to go
through first. Could you open up a bug on gitlab in the mean time?

On Mon, 2020-11-09 at 21:08 +0200, Ville Syrjälä wrote:
> On Mon, Nov 09, 2020 at 12:50:48PM -0500, Lyude Paul wrote:
> > Looking at the patches you sent is on my TODO list for this week at least as
> > a
> > priority, although I really would have hoped that someone from Intel would
> > have looked by now since it's a regression on their end.
> 
> What regression are you talking about?
> 
> > 
> > Gentle ping to Vsyrjala and Imre
> > 
> > On Mon, 2020-11-09 at 14:52 +0300, Kirill A. Shutemov wrote:
> > > On Wed, Nov 04, 2020 at 04:58:14PM -0500, Lyude Paul wrote:
> > > > ACK, I will send out a patch for this asap
> > > 
> > > Any update. AFAICS, v5.10-rc3 is still buggy.
> > > 
> > 
> > -- 
> > Cheers,
> >  Lyude Paul (she/her)
> >  Software Engineer at Red Hat
> 

-- 
Sincerely,
   Lyude Paul (she/her)
   Software Engineer at Red Hat
   
Note: I deal with a lot of emails and have a lot of bugs on my plate. If you've
asked me a question, are waiting for a review/merge on a patch, etc. and I
haven't responded in a while, please feel free to send me another email to check
on my status. I don't bite!

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v9 4/5] RDMA/mlx5: Support dma-buf based userspace memory region

2020-11-09 Thread Jianxin Xiong
Implement the new driver method 'reg_user_mr_dmabuf'.  Utilize the core
functions to import dma-buf based memory region and update the mappings.

Add code to handle dma-buf related page fault.

Signed-off-by: Jianxin Xiong 
Reviewed-by: Sean Hefty 
Acked-by: Michael J. Ruhl 
Acked-by: Christian Koenig 
Acked-by: Daniel Vetter 
---
 drivers/infiniband/hw/mlx5/main.c|   2 +
 drivers/infiniband/hw/mlx5/mlx5_ib.h |  18 ++
 drivers/infiniband/hw/mlx5/mr.c  | 116 +--
 drivers/infiniband/hw/mlx5/odp.c |  76 +--
 4 files changed, 203 insertions(+), 9 deletions(-)

diff --git a/drivers/infiniband/hw/mlx5/main.c 
b/drivers/infiniband/hw/mlx5/main.c
index 36b15a0..e647ea4 100644
--- a/drivers/infiniband/hw/mlx5/main.c
+++ b/drivers/infiniband/hw/mlx5/main.c
@@ -1,6 +1,7 @@
 // SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB
 /*
  * Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved.
+ * Copyright (c) 2020, Intel Corporation. All rights reserved.
  */
 
 #include 
@@ -4055,6 +4056,7 @@ static int mlx5_ib_enable_driver(struct ib_device *dev)
.query_srq = mlx5_ib_query_srq,
.query_ucontext = mlx5_ib_query_ucontext,
.reg_user_mr = mlx5_ib_reg_user_mr,
+   .reg_user_mr_dmabuf = mlx5_ib_reg_user_mr_dmabuf,
.req_notify_cq = mlx5_ib_arm_cq,
.rereg_user_mr = mlx5_ib_rereg_user_mr,
.resize_cq = mlx5_ib_resize_cq,
diff --git a/drivers/infiniband/hw/mlx5/mlx5_ib.h 
b/drivers/infiniband/hw/mlx5/mlx5_ib.h
index bb44080..3ef6872 100644
--- a/drivers/infiniband/hw/mlx5/mlx5_ib.h
+++ b/drivers/infiniband/hw/mlx5/mlx5_ib.h
@@ -1,6 +1,7 @@
 /* SPDX-License-Identifier: GPL-2.0 OR Linux-OpenIB */
 /*
  * Copyright (c) 2013-2020, Mellanox Technologies inc. All rights reserved.
+ * Copyright (c) 2020, Intel Corporation. All rights reserved.
  */
 
 #ifndef MLX5_IB_H
@@ -665,6 +666,12 @@ static inline bool is_odp_mr(struct mlx5_ib_mr *mr)
   mr->umem->is_odp;
 }
 
+static inline bool is_dmabuf_mr(struct mlx5_ib_mr *mr)
+{
+   return IS_ENABLED(CONFIG_INFINIBAND_ON_DEMAND_PAGING) && mr->umem &&
+  mr->umem->is_dmabuf;
+}
+
 struct mlx5_ib_mw {
struct ib_mwibmw;
struct mlx5_core_mkey   mmkey;
@@ -1200,6 +1207,10 @@ int mlx5_ib_create_cq(struct ib_cq *ibcq, const struct 
ib_cq_init_attr *attr,
 struct ib_mr *mlx5_ib_reg_user_mr(struct ib_pd *pd, u64 start, u64 length,
  u64 virt_addr, int access_flags,
  struct ib_udata *udata);
+struct ib_mr *mlx5_ib_reg_user_mr_dmabuf(struct ib_pd *pd, u64 start,
+u64 length, u64 virt_addr,
+int fd, int access_flags,
+struct ib_udata *udata);
 int mlx5_ib_advise_mr(struct ib_pd *pd,
  enum ib_uverbs_advise_mr_advice advice,
  u32 flags,
@@ -1210,11 +1221,13 @@ int mlx5_ib_advise_mr(struct ib_pd *pd,
 int mlx5_ib_dealloc_mw(struct ib_mw *mw);
 int mlx5_ib_update_xlt(struct mlx5_ib_mr *mr, u64 idx, int npages,
   int page_shift, int flags);
+int mlx5_ib_update_mr_pas(struct mlx5_ib_mr *mr, unsigned int flags);
 struct mlx5_ib_mr *mlx5_ib_alloc_implicit_mr(struct mlx5_ib_pd *pd,
 struct ib_udata *udata,
 int access_flags);
 void mlx5_ib_free_implicit_mr(struct mlx5_ib_mr *mr);
 void mlx5_ib_fence_odp_mr(struct mlx5_ib_mr *mr);
+void mlx5_ib_fence_dmabuf_mr(struct mlx5_ib_mr *mr);
 int mlx5_ib_rereg_user_mr(struct ib_mr *ib_mr, int flags, u64 start,
  u64 length, u64 virt_addr, int access_flags,
  struct ib_pd *pd, struct ib_udata *udata);
@@ -1306,6 +1319,7 @@ int mlx5_ib_advise_mr_prefetch(struct ib_pd *pd,
   enum ib_uverbs_advise_mr_advice advice,
   u32 flags, struct ib_sge *sg_list, u32 num_sge);
 int mlx5_ib_init_odp_mr(struct mlx5_ib_mr *mr, bool enable);
+int mlx5_ib_init_dmabuf_mr(struct mlx5_ib_mr *mr);
 #else /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
 static inline void mlx5_ib_internal_fill_odp_caps(struct mlx5_ib_dev *dev)
 {
@@ -1331,6 +1345,10 @@ static inline int mlx5_ib_init_odp_mr(struct mlx5_ib_mr 
*mr, bool enable)
 {
return -EOPNOTSUPP;
 }
+static inline int mlx5_ib_init_dmabuf_mr(struct mlx5_ib_mr *mr)
+{
+   return -EOPNOTSUPP;
+}
 #endif /* CONFIG_INFINIBAND_ON_DEMAND_PAGING */
 
 extern const struct mmu_interval_notifier_ops mlx5_mn_ops;
diff --git a/drivers/infiniband/hw/mlx5/mr.c b/drivers/infiniband/hw/mlx5/mr.c
index 9f653b4..5487e6a 100644
--- a/drivers/infiniband/hw/mlx5/mr.c
+++ b/drivers/infiniband/hw/mlx5/mr.c
@@ -1,5 +1,6 @@
 /*
  * Copyright (c) 2013-2015, Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2020, Intel Corporation. 

[PATCH v9 5/5] dma-buf: Reject attach request from importers that use dma_virt_ops

2020-11-09 Thread Jianxin Xiong
dma_virt_ops is used by virtual devices that map pages / scatterlists to
virtual addresses for CPU access instead of performing DMA. This is not
the intended use of dma_buf_attach() and dma_buf_map_attachment(). CPU
access of dma-buf should use dma_buf_vmap() and related functions.

Signed-off-by: Jianxin Xiong 
---
 drivers/dma-buf/dma-buf.c | 5 +
 1 file changed, 5 insertions(+)

diff --git a/drivers/dma-buf/dma-buf.c b/drivers/dma-buf/dma-buf.c
index 9a054fb5..ba2b877 100644
--- a/drivers/dma-buf/dma-buf.c
+++ b/drivers/dma-buf/dma-buf.c
@@ -686,6 +686,11 @@ struct dma_buf_attachment *
if (WARN_ON(importer_ops && !importer_ops->move_notify))
return ERR_PTR(-EINVAL);
 
+#ifdef CONFIG_DMA_VIRT_OPS
+   if (dev->dma_ops == _virt_ops)
+   return ERR_PTR(-EINVAL);
+#endif
+
attach = kzalloc(sizeof(*attach), GFP_KERNEL);
if (!attach)
return ERR_PTR(-ENOMEM);
-- 
1.8.3.1

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH v9 1/5] RDMA/umem: Support importing dma-buf as user memory region

2020-11-09 Thread Jianxin Xiong
Dma-buf is a standard cross-driver buffer sharing mechanism that can be
used to support peer-to-peer access from RDMA devices.

Device memory exported via dma-buf is associated with a file descriptor.
This is passed to the user space as a property associated with the
buffer allocation. When the buffer is registered as a memory region,
the file descriptor is passed to the RDMA driver along with other
parameters.

Implement the common code for importing dma-buf object and mapping
dma-buf pages.

Signed-off-by: Jianxin Xiong 
Reviewed-by: Sean Hefty 
Acked-by: Michael J. Ruhl 
Acked-by: Christian Koenig 
Acked-by: Daniel Vetter 
---
 drivers/infiniband/core/Makefile  |   2 +-
 drivers/infiniband/core/umem.c|   4 +
 drivers/infiniband/core/umem_dmabuf.c | 201 ++
 drivers/infiniband/core/umem_dmabuf.h |  11 ++
 include/rdma/ib_umem.h|  39 ++-
 5 files changed, 255 insertions(+), 2 deletions(-)
 create mode 100644 drivers/infiniband/core/umem_dmabuf.c
 create mode 100644 drivers/infiniband/core/umem_dmabuf.h

diff --git a/drivers/infiniband/core/Makefile b/drivers/infiniband/core/Makefile
index ccf2670..8ab4eea 100644
--- a/drivers/infiniband/core/Makefile
+++ b/drivers/infiniband/core/Makefile
@@ -40,5 +40,5 @@ ib_uverbs-y :=uverbs_main.o 
uverbs_cmd.o uverbs_marshall.o \
uverbs_std_types_srq.o \
uverbs_std_types_wq.o \
uverbs_std_types_qp.o
-ib_uverbs-$(CONFIG_INFINIBAND_USER_MEM) += umem.o
+ib_uverbs-$(CONFIG_INFINIBAND_USER_MEM) += umem.o umem_dmabuf.o
 ib_uverbs-$(CONFIG_INFINIBAND_ON_DEMAND_PAGING) += umem_odp.o
diff --git a/drivers/infiniband/core/umem.c b/drivers/infiniband/core/umem.c
index f1fc7e3..4bc455f 100644
--- a/drivers/infiniband/core/umem.c
+++ b/drivers/infiniband/core/umem.c
@@ -2,6 +2,7 @@
  * Copyright (c) 2005 Topspin Communications.  All rights reserved.
  * Copyright (c) 2005 Cisco Systems.  All rights reserved.
  * Copyright (c) 2005 Mellanox Technologies. All rights reserved.
+ * Copyright (c) 2020 Intel Corporation. All rights reserved.
  *
  * This software is available to you under a choice of one of two
  * licenses.  You may choose to be licensed under the terms of the GNU
@@ -43,6 +44,7 @@
 #include 
 
 #include "uverbs.h"
+#include "umem_dmabuf.h"
 
 static void __ib_umem_release(struct ib_device *dev, struct ib_umem *umem, int 
dirty)
 {
@@ -278,6 +280,8 @@ void ib_umem_release(struct ib_umem *umem)
 {
if (!umem)
return;
+   if (umem->is_dmabuf)
+   return ib_umem_dmabuf_release(to_ib_umem_dmabuf(umem));
if (umem->is_odp)
return ib_umem_odp_release(to_ib_umem_odp(umem));
 
diff --git a/drivers/infiniband/core/umem_dmabuf.c 
b/drivers/infiniband/core/umem_dmabuf.c
new file mode 100644
index 000..3ef7c78
--- /dev/null
+++ b/drivers/infiniband/core/umem_dmabuf.c
@@ -0,0 +1,201 @@
+// SPDX-License-Identifier: (GPL-2.0 OR BSD-3-Clause)
+/*
+ * Copyright (c) 2020 Intel Corporation. All rights reserved.
+ */
+
+#include 
+#include 
+#include 
+
+#include "uverbs.h"
+#include "umem_dmabuf.h"
+
+int ib_umem_dmabuf_map_pages(struct ib_umem_dmabuf *umem_dmabuf)
+{
+   struct sg_table *sgt;
+   struct scatterlist *sg;
+   struct dma_fence *fence;
+   unsigned long start, end, cur;
+   unsigned int nmap;
+   unsigned int page_size;
+   int i;
+
+   dma_resv_assert_held(umem_dmabuf->attach->dmabuf->resv);
+
+   if (umem_dmabuf->sgt)
+   return 0;
+
+   sgt = dma_buf_map_attachment(umem_dmabuf->attach, DMA_BIDIRECTIONAL);
+   if (IS_ERR(sgt))
+   return PTR_ERR(sgt);
+
+   /* modify the sg list in-place to match umem address and length */
+
+   start = ALIGN_DOWN(umem_dmabuf->umem.address, PAGE_SIZE);
+   end = ALIGN(umem_dmabuf->umem.address + umem_dmabuf->umem.length,
+   PAGE_SIZE);
+   cur = 0;
+   nmap = 0;
+   for_each_sgtable_dma_sg(sgt, sg, i) {
+   if (start < cur + sg_dma_len(sg) && cur < end)
+   nmap++;
+   if (cur <= start && start < cur + sg_dma_len(sg)) {
+   unsigned long offset = start - cur;
+
+   umem_dmabuf->first_sg = sg;
+   umem_dmabuf->first_sg_offset = offset;
+   sg_dma_address(sg) += offset;
+   sg_dma_len(sg) -= offset;
+   cur += offset;
+   }
+   if (cur < end && end <= cur + sg_dma_len(sg)) {
+   unsigned long trim = cur + sg_dma_len(sg) - end;
+
+   umem_dmabuf->last_sg = sg;
+   umem_dmabuf->last_sg_trim = trim;
+   sg_dma_len(sg) -= trim;
+   cur += sg_dma_len(sg);
+   break;
+   }
+

  1   2   3   >