public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Petr Vandrovec <vandrove@vc.cvut.cz>
To: Chris Wright <chrisw@osdl.org>
Cc: Al Viro <viro@parcelfarce.linux.theplanet.co.uk>,
	linux-kernel@vger.kernel.org, stable@kernel.org,
	Justin Forbes <jmforbes@linuxtx.org>,
	Zwane Mwaikambo <zwane@arm.linux.org.uk>,
	"Theodore Ts'o" <tytso@mit.edu>,
	Randy Dunlap <rdunlap@xenotime.net>,
	Chuck Wolber <chuckw@quantumlinux.com>,
	torvalds@osdl.org, akpm@osdl.org, alan@lxorguk.ukuu.org.uk,
	p2@mind.be, dsd@gentoo.org
Subject: Re: [patch 06/16] Fix matroxfb on big-endian hardware
Date: Tue, 24 May 2005 12:15:25 +0200	[thread overview]
Message-ID: <4292FEBD.6020306@vc.cvut.cz> (raw)
In-Reply-To: <20050524011711.GD27549@shell0.pdx.osdl.net>

Chris Wright wrote:
> * Al Viro (viro@parcelfarce.linux.theplanet.co.uk) wrote:
> 
>>On Mon, May 23, 2005 at 04:22:07PM -0700, Chris Wright wrote:
>>
>>>-				mga_writel(mmio, 0, *chardata);
>>>+#if defined(__BIG_ENDIAN)
>>>+				fb_writel((*chardata) << 24, mmio.vaddr);
>>>+#else
>>>+				fb_writel(*chardata, mmio.vaddr);
>>>+#endif
>>
>>So basically you are passing it cpu_to_le32(*chardata)?
>>
>>
>>>+#if defined(__BIG_ENDIAN)
>>>+				fb_writel((*(u_int16_t*)chardata) << 16, mmio.vaddr);
>>>+#else
>>>+				fb_writel(*(u_int16_t*)chardata, mmio.vaddr);
>>>+#endif
>>
>>*yuck*
>>
>>cpu_to_le32(le16_to_cpu(*(__le16 *)chardata)?  Is that what you are doing
>>here?

Yes.  Hardware wants it this way.  For 8bit wide font you must write font data 
in low 8 bits (some hardware on the way does swapping on BE archs), and for 
16bit wide font you must write font data in low 16 bits.  In both cases first 
pixel is in bit7 of byte 0, going through to bit0 of byte 0, followed by bit7 of 
byte 1 through bit0 of byte 1.  And so on for widths > 16.  Inner leX_to_cpu 
works on data of font size, while outer cpu_to_le32 works on accelerator data 
size, which is always 32 bit.

If you want it absolutely correct (as font data are in big endian), you should 
write cpu_to_le32(swab<font_width>(be<font_width>_to_cpup(chardata))).  Inner 
be16_to_cpup retrieves font data into bits 15 -> 0, swab reorders bytes so first 
pixel is in bit 7, not bit 15 (or 31 for 32bit wide font), and outer cpu_to_le32 
nullifies effect of external swab32() engine.

> Petr, care to comment?  Best I can tell this is from you and is already
> upstream.  Any reason not to use cpu_to_xx instead of what's done?

I'm not sure about speed effects.  Is gcc smart enough to notice that two 
different width byteswaps can be combined to simple shift?
						Thanks,
							Petr Vandrovec


  reply	other threads:[~2005-05-24 10:22 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2005-05-23 23:15 [00/16] -stable review Chris Wright
2005-05-23 23:17 ` [patch 01/16] Fix get_unmapped_area sanity tests Chris Wright
2005-05-23 23:18 ` [patch 02/16] 3c59x: only put the device into D3 when we're actually using WOL Chris Wright
2005-05-25 17:30   ` Daniel Ritz
2005-05-23 23:19 ` [patch 03/16] [EBTABLES]: Fix smp race Chris Wright
2005-05-23 23:20 ` [patch 04/16] ext3: fix race between ext3 make block reservation and reservation window discard Chris Wright
2005-05-30 13:28   ` Rodrigo Steinmüller Wanderley
2005-05-31  6:23     ` Mingming Cao
2005-05-23 23:21 ` [patch 05/16] PPC64: Fix LPAR IOMMU setup code for p630 Chris Wright
2005-05-23 23:22 ` [patch 06/16] Fix matroxfb on big-endian hardware Chris Wright
2005-05-23 23:50   ` Al Viro
2005-05-24  1:17     ` Chris Wright
2005-05-24 10:15       ` Petr Vandrovec [this message]
2005-05-23 23:24 ` [patch 07/16] ide-disk: Fix LBA8 DMA Chris Wright
2005-05-23 23:25 ` [patch 08/16] [ROSE]: Fix minor security hole Chris Wright
2005-05-23 23:26 ` [patch 09/16] usbaudio: prevent oops & dead keyboard on usb unplugging Chris Wright
2005-05-23 23:27 ` [patch 10/16] usbusx2y: " Chris Wright
2005-05-23 23:28 ` [patch 11/16] USB: fix bug in visor driver with throttle/unthrottle causing oopses Chris Wright
2005-05-23 23:29 ` [patch 12/16] x86_64: check if ptrace RIP is canonical Chris Wright
2005-05-23 23:30 ` [patch 13/16] x86_64: Fix canonical checking for segment registers in ptrace Chris Wright
2005-05-23 23:30 ` [patch 14/16] x86_64: Add a guard page at the end of the 47bit address space Chris Wright
2005-05-23 23:31 ` [patch 15/16] x86_64: When checking vmalloc mappings don't use pte_page Chris Wright
2005-05-23 23:32 ` [patch 16/16] x86_64: Don't look up struct page pointer of physical address in iounmap Chris Wright

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=4292FEBD.6020306@vc.cvut.cz \
    --to=vandrove@vc.cvut.cz \
    --cc=akpm@osdl.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=chrisw@osdl.org \
    --cc=chuckw@quantumlinux.com \
    --cc=dsd@gentoo.org \
    --cc=jmforbes@linuxtx.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=p2@mind.be \
    --cc=rdunlap@xenotime.net \
    --cc=stable@kernel.org \
    --cc=torvalds@osdl.org \
    --cc=tytso@mit.edu \
    --cc=viro@parcelfarce.linux.theplanet.co.uk \
    --cc=zwane@arm.linux.org.uk \
    /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