From patchwork Wed Apr 22 17:12:16 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: "Luis R. Rodriguez" X-Patchwork-Id: 6259421 Return-Path: X-Original-To: patchwork-dri-devel@patchwork.kernel.org Delivered-To: patchwork-parsemail@patchwork2.web.kernel.org Received: from mail.kernel.org (mail.kernel.org [198.145.29.136]) by patchwork2.web.kernel.org (Postfix) with ESMTP id 690DFBF4A6 for ; Thu, 23 Apr 2015 00:58:25 +0000 (UTC) Received: from mail.kernel.org (localhost [127.0.0.1]) by mail.kernel.org (Postfix) with ESMTP id 57A2D20376 for ; Thu, 23 Apr 2015 00:58:17 +0000 (UTC) Received: from gabe.freedesktop.org (gabe.freedesktop.org [131.252.210.177]) by mail.kernel.org (Postfix) with ESMTP id 699922035E for ; Thu, 23 Apr 2015 00:58:09 +0000 (UTC) Received: from gabe.freedesktop.org (localhost [127.0.0.1]) by gabe.freedesktop.org (Postfix) with ESMTP id 2A0616E571; Wed, 22 Apr 2015 17:58:06 -0700 (PDT) X-Original-To: dri-devel@lists.freedesktop.org Delivered-To: dri-devel@lists.freedesktop.org Received: from mail-pa0-f49.google.com (mail-pa0-f49.google.com [209.85.220.49]) by gabe.freedesktop.org (Postfix) with ESMTP id CD0B06E460 for ; Wed, 22 Apr 2015 10:12:21 -0700 (PDT) Received: by pabsx10 with SMTP id sx10so278355935pab.3 for ; Wed, 22 Apr 2015 10:12:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=sender:from:to:cc:subject:date:message-id:mime-version:content-type :content-transfer-encoding; bh=7vOG/+ox0TUUdUtEOS498lkltDVq0cME18PnQZPgk4A=; b=NdSwCKWf2XWSUHDU8rx4UPiiMJP0ilvscTzl86RDLL2q0IKHtjrwBDd2h9baS6kc8Y qwCKtXCOic4+NRU1UL0Gq2Xtm2dSRGXcnVvwncwImTGYxYqiJCVpaXKkQFR2wxVonqcb z+HiNbIuYB3TESkRCESbCB0fBC7tU7Qtvp8uxkMNnS2iye/lu2VSr7eQ+myf7rOmK/sO RvDkP7FQ6EByqjshMeMdB2DcVtQ71sA09xGef7yFKrGKYTEwoRZAGfFs/gIg1OONFcbM IkTHaD2Sg8RuoOHgoFlpYWNywt95t5OB2TXIxokIN5VbXzVQBNC/n7RAjn3ZRPRGAHa2 a9Kg== X-Received: by 10.67.8.98 with SMTP id dj2mr48554050pad.79.1429722741575; Wed, 22 Apr 2015 10:12:21 -0700 (PDT) Received: from mcgrof@gmail.com ([2601:9:4f00:547:ca60:ff:feda:57a7]) by mx.google.com with ESMTPSA id cu8sm5705875pad.1.2015.04.22.10.12.18 (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 22 Apr 2015 10:12:20 -0700 (PDT) Received: by mcgrof@gmail.com (sSMTP sendmail emulation); Wed, 22 Apr 2015 10:12:17 -0700 From: "Luis R. Rodriguez" To: mingo@elte.hu, tglx@linutronix.de, hpa@zytor.com, plagnioj@jcrosoft.com, tomi.valkeinen@ti.com Subject: [PATCH v4] mtrr: avoid ifdef'ery with phys_wc_to_mtrr_index() Date: Wed, 22 Apr 2015 10:12:16 -0700 Message-Id: <1429722736-4473-1-git-send-email-mcgrof@do-not-panic.com> X-Mailer: git-send-email 2.1.0 MIME-Version: 1.0 X-Mailman-Approved-At: Wed, 22 Apr 2015 17:58:05 -0700 Cc: linux-fbdev@vger.kernel.org, mst@redhat.com, Daniel Vetter , Dave Hansen , Will Deacon , dri-devel@lists.freedesktop.org, Davidlohr Bueso , x86@kernel.org, Ingo Molnar , Mel Gorman , Catalin Marinas , Abhilash Kesavan , Dave Airlie , Thierry Reding , Cristian Stoica , "Luis R. Rodriguez" , Suresh Siddha , Matthias Brugger , Vlastimil Babka , Juergen Gross , Borislav Petkov , Toshi Kani , Greg Kroah-Hartman , linux-kernel@vger.kernel.org, luto@amacapital.net, Andrew Morton , Linus Torvalds X-BeenThere: dri-devel@lists.freedesktop.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: Direct Rendering Infrastructure - Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: dri-devel-bounces@lists.freedesktop.org Sender: "dri-devel" X-Spam-Status: No, score=-1.8 required=5.0 tests=BAYES_00,DKIM_SIGNED, T_DKIM_INVALID, T_RP_MATCHES_RCVD, UNPARSEABLE_RELAY autolearn=no version=3.3.1 X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on mail.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP From: "Luis R. Rodriguez" There is only one user but since we're going to bury MTRR next out of access to drivers expose this last piece of API to drivers in a general fashion only needing io.h for access to helpers. Cc: Toshi Kani Cc: Thomas Gleixner Cc: Ingo Molnar Cc: "H. Peter Anvin" Cc: Will Deacon Cc: Thierry Reding Cc: Andrew Morton Cc: Dave Hansen Cc: Greg Kroah-Hartman Cc: Catalin Marinas Cc: Abhilash Kesavan Cc: Matthias Brugger Cc: Cristian Stoica Cc: dri-devel@lists.freedesktop.org Cc: Suresh Siddha Cc: Linus Torvalds Cc: Juergen Gross Cc: Daniel Vetter Cc: Andy Lutomirski Cc: Dave Airlie Cc: Antonino Daplas Cc: Jean-Christophe Plagniol-Villard Cc: Tomi Valkeinen Cc: Ville Syrjälä Cc: Mel Gorman Cc: Vlastimil Babka Cc: Borislav Petkov Cc: Davidlohr Bueso Cc: x86@kernel.org Cc: linux-fbdev@vger.kernel.org Cc: linux-kernel@vger.kernel.org Signed-off-by: Luis R. Rodriguez --- This v4 adds a missing #endif. arch/x86/include/asm/io.h | 3 +++ arch/x86/include/asm/mtrr.h | 5 ----- arch/x86/kernel/cpu/mtrr/main.c | 6 +++--- drivers/gpu/drm/drm_ioctl.c | 14 +------------- include/linux/io.h | 7 +++++++ 5 files changed, 14 insertions(+), 21 deletions(-) diff --git a/arch/x86/include/asm/io.h b/arch/x86/include/asm/io.h index 4afc05f..a2b9740 100644 --- a/arch/x86/include/asm/io.h +++ b/arch/x86/include/asm/io.h @@ -339,6 +339,9 @@ extern bool xen_biovec_phys_mergeable(const struct bio_vec *vec1, #define IO_SPACE_LIMIT 0xffff #ifdef CONFIG_MTRR +extern int __must_check arch_phys_wc_index(int handle); +#define arch_phys_wc_index arch_phys_wc_index + extern int __must_check arch_phys_wc_add(unsigned long base, unsigned long size); extern void arch_phys_wc_del(int handle); diff --git a/arch/x86/include/asm/mtrr.h b/arch/x86/include/asm/mtrr.h index da8dff1..27e3dc0 100644 --- a/arch/x86/include/asm/mtrr.h +++ b/arch/x86/include/asm/mtrr.h @@ -48,7 +48,6 @@ extern void mtrr_aps_init(void); extern void mtrr_bp_restore(void); extern int mtrr_trim_uncached_memory(unsigned long end_pfn); extern int amd_special_default_mtrr(void); -extern int phys_wc_to_mtrr_index(int handle); # else static inline u8 mtrr_type_lookup(u64 addr, u64 end, u8 *uniform) { @@ -85,10 +84,6 @@ static inline int mtrr_trim_uncached_memory(unsigned long end_pfn) static inline void mtrr_centaur_report_mcr(int mcr, u32 lo, u32 hi) { } -static inline int phys_wc_to_mtrr_index(int handle) -{ - return -1; -} #define mtrr_ap_init() do {} while (0) #define mtrr_bp_init() do {} while (0) diff --git a/arch/x86/kernel/cpu/mtrr/main.c b/arch/x86/kernel/cpu/mtrr/main.c index 12abdbe..d8c106c 100644 --- a/arch/x86/kernel/cpu/mtrr/main.c +++ b/arch/x86/kernel/cpu/mtrr/main.c @@ -580,7 +580,7 @@ void arch_phys_wc_del(int handle) EXPORT_SYMBOL(arch_phys_wc_del); /* - * phys_wc_to_mtrr_index - translates arch_phys_wc_add's return value + * arch_phys_wc_index - translates arch_phys_wc_add's return value * @handle: Return value from arch_phys_wc_add * * This will turn the return value from arch_phys_wc_add into an mtrr @@ -590,14 +590,14 @@ EXPORT_SYMBOL(arch_phys_wc_del); * in printk line. Alas there is an illegitimate use in some ancient * drm ioctls. */ -int phys_wc_to_mtrr_index(int handle) +int arch_phys_wc_index(int handle) { if (handle < MTRR_TO_PHYS_WC_OFFSET) return -1; else return handle - MTRR_TO_PHYS_WC_OFFSET; } -EXPORT_SYMBOL_GPL(phys_wc_to_mtrr_index); +EXPORT_SYMBOL_GPL(arch_phys_wc_index); /* * HACK ALERT! diff --git a/drivers/gpu/drm/drm_ioctl.c b/drivers/gpu/drm/drm_ioctl.c index 266dcd6..0a95782 100644 --- a/drivers/gpu/drm/drm_ioctl.c +++ b/drivers/gpu/drm/drm_ioctl.c @@ -36,9 +36,6 @@ #include #include -#ifdef CONFIG_X86 -#include -#endif static int drm_version(struct drm_device *dev, void *data, struct drm_file *file_priv); @@ -197,16 +194,7 @@ static int drm_getmap(struct drm_device *dev, void *data, map->type = r_list->map->type; map->flags = r_list->map->flags; map->handle = (void *)(unsigned long) r_list->user_token; - -#ifdef CONFIG_X86 - /* - * There appears to be exactly one user of the mtrr index: dritest. - * It's easy enough to keep it working on non-PAT systems. - */ - map->mtrr = phys_wc_to_mtrr_index(r_list->map->mtrr); -#else - map->mtrr = -1; -#endif + map->mtrr = arch_phys_wc_index(r_list->map->mtrr); mutex_unlock(&dev->struct_mutex); diff --git a/include/linux/io.h b/include/linux/io.h index 986f2bf..04cce4d 100644 --- a/include/linux/io.h +++ b/include/linux/io.h @@ -111,6 +111,13 @@ static inline void arch_phys_wc_del(int handle) } #define arch_phys_wc_add arch_phys_wc_add +#ifndef arch_phys_wc_index +static inline int arch_phys_wc_index(int handle) +{ + return -1; +} +#define arch_phys_wc_index arch_phys_wc_index +#endif #endif #endif /* _LINUX_IO_H */