The wrong sizeof values are currently being used as arguments to
kzalloc().
Fix this by using the right arguments *dceip and *vbios,
correspondingly.
Addresses-Coverity-ID: 1502901 ("Wrong sizeof argument")
Fixes: fca1e079055e ("drm/amd/display/dc/calcs/dce_calcs: Remove some large variables from the stack")
Signed-off-by: Gustavo A. R. Silva <gustavoars(a)kernel.org>
---
drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --…
[View More]git a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
index 556ecfabc8d2..1244fcb0f446 100644
--- a/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
+++ b/drivers/gpu/drm/amd/display/dc/calcs/dce_calcs.c
@@ -2051,11 +2051,11 @@ void bw_calcs_init(struct bw_calcs_dceip *bw_dceip,
enum bw_calcs_version version = bw_calcs_version_from_asic_id(asic_id);
- dceip = kzalloc(sizeof(dceip), GFP_KERNEL);
+ dceip = kzalloc(sizeof(*dceip), GFP_KERNEL);
if (!dceip)
return;
- vbios = kzalloc(sizeof(vbios), GFP_KERNEL);
+ vbios = kzalloc(sizeof(*vbios), GFP_KERNEL);
if (!vbios) {
kfree(dceip);
return;
--
2.27.0
[View Less]
nvif/if000c.h has been included at line 33, so remove
the duplicate include at line 36.
Signed-off-by: Wan Jiabing <wanjiabing(a)vivo.com>
---
drivers/gpu/drm/nouveau/nouveau_dmem.c | 1 -
1 file changed, 1 deletion(-)
diff --git a/drivers/gpu/drm/nouveau/nouveau_dmem.c b/drivers/gpu/drm/nouveau/nouveau_dmem.c
index 92987daa5e17..f5cc057b123b 100644
--- a/drivers/gpu/drm/nouveau/nouveau_dmem.c
+++ b/drivers/gpu/drm/nouveau/nouveau_dmem.c
@@ -33,7 +33,6 @@
#include <nvif/if000c.h…
[View More]>
#include <nvif/if500b.h>
#include <nvif/if900b.h>
-#include <nvif/if000c.h>
#include <nvhw/class/cla0b5.h>
--
2.25.1
[View Less]
On Monday, 15 March 2021 6:42:45 PM AEDT Christoph Hellwig wrote:
> > +Not all devices support atomic access to system memory. To support atomic
> > +operations to a shared virtual memory page such a device needs access to
that
> > +page which is exclusive of any userspace access from the CPU. The
> > +``make_device_exclusive_range()`` function can be used to make a memory
range
> > +inaccessible from userspace.
>
> s/Not all devices/Some devices/ ?
I …
[View More]will reword this. What I was trying to convey is that devices may have
features which allow for atomics to be implemented with SW assistance.
> > static inline int mm_has_notifiers(struct mm_struct *mm)
> > @@ -528,7 +534,17 @@ static inline void mmu_notifier_range_init_migrate(
> > {
> > mmu_notifier_range_init(range, MMU_NOTIFY_MIGRATE, flags, vma, mm,
> > start, end);
> > - range->migrate_pgmap_owner = pgmap;
> > + range->owner = pgmap;
> > +}
> > +
> > +static inline void mmu_notifier_range_init_exclusive(
> > + struct mmu_notifier_range *range, unsigned int flags,
> > + struct vm_area_struct *vma, struct mm_struct *mm,
> > + unsigned long start, unsigned long end, void *owner)
> > +{
> > + mmu_notifier_range_init(range, MMU_NOTIFY_EXCLUSIVE, flags, vma, mm,
> > + start, end);
> > + range->owner = owner;
>
> Maybe just replace mmu_notifier_range_init_migrate with a
> mmu_notifier_range_init_owner helper that takes the owner but does
> not hard code a type?
Ok. That does result in a function which takes a fair number of arguments, but
I guess that's no worse than multiple functions hard coding the different
types and it does result in less code overall.
> > }
> > + } else if (is_device_exclusive_entry(entry)) {
> > + page = pfn_swap_entry_to_page(entry);
> > +
> > + get_page(page);
> > + rss[mm_counter(page)]++;
> > +
> > + if (is_writable_device_exclusive_entry(entry) &&
> > + is_cow_mapping(vm_flags)) {
> > + /*
> > + * COW mappings require pages in both
> > + * parent and child to be set to read.
> > + */
> > + entry = make_readable_device_exclusive_entry(
> > + swp_offset(entry));
> > + pte = swp_entry_to_pte(entry);
> > + if (pte_swp_soft_dirty(*src_pte))
> > + pte = pte_swp_mksoft_dirty(pte);
> > + if (pte_swp_uffd_wp(*src_pte))
> > + pte = pte_swp_mkuffd_wp(pte);
> > + set_pte_at(src_mm, addr, src_pte, pte);
> > + }
>
> Just cosmetic, but I wonder if should factor this code block into
> a little helper.
In that case there are arguably are other bits of this function which should
be refactored into helpers as well. Unless you feel strongly about it I would
like to leave this as is and put together a future series to fix this and a
couple of other areas I've noticed that could do with some refactoring/clean
ups.
> > +
> > +static bool try_to_protect_one(struct page *page, struct vm_area_struct
*vma,
> > + unsigned long address, void *arg)
> > +{
> > + struct mm_struct *mm = vma->vm_mm;
> > + struct page_vma_mapped_walk pvmw = {
> > + .page = page,
> > + .vma = vma,
> > + .address = address,
> > + };
> > + struct ttp_args *ttp = (struct ttp_args *) arg;
>
> This cast should not be needed.
>
> > + return ttp.valid && (!page_mapcount(page) ? true : false);
>
> This can be simplified to:
>
> return ttp.valid && !page_mapcount(page);
>
> > + npages = get_user_pages_remote(mm, start, npages,
> > + FOLL_GET | FOLL_WRITE | FOLL_SPLIT_PMD,
> > + pages, NULL, NULL);
> > + for (i = 0; i < npages; i++, start += PAGE_SIZE) {
> > + if (!trylock_page(pages[i])) {
> > + put_page(pages[i]);
> > + pages[i] = NULL;
> > + continue;
> > + }
> > +
> > + if (!try_to_protect(pages[i], mm, start, arg)) {
> > + unlock_page(pages[i]);
> > + put_page(pages[i]);
> > + pages[i] = NULL;
> > + }
>
> Should the trylock_page go into try_to_protect to simplify the loop
> a little? Also I wonder if we need make_device_exclusive_range or
> should just open code the get_user_pages_remote + try_to_protect
> loop in the callers, as that might allow them to also deduct other
> information about the found pages.
This function has evolved over time and putting the trylock_page into
try_to_protect does simplify things nicely. I'm not sure what other
information a caller could deduct through open coding though, but I guess in
some circumstances it might be possible for callers to skip
get_user_pages_remote() which might be a future improvement.
The main reason it looks like this was simply to keep it looking fairly
similar to how hmm_range_fault() and migrate_vma() are used with an array of
pages (or pfns) which are filled out from the given address range.
> Otherwise looks good:
>
> Reviewed-by: Christoph Hellwig <hch(a)lst.de>
>
Thanks.
[View Less]
From: Quanyang Wang <quanyang.wang(a)windriver.com>
When insmod zynqmp-dpsub.ko after rmmod it, system will hang with the
error log as below:
root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
[ 88.391289] [drm] Initialized zynqmp-dpsub 1.0.0 20130509 for fd4a0000.display on minor 0
[ 88.529906] Console: switching to colour frame buffer device 128x48
[ 88.549402] zynqmp-dpsub fd4a0000.display: [drm] fb0: zynqmp-dpsubdrm frame buffer device
[ 88.571624] zynqmp-dpsub fd4a0000.display: …
[View More]ZynqMP DisplayPort Subsystem driver probed
root@xilinx-zynqmp:~# rmmod zynqmp_dpsub
[ 94.023404] Console: switching to colour dummy device 80x25
root@xilinx-zynqmp:~# insmod zynqmp-dpsub.ko
<hang here>
This is because that in zynqmp_dp_probe it tries to access some DP
registers while the DP controller is still in the reset state. When
running "rmmod zynqmp_dpsub", zynqmp_dp_reset(dp, true) in
zynqmp_dp_phy_exit is called to force the DP controller into the reset
state. Then insmod will call zynqmp_dp_probe to write to the DP registers,
but at this moment the DP controller isn't brought out of the reset state
since the function zynqmp_dp_reset(dp, false) is called later and this
will result the system hang.
Releasing the reset to DP controller before any read/write operation to it
will fix this issue.
Signed-off-by: Quanyang Wang <quanyang.wang(a)windriver.com>
---
drivers/gpu/drm/xlnx/zynqmp_dp.c | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/drivers/gpu/drm/xlnx/zynqmp_dp.c b/drivers/gpu/drm/xlnx/zynqmp_dp.c
index 99158ee67d02..bb45b3663d6b 100644
--- a/drivers/gpu/drm/xlnx/zynqmp_dp.c
+++ b/drivers/gpu/drm/xlnx/zynqmp_dp.c
@@ -402,10 +402,6 @@ static int zynqmp_dp_phy_init(struct zynqmp_dp *dp)
}
}
- ret = zynqmp_dp_reset(dp, false);
- if (ret < 0)
- return ret;
-
zynqmp_dp_clr(dp, ZYNQMP_DP_PHY_RESET, ZYNQMP_DP_PHY_RESET_ALL_RESET);
/*
@@ -1682,6 +1678,10 @@ int zynqmp_dp_probe(struct zynqmp_dpsub *dpsub, struct drm_device *drm)
return PTR_ERR(dp->reset);
}
+ ret = zynqmp_dp_reset(dp, false);
+ if (ret < 0)
+ return ret;
+
ret = zynqmp_dp_phy_probe(dp);
if (ret)
return ret;
--
2.25.1
[View Less]
On Monday, 15 March 2021 6:27:57 PM AEDT Christoph Hellwig wrote:
> On Fri, Mar 12, 2021 at 07:38:44PM +1100, Alistair Popple wrote:
> > Remove the migration and device private entry_to_page() and
> > entry_to_pfn() inline functions and instead open code them directly.
> > This results in shorter code which is easier to understand.
>
> I think this commit log should mention pfn_swap_entry_to_page() now.
Will add. Thanks for the review.
> Otherwise looks good:
&…
[View More]gt;
> Reviewed-by: Christoph Hellwig <hch(a)lst.de>
>
[View Less]