Received: by 2002:a25:ef43:0:0:0:0:0 with SMTP id w3csp824593ybm; Wed, 27 May 2020 08:53:07 -0700 (PDT) X-Google-Smtp-Source: ABdhPJy7GHbvCVkY3DM1AN/5tRMrl4BdUkwYqs+pCCj9t8ePmzkLPHwzbqdh+8P4hy4j0PYOgf/2 X-Received: by 2002:a17:906:9719:: with SMTP id k25mr6841136ejx.411.1590594787341; Wed, 27 May 2020 08:53:07 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1590594787; cv=none; d=google.com; s=arc-20160816; b=GBPOa3qbT844B+Hyd4QZsc85noQUsvT+H553h8B10bRLkhNWk1IkkCg0kBsVXZsDVr cSRcetSYH4qnt6KufRarW033/hn7R4bmAbu9UZuM0GnjRO6BtQ2ZghqPBGANzc26Mx43 O5pypT5LUF1IVRHBz7GUl+6bfMThRX9uSgQPQkuwzawIjA1fvslv2DIPPq3cx3mFzX4d W1ZWNATisl6Eeln/PGLGIj+x9o/ES7DE3/I1085aSwyEGJ4Zv7bLbr7cPoQzFEEQRQXp P7InNBebWT3Fdj99YOONxfQsAMDO0jiALnocZPpGv/Ozc3mDyjErLIw8/W07kwMV37mU Sg4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :message-id:date:subject:cc:to:from:dkim-signature; bh=nhqr8/8ONQ5v1eEgppz87JFAm7upBCVp4UT/Q99Q9JI=; b=xCd3kwHSdOdBOxqDDv0Waw/EZsU9wr0gQzhbErKuc1K9+TV5S4lQgDdwUgO7Jhn16B KqcTNca3eSldI098s3cEZHIeZikmiIrHjEH1Cd25gdOOYcSQ6915iqyDz63VNbb+e6Hd mF4OzKEPMOvKWDZO8AAtIPNho4w4+hLLPkpk/NVnevRdIHtIGyPFOr4y0tf4acywHWyu WHnTe1bYaRK9a8jNIasopKm6ea4sxgsQE7q7blfNL468us7j7vPPZBix4xrAIvPIjK9M si4RZWnAvP5JoUiv5cR7Bb1ePTmOXDHnup54FL/n0i8WD8DeRxwUzMjwTpLCiyezXf51 kHHg== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@flygoat.com header.s=vultr header.b=cBI5XsnI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id f1si2210702edl.533.2020.05.27.08.52.44; Wed, 27 May 2020 08:53:07 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@flygoat.com header.s=vultr header.b=cBI5XsnI; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=flygoat.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730244AbgE0NR6 (ORCPT + 99 others); Wed, 27 May 2020 09:17:58 -0400 Received: from vultr.net.flygoat.com ([149.28.68.211]:34470 "EHLO vultr.net.flygoat.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725267AbgE0NR6 (ORCPT ); Wed, 27 May 2020 09:17:58 -0400 Received: from localhost.localdomain (unknown [IPv6:2001:da8:20f:4430:250:56ff:fe9a:7470]) by vultr.net.flygoat.com (Postfix) with ESMTPSA id 904A020CF5; Wed, 27 May 2020 13:17:56 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=flygoat.com; s=vultr; t=1590585477; bh=TyCh2oo8yxVUWVWyl+bhaPPjK8SpeLsyRuP1msgd7cg=; h=From:To:Cc:Subject:Date:From; b=cBI5XsnIeyj7lwzzV2iYA3chZAGVzVdgsI3q3zj55bLXmvU1dJXEsAuWBBv0kXdiM Z+7cZW/8C2h6qx2gQYLsk8yG1yjq7AYvugaFjkmSBcS8QdEduwoBzxMA5Y9Vpz92Sl VYkfD9f3FWYTUn/TPLBWfKacpXz66C+6oREpqd1gv4JiiVKFrzmeS0TsopE65OVD8/ bzVQoGSVeHaUBwizx/XisXpjZkrHtUthjpIAnwQ4unLZVgGQzySw0iY1ObUqYZDkxL FvU5xMMGdO2uTMOZozYYIL+xs77q33uw82gGsxw4GyFxOJRxo0jTtuClC0Qi2YqqK+ JIPkMuHwlXZKw== From: Jiaxun Yang To: linux-mips@vger.kernel.org Cc: Jiaxun Yang , Huacai Chen , Thomas Bogendoerfer , linux-kernel@vger.kernel.org Subject: [PATCH] MIPS: Loongson64: Define PCI_IOBASE Date: Wed, 27 May 2020 21:17:21 +0800 Message-Id: <20200527131721.646926-1-jiaxun.yang@flygoat.com> X-Mailer: git-send-email 2.27.0.rc0 MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org PCI_IOBASE is used to create VM maps for PCI I/O ports, it is required by generic PCI drivers to make memory mapped I/O range work. To deal with legacy drivers that have fixed I/O ports range we reserved 0x10000 in PCI_IOBASE, should be enough for i8259 i8042 stuff. Signed-off-by: Jiaxun Yang --- .../mips/include/asm/mach-loongson64/spaces.h | 8 ++++ arch/mips/loongson64/init.c | 42 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/arch/mips/include/asm/mach-loongson64/spaces.h b/arch/mips/include/asm/mach-loongson64/spaces.h index e85bc1d9c4f2..3de0ac9d8829 100644 --- a/arch/mips/include/asm/mach-loongson64/spaces.h +++ b/arch/mips/include/asm/mach-loongson64/spaces.h @@ -6,5 +6,13 @@ #define CAC_BASE _AC(0x9800000000000000, UL) #endif /* CONFIG_64BIT */ +/* Skip 128k to trap NULL pointer dereferences */ +#define PCI_IOBASE _AC(0xc000000000000000 + SZ_128K, UL) +#define PCI_IOSIZE SZ_16M +#define MAP_BASE (PCI_IOBASE + PCI_IOSIZE) + +/* Reserved at the start of PCI_IOBASE for legacy drivers */ +#define MMIO_LOWER_RESERVED 0x10000 + #include #endif diff --git a/arch/mips/loongson64/init.c b/arch/mips/loongson64/init.c index 23eeb85b1abf..59ddadace83f 100644 --- a/arch/mips/loongson64/init.c +++ b/arch/mips/loongson64/init.c @@ -5,6 +5,7 @@ */ #include +#include #include #include #include @@ -45,8 +46,7 @@ void __init prom_init(void) prom_init_env(); /* init base address of io space */ - set_io_port_base((unsigned long) - ioremap(LOONGSON_PCIIO_BASE, LOONGSON_PCIIO_SIZE)); + set_io_port_base(PCI_IOBASE); loongson_sysconf.early_config(); @@ -63,7 +63,45 @@ void __init prom_free_prom_memory(void) { } +static __init void reserve_pio_range(void) +{ + struct logic_pio_hwaddr *range; + + range = kzalloc(sizeof(*range), GFP_ATOMIC); + if (!range) + return; + + range->fwnode = &of_root->fwnode; + range->size = MMIO_LOWER_RESERVED; + range->hw_start = LOONGSON_PCIIO_BASE; + range->flags = LOGIC_PIO_CPU_MMIO; + + if (logic_pio_register_range(range)) { + pr_err("Failed to reserve PIO range for legacy ISA\n"); + goto free_range; + } + + if (WARN(range->io_start != 0, + "Reserved PIO range does not start from 0\n")) + goto unregister; + + /* + * i8259 would access I/O space, so mapping must be done here. + * Please remove it when all drivers can be managed by logic_pio. + */ + ioremap_page_range(PCI_IOBASE, PCI_IOBASE + MMIO_LOWER_RESERVED, + LOONGSON_PCIIO_BASE, + pgprot_device(PAGE_KERNEL)); + + return; +unregister: + logic_pio_unregister_range(range); +free_range: + kfree(range); +} + void __init arch_init_irq(void) { + reserve_pio_range(); irqchip_init(); } -- 2.27.0.rc0