Re: [PATCH] drm: virtio: fix virtio_gpu_cursor_formats

2017-04-06 Thread Laurent Vivier
On 05/04/2017 19:11, Ville Syrjälä wrote:
> On Wed, Apr 05, 2017 at 10:09:15AM +0200, Laurent Vivier wrote:
>> When we use virtio-vga with a big-endian guest,
>> the mouse pointer disappears.
>>
>> To fix that, on big-endian use DRM_FORMAT_BGRA
>> instead of DRM_FORMAT_ARGB8888.
>>
>> Signed-off-by: Laurent Vivier <lviv...@redhat.com>
>> ---
>>  drivers/gpu/drm/virtio/virtgpu_plane.c | 4 
>>  1 file changed, 4 insertions(+)
>>
>> diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c 
>> b/drivers/gpu/drm/virtio/virtgpu_plane.c
>> index 11288ff..3ed7174 100644
>> --- a/drivers/gpu/drm/virtio/virtgpu_plane.c
>> +++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
>> @@ -39,7 +39,11 @@ static const uint32_t virtio_gpu_formats[] = {
>>  };
>>  
>>  static const uint32_t virtio_gpu_cursor_formats[] = {
>> +#ifdef __BIG_ENDIAN
>> +DRM_FORMAT_BGRA,
>> +#else
>>  DRM_FORMAT_ARGB,
>> +#endif
> 
> DRM formats are supposed to be little endian, so this isn't really
> correct.

In a big endian kernel, we need to swap the bytes order, where do you
think is the best place to do that?

Thanks,
Laurent
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] drm: virtio: fix virtio_gpu_cursor_formats

2017-04-05 Thread Laurent Vivier
When we use virtio-vga with a big-endian guest,
the mouse pointer disappears.

To fix that, on big-endian use DRM_FORMAT_BGRA
instead of DRM_FORMAT_ARGB.

Signed-off-by: Laurent Vivier <lviv...@redhat.com>
---
 drivers/gpu/drm/virtio/virtgpu_plane.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/gpu/drm/virtio/virtgpu_plane.c 
b/drivers/gpu/drm/virtio/virtgpu_plane.c
index 11288ff..3ed7174 100644
--- a/drivers/gpu/drm/virtio/virtgpu_plane.c
+++ b/drivers/gpu/drm/virtio/virtgpu_plane.c
@@ -39,7 +39,11 @@ static const uint32_t virtio_gpu_formats[] = {
 };
 
 static const uint32_t virtio_gpu_cursor_formats[] = {
+#ifdef __BIG_ENDIAN
+   DRM_FORMAT_BGRA,
+#else
DRM_FORMAT_ARGB,
+#endif
 };
 
 static void virtio_gpu_plane_destroy(struct drm_plane *plane)
-- 
2.9.3

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


Re: [PATCH 0/2] virtio: fix virtio_gpu_mode_dumb_create

2017-04-05 Thread Laurent Vivier
On 03/04/2017 09:08, Gerd Hoffmann wrote:
>   Hi,
> 
> Little series to fix xorg display on virtio on bigendian machines.
> First patch factors out the drm -> virtio format mapping code into
> a helper function, second patch actually fixes the issue using the
> new helper.
> 
> cheers,
>   Gerd
> 
> Gerd Hoffmann (2):
>   drm: virtio: add virtio_gpu_translate_format
>   drm: virtio: fix virtio_gpu_mode_dumb_create
> 
>  drivers/gpu/drm/virtio/virtgpu_drv.h   |  1 +
>  drivers/gpu/drm/virtio/virtgpu_fb.c| 58 +
>  drivers/gpu/drm/virtio/virtgpu_gem.c   |  6 ++-
>  drivers/gpu/drm/virtio/virtgpu_plane.c | 68 
> ++
>  4 files changed, 75 insertions(+), 58 deletions(-)
> 

Tested-by: Laurent Vivier <lviv...@redhat.com>

Tested with BE endian kernel in QEMU pseries emulation on a LE endian
kernel host.

This fixes mixed RGB colors with X11.

Thanks,
Laurent
___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] virtio-gpu: disable VIRGL with BE kernel

2017-01-24 Thread Laurent Vivier
VIRTIO_GPU_F_VIRGL is added in features list only
for LE kernel, so we must check for it only on LE kernel,
otherwise virtio_has_feature() calls BUG() and
crashes the kernel.

Suggested-by: Gerd Hoffmann <kra...@redhat.com>
Signed-off-by: Laurent Vivier <lviv...@redhat.com>
---
Note: this patch has been actually written by Gerd,
but to post it I don't know if "Suggested-by" is enough
or if I should change the "author" field.

 drivers/gpu/drm/virtio/virtgpu_kms.c | 6 +-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/drivers/gpu/drm/virtio/virtgpu_kms.c 
b/drivers/gpu/drm/virtio/virtgpu_kms.c
index 1235519..87915d5 100644
--- a/drivers/gpu/drm/virtio/virtgpu_kms.c
+++ b/drivers/gpu/drm/virtio/virtgpu_kms.c
@@ -166,10 +166,14 @@ int virtio_gpu_driver_load(struct drm_device *dev, 
unsigned long flags)
INIT_WORK(>config_changed_work,
  virtio_gpu_config_changed_work_func);
 
+#ifdef __LITTLE_ENDIAN
if (virtio_has_feature(vgdev->vdev, VIRTIO_GPU_F_VIRGL))
vgdev->has_virgl_3d = true;
DRM_INFO("virgl 3d acceleration %s\n",
-vgdev->has_virgl_3d ? "enabled" : "not available");
+vgdev->has_virgl_3d ? "enabled" : "not supported by host");
+#else
+   DRM_INFO("virgl 3d acceleration not supported by guest\n");
+#endif
 
ret = vgdev->vdev->config->find_vqs(vgdev->vdev, 2, vqs,
callbacks, names);
-- 
2.7.4

___
dri-devel mailing list
dri-devel@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/dri-devel


[PATCH] nouveau,openfirmware: remove useless of_size function

2015-10-15 Thread Laurent Vivier
On of_init(), we store the size given by the openfirmware in bios->size,
this allows to remove of_size that is only used by openfirmware interface.
As bios->size is the size of available data in bios->data, we must
copy all data to bios->data.

Tested on PowerMac G5 with 64bit kernel and a NV43 card (GeForce 6600 LE).

CC: imirkin at alum.mit.edu
Signed-off-by: Laurent Vivier 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/priv.h |  1 -
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c   |  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c | 16 ++--
 3 files changed, 7 insertions(+), 12 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/priv.h 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/priv.h
index 212800e..7b026ce 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/priv.h
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/priv.h
@@ -8,7 +8,6 @@ struct nvbios_source {
void *(*init)(struct nvkm_bios *, const char *);
void  (*fini)(void *);
u32   (*read)(void *, u32 offset, u32 length, struct nvkm_bios *);
-   u32   (*size)(void *);
bool rw;
bool ignore_checksum;
bool no_pcir;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
index b2557e8..44e8525 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
@@ -58,7 +58,7 @@ shadow_image(struct nvkm_bios *bios, int idx, u32 offset, 
struct shadow *mthd)
if (mthd->func->no_pcir) {
image.base = 0;
image.type = 0;
-   image.size = mthd->func->size(mthd->data);
+   image.size = bios->size;
image.last = 1;
} else {
if (!shadow_fetch(bios, mthd, offset + 0x1000)) {
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
index 4bf486b..6e4a863 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
@@ -36,19 +36,11 @@ of_read(void *data, u32 offset, u32 length, struct 
nvkm_bios *bios)
struct priv *priv = data;
if (offset < priv->size) {
length = min_t(u32, length, priv->size - offset);
-   memcpy_fromio(bios->data + offset, priv->data + offset, length);
return length;
}
return 0;
 }

-static u32
-of_size(void *data)
-{
-   struct priv *priv = data;
-   return priv->size;
-}
-
 static void *
 of_init(struct nvkm_bios *bios, const char *name)
 {
@@ -60,8 +52,13 @@ of_init(struct nvkm_bios *bios, const char *name)
return ERR_PTR(-ENODEV);
if (!(priv = kzalloc(sizeof(*priv), GFP_KERNEL)))
return ERR_PTR(-ENOMEM);
-   if ((priv->data = of_get_property(dn, "NVDA,BMP", >size)))
+   priv->data = of_get_property(dn, "NVDA,BMP", >size);
+   if (priv->data) {
+   bios->size = priv->size;
+   bios->data = kzalloc(bios->size, GFP_KERNEL);
+   memcpy(bios->data, priv->data, bios->size);
return priv;
+   }
kfree(priv);
return ERR_PTR(-EINVAL);
 }
@@ -72,7 +69,6 @@ nvbios_of = {
.init = of_init,
.fini = (void(*)(void *))kfree,
.read = of_read,
-   .size = of_size,
.rw = false,
.ignore_checksum = true,
.no_pcir = true,
-- 
2.4.3



[PATCH v2] nouveau: fix OpenFirmware support

2015-10-14 Thread Laurent Vivier


Le 14/10/2015 16:52, Ilia Mirkin a écrit :
> On Wed, Oct 14, 2015 at 10:20 AM, Olaf Hering  wrote:
>> On Sun, Oct 11, Laurent Vivier wrote:
>>
>>> On PowerMac G5 (and I think on all OpenFirmware platforms), nvbios_pcirTp()
>>> returns NULL. But in fact the OpenFirmware has given us the size
>>> we can store in image->size.
>>
>>> CC: imirkin at alum.mit.edu
>>> Signed-off-by: Laurent Vivier 
>>
>> Tested-by: Olaf Hering 
>>
>> Broken since a while already...
>> https://lists.ozlabs.org/pipermail/linuxppc-dev/2015-March/126737.html
> 
> FTR, looks like my version is upstream now:
> https://git.kernel.org/cgit/linux/kernel/git/torvalds/linux.git/commit/?id=25d295882a1adfcdaaad85369289677b87c7c8f0
> 
> I agree that my of_size thing was a bit of a hack, if you want to redo
> it by removing of_size/of_read from shadowof.c and copying it in at
> init time (also a hack, IMHO), I certainly wouldn't object. As before,
> it's Ben's call though.

It's nice to have a fix upstream.

I'll send a patch to remove the of_size.

Rereading your patch and mine, I think we don't need no_pcir, we can do
instead:

if (!nvbios_rd16(bios, base + 0x18)) {
/* no PCIr */
image.base = 0;
image.type = 0;
image.size = bios->size;
image.last = 1;
} else {
if (!shadow_fetch(bios, mthd, offset + 0x1000)) {

...
What is you opinion ?

Laurent



[PATCH v2] nouveau: fix OpenFirmware support

2015-10-11 Thread Laurent Vivier
On PowerMac G5 (and I think on all OpenFirmware platforms), nvbios_pcirTp()
returns NULL. But in fact the OpenFirmware has given us the size
we can store in image->size.

The NV34 has a small image and an invalid checksum, we manage this by
changing the size of the header we try to fetch (reduce from 4096 to 1024),
and by setting the image->type from nvbios_of->init(). A type of "1"
avoid to compute the checksum.

This size is stored in bios->size by of_init() as there is no way
to retrieve it otherwise. And as we know the size, copy all data
to bios->data.

Tested on PowerMac G5 with 64bit kernel and a NV43 card (GeForce 6600 LE),
and a NV34 (GeForce FX 5200 Ultra).

Before:

nouveau :0a:00.0: NVIDIA NV43 (043200a4)
u3msi: allocated virq 0x19 (hw 0x8) addr 0xf8004080
nouveau :0a:00.0: Invalid ROM contents
nouveau :0a:00.0: bios: unable to locate usable image
nouveau :0a:00.0: bios ctor failed, -22
nouveau: probe of :0a:00.0 failed with error -22

After:

nouveau :0a:00.0: NVIDIA NV43 (043200a4)
u3msi: allocated virq 0x19 (hw 0x8) addr 0xf8004080
nouveau :0a:00.0: bios: version 05.43.02.75.00
nouveau :0a:00.0: fb: 128 MiB DDR1
nouveau :0a:00.0: Using 32-bit DMA via iommu
[TTM] Zone  kernel: Available graphics memory: 5610528 kiB
[TTM] Zone   dma32: Available graphics memory: 2097152 kiB
[TTM] Initializing pool allocator
[TTM] Initializing DMA pool allocator
nouveau :0a:00.0: DRM: VRAM: 124 MiB
nouveau :0a:00.0: DRM: GART: 512 MiB
nouveau :0a:00.0: DRM: TMDS table version 1.1
nouveau :0a:00.0: DRM: DCB version 3.0
nouveau :0a:00.0: DRM: DCB outp 00: 01000100 0028
nouveau :0a:00.0: DRM: DCB outp 01: 03000102 
nouveau :0a:00.0: DRM: DCB outp 02: 04011210 0028
nouveau :0a:00.0: DRM: DCB outp 03: 02111212 02000100
nouveau :0a:00.0: DRM: DCB outp 04: 02011211 0020c070
nouveau :0a:00.0: DRM: DCB conn 00: 1030
nouveau :0a:00.0: DRM: DCB conn 01: 2130
[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[drm] Driver supports precise vblank timestamp query.
nouveau :0a:00.0: DRM: 0x14C5: Parsing digital output script table
nouveau :0a:00.0: DRM: MM: using M2MF for buffer copies
nouveau :0a:00.0: DRM: Setting dpms mode 3 on TV encoder (output 4)
nouveau :0a:00.0: DRM: allocated 1680x1050 fb: 0x3, bo 
c399d800
nouveau :0a:00.0: DRM: 0x14C5: Parsing digital output script table
Console: switching to colour frame buffer device 210x65
nouveau :0a:00.0: fb0: nouveaufb frame buffer device
[drm] Initialized nouveau 1.3.0 20120801 for :0a:00.0 on minor 0

CC: imirkin at alum.mit.edu
Signed-off-by: Laurent Vivier 
---
v2: manage NV34: fetch a smaller header size to avoid error,
 disable checksum from nvbios_of->init()

 drivers/gpu/drm/nouveau/include/nvkm/subdev/bios.h  |  1 +
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c| 13 +++--
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c   |  2 +-
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c | 12 ++--
 4 files changed, 23 insertions(+), 5 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios.h 
b/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios.h
index e39a1fe..785342d 100644
--- a/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios.h
+++ b/drivers/gpu/drm/nouveau/include/nvkm/subdev/bios.h
@@ -6,6 +6,7 @@ struct nvkm_bios {
struct nvkm_subdev subdev;
u32 size;
u8 *data;
+   u8 type;

u32 bmp_offset;
u32 bit_offset;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c
index 74b14cf..25588f4 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c
@@ -47,8 +47,17 @@ nvbios_imagen(struct nvkm_bios *bios, struct nvbios_image 
*image)
return false;
}

-   if (!(data = nvbios_pcirTp(bios, image->base, , , )))
-   return false;
+   data = nvbios_pcirTp(bios, image->base, , , );
+   if (!data) {
+   /* in the case of openfirmware, size, data and type have
+* already been set and known from the device tree
+*/
+   image->size = bios->size;
+   image->type = bios->type;
+   image->last = true;
+
+   return true;
+   }
image->size = pcir.image_size;
image->type = pcir.image_type;
image->last = pcir.last;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
index 792f017..edc4f23 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadow.c

[PATCH] nouveau: fix OpenFirmware support

2015-10-11 Thread Laurent Vivier


Le 11/10/2015 01:49, Ilia Mirkin a écrit :
> On Sat, Oct 10, 2015 at 7:45 PM, Laurent Vivier  wrote:
>>
>>
>> Le 10/10/2015 21:56, Ilia Mirkin a écrit :
>>> On Sat, Oct 10, 2015 at 3:29 PM, Laurent Vivier  
>>> wrote:
>>>>
>>>>
>>>> Le 10/10/2015 20:41, Ilia Mirkin a écrit :
>>>>> Hi Laurent,
>>>>>
>>>>> On Sat, Oct 10, 2015 at 9:27 AM, Laurent Vivier  
>>>>> wrote:
>>>>>> On PowerMac G5 (and I think on all OpenFirmware platforms), 
>>>>>> nvbios_pcirTp()
>>>>>> returns NULL. But in fact the OpenFirmware has given us the size
>>>>>> we can store in image->size.
>>>>>>
>>>>>> This size is stored in bios->size by of_init() as there is no way
>>>>>> to retrieve it otherwise. And as we know the size, copy all data
>>>>>> to bios->data.
>>>>>>
>>>>>> Tested on PowerMac G5 with 64bit kernel and a NV43 card (GeForce 6600 
>>>>>> LE).
>>>>>
>>>>> Can you give this patch a shot instead?
>>>>>
>>>>> http://cgit.freedesktop.org/~darktama/nouveau/commit/?id=794a63cc75eada9ad6b2a0275c1c8c4d3522864f
>>>>
>>>> Well, I think mine is also a good solution and it is much more simple.
>>>> ;)
>>>>
>>>> ... because it is useless to add a size() function if we can directly
>>>> copy the content/size of the bios in bios->data and bios->size.
>>>> We can do that because we have the size of the property, which is not
>>>> the case when we discover the BIOS directly from a PCI ROM or from ACPI
>>>> (this is why we need a shadow, I think).
>>>
>>> I'll let Ben rule on this.
>>>
>>>>
>>>> For pcir part, I think we can just ignore the result and take the size
>>>> from bios->size, as in the case of non openfirmware bios->size will be 4
>>>> (we have only shadowed the first word to read the id, 0xaa55) and then
>>>> the checksum and others ID searches will fail. So I think the checksum
>>>> should not be ignored.
>>>
>>> Non-OF will still end up with a NVDA,BMP file? That seems surprising.
>>> My understanding is that if OF has it, it should be used. The problem
>>> is that e.g. on my GPU I have a perfectly valid PCI ROM, whose
>>> checksum matches and everything, but it contains who-knows-what apple
>>> happened to leave in there. So I still want OF. Ignoring checksum
>>> failures allows nouveau to always select the OF vbios.
>>>
>>>>
>>>> I've tried to restore behavior before commit:
>>>>
>>>> 7af4dec drm/nouveau/bios: use size/type from pci data structure
>>>>
>>>> and commit:
>>>>
>>>> ad4a362 drm/nouveau/bios: split out shadow methods
>>>>
>>>> Originally, openfirmware content was copied directly into bios->data:
>>>
>>> Yeah, but then the whole interface was redone.
>>>
>>>>
>>>> 77145f1 drm/nouveau: port remainder of drm code, and rip out compat layer
>>>>
>>>>> This resolved my issues on a PPC G5 + NV34. I think mine ran into a
>>>>> few additional problems that you didn't see -- no PCIR header and
>>>>> invalid checksum.
>>>>
>>>> I have no PCIR header too.
>>>
>>> Er right. I realized that shortly after I sent the email. However my
>>> bios isn't even 0x1000 in size, so the read would fail due to not
>>> enough length. (It's also an odd number in size, and your patch chops
>>> off the last few bytes.) The read could, of course, be reduced in
>>> size, but that whole logic is to deal with multiple parts in a vbios,
>>> which on GM20x contain some necessary blobs. I wasn't sure where the
>>> 0x1000 came from or whether it was significant.
>>>
>>>>
>>>> Could you send me the content of the file "NVDA,BMP" you can find
>>>> somewhere under /proc/device-tree/ ?
>>>
>>> http://filebin.ca/2Ib4SdDOAQqC/nv34-vbios.rom
>>>
>>> Note that it's a 2404 byte file as uploaded, but that was from an
>>> attempt to do something silly -- in reality it's 2403 bytes.
>>>
>>>>
>>>> Could you try my patch on your system, please ?
>>>
>>> My G5 is off for now, and the time I do spend with it 

[PATCH] nouveau: fix OpenFirmware support

2015-10-11 Thread Laurent Vivier


Le 10/10/2015 21:56, Ilia Mirkin a écrit :
> On Sat, Oct 10, 2015 at 3:29 PM, Laurent Vivier  wrote:
>>
>>
>> Le 10/10/2015 20:41, Ilia Mirkin a écrit :
>>> Hi Laurent,
>>>
>>> On Sat, Oct 10, 2015 at 9:27 AM, Laurent Vivier  
>>> wrote:
>>>> On PowerMac G5 (and I think on all OpenFirmware platforms), nvbios_pcirTp()
>>>> returns NULL. But in fact the OpenFirmware has given us the size
>>>> we can store in image->size.
>>>>
>>>> This size is stored in bios->size by of_init() as there is no way
>>>> to retrieve it otherwise. And as we know the size, copy all data
>>>> to bios->data.
>>>>
>>>> Tested on PowerMac G5 with 64bit kernel and a NV43 card (GeForce 6600 LE).
>>>
>>> Can you give this patch a shot instead?
>>>
>>> http://cgit.freedesktop.org/~darktama/nouveau/commit/?id=794a63cc75eada9ad6b2a0275c1c8c4d3522864f
>>
>> Well, I think mine is also a good solution and it is much more simple.
>> ;)
>>
>> ... because it is useless to add a size() function if we can directly
>> copy the content/size of the bios in bios->data and bios->size.
>> We can do that because we have the size of the property, which is not
>> the case when we discover the BIOS directly from a PCI ROM or from ACPI
>> (this is why we need a shadow, I think).
> 
> I'll let Ben rule on this.
> 
>>
>> For pcir part, I think we can just ignore the result and take the size
>> from bios->size, as in the case of non openfirmware bios->size will be 4
>> (we have only shadowed the first word to read the id, 0xaa55) and then
>> the checksum and others ID searches will fail. So I think the checksum
>> should not be ignored.
> 
> Non-OF will still end up with a NVDA,BMP file? That seems surprising.
> My understanding is that if OF has it, it should be used. The problem
> is that e.g. on my GPU I have a perfectly valid PCI ROM, whose
> checksum matches and everything, but it contains who-knows-what apple
> happened to leave in there. So I still want OF. Ignoring checksum
> failures allows nouveau to always select the OF vbios.
> 
>>
>> I've tried to restore behavior before commit:
>>
>> 7af4dec drm/nouveau/bios: use size/type from pci data structure
>>
>> and commit:
>>
>> ad4a362 drm/nouveau/bios: split out shadow methods
>>
>> Originally, openfirmware content was copied directly into bios->data:
> 
> Yeah, but then the whole interface was redone.
> 
>>
>> 77145f1 drm/nouveau: port remainder of drm code, and rip out compat layer
>>
>>> This resolved my issues on a PPC G5 + NV34. I think mine ran into a
>>> few additional problems that you didn't see -- no PCIR header and
>>> invalid checksum.
>>
>> I have no PCIR header too.
> 
> Er right. I realized that shortly after I sent the email. However my
> bios isn't even 0x1000 in size, so the read would fail due to not
> enough length. (It's also an odd number in size, and your patch chops
> off the last few bytes.) The read could, of course, be reduced in
> size, but that whole logic is to deal with multiple parts in a vbios,
> which on GM20x contain some necessary blobs. I wasn't sure where the
> 0x1000 came from or whether it was significant.
> 
>>
>> Could you send me the content of the file "NVDA,BMP" you can find
>> somewhere under /proc/device-tree/ ?
> 
> http://filebin.ca/2Ib4SdDOAQqC/nv34-vbios.rom
> 
> Note that it's a 2404 byte file as uploaded, but that was from an
> attempt to do something silly -- in reality it's 2403 bytes.
> 
>>
>> Could you try my patch on your system, please ?
> 
> My G5 is off for now, and the time I do spend with it goes towards
> working out mesa issues (it should kinda-sorta work with Mesa 11.0.3
> again btw). If I have time, I'll try it out.

I've checked on my second PowerMac G5 which seems to be the same as
yours (PowerMac7,3).

It doesn't work but not because of the checksum:

[  140.410535] nouveau :f0:10.0: NVIDIA NV34 (034100a2)
[  140.476781] nouveau :f0:10.0: bios: version 04.34.20.19.00
[  140.476993] nouveau :f0:10.0: bios: DCB table not found
[  140.477186] nouveau :f0:10.0: bios: DCB table not found
[  140.477283] nouveau :f0:10.0: bios: DCB table not found
[  140.477289] nouveau :f0:10.0: bios: DCB table not found
[  140.477664] nouveau :f0:10.0: bios: DCB table not found
[  140.480949] nouveau :f0:10.0: devinit: 0x1a08[ ]: unknown opcode 0x10
[  140.480962] nouveau :f0:10.0: preinit failed with -22
[  140.480978] nouveau: DRM::0080: init failed with -22
[  140.487980] nouveau: probe of :f0:10.0 failed with error -22

Laurent


[PATCH] nouveau: fix OpenFirmware support

2015-10-10 Thread Laurent Vivier


Le 10/10/2015 20:41, Ilia Mirkin a écrit :
> Hi Laurent,
> 
> On Sat, Oct 10, 2015 at 9:27 AM, Laurent Vivier  wrote:
>> On PowerMac G5 (and I think on all OpenFirmware platforms), nvbios_pcirTp()
>> returns NULL. But in fact the OpenFirmware has given us the size
>> we can store in image->size.
>>
>> This size is stored in bios->size by of_init() as there is no way
>> to retrieve it otherwise. And as we know the size, copy all data
>> to bios->data.
>>
>> Tested on PowerMac G5 with 64bit kernel and a NV43 card (GeForce 6600 LE).
> 
> Can you give this patch a shot instead?
> 
> http://cgit.freedesktop.org/~darktama/nouveau/commit/?id=794a63cc75eada9ad6b2a0275c1c8c4d3522864f

Well, I think mine is also a good solution and it is much more simple.
;)

... because it is useless to add a size() function if we can directly
copy the content/size of the bios in bios->data and bios->size.
We can do that because we have the size of the property, which is not
the case when we discover the BIOS directly from a PCI ROM or from ACPI
(this is why we need a shadow, I think).

For pcir part, I think we can just ignore the result and take the size
from bios->size, as in the case of non openfirmware bios->size will be 4
(we have only shadowed the first word to read the id, 0xaa55) and then
the checksum and others ID searches will fail. So I think the checksum
should not be ignored.

I've tried to restore behavior before commit:

7af4dec drm/nouveau/bios: use size/type from pci data structure

and commit:

ad4a362 drm/nouveau/bios: split out shadow methods

Originally, openfirmware content was copied directly into bios->data:

77145f1 drm/nouveau: port remainder of drm code, and rip out compat layer

> This resolved my issues on a PPC G5 + NV34. I think mine ran into a
> few additional problems that you didn't see -- no PCIR header and
> invalid checksum.

I have no PCIR header too.

Could you send me the content of the file "NVDA,BMP" you can find
somewhere under /proc/device-tree/ ?

Could you try my patch on your system, please ?

Laurent


[PATCH] nouveau: fix OpenFirmware support

2015-10-10 Thread Laurent Vivier
On PowerMac G5 (and I think on all OpenFirmware platforms), nvbios_pcirTp()
returns NULL. But in fact the OpenFirmware has given us the size
we can store in image->size.

This size is stored in bios->size by of_init() as there is no way
to retrieve it otherwise. And as we know the size, copy all data
to bios->data.

Tested on PowerMac G5 with 64bit kernel and a NV43 card (GeForce 6600 LE).

Before:

nouveau :0a:00.0: NVIDIA NV43 (043200a4)
u3msi: allocated virq 0x19 (hw 0x8) addr 0xf8004080
nouveau :0a:00.0: Invalid ROM contents
nouveau :0a:00.0: bios: unable to locate usable image
nouveau :0a:00.0: bios ctor failed, -22
nouveau: probe of :0a:00.0 failed with error -22

After:

nouveau :0a:00.0: NVIDIA NV43 (043200a4)
u3msi: allocated virq 0x19 (hw 0x8) addr 0xf8004080
nouveau :0a:00.0: bios: version 05.43.02.75.00
nouveau :0a:00.0: fb: 128 MiB DDR1
nouveau :0a:00.0: Using 32-bit DMA via iommu
[TTM] Zone  kernel: Available graphics memory: 5610528 kiB
[TTM] Zone   dma32: Available graphics memory: 2097152 kiB
[TTM] Initializing pool allocator
[TTM] Initializing DMA pool allocator
nouveau :0a:00.0: DRM: VRAM: 124 MiB
nouveau :0a:00.0: DRM: GART: 512 MiB
nouveau :0a:00.0: DRM: TMDS table version 1.1
nouveau :0a:00.0: DRM: DCB version 3.0
nouveau :0a:00.0: DRM: DCB outp 00: 01000100 0028
nouveau :0a:00.0: DRM: DCB outp 01: 03000102 
nouveau :0a:00.0: DRM: DCB outp 02: 04011210 0028
nouveau :0a:00.0: DRM: DCB outp 03: 02111212 02000100
nouveau :0a:00.0: DRM: DCB outp 04: 02011211 0020c070
nouveau :0a:00.0: DRM: DCB conn 00: 1030
nouveau :0a:00.0: DRM: DCB conn 01: 2130
[drm] Supports vblank timestamp caching Rev 2 (21.10.2013).
[drm] Driver supports precise vblank timestamp query.
nouveau :0a:00.0: DRM: 0x14C5: Parsing digital output script table
nouveau :0a:00.0: DRM: MM: using M2MF for buffer copies
nouveau :0a:00.0: DRM: Setting dpms mode 3 on TV encoder (output 4)
nouveau :0a:00.0: DRM: allocated 1680x1050 fb: 0x3, bo 
c399d800
nouveau :0a:00.0: DRM: 0x14C5: Parsing digital output script table
Console: switching to colour frame buffer device 210x65
nouveau :0a:00.0: fb0: nouveaufb frame buffer device
[drm] Initialized nouveau 1.3.0 20120801 for :0a:00.0 on minor 0

Signed-off-by: Laurent Vivier 
---
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c| 10 --
 drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c |  8 ++--
 2 files changed, 14 insertions(+), 4 deletions(-)

diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c
index 74b14cf..17ba0c726 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/image.c
@@ -47,8 +47,14 @@ nvbios_imagen(struct nvkm_bios *bios, struct nvbios_image 
*image)
return false;
}

-   if (!(data = nvbios_pcirTp(bios, image->base, , , )))
-   return false;
+   data = nvbios_pcirTp(bios, image->base, , , );
+   if (!data) {
+   image->size = bios->size;
+   image->type = 0x00;
+   image->last = true;
+
+   return true;
+   }
image->size = pcir.image_size;
image->type = pcir.image_type;
image->last = pcir.last;
diff --git a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c 
b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
index bd60d7d..d4c8801 100644
--- a/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
+++ b/drivers/gpu/drm/nouveau/nvkm/subdev/bios/shadowof.c
@@ -34,7 +34,6 @@ of_read(void *data, u32 offset, u32 length, struct nvkm_bios 
*bios)
 {
struct priv *priv = data;
if (offset + length <= priv->size) {
-   memcpy_fromio(bios->data + offset, priv->data + offset, length);
return length;
}
return 0;
@@ -50,8 +49,13 @@ of_init(struct nvkm_bios *bios, const char *name)
return ERR_PTR(-ENODEV);
if (!(priv = kzalloc(sizeof(*priv), GFP_KERNEL)))
return ERR_PTR(-ENOMEM);
-   if ((priv->data = of_get_property(dn, "NVDA,BMP", >size)))
+   priv->data = of_get_property(dn, "NVDA,BMP", >size);
+   if (priv->data) {
+   bios->size = (priv->size + 3) & ~3;
+   bios->data = kmalloc(bios->size, GFP_KERNEL);
+   memcpy(bios->data, priv->data, priv->size);
return priv;
+   }
kfree(priv);
return ERR_PTR(-EINVAL);
 }
-- 
2.4.3