From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id 7821CC433FE for ; Wed, 2 Nov 2022 09:33:37 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:In-Reply-To:From:References:Cc:To: Subject:MIME-Version:Date:Message-ID:Reply-To:Content-ID:Content-Description: Resent-Date:Resent-From:Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID: List-Owner; bh=yz6VLxbtfUYN+/JqVYQSfZARQuZ6cmar5GZPOsBtACc=; b=v3paj47/mUP0lT tgPygt4DyGUDi2BqFDRaP0dOpsde9tmDC9+RkgChQ4gQg4fzE0HNyp5ob9/Dui2XaQOPTn/Q05OUa T54CzaM25H4Qnm0ML4BEuv1MD1lj7zDglCxgP/ruwg+Vr1skFLwejfp/jm4Q+2PS1KEaLY2DwERh+ UB0V84k/cV6exhxLVL/gvz9iiXsjibtShTwQ7mefeLfZFZr00Sa1r0EV+8ku/sXHIaUSo6iSm11G0 CTSCBONTig0tCulV5uXZu7taqR2f8BIB3z2vXusH0iTOiZfYQoKyKMo5hvE/nYYY/cfqK5wHUOYyo onGSMlo/T0nRkxYNb8Qg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqA7h-00AHJG-P2; Wed, 02 Nov 2022 09:33:25 +0000 Received: from us-smtp-delivery-124.mimecast.com ([170.10.129.124]) by bombadil.infradead.org with esmtps (Exim 4.94.2 #2 (Red Hat Linux)) id 1oqA6d-00AGmf-Dh for linux-amlogic@lists.infradead.org; Wed, 02 Nov 2022 09:32:30 +0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1667381538; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=qCDrX0xKXyu8erIDNjxDiJKuT0hxZZKKE3HXuUGBVDQ=; b=gOVvVa96O5EjRk1UGNXS6akGr9XDQjQiqdmQBHCQa+tMXWjo4EGQzsrYKTW8LkCTjt8VaT mOIldExhNaLbRlo5rI+VMLayI2ICD5dw1M0bM9yV2WHUb7xS2SyWZO6UVluK7IToeQE+dh Q7CC5UGJ7LzJwPOaa/lrTnivgU+iW1I= Received: from mail-wm1-f70.google.com (mail-wm1-f70.google.com [209.85.128.70]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_128_GCM_SHA256) id us-mta-653-CuHl6AGYMWSeqJ4Zs-vwpA-1; Wed, 02 Nov 2022 05:32:15 -0400 X-MC-Unique: CuHl6AGYMWSeqJ4Zs-vwpA-1 Received: by mail-wm1-f70.google.com with SMTP id 1-20020a05600c028100b003cf7833293cso836885wmk.3 for ; Wed, 02 Nov 2022 02:32:15 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=content-transfer-encoding:in-reply-to:from:references:cc:to :content-language:subject:user-agent:mime-version:date:message-id :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qCDrX0xKXyu8erIDNjxDiJKuT0hxZZKKE3HXuUGBVDQ=; b=UP8BYp42IZ6jJbtaYwQl7vyr2epxz8bIIS7rnh7Cra9zmlj/5M82a5wPtWS9qlt9C7 sW9RwOAFh6mBGMqD4Cv3dDkv753lUHftF3X2eDxzUfadIKkdiybsTaEtss9kw4opntKX 3ptBnG1/y0TfQ+Iufpkcl8rKHDD7MMPIH+1dyKXRtg2NQ9VhXsw3THAQMrE+b3gKY91/ w1g2xbcygZm7bpwsZdYb4Wg1stG2SPLWbL5BUfO8Wl9LafAgnIoMkp+6gGPocsJzjJYK XxqZmXHdHUy8RduOgSd9aHk8BfWuKObTSZrArAITwOjcW0KD6e0sNpJIkQj++MshzwYK +7Tg== X-Gm-Message-State: ACrzQf0wtOl5ljsYPupdhERlKOJJWZV7sEP8enxBjQW1NUlR08xG9aOT Jp4vTjr/prxc+8cCJZ4cjAf1dNAuD9qnCWQr+7lsTZhFDHRnBXJNzHg8zBKPKGQPLEk2ZwYsKCY PjkP4EOB6EosBa+2qmorqBzykMsg9xow= X-Received: by 2002:a05:600c:6023:b0:3cf:7dc1:e08e with SMTP id az35-20020a05600c602300b003cf7dc1e08emr5443617wmb.154.1667381534284; Wed, 02 Nov 2022 02:32:14 -0700 (PDT) X-Google-Smtp-Source: AMsMyM7iks5yFnak5X2iZPcs6wSoPN4c8RmVdgyjVaQzUQOEwDY0j8GZM7MD/vLKrS0XyFefd22bEw== X-Received: by 2002:a05:600c:6023:b0:3cf:7dc1:e08e with SMTP id az35-20020a05600c602300b003cf7dc1e08emr5443583wmb.154.1667381533975; Wed, 02 Nov 2022 02:32:13 -0700 (PDT) Received: from [192.168.1.130] (205.pool92-176-231.dynamic.orange.es. [92.176.231.205]) by smtp.gmail.com with ESMTPSA id x21-20020a1c7c15000000b003b492753826sm1361990wmc.43.2022.11.02.02.32.12 (version=TLS1_3 cipher=TLS_AES_128_GCM_SHA256 bits=128/128); Wed, 02 Nov 2022 02:32:13 -0700 (PDT) Message-ID: <3ab32fc3-f2aa-1b42-fd87-557482ab56d5@redhat.com> Date: Wed, 2 Nov 2022 10:32:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.3.1 Subject: Re: [PATCH v2 17/21] drm/fb-helper: Perform all fbdev I/O with the same implementation To: Thomas Zimmermann , daniel@ffwll.ch, airlied@gmail.com, sam@ravnborg.org, mripard@kernel.org, maarten.lankhorst@linux.intel.com Cc: dri-devel@lists.freedesktop.org, amd-gfx@lists.freedesktop.org, linux-aspeed@lists.ozlabs.org, linux-arm-kernel@lists.infradead.org, etnaviv@lists.freedesktop.org, linux-samsung-soc@vger.kernel.org, linux-hyperv@vger.kernel.org, intel-gfx@lists.freedesktop.org, linux-mips@vger.kernel.org, linux-mediatek@lists.infradead.org, linux-amlogic@lists.infradead.org, linux-arm-msm@vger.kernel.org, freedreno@lists.freedesktop.org, nouveau@lists.freedesktop.org, virtualization@lists.linux-foundation.org, spice-devel@lists.freedesktop.org, linux-renesas-soc@vger.kernel.org, linux-rockchip@lists.infradead.org, linux-stm32@st-md-mailman.stormreply.com, linux-sunxi@lists.linux.dev, linux-tegra@vger.kernel.org, xen-devel@lists.xenproject.org References: <20221024111953.24307-1-tzimmermann@suse.de> <20221024111953.24307-18-tzimmermann@suse.de> From: Javier Martinez Canillas In-Reply-To: <20221024111953.24307-18-tzimmermann@suse.de> X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Language: en-US X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20221102_023219_677548_6E42F818 X-CRM114-Status: GOOD ( 25.33 ) X-BeenThere: linux-amlogic@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit Sender: "linux-amlogic" Errors-To: linux-amlogic-bounces+linux-amlogic=archiver.kernel.org@lists.infradead.org On 10/24/22 13:19, Thomas Zimmermann wrote: > Implement the fbdev's read/write helpers with the same functions. Use > the generic fbdev's code as template. Convert all drivers. > > DRM's fb helpers must implement regular I/O functionality in struct > fb_ops and possibly perform a damage update. Handle all this in the > same functions and convert drivers. The functionality has been used > as part of the generic fbdev code for some time. The drivers don't > set struct drm_fb_helper.fb_dirty, so they will not be affected by > damage handling. > > For I/O memory, fb helpers now provide drm_fb_helper_cfb_read() and > drm_fb_helper_cfb_write(). Several drivers require these. Until now > tegra used I/O read and write, although the memory buffer appears to > be in system memory. So use _sys_ helpers now. > > Signed-off-by: Thomas Zimmermann > --- [...] > +static ssize_t __drm_fb_helper_write(struct fb_info *info, const char __user *buf, size_t count, > + loff_t *ppos, drm_fb_helper_write_screen write_screen) > +{ [...] > + /* > + * Copy to framebuffer even if we already logged an error. Emulates > + * the behavior of the original fbdev implementation. > + */ > + ret = write_screen(info, buf, count, pos); > + if (ret < 0) > + return ret; /* return last error, if any */ > + else if (!ret) > + return err; /* return previous error, if any */ > + > + *ppos += ret; > + Should *ppos be incremented even if the previous error is returned? The write_screen() succeeded anyways, even when the count written was smaller than what the caller asked for. > /** > - * drm_fb_helper_sys_read - wrapper around fb_sys_read > + * drm_fb_helper_sys_read - Implements struct &fb_ops.fb_read for system memory > * @info: fb_info struct pointer > * @buf: userspace buffer to read from framebuffer memory > * @count: number of bytes to read from framebuffer memory > * @ppos: read offset within framebuffer memory > * > - * A wrapper around fb_sys_read implemented by fbdev core > + * Returns: > + * The number of read bytes on success, or an error code otherwise. > */ This sentence sounds a little bit off to me. Shouldn't be "number of bytes read" instead? I'm not a native English speaker though, so feel free to just ignore me. [...] > > +static ssize_t fb_read_screen_base(struct fb_info *info, char __user *buf, size_t count, > + loff_t pos) > +{ > + const char __iomem *src = info->screen_base + pos; > + size_t alloc_size = min_t(size_t, count, PAGE_SIZE); > + ssize_t ret = 0; > + int err = 0; Do you really need these two? AFAIK ssize_t is a signed type so you can just use the ret variable to store and return the errno value. [...] > +static ssize_t fb_write_screen_base(struct fb_info *info, const char __user *buf, size_t count, > + loff_t pos) > +{ > + char __iomem *dst = info->screen_base + pos; > + size_t alloc_size = min_t(size_t, count, PAGE_SIZE); > + ssize_t ret = 0; > + int err = 0; Same here. -- Best regards, Javier Martinez Canillas Core Platforms Red Hat _______________________________________________ linux-amlogic mailing list linux-amlogic@lists.infradead.org http://lists.infradead.org/mailman/listinfo/linux-amlogic