From: Thomas Zimmermann <tzimmermann@suse.de>
To: Niklas Schnelle <schnelle@linux.ibm.com>,
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: linux-arch@vger.kernel.org, "Arnd Bergmann" <arnd@kernel.org>,
"Geert Uytterhoeven" <geert@linux-m68k.org>,
"Albert Ou" <aou@eecs.berkeley.edu>,
"Rafael J. Wysocki" <rafael@kernel.org>,
"Greg Kroah-Hartman" <gregkh@linuxfoundation.org>,
"Uwe Kleine-König" <u.kleine-koenig@pengutronix.de>,
linux-pci@vger.kernel.org, linux-kernel@vger.kernel.org,
dri-devel@lists.freedesktop.org,
virtualization@lists.linux-foundation.org,
"Alan Stern" <stern@rowland.harvard.edu>,
"Paul Walmsley" <paul.walmsley@sifive.com>,
"Bjorn Helgaas" <bhelgaas@google.com>,
spice-devel@lists.freedesktop.org,
"Mauro Carvalho Chehab" <mchehab@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>
Subject: Re: [PATCH v5 09/44] drm: handle HAS_IOPORT dependencies
Date: Mon, 22 May 2023 14:38:22 +0200 [thread overview]
Message-ID: <2043cea3-7553-ee9d-4aaa-6f1d22ac4d87@suse.de> (raw)
In-Reply-To: <20230522105049.1467313-10-schnelle@linux.ibm.com>
[-- Attachment #1.1.1: Type: text/plain, Size: 4511 bytes --]
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)
[-- Attachment #1.2: OpenPGP digital signature --]
[-- Type: application/pgp-signature, Size: 840 bytes --]
[-- Attachment #2: Type: text/plain, Size: 183 bytes --]
_______________________________________________
Virtualization mailing list
Virtualization@lists.linux-foundation.org
https://lists.linuxfoundation.org/mailman/listinfo/virtualization
next parent reply other threads:[~2023-05-22 12:38 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <20230522105049.1467313-1-schnelle@linux.ibm.com>
[not found] ` <20230522105049.1467313-10-schnelle@linux.ibm.com>
2023-05-22 12:38 ` Thomas Zimmermann [this message]
2023-05-22 13:06 ` [PATCH v5 09/44] drm: handle HAS_IOPORT dependencies Arnd Bergmann
2023-05-22 13:14 ` Gerd Hoffmann
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=2043cea3-7553-ee9d-4aaa-6f1d22ac4d87@suse.de \
--to=tzimmermann@suse.de \
--cc=airlied@gmail.com \
--cc=airlied@redhat.com \
--cc=aou@eecs.berkeley.edu \
--cc=arnd@arndb.de \
--cc=arnd@kernel.org \
--cc=bhelgaas@google.com \
--cc=daniel@ffwll.ch \
--cc=dri-devel@lists.freedesktop.org \
--cc=geert@linux-m68k.org \
--cc=gregkh@linuxfoundation.org \
--cc=kraxel@redhat.com \
--cc=linux-arch@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-pci@vger.kernel.org \
--cc=mchehab@kernel.org \
--cc=palmer@dabbelt.com \
--cc=paul.walmsley@sifive.com \
--cc=rafael@kernel.org \
--cc=schnelle@linux.ibm.com \
--cc=spice-devel@lists.freedesktop.org \
--cc=stern@rowland.harvard.edu \
--cc=u.kleine-koenig@pengutronix.de \
--cc=virtualization@lists.linux-foundation.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).