Received: by 10.223.164.202 with SMTP id h10csp1218350wrb; Fri, 17 Nov 2017 16:28:33 -0800 (PST) X-Google-Smtp-Source: AGs4zMbl2sG6voW3PWwyroBbiTujINF27AeqGtJ/5iExyu0fq6VNf1yUl4q+jrQ+OJ4unxCODwbN X-Received: by 10.99.115.85 with SMTP id d21mr6569154pgn.82.1510964913468; Fri, 17 Nov 2017 16:28:33 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1510964913; cv=none; d=google.com; s=arc-20160816; b=IuLZTdnaJClw1vRuAmOwPUk2DvC0zR++YCbsW1TKrJLBMzzurcO90EJq0+ubN6AOR+ /0i+Z8O2LdaIvwYErBxt03LIuDC19MNjtWzXq+FfHgu+EWmihLK3CBWyXPHqwwMVal3d liB9tjoyqsfP8/tA3DDSzb4MJxM3L0VdigiLbJD+UmAy7vMJZ3AuJXp1dz1y+BC/dZW5 3YhKdZbIKxk9c/U2rc5HORkfy9zNoSRZHHhSnqOjxUu/t4FLEsXBNyj0M60ff0nUTqPS ZDhhVTGO02aG9OC8X2tULAQmfnN+eLug1NuNJ+sJdlrNQ7Jf0MAfjsANp+iMeqbRNJy6 qyAA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-language :content-transfer-encoding:in-reply-to:mime-version:user-agent:date :message-id:from:references:cc:to:subject:reply-to:dkim-signature :arc-authentication-results; bh=KK4nSUG3SdvxPnp9vgyBX5wufX7Xqc7cd+kN/JrN2ZI=; b=KcBVWO49bdLa4dumv1veTi8Iwq0v5+c0i2d+H9OUcRuBUwA4JNt00ucnye98dzCCcB 0IvGAEa+Y6+uXf7kK8IDLpO4wi4aTjl+Lwpq24dDqDlmWdCOKTzvULqasVJhZ8w9u1GS rjrRtexM7JWBl8Cl/NvAClx98rtYpqysmR3fBtTFHLBntff7rBiw5WSufdiGnq2Ku7RS 2P1vvZ8146/bX0e9uk0xvN7h834d1z07aioSowvn0+giVnoGIhE3PnSOctseKbTU0OK7 CtKR2IS5aDvOiDwTvj2Y95QEZi93oyr5OSI5XqTXHxECtHby3LnDTgwMkbTl0mohhM5e jxOw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=j7n8TgVU; 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=NONE 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 j11si3562999plt.473.2017.11.17.16.28.20; Fri, 17 Nov 2017 16:28:33 -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=j7n8TgVU; 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=NONE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S934061AbdKQTSc (ORCPT + 93 others); Fri, 17 Nov 2017 14:18:32 -0500 Received: from mail-wm0-f48.google.com ([74.125.82.48]:34585 "EHLO mail-wm0-f48.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1161705AbdKQTSG (ORCPT ); Fri, 17 Nov 2017 14:18:06 -0500 Received: by mail-wm0-f48.google.com with SMTP id y82so4451681wmg.1 for ; Fri, 17 Nov 2017 11:18:05 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=reply-to:subject:to:cc:references:from:message-id:date:user-agent :mime-version:in-reply-to:content-transfer-encoding:content-language; bh=KK4nSUG3SdvxPnp9vgyBX5wufX7Xqc7cd+kN/JrN2ZI=; b=j7n8TgVUAZBEICAZl1QdTi132pqv88p/f+h+sIXafcLjhjQIsCmPCntfeKrlzQRWlR 1I/WBRIH5UDdZH8bvmbrhQDKA1dKeMFLHO6jAFkN/fozz321HhE4UviJujz+nPwS6XWe QUWkzl2myQYXpYMyZU+XO9B85lhuFBQ28sTfk6EzNLr0uJlEewkfHgUSINoTWsPfxNtO 3frh47/ZsSH6WdxC730I489SzcgcCzTf1bfS8x0JUanlQlZd2Z6cUTAbjGCAXJIhHn7a 4DAwIF9HfaDJ13y89j7dpwMbzy6MO9f8DRsTd8ygfbbAs4ITaIQfF1SFAarDTKR0U16R w5Zg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:reply-to:subject:to:cc:references:from :message-id:date:user-agent:mime-version:in-reply-to :content-transfer-encoding:content-language; bh=KK4nSUG3SdvxPnp9vgyBX5wufX7Xqc7cd+kN/JrN2ZI=; b=Av3WzuFZpidJLj5xMbihmySqfTmUgx8z4BMmyX75cRplmir8/V6R0UjEDLK74qo16k gTnDVtktNX4QEOkmNfaMSbUKNhkYIE4XP7XfYbnPNMxYrIrRli0z3lIskaGhH47prUKl H9vTnLwwAVrkxgtj/6KTHJ6Chb6zW77km7mS/SOHdgXy4+NGIrpFuPH0x1uJc4pZCnFb h27qbEP78QLi7qD3DUMY62aaVVMhoe3R5D8ofpNvujji0m0gamUmR3oahILM7hRFStRk 4UsCh19IQI4IGertel5M6IdBmf90tlM27D9+8wSsYCd1yopCHsxn5x0nbHZZhoP/CPGE OZaA== X-Gm-Message-State: AJaThX7tak2QdTSZFR+uompOo0N3p+JEWQRj7Fd9Y/tpjeeaQMvvErJH Pv248154RRIyfvp5p7JZq3k= X-Received: by 10.80.153.125 with SMTP id l58mr8829987edb.183.1510946285076; Fri, 17 Nov 2017 11:18:05 -0800 (PST) Received: from ?IPv6:2a02:908:1251:7981:3c4e:9086:75cd:8e88? ([2a02:908:1251:7981:3c4e:9086:75cd:8e88]) by smtp.gmail.com with ESMTPSA id b17sm3132957edj.21.2017.11.17.11.18.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Fri, 17 Nov 2017 11:18:04 -0800 (PST) Reply-To: christian.koenig@amd.com Subject: Re: [git pull] drm for v4.15 To: Linus Torvalds , =?UTF-8?Q?Christian_K=c3=b6nig?= Cc: =?UTF-8?Q?Nicolai_H=c3=a4hnle?= , LKML , dri-devel References: <26729c32-cfd6-82e0-b370-a46ca951adea@gmail.com> <29dd45a7-4a58-ed71-e6d4-1cd4bfc69ee5@amd.com> From: =?UTF-8?Q?Christian_K=c3=b6nig?= Message-ID: Date: Fri, 17 Nov 2017 20:18:01 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.4.0 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 8bit Content-Language: en-US Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Am 17.11.2017 um 19:55 schrieb Linus Torvalds: > On Fri, Nov 17, 2017 at 10:14 AM, Christian König > wrote: >> Taking an example from the AMD headers why this automation is more tricky >> than it sounds in the first place: Look at the >> mmVM_CONTEXT*_PAGE_TABLE_BASE_ADDR registers for example. >> >> Register 0-7 are consecutive and so could be perfectly addressable with an >> index, but register 8-15 aren't and so we always end with logic like if(i<8) >> ... else .... >> >> The rational from the hardware guys is obvious that they initially had only >> 8 and on a later hardware generation extended that to 16 registers. > Heh. I don't disagree, but at the same time, that case is actually a > wonderful example. > > Let's take the gmc_6_0 case, because it shows your irregularity, but > it also shows another horrid example of nasty nasty automation: > > mmVM_CONTEXT0_PAGE_TABLE_BASE_ADDR 0x054F > mmVM_CONTEXT10_PAGE_TABLE_BASE_ADDR 0x0510 > mmVM_CONTEXT11_PAGE_TABLE_BASE_ADDR 0x0511 > mmVM_CONTEXT12_PAGE_TABLE_BASE_ADDR 0x0512 > mmVM_CONTEXT13_PAGE_TABLE_BASE_ADDR 0x0513 > mmVM_CONTEXT14_PAGE_TABLE_BASE_ADDR 0x0514 > mmVM_CONTEXT15_PAGE_TABLE_BASE_ADDR 0x0515 > mmVM_CONTEXT1_PAGE_TABLE_BASE_ADDR 0x0550 > mmVM_CONTEXT2_PAGE_TABLE_BASE_ADDR 0x0551 > mmVM_CONTEXT3_PAGE_TABLE_BASE_ADDR 0x0552 > mmVM_CONTEXT4_PAGE_TABLE_BASE_ADDR 0x0553 > mmVM_CONTEXT5_PAGE_TABLE_BASE_ADDR 0x0554 > mmVM_CONTEXT6_PAGE_TABLE_BASE_ADDR 0x0555 > mmVM_CONTEXT7_PAGE_TABLE_BASE_ADDR 0x0556 > mmVM_CONTEXT8_PAGE_TABLE_BASE_ADDR 0x050E > mmVM_CONTEXT9_PAGE_TABLE_BASE_ADDR 0x050F > > Oops. Those were clearly sorted automatically, and in entirely the wrong way. > > So automation has _really_ done something inexcusably stupid, and made > the end result completely illegible in the process. Yeah, but that is already the input we get from the hardware teams. E.g. in this case a list of registers sorted by their name or address (or even sometimes some hardware internal magic). There isn't much we could do about that except for manual or semi manually cleaning up the mess. > And yes, you'd be right that it's discontiguous at 8, but it's still > arithmetic, ie you could easily have > > #define mmVM_PAGE_TABLE_BASE_ADDR(ctx) \ > ((ctx)+0x054f-((ctx) & 8)*9-((ctx)&8)/8) > > and if "ctx" is a constant, then the end result is trivially a > constant and can be used as such. And if it isn't, it's still a much > cheaper operation than an "if" or "switch ()" statement (it's just a > bitmask and two shifts). Interesting approach, but it is not so performance critical. So I would still go with the "if" or "?" operator just for the improved readability. > Now, seeing those patterns is likely not something that automation > should do (although it's definitely possible - superoptimizers do that > all the time), but automation could still *verify* the patterns once a > human has made them up. Well, this was just a rather simple example, the real problem is that some blocks have a dozen instances and >10k registers each. Manual intervention is just completely out of question when applied to the general problem. What we need is some automation, but as you wrote as well that is possible but far from easy. > And it's quite possible that it would be a good idea to encode that > pattern even in the original source code. In fact, it may *be* there > somewhere (not as that arithmetic expression, but as the reverse > decode logic, obviously). The obvious alternative which we are working on for a few years now is to improve the input data we get from the hardware people. In other words instead of getting a flat list of registers we want the information about where and how many times a hardware block was instantiated. But getting that proved much more difficult than we thought and yes we are working on that for multiple years now. Regards, Christian. From 1584360747857785343@xxx Sat Nov 18 00:15:53 +0000 2017 X-GM-THRID: 1584194585945726173 X-Gmail-Labels: Inbox,Category Forums,HistoricalUnread