Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3824058imu; Tue, 18 Dec 2018 04:55:53 -0800 (PST) X-Google-Smtp-Source: AFSGD/VibejE4s75Eq5RPbOtggP/Uue3rLqOTWYW9rys1tgE5muXgGJbiMLRto7PqbHepOdP76Bq X-Received: by 2002:a17:902:e28e:: with SMTP id cf14mr16662966plb.311.1545137753510; Tue, 18 Dec 2018 04:55:53 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1545137753; cv=none; d=google.com; s=arc-20160816; b=EEmucxdaeQV5DyyKyG5KKOlTEw3u2bAtHGQO2b3KVbZaKQA9JWwkElRtQs77j+EPOA pIuh/83iPelevbYPxGGR58YQWawdMyZk9IPZm6rnDqJT1nEUlgym/XSJTbu7bz7loh2c PsvHZDzRJgwl3d50ukyo5V2FjGeUXtf6kr5jVMaay0yhhx1jN27koP8MlAvZO9CAa2Tr 9CRZvQ1OBYPEclarLS06My6K2HspwDsOUv9PInfBXNhvFZjrOBPqW+1yM4mWPRWqskX+ N95juYoJxztRhFyZZaCxXmB0ongTHSHNO5qw+Rxw/SgZ8fGfWadnChab39rTERA+ESas 7IXQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :in-reply-to:references:mime-version:dkim-signature; bh=TiOdRpCcB5RW4TqZM074ipMTqVW9QTa6+4OEUBKgdz0=; b=ecnfPzdXTMa0D6kLcf8Aclg+gdkPEkelGJWS2FYGRLdErfsMh9Zwdsr9D+h35/zLJS lfkcx/nRD3S6EcGzGjUWAXTH68YFQMmbegMHgl8EvJcdKSBDk8UMHkq/UZSfcz/7RJ7+ xP+DujXTsiFqpofPELRgBmZn+YCWStdxArQhHoF/caSi6mYPr0MwrCI0kFlFDt/kPl4e if+n1XStBfexvtJa+siWxA6msPkhdvzgC7I2UuWKumOCI2hlKfbZbwCgfvd5orrHFwsA xTJLZ4yqn7nF25LFS3PuPPaki3gY0Vyyw8FOEp6NILq36ZuzsvOTtqvz0E+3EgM0p0Q+ YtZQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j+ofMn9p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id h6si11775090plk.231.2018.12.18.04.55.36; Tue, 18 Dec 2018 04:55:53 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j+ofMn9p; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726552AbeLRMyo (ORCPT + 99 others); Tue, 18 Dec 2018 07:54:44 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:40657 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726403AbeLRMyo (ORCPT ); Tue, 18 Dec 2018 07:54:44 -0500 Received: by mail-lf1-f67.google.com with SMTP id v5so12194183lfe.7 for ; Tue, 18 Dec 2018 04:54:42 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=TiOdRpCcB5RW4TqZM074ipMTqVW9QTa6+4OEUBKgdz0=; b=j+ofMn9pL7ziht+9i0YlnsPRRQqrmCSc4PVj/dbHod6e/WoLSYlDBKG1uxj4Na/pDa PwE3Xpe1xLM1NPPLYmoidU0CP6z1RhTWzECLuDk5STL9DmXNbHRY9FedFR7U0szEccEb ZDupnI94UxtHcmquG9+MtHI60NA7YbhcOjRYn1vWFnCUU/8jjibpTPj7Sp8R2bYWtlHH mZsUFsLvcf4k/LBBr45kTtwHU726vrhdId/Kcv7KTI9HNxvdDcuSHKHWX0cWyRk73Q6z 84AhcUoV5K2PY43vQnajEkeBFoEnP9OJ1m6ZRmLvPu/668Te21in2Lq6PLvfjMO6fZAU v3Aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=TiOdRpCcB5RW4TqZM074ipMTqVW9QTa6+4OEUBKgdz0=; b=YZv0ygtB4rCWs9GXG6zJpfvab0L7nVONE6oKpBeMuJgsm+hAti0jPXgBJ2gGxKsfuh /pP+YA2Ba7m8Ig0sxeLke7dTKYvEBFoHEhZ0PXbSkl1yOdqjuJXmfEbe6HJKcAgin7ed Cw8pB3ZdyarkTV2ShLCqyQIeJdaohHQZdlofs1nI+stoXKL05UQsVKSE15zkf0A75Xzp ioBy8prvIeqNGVHFOo+iTgouR5elD0N+15s6cO/cPsowDAW1aWNyKpC7zkuntHJT5OG5 3otWtFc3gVcHFqQZUMeKCsbeFE+3H5tVnsKAudLxzsg2ROtUvAEaaGS58HuPjcNq3v3z QVqQ== X-Gm-Message-State: AA+aEWZH0B5Cy3CpingGR2I0H2VF85ydMUEojVIfAxF2zh/rXjpU92uS Mz8uRp20PP1o5+FYjrpV3SliJusPMfZkJbZqniY= X-Received: by 2002:a19:6514:: with SMTP id z20mr2633604lfb.31.1545137681798; Tue, 18 Dec 2018 04:54:41 -0800 (PST) MIME-Version: 1.0 References: <20181217202334.GA11758@jordon-HP-15-Notebook-PC> <20181218095709.GJ26090@n2100.armlinux.org.uk> <20181218123318.GN26090@n2100.armlinux.org.uk> In-Reply-To: <20181218123318.GN26090@n2100.armlinux.org.uk> From: Souptick Joarder Date: Tue, 18 Dec 2018 18:24:29 +0530 Message-ID: Subject: Re: [PATCH v4 4/9] drm/rockchip/rockchip_drm_gem.c: Convert to use vm_insert_range To: Russell King - ARM Linux Cc: Michal Hocko , Heiko Stuebner , linux-rockchip@lists.infradead.org, airlied@linux.ie, hjc@rock-chips.com, Matthew Wilcox , linux-kernel@vger.kernel.org, Linux-MM , dri-devel@lists.freedesktop.org, Andrew Morton , linux-arm-kernel@lists.infradead.org Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org On Tue, Dec 18, 2018 at 6:03 PM Russell King - ARM Linux wrote: > > On Tue, Dec 18, 2018 at 05:36:04PM +0530, Souptick Joarder wrote: > > On Tue, Dec 18, 2018 at 3:27 PM Russell King - ARM Linux > > wrote: > > > This looks like a change in behaviour. > > > > > > If user_count is zero, and offset is zero, then we pass into > > > vm_insert_range() a page_count of zero, and vm_insert_range() does > > > nothing and returns zero. > > > > > > However, as we can see from the above code, the original behaviour > > > was to return -ENXIO in that case. > > > > I think these checks are not necessary. I am not sure if we get into mmap > > handlers of driver with user_count = 0. > > I'm not sure either, I'm just pointing out the change of behaviour. Ok. I think feedback from Heiko might be helpful here :) > > > > The other thing that I'm wondering is that if (eg) count is 8 (the > > > object is 8 pages), offset is 2, and the user requests mapping 6 > > > pages (user_count = 6), then we call vm_insert_range() with a > > > pages of rk_obj->pages + 2, and a pages_count of 6 - 2 = 4. So we > > > end up inserting four pages. > > > > Considering the scenario, user_count will remain 8 (user_count = > > vma_pages(vma) ). ? No ? > > Then we call vm_insert_range() with a pages of rk_obj->pages + 2, and > > a pages_count > > of 8 - 2 = 6. So we end up inserting 6 pages. > > > > Please correct me if I am wrong. > > vma_pages(vma) is the number of pages that the user requested, it is > the difference between vma->vm_end and vma->vm_start in pages. As I > said above, "the user requests mapping 6 pages", so vma_pages() will > be 6, and so user_count will also be 6. You are passing > user_count - offset into vm_insert_range(), which will be 6 - 2 = 4 > in my example. This is two pages short of what the user requested. > So, this should be the correct behavior. return vm_insert_range(vma, vma->vm_start, rk_obj->pages + offset, user_count);