[PATCH] fbdev/core: Avoid uninitialized read in aperture_remove_conflicting_pci_device()
Return on error directly from the BAR-iterating loop instead of break+return. This is actually a cosmetic fix, since it would be highly unusual to have this called for a PCI device without any memory BARs. Fixes: 9d69ef183815 ("fbdev/core: Remove remove_conflicting_pci_framebuffers()") Signed-off-by: Michał Mirosław --- drivers/video/aperture.c | 5 + 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/drivers/video/aperture.c b/drivers/video/aperture.c index 9e6bcc03a1a4..41e77de1ea82 100644 --- a/drivers/video/aperture.c +++ b/drivers/video/aperture.c @@ -340,12 +340,9 @@ int aperture_remove_conflicting_pci_devices(struct pci_dev *pdev, const char *na size = pci_resource_len(pdev, bar); ret = aperture_remove_conflicting_devices(base, size, primary, name); if (ret) - break; + return ret; } - if (ret) - return ret; - /* * WARNING: Apparently we must kick fbdev drivers before vgacon, * otherwise the vga fbdev driver falls over. -- 2.30.2
Re: [PATCH 1/6] lib/scatterlist: Add contiguous DMA chunks helpers
On Thu, Sep 16, 2021 at 11:43:59AM +0200, Thierry Reding wrote: > From: Thierry Reding > > Add a few helpers to count the number of contiguous DMA chunks found in > an SG table. This is useful to determine whether or not a mapping can be > used by drivers whose devices need contiguous memory. [...] Is the counting of all blocks necessary if all to be checked is whether there is more than one continuous block? Best Regards Michał Mirosław
Re: [PATCH libdrm 19/25] tests: tegra: Add VIC 3.0 support
On Fri, Aug 27, 2021 at 03:22:59PM +0200, Thierry Reding wrote: > From: Thierry Reding > > The Video Image Composer (VIC) 3.0 can be found on NVIDIA Tegra124 SoCs.a [...] > +static int vic30_clear(struct vic *v, struct vic_image *output, > + unsigned int alpha, unsigned int red, > + unsigned int green, unsigned int blue) > +{ > +struct vic30 *vic = container_of(v, struct vic30, base); > +ConfigStruct *c; > +int err; > + > +err = drm_tegra_bo_map(vic->config.bo, (void **)); > +if (err < 0) { > +fprintf(stderr, "failed to map configuration structure: %s\n", > +strerror(-err)); > +return err; > +} > + > +memset(c, 0, sizeof(*c)); > + > +c->surfaceList0Struct.TargetRectLeft = 0; > +c->surfaceList0Struct.TargetRectTop = 0; > +c->surfaceList0Struct.TargetRectRight = output->width - 1; > +c->surfaceList0Struct.TargetRectBottom = output->height - 1; > + > +c->blending0Struct.PixelFormat = output->format; > +c->blending0Struct.BackgroundAlpha = alpha; > +c->blending0Struct.BackgroundR = red; > +c->blending0Struct.BackgroundG = green; > +c->blending0Struct.BackgroundB = blue; > +c->blending0Struct.LumaWidth = output->stride - 1; > +c->blending0Struct.LumaHeight = output->height - 1; > +c->blending0Struct.ChromaWidth = 16383; > +c->blending0Struct.ChromaHeight = 16383; > +c->blending0Struct.TargetRectLeft = 0; > +c->blending0Struct.TargetRectTop = 0; > +c->blending0Struct.TargetRectRight = output->width - 1; > +c->blending0Struct.TargetRectBottom = output->height - 1; > +c->blending0Struct.SurfaceWidth = output->width - 1; > +c->blending0Struct.SurfaceHeight = output->height - 1; > +c->blending0Struct.BlkKind = output->kind; > +c->blending0Struct.BlkHeight = 0; > + > +c->fetchControl0Struct.TargetRectLeft = 0; > +c->fetchControl0Struct.TargetRectTop = 0; > +c->fetchControl0Struct.TargetRectRight = output->width - 1; > +c->fetchControl0Struct.TargetRectBottom = output->height - 1; > + > +drm_tegra_bo_unmap(vic->config.bo); > + > +return 0; > +} [...] It does look exactly like: return vic30_fill(v, output, 0, 0, output->width - 1, output->height - 1, alpha, red, green, blue); Best Regards Michał Mirosław
Re: [PATCH v7 05/15] gpu: host1x: Add option to skip firewall for a job
On Thu, Jun 10, 2021 at 02:04:46PM +0300, Mikko Perttunen wrote: > The new UAPI will have its own firewall, and we don't want to run > the firewall in the Host1x driver for those jobs. As such, add a > parameter to host1x_job_alloc to specify if we want to skip the > firewall in the Host1x driver. [...] > struct host1x_job *host1x_job_alloc(struct host1x_channel *ch, > - u32 num_cmdbufs, u32 num_relocs) > + u32 num_cmdbufs, u32 num_relocs, > + bool skip_firewall) > { > struct host1x_job *job = NULL; > unsigned int num_unpins = num_relocs; > + bool enable_firewall; > u64 total; > void *mem; > > - if (!IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL)) > + enable_firewall = IS_ENABLED(CONFIG_TEGRA_HOST1X_FIREWALL) && > !skip_firewall; [...] Why negatively name a parameter just to invert it right away? Best Regards Michał Mirosław
Re: [PATCH v5 03/21] gpu: host1x: Show number of pending waiters in debugfs
On Thu, Apr 08, 2021 at 06:13:44AM +0200, Michał Mirosław wrote: > On Fri, Apr 02, 2021 at 07:02:32PM +0300, Dmitry Osipenko wrote: > > 02.04.2021 00:19, Michał Mirosław пишет: > > > On Fri, Mar 26, 2021 at 04:34:13PM +0200, Mikko Perttunen wrote: > > >> On 3/23/21 12:16 PM, Thierry Reding wrote: > > >>> On Mon, Jan 11, 2021 at 03:00:01PM +0200, Mikko Perttunen wrote: > > >>>> Show the number of pending waiters in the debugfs status file. > > >>>> This is useful for testing to verify that waiters do not leak > > >>>> or accumulate incorrectly. > > >>>> > > >>>> Signed-off-by: Mikko Perttunen > > >>>> --- > > >>>> drivers/gpu/host1x/debug.c | 14 +++--- > > >>>> 1 file changed, 11 insertions(+), 3 deletions(-) > > >>>> > > >>>> diff --git a/drivers/gpu/host1x/debug.c b/drivers/gpu/host1x/debug.c > > >>>> index 1b4997bda1c7..8a14880c61bb 100644 > > >>>> --- a/drivers/gpu/host1x/debug.c > > >>>> +++ b/drivers/gpu/host1x/debug.c > > >>>> @@ -69,6 +69,7 @@ static int show_channel(struct host1x_channel *ch, > > >>>> void *data, bool show_fifo) > > >>>> static void show_syncpts(struct host1x *m, struct output *o) > > >>>> { > > >>>> + struct list_head *pos; > > >>>>unsigned int i; > > >>>>host1x_debug_output(o, " syncpts \n"); > > >>>> @@ -76,12 +77,19 @@ static void show_syncpts(struct host1x *m, struct > > >>>> output *o) > > >>>>for (i = 0; i < host1x_syncpt_nb_pts(m); i++) { > > >>>>u32 max = host1x_syncpt_read_max(m->syncpt + i); > > >>>>u32 min = host1x_syncpt_load(m->syncpt + i); > > >>>> + unsigned int waiters = 0; > > >>>> - if (!min && !max) > > >>>> + spin_lock(>syncpt[i].intr.lock); > > >>>> + list_for_each(pos, >syncpt[i].intr.wait_head) > > >>>> + waiters++; > > >>>> + spin_unlock(>syncpt[i].intr.lock); > > >>> > > >>> Would it make sense to keep a running count so that we don't have to > > >>> compute it here? > > >> > > >> Considering this is just a debug facility, I think I prefer not adding a > > >> new > > >> field just for it. > > > > > > This looks like IRQ-disabled region, so unless only root can trigger > > > this code, maybe the additional field could save a potential headache? > > > How many waiters can there be in the worst case? > > > > The host1x's IRQ handler runs in a workqueue, so it should be okay. > > Why, then, this uses a spinlock (and it has 'intr' in its name)? The critical sections are already O(n) in number of waiters, so this patch doesn't make things worse as I previously thought. The questions remain: What is the expected number and upper bound of workers? Shouldn't this be a mutex instead? Best Regards Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 03/21] gpu: host1x: Show number of pending waiters in debugfs
On Fri, Apr 02, 2021 at 07:02:32PM +0300, Dmitry Osipenko wrote: > 02.04.2021 00:19, Michał Mirosław пишет: > > On Fri, Mar 26, 2021 at 04:34:13PM +0200, Mikko Perttunen wrote: > >> On 3/23/21 12:16 PM, Thierry Reding wrote: > >>> On Mon, Jan 11, 2021 at 03:00:01PM +0200, Mikko Perttunen wrote: > >>>> Show the number of pending waiters in the debugfs status file. > >>>> This is useful for testing to verify that waiters do not leak > >>>> or accumulate incorrectly. > >>>> > >>>> Signed-off-by: Mikko Perttunen > >>>> --- > >>>> drivers/gpu/host1x/debug.c | 14 +++--- > >>>> 1 file changed, 11 insertions(+), 3 deletions(-) > >>>> > >>>> diff --git a/drivers/gpu/host1x/debug.c b/drivers/gpu/host1x/debug.c > >>>> index 1b4997bda1c7..8a14880c61bb 100644 > >>>> --- a/drivers/gpu/host1x/debug.c > >>>> +++ b/drivers/gpu/host1x/debug.c > >>>> @@ -69,6 +69,7 @@ static int show_channel(struct host1x_channel *ch, > >>>> void *data, bool show_fifo) > >>>> static void show_syncpts(struct host1x *m, struct output *o) > >>>> { > >>>> +struct list_head *pos; > >>>> unsigned int i; > >>>> host1x_debug_output(o, " syncpts \n"); > >>>> @@ -76,12 +77,19 @@ static void show_syncpts(struct host1x *m, struct > >>>> output *o) > >>>> for (i = 0; i < host1x_syncpt_nb_pts(m); i++) { > >>>> u32 max = host1x_syncpt_read_max(m->syncpt + i); > >>>> u32 min = host1x_syncpt_load(m->syncpt + i); > >>>> +unsigned int waiters = 0; > >>>> -if (!min && !max) > >>>> +spin_lock(>syncpt[i].intr.lock); > >>>> +list_for_each(pos, >syncpt[i].intr.wait_head) > >>>> +waiters++; > >>>> +spin_unlock(>syncpt[i].intr.lock); > >>> > >>> Would it make sense to keep a running count so that we don't have to > >>> compute it here? > >> > >> Considering this is just a debug facility, I think I prefer not adding a > >> new > >> field just for it. > > > > This looks like IRQ-disabled region, so unless only root can trigger > > this code, maybe the additional field could save a potential headache? > > How many waiters can there be in the worst case? > > The host1x's IRQ handler runs in a workqueue, so it should be okay. Why, then, this uses a spinlock (and it has 'intr' in its name)? Best Regards Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v5 03/21] gpu: host1x: Show number of pending waiters in debugfs
On Fri, Mar 26, 2021 at 04:34:13PM +0200, Mikko Perttunen wrote: > On 3/23/21 12:16 PM, Thierry Reding wrote: > > On Mon, Jan 11, 2021 at 03:00:01PM +0200, Mikko Perttunen wrote: > > > Show the number of pending waiters in the debugfs status file. > > > This is useful for testing to verify that waiters do not leak > > > or accumulate incorrectly. > > > > > > Signed-off-by: Mikko Perttunen > > > --- > > > drivers/gpu/host1x/debug.c | 14 +++--- > > > 1 file changed, 11 insertions(+), 3 deletions(-) > > > > > > diff --git a/drivers/gpu/host1x/debug.c b/drivers/gpu/host1x/debug.c > > > index 1b4997bda1c7..8a14880c61bb 100644 > > > --- a/drivers/gpu/host1x/debug.c > > > +++ b/drivers/gpu/host1x/debug.c > > > @@ -69,6 +69,7 @@ static int show_channel(struct host1x_channel *ch, void > > > *data, bool show_fifo) > > > static void show_syncpts(struct host1x *m, struct output *o) > > > { > > > + struct list_head *pos; > > > unsigned int i; > > > host1x_debug_output(o, " syncpts \n"); > > > @@ -76,12 +77,19 @@ static void show_syncpts(struct host1x *m, struct > > > output *o) > > > for (i = 0; i < host1x_syncpt_nb_pts(m); i++) { > > > u32 max = host1x_syncpt_read_max(m->syncpt + i); > > > u32 min = host1x_syncpt_load(m->syncpt + i); > > > + unsigned int waiters = 0; > > > - if (!min && !max) > > > + spin_lock(>syncpt[i].intr.lock); > > > + list_for_each(pos, >syncpt[i].intr.wait_head) > > > + waiters++; > > > + spin_unlock(>syncpt[i].intr.lock); > > > > Would it make sense to keep a running count so that we don't have to > > compute it here? > > Considering this is just a debug facility, I think I prefer not adding a new > field just for it. This looks like IRQ-disabled region, so unless only root can trigger this code, maybe the additional field could save a potential headache? How many waiters can there be in the worst case? Best Regards Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v16 1/2] drm/tegra: dc: Support memory bandwidth management
t; + /* > + * Then we calculate maximum bandwidth of each plane state. > + * The bandwidth includes the plane BW + BW of the "simultaneously" > + * overlapping planes, where "simultaneously" means areas where DC > + * fetches from the planes simultaneously during of scan-out process. > + * > + * For example, if plane A overlaps with planes B and C, but B and C > + * don't overlap, then the peak bandwidth will be either in area where > + * A-and-B or A-and-C planes overlap. > + * > + * The plane_peak_bw[] contains peak memory bandwidth values of > + * each plane, this information is needed by interconnect provider > + * in order to set up latency allowness based on the peak BW, see > + * tegra_crtc_update_memory_bandwidth(). > + */ > + for (i = 0; i < ARRAY_SIZE(plane_peak_bw); i++) { > + overlap_bw = 0; > + > + for_each_set_bit(k, _mask[i], 3) { > + if (k == i) > + continue; > + > + if (all_planes_overlap_simultaneously) > + overlap_bw += plane_peak_bw[k]; > + else > + overlap_bw = max(overlap_bw, plane_peak_bw[k]); > + } > + > + new_dc_state->plane_peak_bw[i] = plane_peak_bw[i] + overlap_bw; > + > + /* > + * If plane's peak bandwidth changed (for example plane isn't > + * overlapped anymore) and plane isn't in the atomic state, > + * then add plane to the state in order to have the bandwidth > + * updated. > + */ > + if (old_dc_state->plane_peak_bw[i] != > + new_dc_state->plane_peak_bw[i]) { > + plane = tegra_crtc_get_plane_by_index(crtc, i); > + if (!plane) > + continue; > + > + plane_state = drm_atomic_get_plane_state(state, plane); > + if (IS_ERR(plane_state)) > + return PTR_ERR(plane_state); > + } > + } > + > + return 0; > +} > + > +static int tegra_crtc_atomic_check(struct drm_crtc *crtc, > +struct drm_atomic_state *state) > +{ > + int err; > + > + err = tegra_crtc_calculate_memory_bandwidth(crtc, state); > + if (err) > + return err; > + > + return 0; > +} > + > +void tegra_crtc_atomic_post_commit(struct drm_crtc *crtc, > +struct drm_atomic_state *state) > +{ > + /* > + * Display bandwidth is allowed to go down only once hardware state > + * is known to be armed, i.e. state was committed and VBLANK event > + * received. > + */ > + tegra_crtc_update_memory_bandwidth(crtc, state, false); > +} > + > static const struct drm_crtc_helper_funcs tegra_crtc_helper_funcs = { > + .atomic_check = tegra_crtc_atomic_check, > .atomic_begin = tegra_crtc_atomic_begin, > .atomic_flush = tegra_crtc_atomic_flush, > .atomic_enable = tegra_crtc_atomic_enable, > @@ -2257,7 +2597,9 @@ static const struct tegra_dc_soc_info > tegra20_dc_soc_info = { > .overlay_formats = tegra20_overlay_formats, > .modifiers = tegra20_modifiers, > .has_win_a_without_filters = true, > + .has_win_b_vfilter_mem_client = true, > .has_win_c_without_vert_filter = true, > + .plane_tiled_memory_bandwidth_x2 = false, > }; > > static const struct tegra_dc_soc_info tegra30_dc_soc_info = { > @@ -2276,7 +2618,9 @@ static const struct tegra_dc_soc_info > tegra30_dc_soc_info = { > .overlay_formats = tegra20_overlay_formats, > .modifiers = tegra20_modifiers, > .has_win_a_without_filters = false, > + .has_win_b_vfilter_mem_client = true, > .has_win_c_without_vert_filter = false, > + .plane_tiled_memory_bandwidth_x2 = true, > }; > > static const struct tegra_dc_soc_info tegra114_dc_soc_info = { > @@ -2295,7 +2639,9 @@ static const struct tegra_dc_soc_info > tegra114_dc_soc_info = { > .overlay_formats = tegra114_overlay_formats, > .modifiers = tegra20_modifiers, > .has_win_a_without_filters = false, > + .has_win_b_vfilter_mem_client = false, > .has_win_c_without_vert_filter = false, > + .plane_tiled_memory_bandwidth_x2 = true, > }; > > static const struct tegra_dc_soc_info tegra124_dc_soc_info = { > @@ -2314,7 +2660,9 @@ static const struct tegra_dc_soc_info > tegra124_dc_soc_info = { > .overlay_formats = tegra124_overlay_formats, > .modifiers = tegra124_modifiers, > .has_win_a_without_filters = false, > + .has_win_b_vfilter_mem_client = false, > .has_win_c_without_vert_filter = false, > + .plane_tiled_memory_bandwidth_x2 = false, > }; > > static const struct tegra_dc_soc_info tegra210_dc_soc_info = { > @@ -2333,7 +2681,9 @@ static const struct tegra_dc_soc_info > tegra210_dc_soc_info = { > .overlay_formats = tegra114_overlay_formats, > .modifiers = tegra124_modifiers, > .has_win_a_without_filters = false, > + .has_win_b_vfilter_mem_client = false, > .has_win_c_without_vert_filter = false, > + .plane_tiled_memory_bandwidth_x2 = false, > }; > > static const struct tegra_windowgroup_soc tegra186_dc_wgrps[] = { > @@ -2382,6 +2732,7 @@ static const struct tegra_dc_soc_info > tegra186_dc_soc_info = { > .has_nvdisplay = true, > .wgrps = tegra186_dc_wgrps, > .num_wgrps = ARRAY_SIZE(tegra186_dc_wgrps), > + .plane_tiled_memory_bandwidth_x2 = false, > }; > > static const struct tegra_windowgroup_soc tegra194_dc_wgrps[] = { > @@ -2430,6 +2781,7 @@ static const struct tegra_dc_soc_info > tegra194_dc_soc_info = { > .has_nvdisplay = true, > .wgrps = tegra194_dc_wgrps, > .num_wgrps = ARRAY_SIZE(tegra194_dc_wgrps), > + .plane_tiled_memory_bandwidth_x2 = false, > }; For globals you will have .x = false by default; I'm not sure those entries add much value. Reviewed-by: Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v15 1/2] drm/tegra: dc: Support memory bandwidth management
lane = tegra_crtc_get_plane_by_index(crtc, i); > + if (!plane) > + continue; > + > + plane_state = drm_atomic_get_plane_state(state, plane); > + if (IS_ERR(plane_state)) > + return PTR_ERR(plane_state); > + } > + } [...] Does it matter to which channel (plane) the peak bw is attached? Would it still work if the first channel specified max(peak_bw of overlaps) and others only zeroes? > + /* > + * Horizontal downscale needs a lower memory latency, which roughly > + * depends on the scaled width. Trying to tune latency of a memory > + * client alone will likely result in a strong negative impact on > + * other memory clients, hence we will request a higher bandwidth > + * since latency depends on bandwidth. This allows to prevent memory > + * FIFO underflows for a large plane downscales, meanwhile allowing > + * display to share bandwidth fairly with other memory clients. > + */ > + if (src_w > dst_w) > + mul = (src_w - dst_w) * bpp / 2048 + 1; > + else > + mul = 1; [...] One point is unexplained yet: why is the multiplier proportional to a *difference* between src and dst widths? Also, I would expect max (worst case) is pixclock * read_size when src_w/dst_w >= read_size. BTW, you could move this below and : if (src > dst_w) peak_bandwidth *= ... > + /* average bandwidth in bytes/s */ > + avg_bandwidth = (bpp * src_w * src_h * mul + 7) / 8; > + avg_bandwidth *= drm_mode_vrefresh(_state->mode); > + > + /* mode.clock in kHz, peak bandwidth in kbit/s */ > + peak_bandwidth = crtc_state->mode.clock * bpp * mul; [...] Best Regards Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v15 2/2] drm/tegra: dc: Extend debug stats with total number of events
On Thu, Mar 11, 2021 at 08:22:55PM +0300, Dmitry Osipenko wrote: > It's useful to know the total number of underflow events and currently > the debug stats are getting reset each time CRTC is being disabled. Let's > account the overall number of events that doesn't get a reset. [...] Looks good. It seems independent from the other patch. Reviewed-by: Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v13 1/2] drm/tegra: dc: Support memory bandwidth management
On Fri, Mar 05, 2021 at 12:45:51AM +0300, Dmitry Osipenko wrote: > 04.03.2021 02:08, Michał Mirosław пишет: > > On Tue, Mar 02, 2021 at 03:44:44PM +0300, Dmitry Osipenko wrote: > >> Display controller (DC) performs isochronous memory transfers, and thus, > >> has a requirement for a minimum memory bandwidth that shall be fulfilled, > >> otherwise framebuffer data can't be fetched fast enough and this results > >> in a DC's data-FIFO underflow that follows by a visual corruption. [...] > >> + /* > >> + * Horizontal downscale takes extra bandwidth which roughly depends > >> + * on the scaled width. > >> + */ > >> + if (src_w > dst_w) > >> + mul = (src_w - dst_w) * bpp / 2048 + 1; > >> + else > >> + mul = 1; > > > > Does it really need more bandwidth to scale down? Does it read the same > > data multiple times just to throw it away? > The hardware isn't optimized for downscale, it indeed takes more > bandwidth. You'll witness a severe underflow of plane's memory FIFO > buffer on trying to downscale 1080p plane to 50x50. [...] In your example, does it really need 16x the bandwidth compared to no scaling case? The naive way to implement downscaling would be to read all the pixels and only take every N-th. Maybe the problem is that in downscaling mode the latency requirements are tighter? Why would bandwidth required be proportional to a difference between the widths (instead e.g. to src/dst or dst*cacheline_size)? Best Regards Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v13 1/2] drm/tegra: dc: Support memory bandwidth management
h the assignments after the following 'if' block. > + /* > + * Tegra30/114 Memory Controller can't interleave DC memory requests > + * and DC uses 16-bytes atom for the tiled windows, while DDR3 uses 32 > + * bytes atom. Hence there is x2 memory overfetch for tiled framebuffer > + * and DDR3 on older SoCs. > + */ > + if (soc->plane_tiled_memory_bandwidth_x2 && > + tegra_state->tiling.mode == TEGRA_BO_TILING_MODE_TILED) { > + peak_bandwidth *= 2; > + avg_bandwidth *= 2; > + } > + > + tegra_state->peak_memory_bandwidth = peak_bandwidth; > + tegra_state->avg_memory_bandwidth = avg_bandwidth; > + > + return 0; > +} [...] > +static const char * const tegra_plane_icc_names[] = { > + "wina", "winb", "winc", "", "", "", "cursor", > +}; > + > +int tegra_plane_interconnect_init(struct tegra_plane *plane) > +{ > + const char *icc_name = tegra_plane_icc_names[plane->index]; Is plane->index guaranteed to be <= 6? I would guess so, but maybe BUILD_BUG_ON(sizeof(icc_names)==TEGRA_DC_LEGACY_PLANES_NUM) or some other check could document this? [...] Best Regards Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v1 00/30] Introduce core voltage scaling for NVIDIA Tegra20/30 SoCs
On Thu, Nov 05, 2020 at 02:43:57AM +0300, Dmitry Osipenko wrote: > Introduce core voltage scaling for NVIDIA Tegra20/30 SoCs, which reduces > power consumption and heating of the Tegra chips. Tegra SoC has multiple > hardware units which belong to a core power domain of the SoC and share > the core voltage. The voltage must be selected in accordance to a minimum > requirement of every core hardware unit. [...] Just looked briefly through the series - it looks like there is a lot of code duplication in *_init_opp_table() functions. Could this be made more generic / data-driven? Best Regards Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 01/25] drm/drm_panel: no error when no callback
On Sat, Dec 07, 2019 at 03:03:29PM +0100, Sam Ravnborg wrote: > The callbacks in drm_panel_funcs are optional, so do not > return an error just because no callback is assigned. [...] > diff --git a/drivers/gpu/drm/drm_panel.c b/drivers/gpu/drm/drm_panel.c > index ed7985c0535a..4ab7229fb22b 100644 > --- a/drivers/gpu/drm/drm_panel.c > +++ b/drivers/gpu/drm/drm_panel.c [...] > @@ -228,10 +240,13 @@ EXPORT_SYMBOL(drm_panel_disable); > */ > int drm_panel_get_modes(struct drm_panel *panel) > { > - if (panel && panel->funcs && panel->funcs->get_modes) > + if (!panel) > + return -EINVAL; > + > + if (panel->funcs && panel->funcs->get_modes) > return panel->funcs->get_modes(panel); > > - return panel ? -ENOSYS : -EINVAL; > + return -EOPNOTSUPP; > } > EXPORT_SYMBOL(drm_panel_get_modes); > > diff --git a/include/drm/drm_panel.h b/include/drm/drm_panel.h > index ce8da64022b4..d71655b2634c 100644 > --- a/include/drm/drm_panel.h > +++ b/include/drm/drm_panel.ha [...] > /** >* @get_modes: >* > - * Add modes to the connector that the panel is attached to and > - * return the number of modes added. > + * Add modes to the connector that the panel is attached to. > + * > + * This function is mandatory. > + * > + * Returns the number of modes added, -EOPNOTSUPP if callback > + * is missing, -EINVAL if panel is NULL. >*/ > int (*get_modes)(struct drm_panel *panel); > Hi! If .get_modes is mandatory, then panel->func != NULL checks can be removed if panel->func and .get_modes presence gets checked at panel probe time. Best Regards, Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 0/3] drm/tegra: Remove space after parenthesis
On Mon, Nov 04, 2019 at 06:23:19PM -0800, Jamal Shareef wrote: > This patchset removes spaces after left open parenthesis. > Issue found by checkpatch. I'd say that those spaces make code easier to look at, so it would be better to teach checkpatch to ignore cases like these. Best Regards, Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2] drm/tegra: Do not use ->load() and ->unload() callbacks
On Thu, Oct 24, 2019 at 07:31:37PM +0200, Thierry Reding wrote: > From: Thierry Reding > > The ->load() and ->unload() drivers are midlayers and should be avoided > in modern drivers. Fix this by moving the code into the driver ->probe() > and ->remove() implementations, respectively. > > v2: kick out conflicting framebuffers before initializing fbdev > > Signed-off-by: Thierry Reding > --- > Michał, Dmitry, > > do you guys have a way of testing that the removal of the conflicting > framebuffer actually works? [...] I might be able to check during the weekend. Is this patch alone enough for v5.3? Best Regards, Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/nouveau: avoid client name truncation
If TASK_COMM_LEN is made bigger DRM client name will be truncated. Avoid that. Signed-off-by: Michał Mirosław --- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 74d2283f2c28..b0a3708992fe 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -894,7 +894,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) { struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_cli *cli; - char name[32], tmpname[TASK_COMM_LEN]; + char name[TASK_COMM_LEN + 16], tmpname[TASK_COMM_LEN]; int ret; /* need to bring up power immediately if opening device */ -- 2.19.1 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] fbdev: fix kerneldoc
As noticed by kbuild test robot , remove_conflicting_pci_framebuffers()'s second argument is called res_id not resource_id. Fix this. Signed-off-by: Michał Mirosław --- * Against drm-misc-next, as this is the branch original patchset was applied to. --- drivers/video/fbdev/core/fbmem.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 5ffadc8e681d..4a2193fe3bc3 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1834,7 +1834,7 @@ EXPORT_SYMBOL(remove_conflicting_framebuffers); /** * remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices * @pdev: PCI device - * @resource_id: index of PCI BAR configuring framebuffer memory + * @res_id: index of PCI BAR configuring framebuffer memory * @name: requesting driver name * * This function removes framebuffer devices (eg. initialized by firmware) -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm/fb-helper: document remove*_conflicting_framebuffers()
Copy remove*_conflicting_framebuffers() kerneldocs from fbdev code to make DRM developers' life easier. Signed-off-by: Michał Mirosław --- * Against drm-misc-next. --- include/drm/drm_fb_helper.h | 22 ++ 1 file changed, 22 insertions(+) diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 8b6ab3200a2c..bb9acea61369 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -604,6 +604,16 @@ drm_fbdev_generic_setup(struct drm_device *dev, unsigned int preferred_bpp) #endif +/** + * drm_fb_helper_remove_conflicting_framebuffers - remove firmware-configured framebuffers + * @a: memory range, users of which are to be removed + * @name: requesting driver name + * @primary: also kick vga16fb if present + * + * This function removes framebuffer devices (initialized by firmware/bootloader) + * which use memory range described by @a. If @a is NULL all such devices are + * removed. + */ static inline int drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary) @@ -615,6 +625,18 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, #endif } +/** + * drm_fb_helper_remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices + * @pdev: PCI device + * @resource_id: index of PCI BAR configuring framebuffer memory + * @name: requesting driver name + * + * This function removes framebuffer devices (eg. initialized by firmware) + * using memory range configured for @pdev's BAR @resource_id. + * + * The function assumes that PCI device with shadowed ROM drives a primary + * display and so kicks out vga16fb. + */ static inline int drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int resource_id, -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2] fbdev: fix kerneldoc
As noticed by kbuild test robot , remove_conflicting_pci_framebuffers()'s second argument is called res_id not resource_id. Fix this. Signed-off-by: Michał Mirosław --- * Against drm-misc-next, as that's where original patchset went to. v2: include second occurrence of @resource_id --- drivers/video/fbdev/core/fbmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 5ffadc8e681d..0da75c55660d 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1834,11 +1834,11 @@ EXPORT_SYMBOL(remove_conflicting_framebuffers); /** * remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices * @pdev: PCI device - * @resource_id: index of PCI BAR configuring framebuffer memory + * @res_id: index of PCI BAR configuring framebuffer memory * @name: requesting driver name * * This function removes framebuffer devices (eg. initialized by firmware) - * using memory range configured for @pdev's BAR @resource_id. + * using memory range configured for @pdev's BAR @res_id. * * The function assumes that PCI device with shadowed ROM drives a primary * display and so kicks out vga16fb. -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 12/13] drm/sun4i: use simpler remove_conflicting_framebuffers(NULL)
Use remove_conflicting_framebuffers(NULL) instead of duplicating it. Signed-off-by: Michał Mirosław Acked-by: Maxime Ripard Acked-by: Daniel Vetter --- drivers/gpu/drm/sun4i/sun4i_drv.c | 18 +- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index 50d19605c38f..555b5db8036f 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -60,22 +60,6 @@ static struct drm_driver sun4i_drv_driver = { /* Frame Buffer Operations */ }; -static void sun4i_remove_framebuffers(void) -{ - struct apertures_struct *ap; - - ap = alloc_apertures(1); - if (!ap) - return; - - /* The framebuffer can be located anywhere in RAM */ - ap->ranges[0].base = 0; - ap->ranges[0].size = ~0; - - drm_fb_helper_remove_conflicting_framebuffers(ap, "sun4i-drm-fb", false); - kfree(ap); -} - static int sun4i_drv_bind(struct device *dev) { struct drm_device *drm; @@ -118,7 +102,7 @@ static int sun4i_drv_bind(struct device *dev) drm->irq_enabled = true; /* Remove early framebuffers (ie. simplefb) */ - sun4i_remove_framebuffers(); + drm_fb_helper_remove_conflicting_framebuffers(NULL, "sun4i-drm-fb", false); /* Create our framebuffer */ ret = sun4i_framebuffer_init(drm); -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 13/13] drm/tegra: kick out simplefb
Kick out firmware fb when loading Tegra driver. Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/tegra/drm.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 7afe2f635f74..b51ec138fed2 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1203,6 +1203,10 @@ static int host1x_drm_probe(struct host1x_device *dev) dev_set_drvdata(>dev, drm); + err = drm_fb_helper_remove_conflicting_framebuffers(NULL, "tegradrmfb", false); + if (err < 0) + goto unref; + err = drm_dev_register(drm, 0); if (err < 0) goto unref; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 11/13] drm/vc4: use simpler remove_conflicting_framebuffers(NULL)
Use remove_conflicting_framebuffers(NULL) instead of open-coding it. Signed-off-by: Michał Mirosław Acked-by: Eric Anholt Acked-by: Daniel Vetter --- drivers/gpu/drm/vc4/vc4_drv.c | 20 +--- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index 94b99c90425a..96bb90325995 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c @@ -246,24 +246,6 @@ static void vc4_match_add_drivers(struct device *dev, } } -static void vc4_kick_out_firmware_fb(void) -{ - struct apertures_struct *ap; - - ap = alloc_apertures(1); - if (!ap) - return; - - /* Since VC4 is a UMA device, the simplefb node may have been -* located anywhere in memory. -*/ - ap->ranges[0].base = 0; - ap->ranges[0].size = ~0; - - drm_fb_helper_remove_conflicting_framebuffers(ap, "vc4drmfb", false); - kfree(ap); -} - static int vc4_drm_bind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -296,7 +278,7 @@ static int vc4_drm_bind(struct device *dev) if (ret) goto gem_destroy; - vc4_kick_out_firmware_fb(); + drm_fb_helper_remove_conflicting_framebuffers(NULL, "vc4drmfb", false); ret = drm_dev_register(drm, 0); if (ret < 0) -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 07/13] drm/cirrus: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/cirrus/cirrus_drv.c | 23 +-- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c index 69c4e352dd78..85ed8657c862 100644 --- a/drivers/gpu/drm/cirrus/cirrus_drv.c +++ b/drivers/gpu/drm/cirrus/cirrus_drv.c @@ -42,33 +42,12 @@ static const struct pci_device_id pciidlist[] = { }; -static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary); - kfree(ap); - - return 0; -} - static int cirrus_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int ret; - ret = cirrus_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "cirrusdrmfb"); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 00/13] remove_conflicting_framebuffers() cleanup
This series cleans up duplicated code for replacing firmware FB driver with proper DRI driver and adds handover support to Tegra driver. This is a sligtly updated version of a series sent on 24 Nov 2017. --- v2: - rebased on current drm-next - dropped staging/sm750fb changes - added kernel docs for DRM helpers v3: - move kerneldoc to fbdev, where functions are implemented - split kerneldoc for remove_conflicting_framebuffers() - propagate return value in remove_conflicting_pci_framebuffers() --- Michał Mirosław (13): fbdev: show fbdev number for debugging fbdev: allow apertures == NULL in remove_conflicting_framebuffers() fbdev: add kerneldoc do remove_conflicting_framebuffers() fbdev: add remove_conflicting_pci_framebuffers() drm/amdgpu: use simpler remove_conflicting_pci_framebuffers() drm/bochs: use simpler remove_conflicting_pci_framebuffers() drm/cirrus: use simpler remove_conflicting_pci_framebuffers() drm/mgag200: use simpler remove_conflicting_pci_framebuffers() drm/radeon: use simpler remove_conflicting_pci_framebuffers() drm/virtio: use simpler remove_conflicting_pci_framebuffers() drm/vc4: use simpler remove_conflicting_framebuffers(NULL) drm/sun4i: use simpler remove_conflicting_framebuffers(NULL) drm/tegra: kick out simplefb drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 + drivers/gpu/drm/bochs/bochs_drv.c| 18 +-- drivers/gpu/drm/cirrus/cirrus_drv.c | 23 + drivers/gpu/drm/mgag200/mgag200_drv.c| 21 +--- drivers/gpu/drm/mgag200/mgag200_main.c | 9 drivers/gpu/drm/radeon/radeon_drv.c | 23 + drivers/gpu/drm/sun4i/sun4i_drv.c| 18 +-- drivers/gpu/drm/tegra/drm.c | 4 ++ drivers/gpu/drm/vc4/vc4_drv.c| 20 +--- drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 ++--- drivers/video/fbdev/core/fbmem.c | 63 +++- include/drm/drm_fb_helper.h | 12 + include/linux/fb.h | 2 + 13 files changed, 89 insertions(+), 172 deletions(-) -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 01/13] fbdev: show fbdev number for debugging
Signed-off-by: Michał Mirosław Acked-by: Bartlomiej Zolnierkiewicz Acked-by: Daniel Vetter --- drivers/video/fbdev/core/fbmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index f741ba8df01b..30a18d4c9de4 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1618,8 +1618,8 @@ static int do_remove_conflicting_framebuffers(struct apertures_struct *a, (primary && gen_aper && gen_aper->count && gen_aper->ranges[0].base == VGA_FB_PHYS)) { - printk(KERN_INFO "fb: switching to %s from %s\n", - name, registered_fb[i]->fix.id); + printk(KERN_INFO "fb%d: switching to %s from %s\n", + i, name, registered_fb[i]->fix.id); ret = do_unregister_framebuffer(registered_fb[i]); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 05/13] drm/amdgpu: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Alex Deucher Acked-by: Daniel Vetter --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 +--- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 0b19482b36b8..9b6e037719db 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -560,28 +560,6 @@ MODULE_DEVICE_TABLE(pci, pciidlist); static struct drm_driver kms_driver; -static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary); - kfree(ap); - - return 0; -} - - static int amdgpu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -609,7 +587,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, return ret; /* Get rid of things like offb */ - ret = amdgpu_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "amdgpudrmfb"); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH v2 00/12] remove_conflicting_framebuffers() cleanup
On Fri, Aug 31, 2018 at 10:07:42AM +0100, Chris Wilson wrote: [...] > Ahah, someone is looking at remove_conflicting_framebuffers(). May I > interest you in a use-after-free? > [ 378.423513] stack segment: [#1] PREEMPT SMP PTI > [ 378.423530] CPU: 1 PID: 4338 Comm: pm_rpm Tainted: G U > 4.19.0-rc1-CI-CI_DRM_4746+ #1 > [ 378.423548] Hardware name: To Be Filled By O.E.M. To Be Filled By > O.E.M./J4205-ITX, BIOS P1.10 09/29/2016 > [ 378.423570] RIP: 0010:do_remove_conflicting_framebuffers+0x56/0x170 > [ 378.423587] Code: 49 8b 45 00 48 85 c0 74 50 f6 40 0a 08 74 4a 4d 85 e4 48 > 8b a8 78 04 00 00 74 1f 48 85 ed 74 1a 41 8b 0c 24 31 db 85 c9 74 10 <8b> 55 > 00 85 d2 75 42 83 c3 01 41 39 1c 24 77 f0 48 85 ed 74 1a 45 > [ 378.423620] RSP: 0018:c91dfa88 EFLAGS: 00010202 > [ 378.423632] RAX: 880274470008 RBX: RCX: > 0001 > [ 378.423646] RDX: 0001 RSI: a025c634 RDI: > 88025cc3b428 > [ 378.423660] RBP: 6b6b6b6b6b6b6b6b R08: 1edaddfa R09: > a025c634 > [ 378.423673] R10: c91dfae8 R11: 820de938 R12: > 88025cc3b428 > [ 378.423687] R13: 8234ca20 R14: 8234cb20 R15: > 0001 > [ 378.423701] FS: 7fcf03d0a980() GS:880277e8() > knlGS: > [ 378.423717] CS: 0010 DS: ES: CR0: 80050033 > [ 378.423729] CR2: 7fffece1fdb8 CR3: 0001fe32e000 CR4: > 003406e0 > [ 378.423742] Call Trace: > [ 378.423756] remove_conflicting_framebuffers+0x28/0x40 > [ 378.423856] i915_driver_load+0x7f5/0x10c0 [i915] [...] Looks like registered_fb[] entry is pointing to (partially?) freed or corrupted fb_info, but I can't see how this could be an effect of remove_conflicting_framebuffers(). Best Regards, Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 04/13] fbdev: add remove_conflicting_pci_framebuffers()
Almost all PCI drivers using remove_conflicting_framebuffers() wrap it with the same code. --- v2: add kerneldoc for DRM helper v3: propagate remove_conflicting_framebuffers() return value + move kerneldoc to where function is implemented Signed-off-by: Michał Mirosław --- drivers/video/fbdev/core/fbmem.c | 35 include/drm/drm_fb_helper.h | 12 +++ include/linux/fb.h | 2 ++ 3 files changed, 49 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 2de93b5014e3..cd96b1c62bbe 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -1812,6 +1813,40 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, } EXPORT_SYMBOL(remove_conflicting_framebuffers); +/** + * remove_conflicting_pci_framebuffers - remove firmware-configured framebuffers for PCI devices + * @pdev: PCI device + * @resource_id: index of PCI BAR configuring framebuffer memory + * @name: requesting driver name + * + * This function removes framebuffer devices (eg. initialized by firmware) + * using memory range configured for @pdev's BAR @resource_id. + * + * The function assumes that PCI device with shadowed ROM drives a primary + * display and so kicks out vga16fb. + */ +int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const char *name) +{ + struct apertures_struct *ap; + bool primary = false; + int err; + + ap = alloc_apertures(1); + if (!ap) + return -ENOMEM; + + ap->ranges[0].base = pci_resource_start(pdev, res_id); + ap->ranges[0].size = pci_resource_len(pdev, res_id); +#ifdef CONFIG_X86 + primary = pdev->resource[PCI_ROM_RESOURCE].flags & + IORESOURCE_ROM_SHADOW; +#endif + err = remove_conflicting_framebuffers(ap, name, primary); + kfree(ap); + return err; +} +EXPORT_SYMBOL(remove_conflicting_pci_framebuffers); + /** * register_framebuffer - registers a frame buffer device * @fb_info: frame buffer info structure diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index b069433e7fc1..20ea856db900 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -577,4 +577,16 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, #endif } +static inline int +drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, + int resource_id, + const char *name) +{ +#if IS_REACHABLE(CONFIG_FB) + return remove_conflicting_pci_framebuffers(pdev, resource_id, name); +#else + return 0; +#endif +} + #endif diff --git a/include/linux/fb.h b/include/linux/fb.h index aa74a228bb92..abeffd55b66a 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -632,6 +632,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, extern int register_framebuffer(struct fb_info *fb_info); extern int unregister_framebuffer(struct fb_info *fb_info); extern int unlink_framebuffer(struct fb_info *fb_info); +extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, + const char *name); extern int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary); extern int fb_prepare_logo(struct fb_info *fb_info, int rotate); -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 06/13] drm/bochs: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/bochs/bochs_drv.c | 18 +- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c index 7b20318483e4..c61b40c72b62 100644 --- a/drivers/gpu/drm/bochs/bochs_drv.c +++ b/drivers/gpu/drm/bochs/bochs_drv.c @@ -143,22 +143,6 @@ static const struct dev_pm_ops bochs_pm_ops = { /* -- */ /* pci interface */ -static int bochs_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - drm_fb_helper_remove_conflicting_framebuffers(ap, "bochsdrmfb", false); - kfree(ap); - - return 0; -} - static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -171,7 +155,7 @@ static int bochs_pci_probe(struct pci_dev *pdev, return -ENOMEM; } - ret = bochs_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "bochsdrmfb"); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 02/13] fbdev: allow apertures == NULL in remove_conflicting_framebuffers()
Interpret (otherwise-invalid) NULL apertures argument to mean all-memory range. This will allow to remove several duplicates of this code from drivers in following patches. Signed-off-by: Michał Mirosław Acked-by: Bartlomiej Zolnierkiewicz --- v2: added kerneldoc to corresponding DRM helper v3: split kerneldoc to another patch --- drivers/video/fbdev/core/fbmem.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 30a18d4c9de4..0df148eb4699 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1779,11 +1779,25 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary) { int ret; + bool do_free = false; + + if (!a) { + a = alloc_apertures(1); + if (!a) + return -ENOMEM; + + a->ranges[0].base = 0; + a->ranges[0].size = ~0; + do_free = true; + } mutex_lock(_lock); ret = do_remove_conflicting_framebuffers(a, name, primary); mutex_unlock(_lock); + if (do_free) + kfree(a); + return ret; } EXPORT_SYMBOL(remove_conflicting_framebuffers); -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 10/13] drm/virtio: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 +++- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c index 7df8d0c9026a..115ed546ca4e 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c +++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c @@ -28,26 +28,6 @@ #include "virtgpu_drv.h" -static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev) -{ - struct apertures_struct *ap; - bool primary; - - ap = alloc_apertures(1); - if (!ap) - return; - - ap->ranges[0].base = pci_resource_start(pci_dev, 0); - ap->ranges[0].size = pci_resource_len(pci_dev, 0); - - primary = pci_dev->resource[PCI_ROM_RESOURCE].flags - & IORESOURCE_ROM_SHADOW; - - drm_fb_helper_remove_conflicting_framebuffers(ap, "virtiodrmfb", primary); - - kfree(ap); -} - int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) { struct drm_device *dev; @@ -69,7 +49,9 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) pname); dev->pdev = pdev; if (vga) - virtio_pci_kick_out_firmware_fb(pdev); + drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, + 0, + "virtiodrmfb"); snprintf(unique, sizeof(unique), "pci:%s", pname); ret = drm_dev_set_unique(dev, unique); -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 09/13] drm/radeon: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Alex Deucher Acked-by: Daniel Vetter --- drivers/gpu/drm/radeon/radeon_drv.c | 23 +-- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index b28288a781ef..36c98a0ec991 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -311,27 +311,6 @@ static struct drm_driver kms_driver; bool radeon_device_is_virtual(void); -static int radeon_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "radeondrmfb", primary); - kfree(ap); - - return 0; -} - static int radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -341,7 +320,7 @@ static int radeon_pci_probe(struct pci_dev *pdev, return -EPROBE_DEFER; /* Get rid of things like offb */ - ret = radeon_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "radeondrmfb"); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 03/13] fbdev: add kerneldoc do remove_conflicting_framebuffers()
Document remove_conflicting_framebuffers() behaviour. Signed-off-by: Michał Mirosław --- drivers/video/fbdev/core/fbmem.c | 10 ++ 1 file changed, 10 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 0df148eb4699..2de93b5014e3 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1775,6 +1775,16 @@ int unlink_framebuffer(struct fb_info *fb_info) } EXPORT_SYMBOL(unlink_framebuffer); +/** + * remove_conflicting_framebuffers - remove firmware-configured framebuffers + * @a: memory range, users of which are to be removed + * @name: requesting driver name + * @primary: also kick vga16fb if present + * + * This function removes framebuffer devices (initialized by firmware/bootloader) + * which use memory range described by @a. If @a is NULL all such devices are + * removed. + */ int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary) { -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v3 08/13] drm/mgag200: use simpler remove_conflicting_pci_framebuffers()
Remove duplicated call, while at it. Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/mgag200/mgag200_drv.c | 21 + drivers/gpu/drm/mgag200/mgag200_main.c | 9 - 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index 74cdde2ee474..ac6af4bd9df6 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -42,29 +42,10 @@ static const struct pci_device_id pciidlist[] = { MODULE_DEVICE_TABLE(pci, pciidlist); -static void mgag200_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "mgag200drmfb", primary); - kfree(ap); -} - static int mga_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - mgag200_kick_out_firmware_fb(pdev); + drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "mgag200drmfb"); return drm_get_pci_dev(pdev, ent, ); } diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 780f983b0294..79d54103d470 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -124,20 +124,11 @@ static int mga_probe_vram(struct mga_device *mdev, void __iomem *mem) static int mga_vram_init(struct mga_device *mdev) { void __iomem *mem; - struct apertures_struct *aper = alloc_apertures(1); - if (!aper) - return -ENOMEM; /* BAR 0 is VRAM */ mdev->mc.vram_base = pci_resource_start(mdev->dev->pdev, 0); mdev->mc.vram_window = pci_resource_len(mdev->dev->pdev, 0); - aper->ranges[0].base = mdev->mc.vram_base; - aper->ranges[0].size = mdev->mc.vram_window; - - drm_fb_helper_remove_conflicting_framebuffers(aper, "mgafb", true); - kfree(aper); - if (!devm_request_mem_region(mdev->dev->dev, mdev->mc.vram_base, mdev->mc.vram_window, "mgadrmfb_vram")) { DRM_ERROR("can't reserve VRAM\n"); -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 11/12] drm/sun4i: use simpler remove_conflicting_framebuffers(NULL)
Use remove_conflicting_framebuffers(NULL) instead of duplicating it. Signed-off-by: Michał Mirosław Acked-by: Maxime Ripard Acked-by: Daniel Vetter --- drivers/gpu/drm/sun4i/sun4i_drv.c | 18 +- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index 50d19605c38f..555b5db8036f 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -60,22 +60,6 @@ static struct drm_driver sun4i_drv_driver = { /* Frame Buffer Operations */ }; -static void sun4i_remove_framebuffers(void) -{ - struct apertures_struct *ap; - - ap = alloc_apertures(1); - if (!ap) - return; - - /* The framebuffer can be located anywhere in RAM */ - ap->ranges[0].base = 0; - ap->ranges[0].size = ~0; - - drm_fb_helper_remove_conflicting_framebuffers(ap, "sun4i-drm-fb", false); - kfree(ap); -} - static int sun4i_drv_bind(struct device *dev) { struct drm_device *drm; @@ -118,7 +102,7 @@ static int sun4i_drv_bind(struct device *dev) drm->irq_enabled = true; /* Remove early framebuffers (ie. simplefb) */ - sun4i_remove_framebuffers(); + drm_fb_helper_remove_conflicting_framebuffers(NULL, "sun4i-drm-fb", false); /* Create our framebuffer */ ret = sun4i_framebuffer_init(drm); -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 06/12] drm/cirrus: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/cirrus/cirrus_drv.c | 23 +-- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c index 69c4e352dd78..85ed8657c862 100644 --- a/drivers/gpu/drm/cirrus/cirrus_drv.c +++ b/drivers/gpu/drm/cirrus/cirrus_drv.c @@ -42,33 +42,12 @@ static const struct pci_device_id pciidlist[] = { }; -static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary); - kfree(ap); - - return 0; -} - static int cirrus_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int ret; - ret = cirrus_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "cirrusdrmfb"); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 09/12] drm/virtio: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 +++- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c index 7df8d0c9026a..115ed546ca4e 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c +++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c @@ -28,26 +28,6 @@ #include "virtgpu_drv.h" -static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev) -{ - struct apertures_struct *ap; - bool primary; - - ap = alloc_apertures(1); - if (!ap) - return; - - ap->ranges[0].base = pci_resource_start(pci_dev, 0); - ap->ranges[0].size = pci_resource_len(pci_dev, 0); - - primary = pci_dev->resource[PCI_ROM_RESOURCE].flags - & IORESOURCE_ROM_SHADOW; - - drm_fb_helper_remove_conflicting_framebuffers(ap, "virtiodrmfb", primary); - - kfree(ap); -} - int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) { struct drm_device *dev; @@ -69,7 +49,9 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) pname); dev->pdev = pdev; if (vga) - virtio_pci_kick_out_firmware_fb(pdev); + drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, + 0, + "virtiodrmfb"); snprintf(unique, sizeof(unique), "pci:%s", pname); ret = drm_dev_set_unique(dev, unique); -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 12/12] drm/tegra: kick out simplefb
Kick out firmware fb when loading Tegra driver. Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/tegra/drm.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 7afe2f635f74..b51ec138fed2 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1203,6 +1203,10 @@ static int host1x_drm_probe(struct host1x_device *dev) dev_set_drvdata(>dev, drm); + err = drm_fb_helper_remove_conflicting_framebuffers(NULL, "tegradrmfb", false); + if (err < 0) + goto unref; + err = drm_dev_register(drm, 0); if (err < 0) goto unref; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 07/12] drm/mgag200: use simpler remove_conflicting_pci_framebuffers()
Remove duplicated call, while at it. Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/mgag200/mgag200_drv.c | 21 + drivers/gpu/drm/mgag200/mgag200_main.c | 9 - 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index 74cdde2ee474..ac6af4bd9df6 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -42,29 +42,10 @@ static const struct pci_device_id pciidlist[] = { MODULE_DEVICE_TABLE(pci, pciidlist); -static void mgag200_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "mgag200drmfb", primary); - kfree(ap); -} - static int mga_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - mgag200_kick_out_firmware_fb(pdev); + drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "mgag200drmfb"); return drm_get_pci_dev(pdev, ent, ); } diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 780f983b0294..79d54103d470 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -124,20 +124,11 @@ static int mga_probe_vram(struct mga_device *mdev, void __iomem *mem) static int mga_vram_init(struct mga_device *mdev) { void __iomem *mem; - struct apertures_struct *aper = alloc_apertures(1); - if (!aper) - return -ENOMEM; /* BAR 0 is VRAM */ mdev->mc.vram_base = pci_resource_start(mdev->dev->pdev, 0); mdev->mc.vram_window = pci_resource_len(mdev->dev->pdev, 0); - aper->ranges[0].base = mdev->mc.vram_base; - aper->ranges[0].size = mdev->mc.vram_window; - - drm_fb_helper_remove_conflicting_framebuffers(aper, "mgafb", true); - kfree(aper); - if (!devm_request_mem_region(mdev->dev->dev, mdev->mc.vram_base, mdev->mc.vram_window, "mgadrmfb_vram")) { DRM_ERROR("can't reserve VRAM\n"); -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 01/12] fbdev: show fbdev number for debugging
Signed-off-by: Michał Mirosław Acked-by: Bartlomiej Zolnierkiewicz Acked-by: Daniel Vetter --- drivers/video/fbdev/core/fbmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index f741ba8df01b..30a18d4c9de4 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1618,8 +1618,8 @@ static int do_remove_conflicting_framebuffers(struct apertures_struct *a, (primary && gen_aper && gen_aper->count && gen_aper->ranges[0].base == VGA_FB_PHYS)) { - printk(KERN_INFO "fb: switching to %s from %s\n", - name, registered_fb[i]->fix.id); + printk(KERN_INFO "fb%d: switching to %s from %s\n", + i, name, registered_fb[i]->fix.id); ret = do_unregister_framebuffer(registered_fb[i]); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 04/12] drm/amdgpu: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Alex Deucher Acked-by: Daniel Vetter --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 +--- 1 file changed, 1 insertion(+), 23 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index 0b19482b36b8..9b6e037719db 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -560,28 +560,6 @@ MODULE_DEVICE_TABLE(pci, pciidlist); static struct drm_driver kms_driver; -static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary); - kfree(ap); - - return 0; -} - - static int amdgpu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -609,7 +587,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, return ret; /* Get rid of things like offb */ - ret = amdgpu_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "amdgpudrmfb"); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 03/12] fbdev: add remove_conflicting_pci_framebuffers()
Almost all PCI drivers using remove_conflicting_framebuffers() wrap it with the same code. Signed-off-by: Michał Mirosław [for v1] Acked-by: Bartlomiej Zolnierkiewicz --- v2: add kerneldoc for DRM helper --- drivers/video/fbdev/core/fbmem.c | 22 ++ include/drm/drm_fb_helper.h | 24 include/linux/fb.h | 2 ++ 3 files changed, 48 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 0df148eb4699..927e016487e9 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -1802,6 +1803,27 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, } EXPORT_SYMBOL(remove_conflicting_framebuffers); +int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const char *name) +{ + struct apertures_struct *ap; + bool primary = false; + + ap = alloc_apertures(1); + if (!ap) + return -ENOMEM; + + ap->ranges[0].base = pci_resource_start(pdev, res_id); + ap->ranges[0].size = pci_resource_len(pdev, res_id); +#ifdef CONFIG_X86 + primary = pdev->resource[PCI_ROM_RESOURCE].flags & + IORESOURCE_ROM_SHADOW; +#endif + remove_conflicting_framebuffers(ap, name, primary); + kfree(ap); + return 0; +} +EXPORT_SYMBOL(remove_conflicting_pci_framebuffers); + /** * register_framebuffer - registers a frame buffer device * @fb_info: frame buffer info structure diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 1c1e53abb25d..6e1fc52d1b1b 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -587,4 +587,28 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, #endif } +/** + * drm_fb_helper_remove_conflicting_framebuffers - remove firmware framebuffers for PCI devices + * @pdev: PCI device being driven + * @resource_id: index of PCI BAR configuring framebuffer memory + * @name: requesting driver name + * + * This function removes framebuffer devices (eg. initialized by firmware) + * using memory range configured for @pdev's BAR @resource_id. + * + * The function assumes that PCI device with shadowed ROM is drives a primary + * display and so kicks out vga16fb. + */ +static inline int +drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, + int resource_id, + const char *name) +{ +#if IS_REACHABLE(CONFIG_FB) + return remove_conflicting_pci_framebuffers(pdev, resource_id, name); +#else + return 0; +#endif +} + #endif diff --git a/include/linux/fb.h b/include/linux/fb.h index aa74a228bb92..abeffd55b66a 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -632,6 +632,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, extern int register_framebuffer(struct fb_info *fb_info); extern int unregister_framebuffer(struct fb_info *fb_info); extern int unlink_framebuffer(struct fb_info *fb_info); +extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, + const char *name); extern int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary); extern int fb_prepare_logo(struct fb_info *fb_info, int rotate); -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 00/12] remove_conflicting_framebuffers() cleanup
This series cleans up duplicated code for replacing firmware FB driver with proper DRI driver and adds handover support to Tegra driver. This is a sligtly updated version of a series sent on 24 Nov 2017. v2: - rebased on current drm-next - dropped staging/sm750fb changes - added kernel docs for DRM helpers Michał Mirosław (12): fbdev: show fbdev number for debugging fbdev: allow apertures == NULL in remove_conflicting_framebuffers() fbdev: add remove_conflicting_pci_framebuffers() drm/amdgpu: use simpler remove_conflicting_pci_framebuffers() drm/bochs: use simpler remove_conflicting_pci_framebuffers() drm/cirrus: use simpler remove_conflicting_pci_framebuffers() drm/mgag200: use simpler remove_conflicting_pci_framebuffers() drm/radeon: use simpler remove_conflicting_pci_framebuffers() drm/virtio: use simpler remove_conflicting_pci_framebuffers() drm/vc4: use simpler remove_conflicting_framebuffers(NULL) drm/sun4i: use simpler remove_conflicting_framebuffers(NULL) drm/tegra: kick out simplefb drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 24 +- drivers/gpu/drm/bochs/bochs_drv.c| 18 +-- drivers/gpu/drm/cirrus/cirrus_drv.c | 23 +- drivers/gpu/drm/mgag200/mgag200_drv.c| 21 + drivers/gpu/drm/mgag200/mgag200_main.c | 9 -- drivers/gpu/drm/radeon/radeon_drv.c | 23 +- drivers/gpu/drm/sun4i/sun4i_drv.c| 18 +-- drivers/gpu/drm/tegra/drm.c | 4 +++ drivers/gpu/drm/vc4/vc4_drv.c| 20 +--- drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 ++ drivers/video/fbdev/core/fbmem.c | 40 ++-- include/drm/drm_fb_helper.h | 34 include/linux/fb.h | 2 ++ 13 files changed, 88 insertions(+), 172 deletions(-) -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 10/12] drm/vc4: use simpler remove_conflicting_framebuffers(NULL)
Use remove_conflicting_framebuffers(NULL) instead of open-coding it. Signed-off-by: Michał Mirosław Acked-by: Eric Anholt Acked-by: Daniel Vetter --- drivers/gpu/drm/vc4/vc4_drv.c | 20 +--- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index 94b99c90425a..96bb90325995 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c @@ -246,24 +246,6 @@ static void vc4_match_add_drivers(struct device *dev, } } -static void vc4_kick_out_firmware_fb(void) -{ - struct apertures_struct *ap; - - ap = alloc_apertures(1); - if (!ap) - return; - - /* Since VC4 is a UMA device, the simplefb node may have been -* located anywhere in memory. -*/ - ap->ranges[0].base = 0; - ap->ranges[0].size = ~0; - - drm_fb_helper_remove_conflicting_framebuffers(ap, "vc4drmfb", false); - kfree(ap); -} - static int vc4_drm_bind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -296,7 +278,7 @@ static int vc4_drm_bind(struct device *dev) if (ret) goto gem_destroy; - vc4_kick_out_firmware_fb(); + drm_fb_helper_remove_conflicting_framebuffers(NULL, "vc4drmfb", false); ret = drm_dev_register(drm, 0); if (ret < 0) -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 08/12] drm/radeon: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Alex Deucher Acked-by: Daniel Vetter --- drivers/gpu/drm/radeon/radeon_drv.c | 23 +-- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index b28288a781ef..36c98a0ec991 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -311,27 +311,6 @@ static struct drm_driver kms_driver; bool radeon_device_is_virtual(void); -static int radeon_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "radeondrmfb", primary); - kfree(ap); - - return 0; -} - static int radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -341,7 +320,7 @@ static int radeon_pci_probe(struct pci_dev *pdev, return -EPROBE_DEFER; /* Get rid of things like offb */ - ret = radeon_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "radeondrmfb"); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 05/12] drm/bochs: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław Acked-by: Daniel Vetter --- drivers/gpu/drm/bochs/bochs_drv.c | 18 +- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c index 7b20318483e4..c61b40c72b62 100644 --- a/drivers/gpu/drm/bochs/bochs_drv.c +++ b/drivers/gpu/drm/bochs/bochs_drv.c @@ -143,22 +143,6 @@ static const struct dev_pm_ops bochs_pm_ops = { /* -- */ /* pci interface */ -static int bochs_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - drm_fb_helper_remove_conflicting_framebuffers(ap, "bochsdrmfb", false); - kfree(ap); - - return 0; -} - static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -171,7 +155,7 @@ static int bochs_pci_probe(struct pci_dev *pdev, return -ENOMEM; } - ret = bochs_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "bochsdrmfb"); if (ret) return ret; -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH v2 02/12] fbdev: allow apertures == NULL in remove_conflicting_framebuffers()
Interpret (otherwise-invalid) NULL apertures argument to mean all-memory range. This will allow to remove several duplicates of this code from drivers in following patches. Signed-off-by: Michał Mirosław [for v1] Acked-by: Bartlomiej Zolnierkiewicz --- v2: added kerneldoc to corresponding DRM helper --- drivers/video/fbdev/core/fbmem.c | 14 ++ include/drm/drm_fb_helper.h | 10 ++ 2 files changed, 24 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 30a18d4c9de4..0df148eb4699 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1779,11 +1779,25 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary) { int ret; + bool do_free = false; + + if (!a) { + a = alloc_apertures(1); + if (!a) + return -ENOMEM; + + a->ranges[0].base = 0; + a->ranges[0].size = ~0; + do_free = true; + } mutex_lock(_lock); ret = do_remove_conflicting_framebuffers(a, name, primary); mutex_unlock(_lock); + if (do_free) + kfree(a); + return ret; } EXPORT_SYMBOL(remove_conflicting_framebuffers); diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index b069433e7fc1..1c1e53abb25d 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -566,6 +566,16 @@ static inline void drm_fb_helper_output_poll_changed(struct drm_device *dev) #endif +/** + * drm_fb_helper_remove_conflicting_framebuffers - remove firmware framebuffers + * @a: memory range, users of which are to be removed + * @name: requesting driver name + * @primary: also kick vga16fb if present + * + * This function removes framebuffer devices (eg. initialized by firmware) + * which use memory range described by @a. If @a is NULL all such devices are + * removed. + */ static inline int drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary) -- 2.18.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 07/13] drm/radeon: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/radeon/radeon_drv.c | 23 +-- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/gpu/drm/radeon/radeon_drv.c b/drivers/gpu/drm/radeon/radeon_drv.c index 31dd04f6baa1..49f51b17ae81 100644 --- a/drivers/gpu/drm/radeon/radeon_drv.c +++ b/drivers/gpu/drm/radeon/radeon_drv.c @@ -311,27 +311,6 @@ static struct drm_driver kms_driver; bool radeon_device_is_virtual(void); -static int radeon_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "radeondrmfb", primary); - kfree(ap); - - return 0; -} - static int radeon_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -341,7 +320,7 @@ static int radeon_pci_probe(struct pci_dev *pdev, return -EPROBE_DEFER; /* Get rid of things like offb */ - ret = radeon_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "radeondrmfb"); if (ret) return ret; -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 09/13] staging: sm750fb: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/staging/sm750fb/sm750.c | 22 +- 1 file changed, 1 insertion(+), 21 deletions(-) diff --git a/drivers/staging/sm750fb/sm750.c b/drivers/staging/sm750fb/sm750.c index 67207b0554cd..0590fc45c493 100644 --- a/drivers/staging/sm750fb/sm750.c +++ b/drivers/staging/sm750fb/sm750.c @@ -1053,26 +1053,6 @@ static int sm750fb_frambuffer_alloc(struct sm750_dev *sm750_dev, int fbidx) return err; } -static int lynxfb_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & - IORESOURCE_ROM_SHADOW; -#endif - remove_conflicting_framebuffers(ap, "sm750_fb1", primary); - kfree(ap); - return 0; -} - static int lynxfb_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -1081,7 +1061,7 @@ static int lynxfb_pci_probe(struct pci_dev *pdev, int fbidx; int err; - err = lynxfb_kick_out_firmware_fb(pdev); + err = remove_conflicting_pci_framebuffers(pdev, 0, "sm750_fb1"); if (err) return err; -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 00/13] remove_conflicting_framebuffers() cleanup
This series cleans up duplicated code for replacing firmware FB driver with proper DRI driver and adds handover support to Tegra driver. The last patch is here because it uses new semantics of remove_conflicting_framebuffers() from this series. This can be considered independently, though. --- Michał Mirosław (13): fbdev: show fbdev number for debugging fbdev: add remove_conflicting_pci_framebuffers() drm/amdgpu: use simpler remove_conflicting_pci_framebuffers() drm/bochs: use simpler remove_conflicting_pci_framebuffers() drm/cirrus: use simpler remove_conflicting_pci_framebuffers() drm/mgag200: use simpler remove_conflicting_pci_framebuffers() drm/radeon: use simpler remove_conflicting_pci_framebuffers() drm/virtio: use simpler remove_conflicting_pci_framebuffers() staging: sm750fb: use simpler remove_conflicting_pci_framebuffers() fbdev: allow apertures == NULL in remove_conflicting_framebuffers() drm/vc4: use simpler remove_conflicting_framebuffers(NULL) drm/sun4i: use simpler remove_conflicting_framebuffers(NULL) drm/tegra: kick out simplefb drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 23 +- drivers/gpu/drm/bochs/bochs_drv.c| 18 +- drivers/gpu/drm/cirrus/cirrus_drv.c | 23 +- drivers/gpu/drm/mgag200/mgag200_drv.c| 21 + drivers/gpu/drm/mgag200/mgag200_main.c | 9 --- drivers/gpu/drm/radeon/radeon_drv.c | 23 +- drivers/gpu/drm/sun4i/sun4i_drv.c| 18 +- drivers/gpu/drm/tegra/drm.c | 4 drivers/gpu/drm/vc4/vc4_drv.c| 20 +--- drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 +++ drivers/staging/sm750fb/sm750.c | 22 +- drivers/video/fbdev/core/fbmem.c | 40 ++-- include/drm/drm_fb_helper.h | 12 ++ include/linux/fb.h | 2 ++ 14 files changed, 67 insertions(+), 192 deletions(-) -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 10/13] fbdev: allow apertures == NULL in remove_conflicting_framebuffers()
Interpret (otherwise-invalid) NULL apertures argument to mean all-memory range. This will allow to remove several duplicates of this code from drivers in following patches. Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/video/fbdev/core/fbmem.c | 14 ++ 1 file changed, 14 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 5ea980e5d3b7..927e016487e9 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1780,11 +1780,25 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary) { int ret; + bool do_free = false; + + if (!a) { + a = alloc_apertures(1); + if (!a) + return -ENOMEM; + + a->ranges[0].base = 0; + a->ranges[0].size = ~0; + do_free = true; + } mutex_lock(_lock); ret = do_remove_conflicting_framebuffers(a, name, primary); mutex_unlock(_lock); + if (do_free) + kfree(a); + return ret; } EXPORT_SYMBOL(remove_conflicting_framebuffers); -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 06/13] drm/mgag200: use simpler remove_conflicting_pci_framebuffers()
Remove duplicated call, while at it. Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/mgag200/mgag200_drv.c | 21 + drivers/gpu/drm/mgag200/mgag200_main.c | 9 - 2 files changed, 1 insertion(+), 29 deletions(-) diff --git a/drivers/gpu/drm/mgag200/mgag200_drv.c b/drivers/gpu/drm/mgag200/mgag200_drv.c index 74cdde2ee474..ac6af4bd9df6 100644 --- a/drivers/gpu/drm/mgag200/mgag200_drv.c +++ b/drivers/gpu/drm/mgag200/mgag200_drv.c @@ -42,29 +42,10 @@ static const struct pci_device_id pciidlist[] = { MODULE_DEVICE_TABLE(pci, pciidlist); -static void mgag200_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "mgag200drmfb", primary); - kfree(ap); -} - static int mga_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { - mgag200_kick_out_firmware_fb(pdev); + drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "mgag200drmfb"); return drm_get_pci_dev(pdev, ent, ); } diff --git a/drivers/gpu/drm/mgag200/mgag200_main.c b/drivers/gpu/drm/mgag200/mgag200_main.c index 780f983b0294..79d54103d470 100644 --- a/drivers/gpu/drm/mgag200/mgag200_main.c +++ b/drivers/gpu/drm/mgag200/mgag200_main.c @@ -124,20 +124,11 @@ static int mga_probe_vram(struct mga_device *mdev, void __iomem *mem) static int mga_vram_init(struct mga_device *mdev) { void __iomem *mem; - struct apertures_struct *aper = alloc_apertures(1); - if (!aper) - return -ENOMEM; /* BAR 0 is VRAM */ mdev->mc.vram_base = pci_resource_start(mdev->dev->pdev, 0); mdev->mc.vram_window = pci_resource_len(mdev->dev->pdev, 0); - aper->ranges[0].base = mdev->mc.vram_base; - aper->ranges[0].size = mdev->mc.vram_window; - - drm_fb_helper_remove_conflicting_framebuffers(aper, "mgafb", true); - kfree(aper); - if (!devm_request_mem_region(mdev->dev->dev, mdev->mc.vram_base, mdev->mc.vram_window, "mgadrmfb_vram")) { DRM_ERROR("can't reserve VRAM\n"); -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 13/13] drm/tegra: kick out simplefb
Kick out firmware fb when loading tegra driver. Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/tegra/drm.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 943bdf88c4a2..1ec66ae29839 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1239,6 +1239,10 @@ static int host1x_drm_probe(struct host1x_device *dev) dev_set_drvdata(>dev, drm); + err = drm_fb_helper_remove_conflicting_framebuffers(NULL, "tegradrmfb", false); + if (err < 0) + goto unref; + err = drm_dev_register(drm, 0); if (err < 0) goto unref; -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 08/13] drm/virtio: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/virtio/virtgpu_drm_bus.c | 24 +++- 1 file changed, 3 insertions(+), 21 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c index 7df8d0c9026a..115ed546ca4e 100644 --- a/drivers/gpu/drm/virtio/virtgpu_drm_bus.c +++ b/drivers/gpu/drm/virtio/virtgpu_drm_bus.c @@ -28,26 +28,6 @@ #include "virtgpu_drv.h" -static void virtio_pci_kick_out_firmware_fb(struct pci_dev *pci_dev) -{ - struct apertures_struct *ap; - bool primary; - - ap = alloc_apertures(1); - if (!ap) - return; - - ap->ranges[0].base = pci_resource_start(pci_dev, 0); - ap->ranges[0].size = pci_resource_len(pci_dev, 0); - - primary = pci_dev->resource[PCI_ROM_RESOURCE].flags - & IORESOURCE_ROM_SHADOW; - - drm_fb_helper_remove_conflicting_framebuffers(ap, "virtiodrmfb", primary); - - kfree(ap); -} - int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) { struct drm_device *dev; @@ -69,7 +49,9 @@ int drm_virtio_init(struct drm_driver *driver, struct virtio_device *vdev) pname); dev->pdev = pdev; if (vga) - virtio_pci_kick_out_firmware_fb(pdev); + drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, + 0, + "virtiodrmfb"); snprintf(unique, sizeof(unique), "pci:%s", pname); ret = drm_dev_set_unique(dev, unique); -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 12/13] drm/sun4i: use simpler remove_conflicting_framebuffers(NULL)
Use remove_conflicting_framebuffers(NULL) instead of duplicating it. Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/sun4i/sun4i_drv.c | 18 +- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/gpu/drm/sun4i/sun4i_drv.c b/drivers/gpu/drm/sun4i/sun4i_drv.c index 75c76cdd82bc..febc591e9c17 100644 --- a/drivers/gpu/drm/sun4i/sun4i_drv.c +++ b/drivers/gpu/drm/sun4i/sun4i_drv.c @@ -66,22 +66,6 @@ static struct drm_driver sun4i_drv_driver = { /* Frame Buffer Operations */ }; -static void sun4i_remove_framebuffers(void) -{ - struct apertures_struct *ap; - - ap = alloc_apertures(1); - if (!ap) - return; - - /* The framebuffer can be located anywhere in RAM */ - ap->ranges[0].base = 0; - ap->ranges[0].size = ~0; - - drm_fb_helper_remove_conflicting_framebuffers(ap, "sun4i-drm-fb", false); - kfree(ap); -} - static int sun4i_drv_bind(struct device *dev) { struct drm_device *drm; @@ -123,7 +107,7 @@ static int sun4i_drv_bind(struct device *dev) drm->irq_enabled = true; /* Remove early framebuffers (ie. simplefb) */ - sun4i_remove_framebuffers(); + drm_fb_helper_remove_conflicting_framebuffers(NULL, "sun4i-drm-fb", false); /* Create our framebuffer */ drv->fbdev = sun4i_framebuffer_init(drm); -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
Re: [PATCH 13/13] drm/tegra: kick out simplefb
On Fri, Nov 24, 2017 at 09:50:50PM +0100, Thierry Reding wrote: > On Fri, Nov 24, 2017 at 06:53:34PM +0100, Michał Mirosław wrote: > > Kick out firmware fb when loading tegra driver. > Cool. Can you provide some background on how you tested this? What is > your firmware FB? That'd be useful information to put in the commit > message. Also, nit: "tegra driver" -> "Tegra driver". I checked this on my Asus TF300T, as I use simplefb for initial boot messages. simplefb uses framebuffer set up by the bootloader. Best Regards, Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 05/13] drm/cirrus: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/cirrus/cirrus_drv.c | 23 +-- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/gpu/drm/cirrus/cirrus_drv.c b/drivers/gpu/drm/cirrus/cirrus_drv.c index 69c4e352dd78..85ed8657c862 100644 --- a/drivers/gpu/drm/cirrus/cirrus_drv.c +++ b/drivers/gpu/drm/cirrus/cirrus_drv.c @@ -42,33 +42,12 @@ static const struct pci_device_id pciidlist[] = { }; -static int cirrus_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "cirrusdrmfb", primary); - kfree(ap); - - return 0; -} - static int cirrus_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { int ret; - ret = cirrus_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "cirrusdrmfb"); if (ret) return ret; -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 11/13] drm/vc4: use simpler remove_conflicting_framebuffers(NULL)
Use remove_conflicting_framebuffers(NULL) instead of open-coding it. Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/vc4/vc4_drv.c | 20 +--- 1 file changed, 1 insertion(+), 19 deletions(-) diff --git a/drivers/gpu/drm/vc4/vc4_drv.c b/drivers/gpu/drm/vc4/vc4_drv.c index e3c29729da2e..b65cddb775bb 100644 --- a/drivers/gpu/drm/vc4/vc4_drv.c +++ b/drivers/gpu/drm/vc4/vc4_drv.c @@ -227,24 +227,6 @@ static void vc4_match_add_drivers(struct device *dev, } } -static void vc4_kick_out_firmware_fb(void) -{ - struct apertures_struct *ap; - - ap = alloc_apertures(1); - if (!ap) - return; - - /* Since VC4 is a UMA device, the simplefb node may have been -* located anywhere in memory. -*/ - ap->ranges[0].base = 0; - ap->ranges[0].size = ~0; - - drm_fb_helper_remove_conflicting_framebuffers(ap, "vc4drmfb", false); - kfree(ap); -} - static int vc4_drm_bind(struct device *dev) { struct platform_device *pdev = to_platform_device(dev); @@ -277,7 +259,7 @@ static int vc4_drm_bind(struct device *dev) if (ret) goto gem_destroy; - vc4_kick_out_firmware_fb(); + drm_fb_helper_remove_conflicting_framebuffers(NULL, "vc4drmfb", false); ret = drm_dev_register(drm, 0); if (ret < 0) -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 04/13] drm/bochs: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/bochs/bochs_drv.c | 18 +- 1 file changed, 1 insertion(+), 17 deletions(-) diff --git a/drivers/gpu/drm/bochs/bochs_drv.c b/drivers/gpu/drm/bochs/bochs_drv.c index 7b20318483e4..c61b40c72b62 100644 --- a/drivers/gpu/drm/bochs/bochs_drv.c +++ b/drivers/gpu/drm/bochs/bochs_drv.c @@ -143,22 +143,6 @@ static const struct dev_pm_ops bochs_pm_ops = { /* -- */ /* pci interface */ -static int bochs_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - drm_fb_helper_remove_conflicting_framebuffers(ap, "bochsdrmfb", false); - kfree(ap); - - return 0; -} - static int bochs_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -171,7 +155,7 @@ static int bochs_pci_probe(struct pci_dev *pdev, return -ENOMEM; } - ret = bochs_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "bochsdrmfb"); if (ret) return ret; -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 02/13] fbdev: add remove_conflicting_pci_framebuffers()
Almost all drivers using remove_conflicting_framebuffers() wrap it with the same code. Extract common part from PCI drivers into separate remove_conflicting_pci_framebuffers(). Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/video/fbdev/core/fbmem.c | 22 ++ include/drm/drm_fb_helper.h | 12 include/linux/fb.h | 2 ++ 3 files changed, 36 insertions(+) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index 30a18d4c9de4..5ea980e5d3b7 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -34,6 +34,7 @@ #include #include #include +#include #include @@ -1788,6 +1789,27 @@ int remove_conflicting_framebuffers(struct apertures_struct *a, } EXPORT_SYMBOL(remove_conflicting_framebuffers); +int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, const char *name) +{ + struct apertures_struct *ap; + bool primary = false; + + ap = alloc_apertures(1); + if (!ap) + return -ENOMEM; + + ap->ranges[0].base = pci_resource_start(pdev, res_id); + ap->ranges[0].size = pci_resource_len(pdev, res_id); +#ifdef CONFIG_X86 + primary = pdev->resource[PCI_ROM_RESOURCE].flags & + IORESOURCE_ROM_SHADOW; +#endif + remove_conflicting_framebuffers(ap, name, primary); + kfree(ap); + return 0; +} +EXPORT_SYMBOL(remove_conflicting_pci_framebuffers); + /** * register_framebuffer - registers a frame buffer device * @fb_info: frame buffer info structure diff --git a/include/drm/drm_fb_helper.h b/include/drm/drm_fb_helper.h index 33fe95927742..ac3412290289 100644 --- a/include/drm/drm_fb_helper.h +++ b/include/drm/drm_fb_helper.h @@ -520,4 +520,16 @@ drm_fb_helper_remove_conflicting_framebuffers(struct apertures_struct *a, #endif } +static inline int +drm_fb_helper_remove_conflicting_pci_framebuffers(struct pci_dev *pdev, + int resource_id, + const char *name) +{ +#if IS_REACHABLE(CONFIG_FB) + return remove_conflicting_pci_framebuffers(pdev, resource_id, name); +#else + return 0; +#endif +} + #endif diff --git a/include/linux/fb.h b/include/linux/fb.h index f4386b0ccf40..4196cb09e58e 100644 --- a/include/linux/fb.h +++ b/include/linux/fb.h @@ -624,6 +624,8 @@ extern ssize_t fb_sys_write(struct fb_info *info, const char __user *buf, extern int register_framebuffer(struct fb_info *fb_info); extern int unregister_framebuffer(struct fb_info *fb_info); extern int unlink_framebuffer(struct fb_info *fb_info); +extern int remove_conflicting_pci_framebuffers(struct pci_dev *pdev, int res_id, + const char *name); extern int remove_conflicting_framebuffers(struct apertures_struct *a, const char *name, bool primary); extern int fb_prepare_logo(struct fb_info *fb_info, int rotate); -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 03/13] drm/amdgpu: use simpler remove_conflicting_pci_framebuffers()
Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c | 23 +-- 1 file changed, 1 insertion(+), 22 deletions(-) diff --git a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c index dd2f060d62a8..b726222b7dd4 100644 --- a/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c +++ b/drivers/gpu/drm/amd/amdgpu/amdgpu_drv.c @@ -537,27 +537,6 @@ MODULE_DEVICE_TABLE(pci, pciidlist); static struct drm_driver kms_driver; -static int amdgpu_kick_out_firmware_fb(struct pci_dev *pdev) -{ - struct apertures_struct *ap; - bool primary = false; - - ap = alloc_apertures(1); - if (!ap) - return -ENOMEM; - - ap->ranges[0].base = pci_resource_start(pdev, 0); - ap->ranges[0].size = pci_resource_len(pdev, 0); - -#ifdef CONFIG_X86 - primary = pdev->resource[PCI_ROM_RESOURCE].flags & IORESOURCE_ROM_SHADOW; -#endif - drm_fb_helper_remove_conflicting_framebuffers(ap, "amdgpudrmfb", primary); - kfree(ap); - - return 0; -} - static int amdgpu_pci_probe(struct pci_dev *pdev, const struct pci_device_id *ent) { @@ -580,7 +559,7 @@ static int amdgpu_pci_probe(struct pci_dev *pdev, return ret; /* Get rid of things like offb */ - ret = amdgpu_kick_out_firmware_fb(pdev); + ret = drm_fb_helper_remove_conflicting_pci_framebuffers(pdev, 0, "amdgpudrmfb"); if (ret) return ret; -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 01/13] fbdev: show fbdev number for debugging
Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/video/fbdev/core/fbmem.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/video/fbdev/core/fbmem.c b/drivers/video/fbdev/core/fbmem.c index f741ba8df01b..30a18d4c9de4 100644 --- a/drivers/video/fbdev/core/fbmem.c +++ b/drivers/video/fbdev/core/fbmem.c @@ -1618,8 +1618,8 @@ static int do_remove_conflicting_framebuffers(struct apertures_struct *a, (primary && gen_aper && gen_aper->count && gen_aper->ranges[0].base == VGA_FB_PHYS)) { - printk(KERN_INFO "fb: switching to %s from %s\n", - name, registered_fb[i]->fix.id); + printk(KERN_INFO "fb%d: switching to %s from %s\n", + i, name, registered_fb[i]->fix.id); ret = do_unregister_framebuffer(registered_fb[i]); if (ret) return ret; -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] virtgpu: remove redundant task_comm copying
Remove redundant task name copying because: 1. task->comm is already NUL-terminated 2. virtio_gpu_context_create() trims passed dbgname anyway Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/virtio/virtgpu_kms.c | 6 ++ 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c b/drivers/gpu/drm/virtio/virtgpu_kms.c index 1e1c90b30d4a..6f5c4a8c0ba8 100644 --- a/drivers/gpu/drm/virtio/virtgpu_kms.c +++ b/drivers/gpu/drm/virtio/virtgpu_kms.c @@ -272,20 +272,18 @@ int virtio_gpu_driver_open(struct drm_device *dev, struct drm_file *file) struct virtio_gpu_device *vgdev = dev->dev_private; struct virtio_gpu_fpriv *vfpriv; uint32_t id; - char dbgname[64], tmpname[TASK_COMM_LEN]; + char dbgname[TASK_COMM_LEN]; /* can't create contexts without 3d renderer */ if (!vgdev->has_virgl_3d) return 0; - get_task_comm(tmpname, current); - snprintf(dbgname, sizeof(dbgname), "%s", tmpname); - dbgname[63] = 0; /* allocate a virt GPU context for this opener */ vfpriv = kzalloc(sizeof(*vfpriv), GFP_KERNEL); if (!vfpriv) return -ENOMEM; + get_task_comm(dbgname, current); virtio_gpu_context_create(vgdev, strlen(dbgname), dbgname, ); vfpriv->ctx_id = id; -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm: nouveau: replace magic constant for TASK_COMM_LEN
Client's name is task_comm + pid: use constant for clarity and prepare for changed TASK_COMM_LEN. Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/nouveau/nouveau_drm.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/drivers/gpu/drm/nouveau/nouveau_drm.c b/drivers/gpu/drm/nouveau/nouveau_drm.c index 15a13d09d431..28396d0b0864 100644 --- a/drivers/gpu/drm/nouveau/nouveau_drm.c +++ b/drivers/gpu/drm/nouveau/nouveau_drm.c @@ -830,7 +830,7 @@ nouveau_drm_open(struct drm_device *dev, struct drm_file *fpriv) { struct nouveau_drm *drm = nouveau_drm(dev); struct nouveau_cli *cli; - char name[32], tmpname[TASK_COMM_LEN]; + char name[TASK_COMM_LEN + 16], tmpname[TASK_COMM_LEN]; int ret; /* need to bring up power immediately if opening device */ -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm: tegra: fix NULL deref in debugfs/iova
When IOMMU is off, ->mm_lock is not initialized and ->mm is NULL. Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/tegra/drm.c | 8 +--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/drivers/gpu/drm/tegra/drm.c b/drivers/gpu/drm/tegra/drm.c index 8b7842548b9f..f859c06b8ab0 100644 --- a/drivers/gpu/drm/tegra/drm.c +++ b/drivers/gpu/drm/tegra/drm.c @@ -1033,9 +1033,11 @@ static int tegra_debugfs_iova(struct seq_file *s, void *data) struct tegra_drm *tegra = drm->dev_private; struct drm_printer p = drm_seq_file_printer(s); - mutex_lock(>mm_lock); - drm_mm_print(>mm, ); - mutex_unlock(>mm_lock); + if (tegra->domain) { + mutex_lock(>mm_lock); + drm_mm_print(>mm, ); + mutex_unlock(>mm_lock); + } return 0; } -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH] drm: make DRM_STM default n
Default config value for all other drivers is N. Signed-off-by: Michał Mirosław <mirq-li...@rere.qmqm.pl> --- drivers/gpu/drm/stm/Kconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/drivers/gpu/drm/stm/Kconfig b/drivers/gpu/drm/stm/Kconfig index 4b88223f9aed..5071df28532f 100644 --- a/drivers/gpu/drm/stm/Kconfig +++ b/drivers/gpu/drm/stm/Kconfig @@ -7,7 +7,6 @@ config DRM_STM select DRM_PANEL_BRIDGE select VIDEOMODE_HELPERS select FB_PROVIDE_GET_FB_UNMAPPED_AREA - default y help Enable support for the on-chip display controller on -- 2.11.0 ___ dri-devel mailing list dri-devel@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/dri-devel
[PATCH 4/5] DRM: Add support for the sii902x HDMI/DVI encoder
2011/6/7 Sascha Hauer : [...] > --- /dev/null > +++ b/drivers/gpu/drm/i2c/sii902x.c > @@ -0,0 +1,334 @@ [...] > +static int sii902x_write(struct i2c_client *client, uint8_t addr, uint8_t > val) > +{ > + ? ? ? int ret; > + > + ? ? ? ret = i2c_smbus_write_byte_data(client, addr, val); > + ? ? ? if (ret) { > + ? ? ? ? ? ? ? dev_dbg(>dev, "%s failed with %d\n", __func__, ret); > + ? ? ? } > + ? ? ? return ret; > +} Return value is never tested. > +static irqreturn_t sii902x_detect_handler(int irq, void *data) > +{ > + ? ? ? struct sii902x_priv *priv = data; > + ? ? ? struct i2c_client *client = priv->client; > + ? ? ? int dat; > + > + ? ? ? dat = sii902x_read(client, 0x3D); > + ? ? ? if (dat & 0x1) { > + ? ? ? ? ? ? ? /* cable connection changes */ > + ? ? ? ? ? ? ? if (dat & 0x4) { > + ? ? ? ? ? ? ? ? ? ? ? printk("plugin\n"); > + ? ? ? ? ? ? ? } else { > + ? ? ? ? ? ? ? ? ? ? ? printk("plugout\n"); > + ? ? ? ? ? ? ? } Missing code? > + ? ? ? } > + ? ? ? sii902x_write(client, 0x3D, dat); > + > + ? ? ? return IRQ_HANDLED; > +} [...] > +/* I2C driver functions */ > + > +static int > +sii902x_probe(struct i2c_client *client, const struct i2c_device_id *id) > +{ > + ? ? ? int dat, ret; > + ? ? ? struct sii902x_priv *priv; > + ? ? ? const char *drm_name = "imx-drm.0"; /* FIXME: pass from pdata */ > + ? ? ? int encon_id = 0; /* FIXME: pass from pdata */ > + > + ? ? ? priv = kzalloc(sizeof(*priv), GFP_KERNEL); > + ? ? ? if (!priv) > + ? ? ? ? ? ? ? return -ENOMEM; > + > + ? ? ? priv->client = client; > + > + ? ? ? /* Set 902x in hardware TPI mode on and jump out of D3 state */ > + ? ? ? if (sii902x_write(client, 0xc7, 0x00) < 0) { > + ? ? ? ? ? ? ? dev_err(>dev, "SII902x: cound not find device\n"); > + ? ? ? ? ? ? ? return -ENODEV; Leaks priv. Same on other error paths. > + ? ? ? } [...] > + > + > +static int sii902x_remove(struct i2c_client *client) > +{ > + ? ? ? struct sii902x_priv *priv; > + ? ? ? int ret; > + > + ? ? ? priv = i2c_get_clientdata(client); > + > + ? ? ? ret = drm_encon_unregister(>encon); > + ? ? ? if (ret) > + ? ? ? ? ? ? ? return ret; Leaks priv on error. > + > + ? ? ? kfree(priv); > + > + ? ? ? return 0; > +} [...] Best Regards, Micha? Miros?aw
Re: [PATCH 4/5] DRM: Add support for the sii902x HDMI/DVI encoder
2011/6/7 Sascha Hauer s.ha...@pengutronix.de: [...] --- /dev/null +++ b/drivers/gpu/drm/i2c/sii902x.c @@ -0,0 +1,334 @@ [...] +static int sii902x_write(struct i2c_client *client, uint8_t addr, uint8_t val) +{ + int ret; + + ret = i2c_smbus_write_byte_data(client, addr, val); + if (ret) { + dev_dbg(client-dev, %s failed with %d\n, __func__, ret); + } + return ret; +} Return value is never tested. +static irqreturn_t sii902x_detect_handler(int irq, void *data) +{ + struct sii902x_priv *priv = data; + struct i2c_client *client = priv-client; + int dat; + + dat = sii902x_read(client, 0x3D); + if (dat 0x1) { + /* cable connection changes */ + if (dat 0x4) { + printk(plugin\n); + } else { + printk(plugout\n); + } Missing code? + } + sii902x_write(client, 0x3D, dat); + + return IRQ_HANDLED; +} [...] +/* I2C driver functions */ + +static int +sii902x_probe(struct i2c_client *client, const struct i2c_device_id *id) +{ + int dat, ret; + struct sii902x_priv *priv; + const char *drm_name = imx-drm.0; /* FIXME: pass from pdata */ + int encon_id = 0; /* FIXME: pass from pdata */ + + priv = kzalloc(sizeof(*priv), GFP_KERNEL); + if (!priv) + return -ENOMEM; + + priv-client = client; + + /* Set 902x in hardware TPI mode on and jump out of D3 state */ + if (sii902x_write(client, 0xc7, 0x00) 0) { + dev_err(client-dev, SII902x: cound not find device\n); + return -ENODEV; Leaks priv. Same on other error paths. + } [...] + + +static int sii902x_remove(struct i2c_client *client) +{ + struct sii902x_priv *priv; + int ret; + + priv = i2c_get_clientdata(client); + + ret = drm_encon_unregister(priv-encon); + if (ret) + return ret; Leaks priv on error. + + kfree(priv); + + return 0; +} [...] Best Regards, Michał Mirosław ___ dri-devel mailing list dri-devel@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/dri-devel