Received: by 2002:ac0:aa62:0:0:0:0:0 with SMTP id w31-v6csp1738799ima; Sun, 21 Oct 2018 19:48:28 -0700 (PDT) X-Google-Smtp-Source: ACcGV61vg5oFkoHHhW6IhWyIKnBlrxNGPAxRGGUIC8ajGEPAHzlXE4XHUuo4Csq2bsHV3YLr046c X-Received: by 2002:a63:8f09:: with SMTP id n9-v6mr40707415pgd.222.1540176508149; Sun, 21 Oct 2018 19:48:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1540176508; cv=none; d=google.com; s=arc-20160816; b=GWIPx7tAm3MWqmc0+mu8z3VwTokY1vETOpw17Lo02G2CnsM0eTOku1NioviHr7x2Lx MbrxyNtK0ONZWsIlvxLirTIPJvg/O1P1Phq5LoCBeebide4YHHYNrZEoR7U0G/jiZan3 kb9OFEmZwRcu6BWLTh4n7PYwWEOeIyx7yQqrVIALSmVibdP0eimPqLWPHBD7DW8rNbQX c6fOh92T7FWHe0ljzxshIGpDOO1t3AurkagyWa7RFAN8p0UFurHJbALDlnvdwrWVSeuo KAeJLLIXldTAzLnSURjI80TuVQ9/O4HTdRawLKYUXF3ayI5FFwAOSA++1UvDlZwYOMXE RLgg== 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=0+pzG0OE6izSccu5uCiBS+u+9cbPciRkMW/jQiCRvIE=; b=sni3AXcMm8goJFv5q5SKebLS7oD00ciX36A2tQk/qfflWA5LYLzqrsu003/dzLu2w8 AxfUYBAAkFSHBYOURC4P1iytRIy54ouxBYRVnDqxji1YG+2hE8S+4pZgyFtIc5UkpeAZ RYaY4H3RRbpSE4qdcNwyQ63Wp9RMBn838znry9cQV7FLu/emfAc0YcWtLxY0vWpni5cW Wd99e5VvOl/n6XFcbUtN78Two8V7YTDCK3/AjCUKfk+17EBkfhK3DL7o8emu9qkFH6gC NkhIXosKCIZajXmirdZApeG+Wz0l0L717EeBVTYrJyGJAkkG6S3ZfkaiAZ5MxagalmUh saCA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m509C7vi; 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 14-v6si17625394pgl.157.2018.10.21.19.48.12; Sun, 21 Oct 2018 19:48:28 -0700 (PDT) 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=m509C7vi; 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 S1727187AbeJVLDV (ORCPT + 99 others); Mon, 22 Oct 2018 07:03:21 -0400 Received: from mail-oi1-f178.google.com ([209.85.167.178]:38708 "EHLO mail-oi1-f178.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726963AbeJVLDV (ORCPT ); Mon, 22 Oct 2018 07:03:21 -0400 Received: by mail-oi1-f178.google.com with SMTP id u197-v6so30980380oif.5 for ; Sun, 21 Oct 2018 19:46:46 -0700 (PDT) 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=0+pzG0OE6izSccu5uCiBS+u+9cbPciRkMW/jQiCRvIE=; b=m509C7viLwFLbfdpVAAQqBEYaCsgtGW7pGwiGNNzN4JEL/1PMNxv5XZhQxed76QVvh ZrXr16L3GMsyba1S5CxUBtNHuEzeg/7mpIMWkaFl+/WJtTC1bUFAQgSqwAwz0zNS5iqz hIaGKn+BnfwsHsXGmgJeWp/sx9mSISsNGjN0JHsgnWsEJGkK0WM8+hB2Vgn9J6J3ccIb cQLGj6dByZXFrpKRKFhrjw6uCNJ6XMpRYscz8rCWaR2gRjKu8n4Q1rk+itZPaYULIX/M 1ZvApXoeF9DS27/reQy++mmAaf4Nob8DMiiMplND6PdhS8yb9wgoR6Y5CboMgXEorMhP ooOQ== 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=0+pzG0OE6izSccu5uCiBS+u+9cbPciRkMW/jQiCRvIE=; b=IcKTbPf/zMedqpKje8LgIq1h9mHDjc37fdAuD1o35vqNkK/I4hqU3NBiJeIi2vkVPA 0y5IB5uMbLsifnahDxvoBh8g4/23313Dw37M8ORZoKK/IiUqTcvWfar3oRp4/EZfvMQm JOl70hyfS4mIlUMrM9Y9fCK89j+uheKan12hhPIJib/7Nd7s40dGegtuPzuCZZnwJ+1m 92vzK61TL0W/N85AcNuI6TqmuGeOFkl+aFAy840x9PllULkEi3hVid1/IJ//78iQBjlg LOR3DRKalEW+AkDVVydRU83AZmaTX/CxZxLmXczza1vaoXi0LKxKfjgRtqSYwTKMPT0Y SCKQ== X-Gm-Message-State: ABuFfoixVemHZqbj0rxgO0jG5rSzKvyTKHfb1iEKdXuBg1zzY4Wgmw3P iqGSR/WVGDBPlT/Q+ROMh6CyaVht4zUJSKZFf3s= X-Received: by 2002:a54:4e0f:: with SMTP id a15-v6mr23606743oiy.346.1540176405500; Sun, 21 Oct 2018 19:46:45 -0700 (PDT) MIME-Version: 1.0 References: In-Reply-To: From: Michael Tirado Date: Sun, 21 Oct 2018 22:20:31 +0000 Message-ID: Subject: Re: To: Dave Airlie Cc: Airlied@linux.ie, dri-devel@lists.freedesktop.org, LKML , kraxel@redhat.com, alexander.deucher@amd.com, christian.koenig@amd.com, David1.zhou@amd.com, Hongbo.He@amd.com, Sean Paul , Gustavo@padovan.org, maarten.lankhorst@linux.intel.com Content-Type: multipart/mixed; boundary="0000000000008b01e70578c8437d" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org --0000000000008b01e70578c8437d Content-Type: text/plain; charset="UTF-8" On Mon, Oct 22, 2018 at 1:50 AM Dave Airlie wrote: > > On Mon, 22 Oct 2018 at 10:49, Michael Tirado wrote: > > > > On Mon, Oct 22, 2018 at 12:26 AM Dave Airlie wrote: > > > > > > This shouldn't be necessary, did someone misbackport the mmap changes without: > If you have custom userspace software, make sure it's using > AC_SYS_LARGEFILE or whatever the equivalant is in your build system. > > 64-bit file offsets are important. > That fixed it! -D_FILE_OFFSET_BITS=64 is the pre-processor define needed. It's a bit more than unintuitive but I'm glad I don't need this stupid patch anymore, Thanks. In case anyone is further interested I have attached test program since I spent the last hour or so chopping it up anyway :S [ gcc -o kms -D_FILE_OFFSET_BITS=64 main.c ] --0000000000008b01e70578c8437d Content-Type: application/octet-stream; name="main.c" Content-Disposition: attachment; filename="main.c" Content-Transfer-Encoding: base64 Content-ID: X-Attachment-Id: f_jnjfn5vj0 LyogQ29weXJpZ2h0IChDKSAyMDE3IE1pY2hhZWwgUi4gVGlyYWRvIDxtdGlyYWRvNDE4QGdtYWls LmNvbT4gLS0gR1BMdjMrCiAqCiAqIFRoaXMgcHJvZ3JhbSBpcyBsaWJyZSBzb2Z0d2FyZTogeW91 IGNhbiByZWRpc3RyaWJ1dGUgaXQgYW5kL29yIG1vZGlmeQogKiBpdCB1bmRlciB0aGUgdGVybXMg b2YgdGhlIEdOVSBHZW5lcmFsIFB1YmxpYyBMaWNlbnNlIGFzIHB1Ymxpc2hlZCBieQogKiB0aGUg RnJlZSBTb2Z0d2FyZSBGb3VuZGF0aW9uL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