Received: by 2002:a25:1506:0:0:0:0:0 with SMTP id 6csp331656ybv; Wed, 19 Feb 2020 00:16:28 -0800 (PST) X-Google-Smtp-Source: APXvYqz3epfPMi5NY4wcEIFtVE98D5SL+GK5mRaKJFzxQU9eJcRNySaXD0gLJohkurlWT0YIhBmF X-Received: by 2002:aca:b808:: with SMTP id i8mr3747245oif.66.1582100188648; Wed, 19 Feb 2020 00:16:28 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1582100188; cv=none; d=google.com; s=arc-20160816; b=auVy6WaRWTw27no1Ev2nWnM9gFjuPEyBud7rxrIqc6XkgP6uSFJB5FKyvg2+P3S5B+ 1aW9fsFiI79eRvvK9D6KGuiHLuvne1gLtu8GZRRkC6NZgTC6BdfLw//VRH18H1YCWXHo KdIDs2IjUBqRwnpmyvySJ0Hwur6tOhi6cK/vrBdvHM5JT65qEJoJFkNgKRGBqY7yN+wf FjVVCuV0abwbDrUePIiI3t8dvals5dmnCm02FgETt80F1WnMXN4aH4K3pAjsPL4bt1sT EC/vqCsKZ9lpU0x57Fx45zHExA5q14G+y9T4Kuoffkfj8+B8qSE4gXuCJw9vhA9hQ2XJ oC2Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:in-reply-to:mime-version:user-agent:date :message-id:autocrypt:from:references:cc:to:subject; bh=hlnUVZaXw9//ugUEPaUBcdnIuhSTgMJT7F3QHyRWQLY=; b=E8X03aW4E/ilugpS5C6oLz5x/ia2MejsvxNs14AbZqlBvGhIY06IqWm4jhBJqNr+y+ Yv44+pi5tzpeds5COdG59HHNbli0svf6G3zmTYEjNYPFE0cHg4ghqIsI52fesk4ysJo/ /HajWSNsbV3yLS5q1zKX2KjSlGRLO6yQkCN8mUw7YrzjdT+k7lka63Nhv5FqSazRNH8B 0+0dfRBrCjm+d7/CDfkR9WkjtFFgPtT7ktNDA/K70ARK5o9JAdV6UqFwolrcqnk/dJBX UaOozsW4ui5Iczm2VYpAftkcqVl3LQGRzI+qLPDrDaziGk7QdFCCvzqDEJIGW3sdy3g9 HDFg== ARC-Authentication-Results: i=1; mx.google.com; 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 Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id v14si770959oto.127.2020.02.19.00.16.16; Wed, 19 Feb 2020 00:16:28 -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; 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 Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726651AbgBSIPw (ORCPT + 99 others); Wed, 19 Feb 2020 03:15:52 -0500 Received: from mx2.suse.de ([195.135.220.15]:56954 "EHLO mx2.suse.de" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726156AbgBSIPw (ORCPT ); Wed, 19 Feb 2020 03:15:52 -0500 X-Virus-Scanned: by amavisd-new at test-mx.suse.de Received: from relay2.suse.de (unknown [195.135.220.254]) by mx2.suse.de (Postfix) with ESMTP id B156BAC77; Wed, 19 Feb 2020 08:15:49 +0000 (UTC) Subject: Re: [PATCH] drm/hisilicon: Fixed pcie resource conflict between drm and firmware To: Tian Tao , puck.chen@hisilicon.com, airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de, dri-devel@lists.freedesktop.org, xinliang.liu@linaro.org, linux-kernel@vger.kernel.org Cc: linuxarm@huawei.com References: <1582099028-11898-1-git-send-email-tiantao6@hisilicon.com> From: Thomas Zimmermann Autocrypt: addr=tzimmermann@suse.de; keydata= mQENBFs50uABCADEHPidWt974CaxBV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2Dyoklv5g4BzkgqTqwmaYzsl8UxZKvbaxq0zb ehDda8lvhFXodNFMAgTLJlLuDYOGLK2AwbrS3Sp0AEbkpdJBb44qVlGm5bApZouHeJ/+n+7r 12+lqdsAEQEAAYkBPAQYAQgAJhYhBHIX+6yM6c9jRKFo5WgNwR1TC3ojBQJbOdLgAhsMBQkD wmcAAAoJEGgNwR1TC3ojpfcIAInwP5OlcEKokTnHCiDTz4Ony4GnHRP2fXATQZCKxmu4AJY2 h9ifw9Nf2TjCZ6AMvC3thAN0rFDj55N9l4s1CpaDo4J+0fkrHuyNacnT206CeJV1E7NYntxU n+LSiRrOdywn6erjxRi9EYTVLCHcDhBEjKmFZfg4AM4GZMWX1lg0+eHbd5oL1as28WvvI/uI aMyV8RbyXot1r/8QLlWldU3NrTF5p7TMU2y3ZH2mf5suSKHAMtbE4jKJ8ZHFOo3GhLgjVrBW HE9JXO08xKkgD+w6v83+nomsEuf6C6LYrqY/tsZvyEX6zN8CtirPdPWu/VXNRYAl/lat7lSI 3H26qrE= Message-ID: Date: Wed, 19 Feb 2020 09:15:43 +0100 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:68.0) Gecko/20100101 Thunderbird/68.4.1 MIME-Version: 1.0 In-Reply-To: <1582099028-11898-1-git-send-email-tiantao6@hisilicon.com> Content-Type: multipart/signed; micalg=pgp-sha256; protocol="application/pgp-signature"; boundary="2TCicCorfrob0WIHJP1kYN0Mbg5J7q3gq" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is an OpenPGP/MIME signed message (RFC 4880 and 3156) --2TCicCorfrob0WIHJP1kYN0Mbg5J7q3gq Content-Type: multipart/mixed; boundary="7FeCYlLoLepIv4tveMASgztSRpcpIUxb1"; protected-headers="v1" From: Thomas Zimmermann To: Tian Tao , puck.chen@hisilicon.com, airlied@linux.ie, daniel@ffwll.ch, kraxel@redhat.com, alexander.deucher@amd.com, tglx@linutronix.de, dri-devel@lists.freedesktop.org, xinliang.liu@linaro.org, linux-kernel@vger.kernel.org Cc: linuxarm@huawei.com Message-ID: Subject: Re: [PATCH] drm/hisilicon: Fixed pcie resource conflict between drm and firmware References: <1582099028-11898-1-git-send-email-tiantao6@hisilicon.com> In-Reply-To: <1582099028-11898-1-git-send-email-tiantao6@hisilicon.com> --7FeCYlLoLepIv4tveMASgztSRpcpIUxb1 Content-Type: text/plain; charset=utf-8 Content-Language: en-US Content-Transfer-Encoding: quoted-printable Hi Am 19.02.20 um 08:57 schrieb Tian Tao: > remove the framebuffer initialized by fireware/bootloader,which will us= e > hibmc's pcie resource, and may cause conflict. >=20 > Signed-off-by: Tian Tao > Signed-off-by: Gong junjie > --- > drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c | 18 +++++++++++++++++= + > 1 file changed, 18 insertions(+) >=20 > diff --git a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c b/drivers/= gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c > index 5f612f6..7ebe831 100644 > --- a/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c > +++ b/drivers/gpu/drm/hisilicon/hibmc/hibmc_drm_drv.c > @@ -47,6 +47,22 @@ static irqreturn_t hibmc_drm_interrupt(int irq, void= *arg) > return IRQ_HANDLED; > } > =20 > +static void hibmc_remove_framebuffers(struct pci_dev *pdev) > +{ > + struct apertures_struct *ap; > + > + ap =3D alloc_apertures(1); > + if (!ap) > + return; > + > + ap->ranges[0].base =3D pci_resource_start(pdev, 0); > + ap->ranges[0].size =3D pci_resource_len(pdev, 0); > + > + drm_fb_helper_remove_conflicting_framebuffers(ap, "hibmcdrmfb", false= ); > + > + kfree(ap); > +} > + > static struct drm_driver hibmc_driver =3D { > .driver_features =3D DRIVER_GEM | DRIVER_MODESET | DRIVER_ATOMIC, > .fops =3D &hibmc_fops, > @@ -327,6 +343,8 @@ static int hibmc_pci_probe(struct pci_dev *pdev, > struct drm_device *dev; > int ret; > =20 > + hibmc_remove_framebuffers(pdev); Instead of rolling your own, you should try drm_fb_helper_remove_conflicting_pci_framebuffers(). It releases any I/O memory resource of the device. Best regards Thomas > + > dev =3D drm_dev_alloc(&hibmc_driver, &pdev->dev); > if (IS_ERR(dev)) { > DRM_ERROR("failed to allocate drm_device\n"); >=20 --=20 Thomas Zimmermann Graphics Driver Developer SUSE Software Solutions Germany GmbH Maxfeldstr. 5, 90409 N=C3=BCrnberg, Germany (HRB 36809, AG N=C3=BCrnberg) Gesch=C3=A4ftsf=C3=BChrer: Felix Imend=C3=B6rffer --7FeCYlLoLepIv4tveMASgztSRpcpIUxb1-- --2TCicCorfrob0WIHJP1kYN0Mbg5J7q3gq Content-Type: application/pgp-signature; name="signature.asc" Content-Description: OpenPGP digital signature Content-Disposition: attachment; filename="signature.asc" -----BEGIN PGP SIGNATURE----- iQEzBAEBCAAdFiEEchf7rIzpz2NEoWjlaA3BHVMLeiMFAl5M7rAACgkQaA3BHVML eiOFygf/XtAbLO8y9AboCrN7iwvg4K6NMpmYYaK2XuoPB7skvflM1IH+unp8utMc ihNeWnjT6x2yMfP5UPk32kI8LYNBIUepzLTQkSWMV+t7HV0sC/fYnKMV521jDxq/ s0KGECISBrGOGp/ZwYWodY3Gor4zuSF+6/qqIIB8Watb+ly/0cSjnH4SahZCUd1l r7+RLW3vsUWhpG2hkh+Tx8g8J2jRKU2+rAoEPOUOtnZrmk3thWocYdJ8X9uP8BRN 4aG4cTpRYWgnZiS/dLsm2BFL/zJciUUnbPMgMYr2sMzZ5k1hItZzFXupyS3cH659 aOWtpbyn4iJreiuiNqxhGQHI6IWxtA== =wpyX -----END PGP SIGNATURE----- --2TCicCorfrob0WIHJP1kYN0Mbg5J7q3gq--