Message ID | 20230522105049.1467313-10-schnelle@linux.ibm.com |
---|---|
State | New |
Headers |
Return-Path: <linux-kernel-owner@vger.kernel.org> Delivered-To: ouuuleilei@gmail.com Received: by 2002:a59:b0ea:0:b0:3b6:4342:cba0 with SMTP id b10csp1363339vqo; Mon, 22 May 2023 04:09:55 -0700 (PDT) X-Google-Smtp-Source: ACHHUZ5HM4jnWibev+AgdM60inCXOLg7v5Uyi1BgBlp5oJrjzMcRhRnGTa0yI5SaFzNMVsn2w6QW X-Received: by 2002:a17:902:ab4e:b0:1ae:4ddd:9961 with SMTP id ij14-20020a170902ab4e00b001ae4ddd9961mr10749588plb.20.1684753795626; Mon, 22 May 2023 04:09:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1684753795; cv=none; d=google.com; s=arc-20160816; b=iG1O6vzUf3wJHJH8DM/QzTOO3LVy6L5ummn9h4YTisde7Yuo1ypn1SdW/ZPASlM+DG aPiKfYglldh3WRfxGoj2bzcGH5ku+OJxk7fsAzUnpSP+6C4P/UIT/4ZkgD9evh3bEXAR qluvbVLe02c3UQhB7380pFre8ST6N0hg97K1SDt+HW/6NYJk6Z82t1BiL9MkyFuTElXp Pt+5A+m9+0qyAGAU4WAEaIYHAHAL1q7lrgIqB0Q4l39eaLSqfw78o9XDuI2W0K09byd1 wDVSFQ+XSpONOrzx373ttswCcWFqWZUyfjQxGocZv4W/0dcgnoP8WCLCj3rKmUW8do5T pqzQ== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature; bh=9Kmlo6ZCBjkmXN6T3y03XJrR9HuwFE+uXebCLLUEKWc=; b=s6bMq71KsZJVS5AOWcDreUW9Icx879RMlqqi2LBk2r0dkOlWzttpl1DQJWXRF7GyWx upKkoSQbMLqMDmnQQp85ZsuS1kgjw4epMUdqbzoCHKR3kOH4NoflqY8QGlwNdPHpfqK8 wrXe1L9sMiwWnEU6aMEM2oHX69VdSt+QBAz+wz6Lk9q7c5dHEiDZUP9dGq6ofpStp/fW 9f5IBKRglpwMJJ4sTuZdKwRLEMbPsWHaZNWeAnoekHTZ5JgMMz+RK1JfA6KFRI6b4RVk 042jjpiu3gGECRxuyZ5P+hoib3R3azttrKa9aOec1391Nzmh8SeoNoGYL7nkh6UZU3f3 RktQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jr47dkIC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: from out1.vger.email (out1.vger.email. [2620:137:e000::1:20]) by mx.google.com with ESMTP id 4-20020a170902c24400b001a92875cda9si4224394plg.288.2023.05.22.04.09.40; Mon, 22 May 2023 04:09:55 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) client-ip=2620:137:e000::1:20; Authentication-Results: mx.google.com; dkim=pass header.i=@ibm.com header.s=pp1 header.b=jr47dkIC; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 2620:137:e000::1:20 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=REJECT sp=NONE dis=NONE) header.from=ibm.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232973AbjEVKwD (ORCPT <rfc822;cscallsign@gmail.com> + 99 others); Mon, 22 May 2023 06:52:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41142 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232885AbjEVKvj (ORCPT <rfc822;linux-kernel@vger.kernel.org>); Mon, 22 May 2023 06:51:39 -0400 Received: from mx0b-001b2d01.pphosted.com (mx0b-001b2d01.pphosted.com [148.163.158.5]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DA893100; Mon, 22 May 2023 03:51:18 -0700 (PDT) Received: from pps.filterd (m0353725.ppops.net [127.0.0.1]) by mx0a-001b2d01.pphosted.com (8.17.1.19/8.17.1.19) with ESMTP id 34M9qg4P025283; Mon, 22 May 2023 10:51:04 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ibm.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=pp1; bh=9Kmlo6ZCBjkmXN6T3y03XJrR9HuwFE+uXebCLLUEKWc=; b=jr47dkICdmjhhzDFIKsksvNwxunKZ4lkXK7WMfk+Kv2XJd52XXZQbJ7RWnjwM5WZbLOM CGa/YQQpyXvd6q+pz1T/s7L2equMdbfXWERr9uydF60cR7K0JMROGK7KBzhmfOnvDB7A HCpKIfu+4yfq8oiJoVfOFWWrJQIWR30wVHZwROGAxoJrpJOE4FKwUHIqsY8JM+3zWxl9 uXnXbfdxnJkZ+X6/q2hAZr3yT/A8yQxd8Ws/LKB6OTXqI1eCZVS/ANIf1yuqnu6aZ+FU z8hODjAUZzJlgHHLU4IT8f9+jxi6LOltsQ06wOwVav/BQEIU7DbMqjkYwGpfQAe9rHKS 1Q== Received: from pps.reinject (localhost [127.0.0.1]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qqawenue2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 May 2023 10:51:03 +0000 Received: from m0353725.ppops.net (m0353725.ppops.net [127.0.0.1]) by pps.reinject (8.17.1.5/8.17.1.5) with ESMTP id 34MAaIag031931; Mon, 22 May 2023 10:51:02 GMT Received: from ppma03fra.de.ibm.com (6b.4a.5195.ip4.static.sl-reverse.com [149.81.74.107]) by mx0a-001b2d01.pphosted.com (PPS) with ESMTPS id 3qqawenud2-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 May 2023 10:51:02 +0000 Received: from pps.filterd (ppma03fra.de.ibm.com [127.0.0.1]) by ppma03fra.de.ibm.com (8.17.1.19/8.17.1.19) with ESMTP id 34M6Md9P026246; Mon, 22 May 2023 10:51:00 GMT Received: from smtprelay01.fra02v.mail.ibm.com ([9.218.2.227]) by ppma03fra.de.ibm.com (PPS) with ESMTPS id 3qppe08rk1-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=NOT); Mon, 22 May 2023 10:51:00 +0000 Received: from smtpav04.fra02v.mail.ibm.com (smtpav04.fra02v.mail.ibm.com [10.20.54.103]) by smtprelay01.fra02v.mail.ibm.com (8.14.9/8.14.9/NCO v10.0) with ESMTP id 34MAovm211076336 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Mon, 22 May 2023 10:50:57 GMT Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id A070920043; Mon, 22 May 2023 10:50:57 +0000 (GMT) Received: from smtpav04.fra02v.mail.ibm.com (unknown [127.0.0.1]) by IMSVA (Postfix) with ESMTP id 3649520040; Mon, 22 May 2023 10:50:57 +0000 (GMT) Received: from tuxmaker.boeblingen.de.ibm.com (unknown [9.152.85.9]) by smtpav04.fra02v.mail.ibm.com (Postfix) with ESMTP; Mon, 22 May 2023 10:50:57 +0000 (GMT) From: Niklas Schnelle <schnelle@linux.ibm.com> To: Arnd Bergmann <arnd@arndb.de>, Dave Airlie <airlied@redhat.com>, Gerd Hoffmann <kraxel@redhat.com>, David Airlie <airlied@gmail.com>, Daniel Vetter <daniel@ffwll.ch> Cc: Greg Kroah-Hartman <gregkh@linuxfoundation.org>, Bjorn Helgaas <bhelgaas@google.com>, =?utf-8?q?Uwe_Kleine-K=C3=B6nig?= <u.kleine-koenig@pengutronix.de>, Mauro Carvalho Chehab <mchehab@kernel.org>, Alan Stern <stern@rowland.harvard.edu>, "Rafael J. Wysocki" <rafael@kernel.org>, Geert Uytterhoeven <geert@linux-m68k.org>, Paul Walmsley <paul.walmsley@sifive.com>, Palmer Dabbelt <palmer@dabbelt.com>, Albert Ou <aou@eecs.berkeley.edu>, linux-kernel@vger.kernel.org, linux-arch@vger.kernel.org, linux-pci@vger.kernel.org, Arnd Bergmann <arnd@kernel.org>, virtualization@lists.linux-foundation.org, spice-devel@lists.freedesktop.org, dri-devel@lists.freedesktop.org Subject: [PATCH v5 09/44] drm: handle HAS_IOPORT dependencies Date: Mon, 22 May 2023 12:50:14 +0200 Message-Id: <20230522105049.1467313-10-schnelle@linux.ibm.com> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20230522105049.1467313-1-schnelle@linux.ibm.com> References: <20230522105049.1467313-1-schnelle@linux.ibm.com> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-TM-AS-GCONF: 00 X-Proofpoint-ORIG-GUID: Yn1aYozOoQRQ35axx6-QJVU4LBPEu3YW X-Proofpoint-GUID: embi3Xmr-Ok9P1L4jvo5o27uBBDwkiPk X-Proofpoint-Virus-Version: vendor=baseguard engine=ICAP:2.0.254,Aquarius:18.0.957,Hydra:6.0.573,FMLib:17.11.170.22 definitions=2023-05-22_06,2023-05-22_03,2023-02-09_01 X-Proofpoint-Spam-Details: rule=outbound_notspam policy=outbound score=0 impostorscore=0 adultscore=0 clxscore=1015 malwarescore=0 phishscore=0 spamscore=0 mlxscore=0 priorityscore=1501 bulkscore=0 suspectscore=0 lowpriorityscore=0 mlxlogscore=679 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.12.0-2304280000 definitions=main-2305220089 X-Spam-Status: No, score=-2.0 required=5.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_EF,RCVD_IN_MSPIKE_H2,SPF_HELO_NONE,SPF_PASS, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on lindbergh.monkeyblade.net Precedence: bulk List-ID: <linux-kernel.vger.kernel.org> X-Mailing-List: linux-kernel@vger.kernel.org X-getmail-retrieved-from-mailbox: =?utf-8?q?INBOX?= X-GMAIL-THRID: =?utf-8?q?1766592396230681226?= X-GMAIL-MSGID: =?utf-8?q?1766592396230681226?= |
Series |
treewide: Remove I/O port accessors for HAS_IOPORT=n
|
|
Commit Message
Niklas Schnelle
May 22, 2023, 10:50 a.m. UTC
In a future patch HAS_IOPORT=n will result in inb()/outb() and friends not being declared. We thus need to add HAS_IOPORT as dependency for those drivers using them. In the bochs driver there is optional MMIO support detected at runtime, warn if this isn't taken when HAS_IOPORT is not defined. There is also a direct and hard coded use in cirrus.c which according to the comment is only necessary during resume. Let's just skip this as for example s390 which doesn't have I/O port support also doesen't support suspend/resume. Co-developed-by: Arnd Bergmann <arnd@kernel.org> Signed-off-by: Arnd Bergmann <arnd@kernel.org> Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> --- drivers/gpu/drm/qxl/Kconfig | 1 + drivers/gpu/drm/tiny/bochs.c | 17 +++++++++++++++++ drivers/gpu/drm/tiny/cirrus.c | 2 ++ 3 files changed, 20 insertions(+)
Comments
Hi Am 22.05.23 um 12:50 schrieb Niklas Schnelle: > In a future patch HAS_IOPORT=n will result in inb()/outb() and friends > not being declared. We thus need to add HAS_IOPORT as dependency for > those drivers using them. In the bochs driver there is optional MMIO > support detected at runtime, warn if this isn't taken when > HAS_IOPORT is not defined. > > There is also a direct and hard coded use in cirrus.c which according to > the comment is only necessary during resume. Let's just skip this as > for example s390 which doesn't have I/O port support also doesen't > support suspend/resume. I think we should consider making cirrus depend on HAS_IOPORT. The driver is only for qemu's cirrus emulation, which IIRC can only be enabled for i586. And it has all been deprecated long ago. > > Co-developed-by: Arnd Bergmann <arnd@kernel.org> > Signed-off-by: Arnd Bergmann <arnd@kernel.org> > Signed-off-by: Niklas Schnelle <schnelle@linux.ibm.com> > --- > drivers/gpu/drm/qxl/Kconfig | 1 + > drivers/gpu/drm/tiny/bochs.c | 17 +++++++++++++++++ > drivers/gpu/drm/tiny/cirrus.c | 2 ++ > 3 files changed, 20 insertions(+) > > diff --git a/drivers/gpu/drm/qxl/Kconfig b/drivers/gpu/drm/qxl/Kconfig > index ca3f51c2a8fe..d0e0d440c8d9 100644 > --- a/drivers/gpu/drm/qxl/Kconfig > +++ b/drivers/gpu/drm/qxl/Kconfig > @@ -2,6 +2,7 @@ > config DRM_QXL > tristate "QXL virtual GPU" > depends on DRM && PCI && MMU > + depends on HAS_IOPORT > select DRM_KMS_HELPER > select DRM_TTM > select DRM_TTM_HELPER > diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c > index d254679a136e..3710339407cc 100644 > --- a/drivers/gpu/drm/tiny/bochs.c > +++ b/drivers/gpu/drm/tiny/bochs.c > @@ -2,6 +2,7 @@ > > #include <linux/module.h> > #include <linux/pci.h> > +#include <asm/bug.h> Why not <linux/bug.h> ? > > #include <drm/drm_aperture.h> > #include <drm/drm_atomic_helper.h> > @@ -105,7 +106,9 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val) > > writeb(val, bochs->mmio + offset); > } else { > +#ifdef CONFIG_HAS_IOPORT > outb(val, ioport); > +#endif Would it be feasible to define inb, inw, outb and outw at the top of bochs.c if no HAS_IOPORT has been set? That would avoid the ifdef branching within the code. > } > } > > @@ -119,7 +122,11 @@ static u8 bochs_vga_readb(struct bochs_device *bochs, u16 ioport) > > return readb(bochs->mmio + offset); > } else { > +#ifdef CONFIG_HAS_IOPORT > return inb(ioport); > +#else > + return 0xff; > +#endif > } > } > > @@ -132,8 +139,12 @@ static u16 bochs_dispi_read(struct bochs_device *bochs, u16 reg) > > ret = readw(bochs->mmio + offset); > } else { > +#ifdef CONFIG_HAS_IOPORT > outw(reg, VBE_DISPI_IOPORT_INDEX); > ret = inw(VBE_DISPI_IOPORT_DATA); > +#else > + ret = 0xffff; > +#endif > } > return ret; > } > @@ -145,8 +156,10 @@ static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val) > > writew(val, bochs->mmio + offset); > } else { > +#ifdef CONFIG_HAS_IOPORT > outw(reg, VBE_DISPI_IOPORT_INDEX); > outw(val, VBE_DISPI_IOPORT_DATA); > +#endif > } > } > > @@ -229,6 +242,10 @@ static int bochs_hw_init(struct drm_device *dev) > return -ENOMEM; > } > } else { > + if (!IS_ENABLED(CONFIG_HAS_IOPORT)) { > + DRM_ERROR("I/O ports are not supported\n"); Use drm_err() here. Best regards Thomas > + return -EIO; > + } > ioaddr = VBE_DISPI_IOPORT_INDEX; > iosize = 2; > if (!request_region(ioaddr, iosize, "bochs-drm")) { > diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c > index 594bc472862f..c65fea049bc7 100644 > --- a/drivers/gpu/drm/tiny/cirrus.c > +++ b/drivers/gpu/drm/tiny/cirrus.c > @@ -508,8 +508,10 @@ static void cirrus_crtc_helper_atomic_enable(struct drm_crtc *crtc, > > cirrus_mode_set(cirrus, &crtc_state->mode); > > +#ifdef CONFIG_HAS_IOPORT > /* Unblank (needed on S3 resume, vgabios doesn't do it then) */ > outb(VGA_AR_ENABLE_DISPLAY, VGA_ATT_W); > +#endif > > drm_dev_exit(idx); > } -- Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Frankenstrasse 146, 90461 Nuernberg, Germany GF: Ivo Totev, Andrew Myers, Andrew McDonald, Boudien Moerman HRB 36809 (AG Nuernberg)
On Mon, May 22, 2023, at 14:38, Thomas Zimmermann wrote: > Am 22.05.23 um 12:50 schrieb Niklas Schnelle: >> There is also a direct and hard coded use in cirrus.c which according to >> the comment is only necessary during resume. Let's just skip this as >> for example s390 which doesn't have I/O port support also doesen't >> support suspend/resume. > > I think we should consider making cirrus depend on HAS_IOPORT. The > driver is only for qemu's cirrus emulation, which IIRC can only be > enabled for i586. And it has all been deprecated long ago. I tried it out in arm64 debvm, and both the kernel and Xorg drivers are detected just fine according to the log. I only get a black screen, which could be the result of a missing VGA BIOS or the missing unblank Port I/O in the driver (I doubt the VGA ports are hooked up on arm64 qemu), but there is a good chance that it's currently working for someone else. Arnd
Hi, > > There is also a direct and hard coded use in cirrus.c which according to > > the comment is only necessary during resume. Let's just skip this as > > for example s390 which doesn't have I/O port support also doesen't > > support suspend/resume. > > I think we should consider making cirrus depend on HAS_IOPORT. The driver is > only for qemu's cirrus emulation, which IIRC can only be enabled for i586. Agree. cirrus is x86 only (both i386 / x86_64 though). Just require HAS_IOPORT and be done with it. > And it has all been deprecated long ago. The fact that cirrus used to be the qemu default for many years is pretty much the only reason it is still somewhat relevant today ... take care, Gerd
diff --git a/drivers/gpu/drm/qxl/Kconfig b/drivers/gpu/drm/qxl/Kconfig index ca3f51c2a8fe..d0e0d440c8d9 100644 --- a/drivers/gpu/drm/qxl/Kconfig +++ b/drivers/gpu/drm/qxl/Kconfig @@ -2,6 +2,7 @@ config DRM_QXL tristate "QXL virtual GPU" depends on DRM && PCI && MMU + depends on HAS_IOPORT select DRM_KMS_HELPER select DRM_TTM select DRM_TTM_HELPER diff --git a/drivers/gpu/drm/tiny/bochs.c b/drivers/gpu/drm/tiny/bochs.c index d254679a136e..3710339407cc 100644 --- a/drivers/gpu/drm/tiny/bochs.c +++ b/drivers/gpu/drm/tiny/bochs.c @@ -2,6 +2,7 @@ #include <linux/module.h> #include <linux/pci.h> +#include <asm/bug.h> #include <drm/drm_aperture.h> #include <drm/drm_atomic_helper.h> @@ -105,7 +106,9 @@ static void bochs_vga_writeb(struct bochs_device *bochs, u16 ioport, u8 val) writeb(val, bochs->mmio + offset); } else { +#ifdef CONFIG_HAS_IOPORT outb(val, ioport); +#endif } } @@ -119,7 +122,11 @@ static u8 bochs_vga_readb(struct bochs_device *bochs, u16 ioport) return readb(bochs->mmio + offset); } else { +#ifdef CONFIG_HAS_IOPORT return inb(ioport); +#else + return 0xff; +#endif } } @@ -132,8 +139,12 @@ static u16 bochs_dispi_read(struct bochs_device *bochs, u16 reg) ret = readw(bochs->mmio + offset); } else { +#ifdef CONFIG_HAS_IOPORT outw(reg, VBE_DISPI_IOPORT_INDEX); ret = inw(VBE_DISPI_IOPORT_DATA); +#else + ret = 0xffff; +#endif } return ret; } @@ -145,8 +156,10 @@ static void bochs_dispi_write(struct bochs_device *bochs, u16 reg, u16 val) writew(val, bochs->mmio + offset); } else { +#ifdef CONFIG_HAS_IOPORT outw(reg, VBE_DISPI_IOPORT_INDEX); outw(val, VBE_DISPI_IOPORT_DATA); +#endif } } @@ -229,6 +242,10 @@ static int bochs_hw_init(struct drm_device *dev) return -ENOMEM; } } else { + if (!IS_ENABLED(CONFIG_HAS_IOPORT)) { + DRM_ERROR("I/O ports are not supported\n"); + return -EIO; + } ioaddr = VBE_DISPI_IOPORT_INDEX; iosize = 2; if (!request_region(ioaddr, iosize, "bochs-drm")) { diff --git a/drivers/gpu/drm/tiny/cirrus.c b/drivers/gpu/drm/tiny/cirrus.c index 594bc472862f..c65fea049bc7 100644 --- a/drivers/gpu/drm/tiny/cirrus.c +++ b/drivers/gpu/drm/tiny/cirrus.c @@ -508,8 +508,10 @@ static void cirrus_crtc_helper_atomic_enable(struct drm_crtc *crtc, cirrus_mode_set(cirrus, &crtc_state->mode); +#ifdef CONFIG_HAS_IOPORT /* Unblank (needed on S3 resume, vgabios doesn't do it then) */ outb(VGA_AR_ENABLE_DISPLAY, VGA_ATT_W); +#endif drm_dev_exit(idx); }