[PATCH v2 hmm 4/9] mm/hmm: remove HMM_FAULT_SNAPSHOT

2020-03-24 Thread Jason Gunthorpe
From: Jason Gunthorpe 

Now that flags are handled on a fine-grained per-page basis this global
flag is redundant and has a confusing overlap with the pfn_flags_mask and
default_flags.

Normalize the HMM_FAULT_SNAPSHOT behavior into one place. Callers needing
the SNAPSHOT behavior should set a pfn_flags_mask and default_flags that
always results in a cleared HMM_PFN_VALID. Then no pages will be faulted,
and HMM_FAULT_SNAPSHOT is not a special flow that overrides the masking
mechanism.

As this is the last flag, also remove the flags argument. If future flags
are needed they can be part of the struct hmm_range function arguments.

Signed-off-by: Jason Gunthorpe 
---
 Documentation/vm/hmm.rst| 12 +---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |  2 +-
 drivers/gpu/drm/nouveau/nouveau_svm.c   |  2 +-
 include/linux/hmm.h |  5 +
 mm/hmm.c| 22 ++
 5 files changed, 22 insertions(+), 21 deletions(-)

diff --git a/Documentation/vm/hmm.rst b/Documentation/vm/hmm.rst
index 95fec596836262..4e3e9362afeb10 100644
--- a/Documentation/vm/hmm.rst
+++ b/Documentation/vm/hmm.rst
@@ -161,13 +161,11 @@ device must complete the update before the driver 
callback returns.
 When the device driver wants to populate a range of virtual addresses, it can
 use::
 
-  long hmm_range_fault(struct hmm_range *range, unsigned int flags);
+  long hmm_range_fault(struct hmm_range *range);
 
-With the HMM_RANGE_SNAPSHOT flag, it will only fetch present CPU page table
-entries and will not trigger a page fault on missing or non-present entries.
-Without that flag, it does trigger a page fault on missing or read-only entries
-if write access is requested (see below). Page faults use the generic mm page
-fault code path just like a CPU page fault.
+It will trigger a page fault on missing or read-only entries if write access is
+requested (see below). Page faults use the generic mm page fault code path just
+like a CPU page fault.
 
 Both functions copy CPU page table entries into their pfns array argument. Each
 entry in that array corresponds to an address in the virtual range. HMM
@@ -197,7 +195,7 @@ The usage pattern is::
  again:
   range.notifier_seq = mmu_interval_read_begin(&interval_sub);
   down_read(&mm->mmap_sem);
-  ret = hmm_range_fault(&range, HMM_RANGE_SNAPSHOT);
+  ret = hmm_range_fault(&range);
   if (ret) {
   up_read(&mm->mmap_sem);
   if (ret == -EBUSY)
diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index 90821ce5e6cad0..c520290709371b 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -856,7 +856,7 @@ int amdgpu_ttm_tt_get_user_pages(struct amdgpu_bo *bo, 
struct page **pages)
range->notifier_seq = mmu_interval_read_begin(&bo->notifier);
 
down_read(&mm->mmap_sem);
-   r = hmm_range_fault(range, 0);
+   r = hmm_range_fault(range);
up_read(&mm->mmap_sem);
if (unlikely(r <= 0)) {
/*
diff --git a/drivers/gpu/drm/nouveau/nouveau_svm.c 
b/drivers/gpu/drm/nouveau/nouveau_svm.c
index 39c731a99937c6..e3797b2d4d1759 100644
--- a/drivers/gpu/drm/nouveau/nouveau_svm.c
+++ b/drivers/gpu/drm/nouveau/nouveau_svm.c
@@ -540,7 +540,7 @@ static int nouveau_range_fault(struct nouveau_svmm *svmm,
range.default_flags = 0;
range.pfn_flags_mask = -1UL;
down_read(&mm->mmap_sem);
-   ret = hmm_range_fault(&range, 0);
+   ret = hmm_range_fault(&range);
up_read(&mm->mmap_sem);
if (ret <= 0) {
if (ret == 0 || ret == -EBUSY)
diff --git a/include/linux/hmm.h b/include/linux/hmm.h
index daee6508a3f609..7475051100c782 100644
--- a/include/linux/hmm.h
+++ b/include/linux/hmm.h
@@ -117,13 +117,10 @@ static inline struct page *hmm_device_entry_to_page(const 
struct hmm_range *rang
return pfn_to_page(entry >> range->pfn_shift);
 }
 
-/* Don't fault in missing PTEs, just snapshot the current state. */
-#define HMM_FAULT_SNAPSHOT (1 << 1)
-
 /*
  * Please see Documentation/vm/hmm.rst for how to use the range API.
  */
-long hmm_range_fault(struct hmm_range *range, unsigned int flags);
+long hmm_range_fault(struct hmm_range *range);
 
 /*
  * HMM_RANGE_DEFAULT_TIMEOUT - default timeout (ms) when waiting for a range
diff --git a/mm/hmm.c b/mm/hmm.c
index c298c936469bbb..43d107a4d9dec6 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -29,7 +29,6 @@
 struct hmm_vma_walk {
struct hmm_range*range;
unsigned long   last;
-   unsigned intflags;
 };
 
 enum {
@@ -112,9 +111,6 @@ static unsigned int hmm_pte_need_fault(const struct 
hmm_vma_walk *hmm_vma_walk,
 {
struct hmm_range *range = hmm_vma_walk->range;
 
-   if (hmm_vma_walk->flags & HMM_FAULT_SNAPSHOT)
-   return 0;
-
 

[PATCH v2 hmm 3/9] mm/hmm: remove unused code and tidy comments

2020-03-24 Thread Jason Gunthorpe
From: Jason Gunthorpe 

Delete several functions that are never called, fix some desync between
comments and structure content, toss the now out of date top of file
header, and move one function only used by hmm.c into hmm.c

Signed-off-by: Jason Gunthorpe 
---
 include/linux/hmm.h | 104 +---
 mm/hmm.c|  24 +++---
 2 files changed, 19 insertions(+), 109 deletions(-)

diff --git a/include/linux/hmm.h b/include/linux/hmm.h
index bb6be4428633a8..daee6508a3f609 100644
--- a/include/linux/hmm.h
+++ b/include/linux/hmm.h
@@ -3,58 +3,8 @@
  * Copyright 2013 Red Hat Inc.
  *
  * Authors: Jérôme Glisse 
- */
-/*
- * Heterogeneous Memory Management (HMM)
- *
- * See Documentation/vm/hmm.rst for reasons and overview of what HMM is and it
- * is for. Here we focus on the HMM API description, with some explanation of
- * the underlying implementation.
- *
- * Short description: HMM provides a set of helpers to share a virtual address
- * space between CPU and a device, so that the device can access any valid
- * address of the process (while still obeying memory protection). HMM also
- * provides helpers to migrate process memory to device memory, and back. Each
- * set of functionality (address space mirroring, and migration to and from
- * device memory) can be used independently of the other.
- *
- *
- * HMM address space mirroring API:
- *
- * Use HMM address space mirroring if you want to mirror a range of the CPU
- * page tables of a process into a device page table. Here, "mirror" means 
"keep
- * synchronized". Prerequisites: the device must provide the ability to write-
- * protect its page tables (at PAGE_SIZE granularity), and must be able to
- * recover from the resulting potential page faults.
  *
- * HMM guarantees that at any point in time, a given virtual address points to
- * either the same memory in both CPU and device page tables (that is: CPU and
- * device page tables each point to the same pages), or that one page table 
(CPU
- * or device) points to no entry, while the other still points to the old page
- * for the address. The latter case happens when the CPU page table update
- * happens first, and then the update is mirrored over to the device page 
table.
- * This does not cause any issue, because the CPU page table cannot start
- * pointing to a new page until the device page table is invalidated.
- *
- * HMM uses mmu_notifiers to monitor the CPU page tables, and forwards any
- * updates to each device driver that has registered a mirror. It also provides
- * some API calls to help with taking a snapshot of the CPU page table, and to
- * synchronize with any updates that might happen concurrently.
- *
- *
- * HMM migration to and from device memory:
- *
- * HMM provides a set of helpers to hotplug device memory as ZONE_DEVICE, with
- * a new MEMORY_DEVICE_PRIVATE type. This provides a struct page for each page
- * of the device memory, and allows the device driver to manage its memory
- * using those struct pages. Having struct pages for device memory makes
- * migration easier. Because that memory is not addressable by the CPU it must
- * never be pinned to the device; in other words, any CPU page fault can always
- * cause the device memory to be migrated (copied/moved) back to regular 
memory.
- *
- * A new migrate helper (migrate_vma()) has been added (see mm/migrate.c) that
- * allows use of a device DMA engine to perform the copy operation between
- * regular system memory and device memory.
+ * See Documentation/vm/hmm.rst for reasons and overview of what HMM is.
  */
 #ifndef LINUX_HMM_H
 #define LINUX_HMM_H
@@ -120,9 +70,6 @@ enum hmm_pfn_value_e {
  *
  * @notifier: a mmu_interval_notifier that includes the start/end
  * @notifier_seq: result of mmu_interval_read_begin()
- * @hmm: the core HMM structure this range is active against
- * @vma: the vm area struct for the range
- * @list: all range lock are on a list
  * @start: range virtual start address (inclusive)
  * @end: range virtual end address (exclusive)
  * @pfns: array of pfns (big enough for the range)
@@ -130,8 +77,7 @@ enum hmm_pfn_value_e {
  * @values: pfn value for some special case (none, special, error, ...)
  * @default_flags: default flags for the range (write, read, ... see hmm doc)
  * @pfn_flags_mask: allows to mask pfn flags so that only default_flags matter
- * @pfn_shifts: pfn shift value (should be <= PAGE_SHIFT)
- * @valid: pfns array did not change since it has been fill by an HMM function
+ * @pfn_shift: pfn shift value (should be <= PAGE_SHIFT)
  * @dev_private_owner: owner of device private pages
  */
 struct hmm_range {
@@ -171,52 +117,6 @@ static inline struct page *hmm_device_entry_to_page(const 
struct hmm_range *rang
return pfn_to_page(entry >> range->pfn_shift);
 }
 
-/*
- * hmm_device_entry_to_pfn() - return pfn value store in a device entry
- * @range: range use to decode device entry value
- * @entry: device entry to extract pfn

[PATCH v2 hmm 8/9] mm/hmm: do not set pfns when returning an error code

2020-03-24 Thread Jason Gunthorpe
From: Jason Gunthorpe 

Most places that return an error code, like -EFAULT, do not set
HMM_PFN_ERROR, only two places do this.

Resolve this inconsistency by never setting the pfns on an error
exit. This doesn't seem like a worthwhile thing to do anyhow.

If for some reason it becomes important, it makes more sense to directly
return the address of the failing page rather than have the caller scan
for the HMM_PFN_ERROR.

No caller inspects the pnfs output array if hmm_range_fault() fails.

Signed-off-by: Jason Gunthorpe 
---
 mm/hmm.c | 18 +++---
 1 file changed, 3 insertions(+), 15 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index bf77b852f12d3a..14c33e1225866c 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -77,17 +77,14 @@ static int hmm_vma_fault(unsigned long addr, unsigned long 
end,
 unsigned int required_fault, struct mm_walk *walk)
 {
struct hmm_vma_walk *hmm_vma_walk = walk->private;
-   struct hmm_range *range = hmm_vma_walk->range;
struct vm_area_struct *vma = walk->vma;
-   uint64_t *pfns = range->pfns;
-   unsigned long i = (addr - range->start) >> PAGE_SHIFT;
unsigned int fault_flags = FAULT_FLAG_REMOTE;
 
WARN_ON_ONCE(!required_fault);
hmm_vma_walk->last = addr;
 
if (!vma)
-   goto out_error;
+   return -EFAULT;
 
if ((required_fault & HMM_NEED_WRITE_FAULT) == HMM_NEED_WRITE_FAULT) {
if (!(vma->vm_flags & VM_WRITE))
@@ -95,15 +92,10 @@ static int hmm_vma_fault(unsigned long addr, unsigned long 
end,
fault_flags |= FAULT_FLAG_WRITE;
}
 
-   for (; addr < end; addr += PAGE_SIZE, i++)
+   for (; addr < end; addr += PAGE_SIZE)
if (handle_mm_fault(vma, addr, fault_flags) & VM_FAULT_ERROR)
-   goto out_error;
-
+   return -EFAULT;
return -EBUSY;
-
-out_error:
-   pfns[i] = range->values[HMM_PFN_ERROR];
-   return -EFAULT;
 }
 
 static unsigned int hmm_pte_need_fault(const struct hmm_vma_walk *hmm_vma_walk,
@@ -291,7 +283,6 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, 
unsigned long addr,
 
/* Report error for everything else */
pte_unmap(ptep);
-   *pfn = range->values[HMM_PFN_ERROR];
return -EFAULT;
}
 
@@ -577,9 +568,6 @@ static const struct mm_walk_ops hmm_walk_ops = {
  *
  * This is similar to get_user_pages(), except that it can read the page tables
  * without mutating them (ie causing faults).
- *
- * On error, for one virtual address in the range, the function will mark the
- * corresponding HMM pfn entry with an error flag.
  */
 long hmm_range_fault(struct hmm_range *range)
 {
-- 
2.25.2

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


RE: [PATCH] drm/vkms: use bitfield op to get xrgb on compute crc

2020-03-24 Thread David Laight
From: Melissa Wen
> Sent: 21 March 2020 20:37
> The previous memset operation was not correctly setting zero on the
> alpha channel to compute the crc, and as a result, the
> pipe-A-cursor-alpha-transparent subtest of the IGT test kms_cursor_crc
> was crashing. To avoid errors of misinterpretation related to
> endianness, this solution uses a bitfield operation to extract the RGB
> values from each pixel and ignores the alpha channel as expected.
> 
> Signed-off-by: Melissa Wen 
> ---
>  drivers/gpu/drm/vkms/vkms_composer.c | 7 ++-
>  1 file changed, 6 insertions(+), 1 deletion(-)
> 
> diff --git a/drivers/gpu/drm/vkms/vkms_composer.c 
> b/drivers/gpu/drm/vkms/vkms_composer.c
> index 4af2f19480f4..8c1c005bb717 100644
> --- a/drivers/gpu/drm/vkms/vkms_composer.c
> +++ b/drivers/gpu/drm/vkms/vkms_composer.c
> @@ -1,6 +1,7 @@
>  // SPDX-License-Identifier: GPL-2.0+
> 
>  #include 
> +#include 
> 
>  #include 
>  #include 
> @@ -9,6 +10,8 @@
> 
>  #include "vkms_drv.h"
> 
> +#define XRGB_MSK GENMASK(23, 0)
> +
>  /**
>   * compute_crc - Compute CRC value on output frame
>   *
> @@ -26,6 +29,7 @@ static uint32_t compute_crc(void *vaddr_out, struct 
> vkms_composer *composer)
>   int h_src = drm_rect_height(&composer->src) >> 16;
>   int w_src = drm_rect_width(&composer->src) >> 16;
>   u32 crc = 0;
> + u32 *pixel;
> 
>   for (i = y_src; i < y_src + h_src; ++i) {
>   for (j = x_src; j < x_src + w_src; ++j) {
> @@ -33,7 +37,8 @@ static uint32_t compute_crc(void *vaddr_out, struct 
> vkms_composer *composer)
>+ (i * composer->pitch)
>+ (j * composer->cpp);
>   /* XRGB format ignores Alpha channel */
> - memset(vaddr_out + src_offset + 24, 0,  8);
> + pixel = vaddr_out + src_offset;
> + *pixel = FIELD_GET(XRGB_MSK, *(u32 *)pixel);
>   crc = crc32_le(crc, vaddr_out + src_offset,
>  sizeof(u32));

That looks horrid.
I suspect the simplest fix is to change the memset() offset/length
to bytes from bits.
Or (assuming the alpha channel is last) just:
*(u8 *)(vaddr_out + src_offset + 3) = 0;
I'm not sure of the options for the crc code, but if you are only
passing in 4 bytes there ought to be an option to pass in the value
itself (rather than the address).

Do you actually want to 'zap' the alpha channel data from the
output buffer? or just exclude it from the crc??

David

-
Registered Address Lakeside, Bramley Road, Mount Farm, Milton Keynes, MK1 1PT, 
UK
Registration No: 1397386 (Wales)

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


[PATCH V4 2/4] backlight: qcom-wled: Add callback functions

2020-03-24 Thread Kiran Gunda
Add wled_cabc_config, wled_sync_toggle, wled_ovp_fault_status
and wled_ovp_delay callback functions to prepare the driver for
adding WLED5 support.

wled_cabc_config() ===> Used to configure the cabc register.
 It is applicable for wled4 and wled5.

wled_sync_toggle() ===> used to toggle the Sync register bit for the
brightness update to take place.
It is applicable for WLED3, WLED4 and WLED5.

wled_ovp_fault_status() ===> Used to determine if the OVP fault is triggered.
 It is applicable for WLED4 and WLED5.

wled_ovp_delay() ===> Provides the time to wait before checking the OVP status
after wled module enable.
It is applicable for WLED4 and WLED5.

Signed-off-by: Kiran Gunda 
---
 drivers/video/backlight/qcom-wled.c | 188 ++--
 1 file changed, 118 insertions(+), 70 deletions(-)

diff --git a/drivers/video/backlight/qcom-wled.c 
b/drivers/video/backlight/qcom-wled.c
index 3d276b3..a3daf9e 100644
--- a/drivers/video/backlight/qcom-wled.c
+++ b/drivers/video/backlight/qcom-wled.c
@@ -147,6 +147,7 @@ struct wled {
u32 max_brightness;
u32 short_count;
u32 auto_detect_count;
+   u32 version;
bool disabled_by_short;
bool has_short_detect;
int short_irq;
@@ -155,6 +156,10 @@ struct wled {
struct wled_config cfg;
struct delayed_work ovp_work;
int (*wled_set_brightness)(struct wled *wled, u16 brightness);
+   int (*wled_cabc_config)(struct wled *wled, bool enable);
+   int (*wled_sync_toggle)(struct wled *wled);
+   int (*wled_ovp_fault_status)(struct wled *wled, bool *fault_set);
+   int (*wled_ovp_delay)(struct wled *wled);
 };
 
 static int wled3_set_brightness(struct wled *wled, u16 brightness)
@@ -237,7 +242,7 @@ static int wled_module_enable(struct wled *wled, int val)
return 0;
 }
 
-static int wled_sync_toggle(struct wled *wled)
+static int wled3_sync_toggle(struct wled *wled)
 {
int rc;
unsigned int mask = GENMASK(wled->max_string_count - 1, 0);
@@ -255,6 +260,46 @@ static int wled_sync_toggle(struct wled *wled)
return rc;
 }
 
+static int wled4_ovp_fault_status(struct wled *wled, bool *fault_set)
+{
+   int rc;
+   u32 int_rt_sts, fault_sts;
+
+   *fault_set = false;
+   rc = regmap_read(wled->regmap,
+   wled->ctrl_addr + WLED3_CTRL_REG_INT_RT_STS,
+   &int_rt_sts);
+   if (rc < 0) {
+   dev_err(wled->dev, "Failed to read INT_RT_STS rc=%d\n", rc);
+   return rc;
+   }
+
+   rc = regmap_read(wled->regmap,
+   wled->ctrl_addr + WLED3_CTRL_REG_FAULT_STATUS,
+   &fault_sts);
+   if (rc < 0) {
+   dev_err(wled->dev, "Failed to read FAULT_STATUS rc=%d\n", rc);
+   return rc;
+   }
+
+   if (int_rt_sts & WLED3_CTRL_REG_OVP_FAULT_STATUS)
+   *fault_set = true;
+
+   if (fault_sts & WLED3_CTRL_REG_OVP_FAULT_BIT)
+   *fault_set = true;
+
+   if (*fault_set)
+   dev_dbg(wled->dev, "WLED OVP fault detected, int_rt_sts=0x%x 
fault_sts=0x%x\n",
+   int_rt_sts, fault_sts);
+
+   return rc;
+}
+
+static int wled4_ovp_delay(struct wled *wled)
+{
+   return WLED_SOFT_START_DLY_US;
+}
+
 static int wled_update_status(struct backlight_device *bl)
 {
struct wled *wled = bl_get_data(bl);
@@ -275,7 +320,7 @@ static int wled_update_status(struct backlight_device *bl)
goto unlock_mutex;
}
 
-   rc = wled_sync_toggle(wled);
+   rc = wled->wled_sync_toggle(wled);
if (rc < 0) {
dev_err(wled->dev, "wled sync failed rc:%d\n", rc);
goto unlock_mutex;
@@ -298,6 +343,25 @@ static int wled_update_status(struct backlight_device *bl)
return rc;
 }
 
+static int wled4_cabc_config(struct wled *wled, bool enable)
+{
+   int i, j, rc;
+   u8 val;
+
+   for (i = 0; i < wled->cfg.num_strings; i++) {
+   j = wled->cfg.enabled_strings[i];
+
+   val = enable ? WLED4_SINK_REG_STR_CABC_MASK : 0;
+   rc = regmap_update_bits(wled->regmap, wled->sink_addr +
+   WLED4_SINK_REG_STR_CABC(j),
+   WLED4_SINK_REG_STR_CABC_MASK, val);
+   if (rc < 0)
+   return rc;
+   }
+
+   return 0;
+}
+
 #define WLED_SHORT_DLY_MS  20
 #define WLED_SHORT_CNT_MAX 5
 #define WLED_SHORT_RESET_CNT_DLY_USUSEC_PER_SEC
@@ -345,9 +409,10 @@ static irqreturn_t wled_short_irq_handler(int irq, void 
*_wled)
 
 static void wled_auto_string_detection(struct wled *wled)
 {
-   int rc = 0, i;
- 

Re: [PATCH 07/89] clk: bcm: rpi: Allow the driver to be probed by DT

2020-03-24 Thread Maxime Ripard
Hi Stefan,

On Sun, Mar 01, 2020 at 01:16:28PM +0100, Stefan Wahren wrote:
> Hi Maxime,
>
> Am 24.02.20 um 10:06 schrieb Maxime Ripard:
> > The current firmware clock driver for the RaspberryPi can only be probed by
> > manually registering an associated platform_device.
> >
> > While this works fine for cpufreq where the device gets attached a clkdev
> > lookup, it would be tedious to maintain a table of all the devices using
> > one of the clocks exposed by the firmware.
> >
> > Since the DT on the other hand is the perfect place to store those
> > associations, make the firmware clocks driver probe-able through the device
> > tree so that we can represent it as a node.
> >
> > Cc: Michael Turquette 
> > Cc: Stephen Boyd 
> > Cc: linux-...@vger.kernel.org
> > Signed-off-by: Maxime Ripard 
>
> FWIW i want to mention that starting with this commit, X doesn't start
> on my Raspberry Pi 3A (applied on top of linux-next using
> multi_v7_defconfig).

Was this the same issue you reported with the HSM clock rate, or truly
an issue with my series?

Maxime


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


Re: [PATCH hmm 6/6] mm/hmm: use device_private_entry_to_pfn()

2020-03-24 Thread Jason Gunthorpe
On Sat, Mar 21, 2020 at 09:43:47AM +0100, Christoph Hellwig wrote:
> On Fri, Mar 20, 2020 at 01:49:05PM -0300, Jason Gunthorpe wrote:
> > From: Jason Gunthorpe 
> > 
> > swp_offset() should not be called directly, the wrappers are supposed to
> > abstract away the encoding of the device_private specific information in
> > the swap entry.
> > 
> > Signed-off-by: Jason Gunthorpe 
> >  mm/hmm.c | 4 ++--
> >  1 file changed, 2 insertions(+), 2 deletions(-)
> > 
> > diff --git a/mm/hmm.c b/mm/hmm.c
> > index a09b4908e9c81a..fd9ee2b5fd9989 100644
> > +++ b/mm/hmm.c
> > @@ -259,8 +259,8 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, 
> > unsigned long addr,
> >  * the PFN even if not present.
> >  */
> > if (hmm_is_device_private_entry(range, entry)) {
> > -   *pfn = hmm_device_entry_from_pfn(range,
> > -   swp_offset(entry));
> > +   *pfn = hmm_device_entry_from_pfn(
> > +   range, device_private_entry_to_pfn(entry));
> 
> The range parameter can stay on the first line..

Done. Makes the diff smaller.

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


[PATCH V4 4/4] backlight: qcom-wled: Add support for WLED5 peripheral in PM8150L

2020-03-24 Thread Kiran Gunda
From: Subbaraman Narayanamurthy 

Add support for WLED5 peripheral that is present on PM8150L PMICs.

PM8150L WLED supports the following:
- Two modulators and each sink can use any of the modulator
- Multiple CABC selection options from which one can be selected/enabled
- Multiple brightness width selection (12 bits to 15 bits)

Signed-off-by: Subbaraman Narayanamurthy 
Signed-off-by: Kiran Gunda 
---
 drivers/video/backlight/qcom-wled.c | 427 +++-
 1 file changed, 424 insertions(+), 3 deletions(-)

diff --git a/drivers/video/backlight/qcom-wled.c 
b/drivers/video/backlight/qcom-wled.c
index a3daf9e..5a347ef 100644
--- a/drivers/video/backlight/qcom-wled.c
+++ b/drivers/video/backlight/qcom-wled.c
@@ -19,12 +19,15 @@
 #define WLED_DEFAULT_BRIGHTNESS2048
 #define WLED_SOFT_START_DLY_US 1
 #define WLED3_SINK_REG_BRIGHT_MAX  0xFFF
+#define WLED5_SINK_REG_BRIGHT_MAX_12B  0xFFF
+#define WLED5_SINK_REG_BRIGHT_MAX_15B  0x7FFF
 
 /* WLED3/WLED4 control registers */
 #define WLED3_CTRL_REG_FAULT_STATUS0x08
 #define  WLED3_CTRL_REG_ILIM_FAULT_BIT BIT(0)
 #define  WLED3_CTRL_REG_OVP_FAULT_BIT  BIT(1)
 #define  WLED4_CTRL_REG_SC_FAULT_BIT   BIT(2)
+#define  WLED5_CTRL_REG_OVP_PRE_ALARM_BIT  BIT(4)
 
 #define WLED3_CTRL_REG_INT_RT_STS  0x10
 #define  WLED3_CTRL_REG_OVP_FAULT_STATUS   BIT(1)
@@ -40,6 +43,7 @@
 
 #define WLED3_CTRL_REG_OVP 0x4d
 #define  WLED3_CTRL_REG_OVP_MASK   GENMASK(1, 0)
+#define  WLED5_CTRL_REG_OVP_MASK   GENMASK(3, 0)
 
 #define WLED3_CTRL_REG_ILIMIT  0x4e
 #define  WLED3_CTRL_REG_ILIMIT_MASKGENMASK(2, 0)
@@ -101,6 +105,44 @@
 
 #define WLED4_SINK_REG_BRIGHT(n)   (0x57 + (n * 0x10))
 
+/* WLED5 specific control registers */
+#define WLED5_CTRL_REG_OVP_INT_CTL 0x5f
+#define  WLED5_CTRL_REG_OVP_INT_TIMER_MASK GENMASK(2, 0)
+
+/* WLED5 specific sink registers */
+#define WLED5_SINK_REG_MOD_A_EN0x50
+#define WLED5_SINK_REG_MOD_B_EN0x60
+#define  WLED5_SINK_REG_MOD_EN_MASKBIT(7)
+
+#define WLED5_SINK_REG_MOD_A_SRC_SEL   0x51
+#define WLED5_SINK_REG_MOD_B_SRC_SEL   0x61
+#define  WLED5_SINK_REG_MOD_SRC_SEL_HIGH   0
+#define  WLED5_SINK_REG_MOD_SRC_SEL_EXT0x03
+#define  WLED5_SINK_REG_MOD_SRC_SEL_MASK   GENMASK(1, 0)
+
+#define WLED5_SINK_REG_MOD_A_BRIGHTNESS_WIDTH_SEL  0x52
+#define WLED5_SINK_REG_MOD_B_BRIGHTNESS_WIDTH_SEL  0x62
+#define  WLED5_SINK_REG_BRIGHTNESS_WIDTH_12B   0
+#define  WLED5_SINK_REG_BRIGHTNESS_WIDTH_15B   1
+
+#define WLED5_SINK_REG_MOD_A_BRIGHTNESS_LSB0x53
+#define WLED5_SINK_REG_MOD_A_BRIGHTNESS_MSB0x54
+#define WLED5_SINK_REG_MOD_B_BRIGHTNESS_LSB0x63
+#define WLED5_SINK_REG_MOD_B_BRIGHTNESS_MSB0x64
+
+#define WLED5_SINK_REG_MOD_SYNC_BIT0x65
+#define  WLED5_SINK_REG_SYNC_MOD_A_BIT BIT(0)
+#define  WLED5_SINK_REG_SYNC_MOD_B_BIT BIT(1)
+#define  WLED5_SINK_REG_SYNC_MASK  GENMASK(1, 0)
+
+/* WLED5 specific per-'string' registers below */
+#define WLED5_SINK_REG_STR_FULL_SCALE_CURR(n)  (0x72 + (n * 0x10))
+
+#define WLED5_SINK_REG_STR_SRC_SEL(n)  (0x73 + (n * 0x10))
+#define  WLED5_SINK_REG_SRC_SEL_MOD_A  0
+#define  WLED5_SINK_REG_SRC_SEL_MOD_B  1
+#define  WLED5_SINK_REG_SRC_SEL_MASK   GENMASK(1, 0)
+
 struct wled_var_cfg {
const u32 *values;
u32 (*fn)(u32);
@@ -125,6 +167,8 @@ struct wled_config {
u32 num_strings;
u32 string_i_limit;
u32 enabled_strings[WLED_MAX_STRINGS];
+   u32 mod_sel;
+   u32 cabc_sel;
bool cs_out_en;
bool ext_gen;
bool cabc;
@@ -150,6 +194,7 @@ struct wled {
u32 version;
bool disabled_by_short;
bool has_short_detect;
+   bool cabc_disabled;
int short_irq;
int ovp_irq;
 
@@ -162,6 +207,27 @@ struct wled {
int (*wled_ovp_delay)(struct wled *wled);
 };
 
+enum wled5_mod_sel {
+   MOD_A,
+   MOD_B,
+   MOD_MAX,
+};
+
+static const u8 wled5_brightness_reg[MOD_MAX] = {
+   [MOD_A] = WLED5_SINK_REG_MOD_A_BRIGHTNESS_LSB,
+   [MOD_B] = WLED5_SINK_REG_MOD_B_BRIGHTNESS_LSB,
+};
+
+static const u8 wled5_src_sel_reg[MOD_MAX] = {
+   [MOD_A] = WLED5_SINK_REG_MOD_A_SRC_SEL,
+   [MOD_B] = WLED5_SINK_REG_MOD_B_SRC_SEL,
+};
+
+static const u8 wled5_brt_wid_sel_reg[MOD_MAX] = {
+   [MOD_A] = WLED5_SINK_REG_MOD_A_BRIGHTNESS_WIDT

[PATCH V4 1/4] backlight: qcom-wled: convert the wled bindings to .yaml format

2020-03-24 Thread Kiran Gunda
Convert the qcom-wled bindings from .txt to .yaml format.

Signed-off-by: Kiran Gunda 
Signed-off-by: Subbaraman Narayanamurthy 
Acked-by: Daniel Thompson 
---
 .../bindings/leds/backlight/qcom-wled.txt  | 154 -
 .../bindings/leds/backlight/qcom-wled.yaml | 184 +
 2 files changed, 184 insertions(+), 154 deletions(-)
 delete mode 100644 
Documentation/devicetree/bindings/leds/backlight/qcom-wled.txt
 create mode 100644 
Documentation/devicetree/bindings/leds/backlight/qcom-wled.yaml

diff --git a/Documentation/devicetree/bindings/leds/backlight/qcom-wled.txt 
b/Documentation/devicetree/bindings/leds/backlight/qcom-wled.txt
deleted file mode 100644
index c06863b..000
--- a/Documentation/devicetree/bindings/leds/backlight/qcom-wled.txt
+++ /dev/null
@@ -1,154 +0,0 @@
-Binding for Qualcomm Technologies, Inc. WLED driver
-
-WLED (White Light Emitting Diode) driver is used for controlling display
-backlight that is part of PMIC on Qualcomm Technologies, Inc. reference
-platforms. The PMIC is connected to the host processor via SPMI bus.
-
-- compatible
-   Usage:required
-   Value type:   
-   Definition:   should be one of:
-   "qcom,pm8941-wled"
-   "qcom,pmi8998-wled"
-   "qcom,pm660l-wled"
-
-- reg
-   Usage:required
-   Value type:   
-   Definition:   Base address of the WLED modules.
-
-- default-brightness
-   Usage:optional
-   Value type:   
-   Definition:   brightness value on boot, value from: 0-4095.
- Default: 2048
-
-- label
-   Usage:required
-   Value type:   
-   Definition:   The name of the backlight device
-
-- qcom,cs-out
-   Usage:optional
-   Value type:   
-   Definition:   enable current sink output.
- This property is supported only for PM8941.
-
-- qcom,cabc
-   Usage:optional
-   Value type:   
-   Definition:   enable content adaptive backlight control.
-
-- qcom,ext-gen
-   Usage:optional
-   Value type:   
-   Definition:   use externally generated modulator signal to dim.
- This property is supported only for PM8941.
-
-- qcom,current-limit
-   Usage:optional
-   Value type:   
-   Definition:   mA; per-string current limit; value from 0 to 25 with
- 1 mA step. Default 20 mA.
- This property is supported only for pm8941.
-
-- qcom,current-limit-microamp
-   Usage:optional
-   Value type:   
-   Definition:   uA; per-string current limit; value from 0 to 3 with
- 2500 uA step. Default 25 mA.
-
-- qcom,current-boost-limit
-   Usage:optional
-   Value type:   
-   Definition:   mA; boost current limit.
- For pm8941: one of: 105, 385, 525, 805, 980, 1260, 1400,
- 1680. Default: 805 mA.
- For pmi8998: one of: 105, 280, 450, 620, 970, 1150, 1300,
- 1500. Default: 970 mA.
-
-- qcom,switching-freq
-   Usage:optional
-   Value type:   
-Definition:   kHz; switching frequency; one of: 600, 640, 685, 738,
-  800, 872, 960, 1066, 1200, 1371, 1600, 1920, 2400, 3200,
-  4800, 9600.
-  Default: for pm8941: 1600 kHz
-   for pmi8998: 800 kHz
-
-- qcom,ovp
-   Usage:optional
-   Value type:   
-   Definition:   V; Over-voltage protection limit; one of:
- 27, 29, 32, 35. Default: 29V
- This property is supported only for PM8941.
-
-- qcom,ovp-millivolt
-   Usage:optional
-   Value type:   
-   Definition:   mV; Over-voltage protection limit;
- For pmi8998: one of 18100, 19600, 29600, 31100.
- Default 29600 mV.
- If this property is not specified for PM8941, it
- falls back to "qcom,ovp" property.
-
-- qcom,num-strings
-   Usage:optional
-   Value type:   
-   Definition:   #; number of led strings attached;
- value: For PM8941 from 1 to 3. Default: 2
-For PMI8998 from 1 to 4.
-
-- interrupts
-   Usage:optional
-   Value type:   
-   Definition:   Interrupts associated with WLED. This should be
- "short" and "ovp" interrupts. Interrupts can be
- specified as per the encoding listed under
- Documentation/devicetree/bindings/spmi/
- qcom,spmi-pmic-arb.txt.
-
-- interrupt-names
-   Usage:optional
-   Value type:   
-   Definition:   Interrupt names associated with the interrupts.
- Must be "short" and "ovp". The short ci

Re: [PATCH hmm 3/6] mm/hmm: remove unused code and tidy comments

2020-03-24 Thread Jason Gunthorpe
On Fri, Mar 20, 2020 at 02:46:09PM -0700, Ralph Campbell wrote:
> 
> On 3/20/20 9:49 AM, Jason Gunthorpe wrote:
> > From: Jason Gunthorpe 
> > 
> > Delete several functions that are never called, fix some desync between
> > comments and structure content, remove an unused ret, and move one
> > function only used by hmm.c into hmm.c
> > 
> > Signed-off-by: Jason Gunthorpe 
> 
> Reviewed-by: Ralph Campbell 
> 
> >   include/linux/hmm.h | 50 -
> >   mm/hmm.c| 12 +++
> >   2 files changed, 12 insertions(+), 50 deletions(-)
> > 
> > diff --git a/include/linux/hmm.h b/include/linux/hmm.h
> > index bb6be4428633a8..184a8633260f9d 100644
> > +++ b/include/linux/hmm.h
> > @@ -120,9 +120,6 @@ enum hmm_pfn_value_e {
> >*
> >* @notifier: a mmu_interval_notifier that includes the start/end
> >* @notifier_seq: result of mmu_interval_read_begin()
> > - * @hmm: the core HMM structure this range is active against
> > - * @vma: the vm area struct for the range
> > - * @list: all range lock are on a list
> >* @start: range virtual start address (inclusive)
> >* @end: range virtual end address (exclusive)
> >* @pfns: array of pfns (big enough for the range)
> > @@ -131,7 +128,6 @@ enum hmm_pfn_value_e {
> >* @default_flags: default flags for the range (write, read, ... see hmm 
> > doc)
> >* @pfn_flags_mask: allows to mask pfn flags so that only default_flags 
> > matter
> >* @pfn_shifts: pfn shift value (should be <= PAGE_SHIFT)
> 
> s/pfn_shifts/pfn_shift

Got it in v2, thanks

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


[PATCH v2 hmm 1/9] mm/hmm: remove pgmap checking for devmap pages

2020-03-24 Thread Jason Gunthorpe
From: Jason Gunthorpe 

The checking boils down to some racy check if the pagemap is still
available or not. Instead of checking this, rely entirely on the
notifiers, if a pagemap is destroyed then all pages that belong to it must
be removed from the tables and the notifiers triggered.

Reviewed-by: Ralph Campbell 
Reviewed-by: Christoph Hellwig 
Signed-off-by: Jason Gunthorpe 
---
 mm/hmm.c | 50 ++
 1 file changed, 2 insertions(+), 48 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index a491d9aaafe45d..3a2610e0713329 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -28,7 +28,6 @@
 
 struct hmm_vma_walk {
struct hmm_range*range;
-   struct dev_pagemap  *pgmap;
unsigned long   last;
unsigned intflags;
 };
@@ -196,19 +195,8 @@ static int hmm_vma_handle_pmd(struct mm_walk *walk, 
unsigned long addr,
return hmm_vma_fault(addr, end, fault, write_fault, walk);
 
pfn = pmd_pfn(pmd) + ((addr & ~PMD_MASK) >> PAGE_SHIFT);
-   for (i = 0; addr < end; addr += PAGE_SIZE, i++, pfn++) {
-   if (pmd_devmap(pmd)) {
-   hmm_vma_walk->pgmap = get_dev_pagemap(pfn,
- hmm_vma_walk->pgmap);
-   if (unlikely(!hmm_vma_walk->pgmap))
-   return -EBUSY;
-   }
+   for (i = 0; addr < end; addr += PAGE_SIZE, i++, pfn++)
pfns[i] = hmm_device_entry_from_pfn(range, pfn) | cpu_flags;
-   }
-   if (hmm_vma_walk->pgmap) {
-   put_dev_pagemap(hmm_vma_walk->pgmap);
-   hmm_vma_walk->pgmap = NULL;
-   }
hmm_vma_walk->last = end;
return 0;
 }
@@ -300,15 +288,6 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, 
unsigned long addr,
if (fault || write_fault)
goto fault;
 
-   if (pte_devmap(pte)) {
-   hmm_vma_walk->pgmap = get_dev_pagemap(pte_pfn(pte),
- hmm_vma_walk->pgmap);
-   if (unlikely(!hmm_vma_walk->pgmap)) {
-   pte_unmap(ptep);
-   return -EBUSY;
-   }
-   }
-
/*
 * Since each architecture defines a struct page for the zero page, just
 * fall through and treat it like a normal page.
@@ -328,10 +307,6 @@ static int hmm_vma_handle_pte(struct mm_walk *walk, 
unsigned long addr,
return 0;
 
 fault:
-   if (hmm_vma_walk->pgmap) {
-   put_dev_pagemap(hmm_vma_walk->pgmap);
-   hmm_vma_walk->pgmap = NULL;
-   }
pte_unmap(ptep);
/* Fault any virtual address we were asked to fault */
return hmm_vma_fault(addr, end, fault, write_fault, walk);
@@ -418,16 +393,6 @@ static int hmm_vma_walk_pmd(pmd_t *pmdp,
return r;
}
}
-   if (hmm_vma_walk->pgmap) {
-   /*
-* We do put_dev_pagemap() here and not in hmm_vma_handle_pte()
-* so that we can leverage get_dev_pagemap() optimization which
-* will not re-take a reference on a pgmap if we already have
-* one.
-*/
-   put_dev_pagemap(hmm_vma_walk->pgmap);
-   hmm_vma_walk->pgmap = NULL;
-   }
pte_unmap(ptep - 1);
 
hmm_vma_walk->last = addr;
@@ -491,20 +456,9 @@ static int hmm_vma_walk_pud(pud_t *pudp, unsigned long 
start, unsigned long end,
}
 
pfn = pud_pfn(pud) + ((addr & ~PUD_MASK) >> PAGE_SHIFT);
-   for (i = 0; i < npages; ++i, ++pfn) {
-   hmm_vma_walk->pgmap = get_dev_pagemap(pfn,
- hmm_vma_walk->pgmap);
-   if (unlikely(!hmm_vma_walk->pgmap)) {
-   ret = -EBUSY;
-   goto out_unlock;
-   }
+   for (i = 0; i < npages; ++i, ++pfn)
pfns[i] = hmm_device_entry_from_pfn(range, pfn) |
  cpu_flags;
-   }
-   if (hmm_vma_walk->pgmap) {
-   put_dev_pagemap(hmm_vma_walk->pgmap);
-   hmm_vma_walk->pgmap = NULL;
-   }
hmm_vma_walk->last = end;
goto out_unlock;
}
-- 
2.25.2

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


[PATCH] drm/vram-helper: remove unneeded #if defined/endif guards.

2020-03-24 Thread Wambui Karuga
Remove unneeded #if/#endif guards for checking whether the
CONFIG_DEBUG_FS option is set or not. If the option is not set, the
compiler optimizes the functions making the guards
unnecessary.

Signed-off-by: Wambui Karuga 
---
 drivers/gpu/drm/drm_gem_vram_helper.c | 4 
 1 file changed, 4 deletions(-)

diff --git a/drivers/gpu/drm/drm_gem_vram_helper.c 
b/drivers/gpu/drm/drm_gem_vram_helper.c
index 76506bedac11..b3201a70cbfc 100644
--- a/drivers/gpu/drm/drm_gem_vram_helper.c
+++ b/drivers/gpu/drm/drm_gem_vram_helper.c
@@ -1018,7 +1018,6 @@ static struct ttm_bo_driver bo_driver = {
  * struct drm_vram_mm
  */
 
-#if defined(CONFIG_DEBUG_FS)
 static int drm_vram_mm_debugfs(struct seq_file *m, void *data)
 {
struct drm_info_node *node = (struct drm_info_node *) m->private;
@@ -1035,7 +1034,6 @@ static int drm_vram_mm_debugfs(struct seq_file *m, void 
*data)
 static const struct drm_info_list drm_vram_mm_debugfs_list[] = {
{ "vram-mm", drm_vram_mm_debugfs, 0, NULL },
 };
-#endif
 
 /**
  * drm_vram_mm_debugfs_init() - Register VRAM MM debugfs file.
@@ -1045,11 +1043,9 @@ static const struct drm_info_list 
drm_vram_mm_debugfs_list[] = {
  */
 void drm_vram_mm_debugfs_init(struct drm_minor *minor)
 {
-#if defined(CONFIG_DEBUG_FS)
drm_debugfs_create_files(drm_vram_mm_debugfs_list,
 ARRAY_SIZE(drm_vram_mm_debugfs_list),
 minor->debugfs_root, minor);
-#endif
 }
 EXPORT_SYMBOL(drm_vram_mm_debugfs_init);
 
-- 
2.25.1

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


Re: [PATCH 27/89] clk: bcm: Add BCM2711 DVP driver

2020-03-24 Thread Maxime Ripard
Hi Stephen,

On Thu, Mar 12, 2020 at 06:00:59PM -0700, Stephen Boyd wrote:
> > +   dvp->clks[1] = clk_register_gate(&pdev->dev, "hdmi1-108MHz",
> > +parent, CLK_IS_CRITICAL,
> > +base + DVP_HT_RPI_MISC_CONFIG, 4,
> > +CLK_GATE_SET_TO_DISABLE, 
> > &dvp->reset.lock);
>
> Can we use clk_hw APIs, document why CLK_IS_CRITICAL, and use something
> like clk_hw_register_gate_parent_data() so that we don't have to use
> of_clk_get_parent_name() above?

That function is new to me, and I'm not sure how I'm supposed to use it?

It looks like clk_hw_register_gate, clk_hw_register_gate_parent_hw and
clk_hw_register_gate_parent_data all call __clk_hw_register_gate with
the same arguments, each expecting the parent_name, so they look
equivalent?

It looks like the original intent was to have the parent name, clk_hw
or clk_parent_data as argument, but the macro itself was copy pasted
without changing the arguments it's calling __clk_hw_register_gate
with?

Maxime


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


[PATCH v2 hmm 9/9] mm/hmm: return error for non-vma snapshots

2020-03-24 Thread Jason Gunthorpe
From: Jason Gunthorpe 

The pagewalker does not call most ops with NULL vma, those are all routed
to pte_hole instead.

Thus hmm_vma_fault() is only called with a NULL vma from
hmm_vma_walk_hole(), so hoist the check to there.

Now it is clear that snapshotting with no vma is a HMM_PFN_ERROR as
without a vma we have no path to call hmm_vma_fault().

Signed-off-by: Jason Gunthorpe 
---
 mm/hmm.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/mm/hmm.c b/mm/hmm.c
index 14c33e1225866c..df0574061b37d3 100644
--- a/mm/hmm.c
+++ b/mm/hmm.c
@@ -83,9 +83,6 @@ static int hmm_vma_fault(unsigned long addr, unsigned long 
end,
WARN_ON_ONCE(!required_fault);
hmm_vma_walk->last = addr;
 
-   if (!vma)
-   return -EFAULT;
-
if ((required_fault & HMM_NEED_WRITE_FAULT) == HMM_NEED_WRITE_FAULT) {
if (!(vma->vm_flags & VM_WRITE))
return -EPERM;
@@ -175,6 +172,11 @@ static int hmm_vma_walk_hole(unsigned long addr, unsigned 
long end,
npages = (end - addr) >> PAGE_SHIFT;
pfns = &range->pfns[i];
required_fault = hmm_range_need_fault(hmm_vma_walk, pfns, npages, 0);
+   if (!walk->vma) {
+   if (required_fault)
+   return -EFAULT;
+   return hmm_pfns_fill(addr, end, range, HMM_PFN_ERROR);
+   }
if (required_fault)
return hmm_vma_fault(addr, end, required_fault, walk);
hmm_vma_walk->last = addr;
-- 
2.25.2

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


[PATCH v2 hmm 0/9] Small hmm_range_fault() cleanups

2020-03-24 Thread Jason Gunthorpe
From: Jason Gunthorpe 

This is v2 of the first simple series with a few additional patches of little
adjustments.

This needs an additional patch to the hmm tester:

diff --git a/tools/testing/selftests/vm/hmm-tests.c 
b/tools/testing/selftests/vm/hmm-tests.c
index 033a12c7ab5b6d..da15471a2bbf9a 100644
--- a/tools/testing/selftests/vm/hmm-tests.c
+++ b/tools/testing/selftests/vm/hmm-tests.c
@@ -1274,7 +1274,7 @@ TEST_F(hmm2, snapshot)
/* Check what the device saw. */
m = buffer->mirror;
ASSERT_EQ(m[0], HMM_DMIRROR_PROT_ERROR);
-   ASSERT_EQ(m[1], HMM_DMIRROR_PROT_NONE);
+   ASSERT_EQ(m[1], HMM_DMIRROR_PROT_ERROR);
ASSERT_EQ(m[2], HMM_DMIRROR_PROT_ZERO | HMM_DMIRROR_PROT_READ);
ASSERT_EQ(m[3], HMM_DMIRROR_PROT_READ);
ASSERT_EQ(m[4], HMM_DMIRROR_PROT_WRITE);

v2 changes:
 - Simplify and rename the flags, rework hmm_vma_walk_test in patch 2 (CH)
 - Adjust more comments in patch 3 (CH, Ralph)
 - Put the ugly boolean logic into a function in patch 3 (CH)
 - Update commit message of patch 4 (CH)
 - Adjust formatting in patch 5 (CH)
 Patches 6, 7, 8 are new

v1: https://lore.kernel.org/r/20200320164905.21722-1-...@ziepe.ca

Jason Gunthorpe (9):
  mm/hmm: remove pgmap checking for devmap pages
  mm/hmm: return the fault type from hmm_pte_need_fault()
  mm/hmm: remove unused code and tidy comments
  mm/hmm: remove HMM_FAULT_SNAPSHOT
  mm/hmm: remove the CONFIG_TRANSPARENT_HUGEPAGE #ifdef
  mm/hmm: use device_private_entry_to_pfn()
  mm/hmm: do not unconditionally set pfns when returning EBUSY
  mm/hmm: do not set pfns when returning an error code
  mm/hmm: return error for non-vma snapshots

 Documentation/vm/hmm.rst|  12 +-
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c |   2 +-
 drivers/gpu/drm/nouveau/nouveau_svm.c   |   2 +-
 include/linux/hmm.h | 109 +
 mm/hmm.c| 312 ++--
 5 files changed, 133 insertions(+), 304 deletions(-)

-- 
2.25.2

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


Re: [PATCH hmm 5/6] mm/hmm: remove the CONFIG_TRANSPARENT_HUGEPAGE #ifdef

2020-03-24 Thread Jason Gunthorpe
On Sat, Mar 21, 2020 at 09:43:17AM +0100, Christoph Hellwig wrote:
> On Fri, Mar 20, 2020 at 01:49:04PM -0300, Jason Gunthorpe wrote:
> > From: Jason Gunthorpe 
> > 
> > This code can be compiled when CONFIG_TRANSPARENT_HUGEPAGE is off, so
> > remove the ifdef.
> 
> It can compile, but will the compiler optimize it away?  

Yes, the enclosing conditional:

if (pmd_devmap(pmd) || pmd_trans_huge(pmd)) {

is statically false if !CONFIG_TRANSPARENT_HUGEPAGE

This is proven today, as the fallback stub is a function prototype
with no implementation:

-int hmm_vma_handle_pmd(struct mm_walk *walk, unsigned long addr,
-   unsigned long end, uint64_t *pfns, pmd_t pmd);

If the compiler wasn't optimizing the above branch we'd get link
failures.

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


Re: [PATCH V3 2/4] backlight: qcom-wled: Add callback functions

2020-03-24 Thread kgunda

On 2020-03-11 16:00, Daniel Thompson wrote:

On Wed, Mar 11, 2020 at 12:11:00PM +0530, kgu...@codeaurora.org wrote:

On 2020-03-10 20:57, Daniel Thompson wrote:
> On Mon, Mar 09, 2020 at 06:56:00PM +0530, Kiran Gunda wrote:
> > Add cabc_config, sync_toggle, wled_ovp_fault_status and wled_ovp_delay
> > callback functions to prepare the driver for adding WLED5 support.
> >
> > Signed-off-by: Kiran Gunda 
>
> Overall this code would a lot easier to review if
> > ---
> >  drivers/video/backlight/qcom-wled.c | 196
> > +++-
> >  1 file changed, 126 insertions(+), 70 deletions(-)
> >
> > diff --git a/drivers/video/backlight/qcom-wled.c
> > b/drivers/video/backlight/qcom-wled.c
> > index 3d276b3..b73f273 100644
> > --- a/drivers/video/backlight/qcom-wled.c
> > +++ b/drivers/video/backlight/qcom-wled.c
> > @@ -128,6 +128,7 @@ struct wled_config {
> >   bool cs_out_en;
> >   bool ext_gen;
> >   bool cabc;
> > + bool en_cabc;
>
> Does this ever get set to true?
>
Yes. If user wants use the cabc pin to control the brightness and
use the "qcom,cabc" DT property in the device tree.


That sounds like what you intended the code to do!

Is the code that does this present in the patch? I could not find
it.

okay... It's my bad. We already have the "cabc" for this. I will remove 
the en_cabc in

next series.


Daniel.

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


Re: [PATCH hmm 3/6] mm/hmm: remove unused code and tidy comments

2020-03-24 Thread Jason Gunthorpe
On Sat, Mar 21, 2020 at 09:39:02AM +0100, Christoph Hellwig wrote:
> On Fri, Mar 20, 2020 at 01:49:02PM -0300, Jason Gunthorpe wrote:
> > From: Jason Gunthorpe 
> > 
> > Delete several functions that are never called, fix some desync between
> > comments and structure content, remove an unused ret, and move one
> > function only used by hmm.c into hmm.c
> 
> This looks good:
> 
> Signed-off-by: Christoph Hellwig 

You mean Reviewed-by?
 
> Btw, the top of file comment in include/linux/hmm.h really needs some
> work as well.  In fact I think it should be mostly removed with any
> remaining useful bit moved to Documentation/vm/hmm.rst.

Okay, in v2 I'll just deleted the top, the only thing in this file now
is hmm_range_fault() and it can be adaquately described by its
kdoc comments.

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


[PATCH 2/2] drm/amdgpu: fix scatter-gather mapping with user pages

2020-03-24 Thread Shane Francis
Calls to dma_map_sg may return segments / entries than requested
if they fall on page bounderies. The old implementation did not
support this use case.

Signed-off-by: Shane Francis 
---
 drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c | 7 ---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c 
b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
index dee446278417..d07f143b50c3 100644
--- a/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
+++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_ttm.c
@@ -974,12 +974,13 @@ static int amdgpu_ttm_tt_pin_userptr(struct ttm_tt *ttm)
/* Map SG to device */
r = -ENOMEM;
nents = dma_map_sg(adev->dev, ttm->sg->sgl, ttm->sg->nents, direction);
-   if (nents != ttm->sg->nents)
+   if (nents == 0)
goto release_sg;
 
/* convert SG to linear array of pages and dma addresses */
-   drm_prime_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
-gtt->ttm.dma_address, ttm->num_pages);
+   drm_prime_dma_sg_to_page_addr_arrays(ttm->sg, ttm->pages,
+   gtt->ttm.dma_address, ttm->num_pages,
+   nents);
 
return 0;
 
-- 
2.26.0

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


<    1   2