LinuxPPC-Dev Archive on lore.kernel.org
 help / color / mirror / Atom feed
* [GIT PULL] Disintegrate UAPI for powerpc [ver #2]
From: David Howells @ 2012-10-09  9:15 UTC (permalink / raw)
  To: benh; +Cc: dhowells, linuxppc-dev, linux-kernel

Can you merge the following branch into the powerpc tree please.

This is to complete part of the UAPI disintegration for which the preparatory
patches were pulled recently.

Now that the fixups and the asm-generic chunk have been merged, I've
regenerated the patches to get rid of those dependencies and to take account of
any changes made so far in the merge window.  If you have already pulled the
older version of the branch aimed at you, then please feel free to ignore this
request.

The following changes since commit 9e2d8656f5e8aa214e66b462680cf86b210b74a8:

  Merge branch 'akpm' (Andrew's patch-bomb) (2012-10-09 16:23:15 +0900)

are available in the git repository at:


  git://git.infradead.org/users/dhowells/linux-headers.git tags/disintegrate-powerpc-20121009

for you to fetch changes up to c3617f72036c909e1f6086b5b9e364e0ef90a6da:

  UAPI: (Scripted) Disintegrate arch/powerpc/include/asm (2012-10-09 09:47:26 +0100)

----------------------------------------------------------------
UAPI Disintegration 2012-10-09

----------------------------------------------------------------
David Howells (1):
      UAPI: (Scripted) Disintegrate arch/powerpc/include/asm

 arch/powerpc/include/asm/Kbuild                   |  35 --
 arch/powerpc/include/asm/bootx.h                  | 123 +------
 arch/powerpc/include/asm/cputable.h               |  35 +-
 arch/powerpc/include/asm/elf.h                    | 311 +-----------------
 arch/powerpc/include/asm/kvm_para.h               |  70 +---
 arch/powerpc/include/asm/mman.h                   |  27 +-
 arch/powerpc/include/asm/nvram.h                  |  55 +---
 arch/powerpc/include/asm/ptrace.h                 | 242 +-------------
 arch/powerpc/include/asm/signal.h                 | 143 +-------
 arch/powerpc/include/asm/spu_info.h               |  29 +-
 arch/powerpc/include/asm/swab.h                   |  15 +-
 arch/powerpc/include/asm/termios.h                |  69 +---
 arch/powerpc/include/asm/types.h                  |  30 +-
 arch/powerpc/include/asm/unistd.h                 | 374 +--------------------
 arch/powerpc/include/uapi/asm/Kbuild              |  41 +++
 arch/powerpc/include/{ => uapi}/asm/auxvec.h      |   0
 arch/powerpc/include/{ => uapi}/asm/bitsperlong.h |   0
 arch/powerpc/include/uapi/asm/bootx.h             | 132 ++++++++
 arch/powerpc/include/{ => uapi}/asm/byteorder.h   |   0
 arch/powerpc/include/uapi/asm/cputable.h          |  36 ++
 arch/powerpc/include/uapi/asm/elf.h               | 307 +++++++++++++++++
 arch/powerpc/include/{ => uapi}/asm/errno.h       |   0
 arch/powerpc/include/{ => uapi}/asm/fcntl.h       |   0
 arch/powerpc/include/{ => uapi}/asm/ioctl.h       |   0
 arch/powerpc/include/{ => uapi}/asm/ioctls.h      |   0
 arch/powerpc/include/{ => uapi}/asm/ipcbuf.h      |   0
 arch/powerpc/include/{ => uapi}/asm/kvm.h         |   0
 arch/powerpc/include/uapi/asm/kvm_para.h          |  90 +++++
 arch/powerpc/include/{ => uapi}/asm/linkage.h     |   0
 arch/powerpc/include/uapi/asm/mman.h              |  31 ++
 arch/powerpc/include/{ => uapi}/asm/msgbuf.h      |   0
 arch/powerpc/include/uapi/asm/nvram.h             |  62 ++++
 arch/powerpc/include/{ => uapi}/asm/param.h       |   0
 arch/powerpc/include/{ => uapi}/asm/poll.h        |   0
 arch/powerpc/include/{ => uapi}/asm/posix_types.h |   0
 arch/powerpc/include/{ => uapi}/asm/ps3fb.h       |   0
 arch/powerpc/include/uapi/asm/ptrace.h            | 259 +++++++++++++++
 arch/powerpc/include/{ => uapi}/asm/resource.h    |   0
 arch/powerpc/include/{ => uapi}/asm/seccomp.h     |   0
 arch/powerpc/include/{ => uapi}/asm/sembuf.h      |   0
 arch/powerpc/include/{ => uapi}/asm/setup.h       |   0
 arch/powerpc/include/{ => uapi}/asm/shmbuf.h      |   0
 arch/powerpc/include/{ => uapi}/asm/sigcontext.h  |   0
 arch/powerpc/include/{ => uapi}/asm/siginfo.h     |   0
 arch/powerpc/include/uapi/asm/signal.h            | 145 +++++++++
 arch/powerpc/include/{ => uapi}/asm/socket.h      |   0
 arch/powerpc/include/{ => uapi}/asm/sockios.h     |   0
 arch/powerpc/include/uapi/asm/spu_info.h          |  53 +++
 arch/powerpc/include/{ => uapi}/asm/stat.h        |   0
 arch/powerpc/include/{ => uapi}/asm/statfs.h      |   0
 arch/powerpc/include/uapi/asm/swab.h              |  23 ++
 arch/powerpc/include/{ => uapi}/asm/termbits.h    |   0
 arch/powerpc/include/uapi/asm/termios.h           |  76 +++++
 arch/powerpc/include/uapi/asm/types.h             |  40 +++
 arch/powerpc/include/{ => uapi}/asm/ucontext.h    |   0
 arch/powerpc/include/uapi/asm/unistd.h            | 380 ++++++++++++++++++++++
 56 files changed, 1705 insertions(+), 1528 deletions(-)
 rename arch/powerpc/include/{ => uapi}/asm/auxvec.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/bitsperlong.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/bootx.h
 rename arch/powerpc/include/{ => uapi}/asm/byteorder.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/cputable.h
 create mode 100644 arch/powerpc/include/uapi/asm/elf.h
 rename arch/powerpc/include/{ => uapi}/asm/errno.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/fcntl.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/ioctl.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/ioctls.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/ipcbuf.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/kvm.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/kvm_para.h
 rename arch/powerpc/include/{ => uapi}/asm/linkage.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/mman.h
 rename arch/powerpc/include/{ => uapi}/asm/msgbuf.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/nvram.h
 rename arch/powerpc/include/{ => uapi}/asm/param.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/poll.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/posix_types.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/ps3fb.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/ptrace.h
 rename arch/powerpc/include/{ => uapi}/asm/resource.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/seccomp.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/sembuf.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/setup.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/shmbuf.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/sigcontext.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/siginfo.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/signal.h
 rename arch/powerpc/include/{ => uapi}/asm/socket.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/sockios.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/spu_info.h
 rename arch/powerpc/include/{ => uapi}/asm/stat.h (100%)
 rename arch/powerpc/include/{ => uapi}/asm/statfs.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/swab.h
 rename arch/powerpc/include/{ => uapi}/asm/termbits.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/termios.h
 create mode 100644 arch/powerpc/include/uapi/asm/types.h
 rename arch/powerpc/include/{ => uapi}/asm/ucontext.h (100%)
 create mode 100644 arch/powerpc/include/uapi/asm/unistd.h
.

^ permalink raw reply

* [m68k,powerpc,dma,ethernet,freescale RFA] Coldfire m54xx FEC ethernet driver
From: Philippe De Muyter @ 2012-10-09  9:07 UTC (permalink / raw)
  To: Greg Ungerer
  Cc: uClinux development list, netdev, linux-kernel, linux-m68k,
	stany.marcel, linuxppc-dev
In-Reply-To: <5073C05C.2080809@snapgear.com>

[CCing lkml, linux-ppc, netdev, linux-m68k]

Hello kernel sources architects

I have a working driver for the m54xx FEC ethernet driver that I
would like to integrate in the kernel tree.  Problems are that
- this driver needs an associated DMA driver (provided by FreeScale)
wich is not dma-engine enabled
- they're are already many fec drivers in the kernel tree, and
at least one, fec_mpc52xx.c, seems to be very similar (information
below), to the one for the mcf54xx, except it uses a differently
named associated DMA driver (BestComm/SmartDma/SDMA) which is also
not dma-engine enabled, and even kept hidden in /arch/powerpc where
it is inaccessible when compiling for m68k.  The underlying DMA part
from Freescale however seems similar to the one used in the
m54xx. (again, see information below)

So, now I am lost, what should I do ?

The current state of my patches
[http://mailman.uclinux.org/pipermail/uclinux-dev/2012-September/052147.html]
is pushing the freescale provided MCD_DMA dma driver to /drivers/dma,
without adding the dma-engine compatibility layer, and adding the specific
fec_m54xx ethernet driver to /drivers/net/ethernet/freescale

Best regards

Philippe

On Tue, Oct 09, 2012 at 04:12:44PM +1000, Greg Ungerer wrote:
> Hi Philippe,
>
> On 05/10/12 01:03, Philippe De Muyter wrote:
>> On Thu, Oct 04, 2012 at 04:56:01PM +0200, Philippe De Muyter wrote:
>>> On Thu, Oct 04, 2012 at 11:33:32PM +1000, Greg Ungerer wrote:
>>>>
>>>> My biggest concern is the amount of MCD/DMA support code. And it is
>>>> all done quite differently to everything else in the kernel. We may
>>>> get a bit of push back from kernel folk who look after DMA.
>>>
>>> Actually, there is already a similar code in arch/powerpc/sysdev/bestcomm
>>> (also from freescale, maybe an identical part, but I did not find any
>>> usable doc), but the powerpc folks kept that hidden in the arch/powerpc
>>> tree, instead of installing it in drivers/dma.
>>
>> The MCD DMA or DMA FEC code from freescale has a comment implying that 
>> this
>> was first used in the MPC8220 part.  And Montavista has a MPC8220 port, 
>> but
>> I did not find it, so I do not know where they installed the MCD DMA 
>> driver.
>
> Ok, looks like there is a bit a variance in all this.

I also began to read the mpc5200 user's guide parts about the fec and
BestComm/SmartDma/SDMA (not sure which one is the official FreeScale name)
and they look very similar, but not identical, to their m54xx counterparts.

It seems possible to make the fec_mpc52xx.c driver work for the m54xx
but that needs at least:
- moving some files or part of them from /arch/powerpc/sysdev and
  /arch/powerpc/include/asm to /drivers/dma and /include/linux,
- renaming the fec_mpc52xx files to a more sensible name,
- providing out_be32 and in_be32 in /arch/m68k/include/asm/io.h,
- and then unifying the interface to BestComm/SmartDma/SDMA and MCD_DMA
  in mcf_52xx.c.

An additional problem is that the freescale docs for powerpcs and for
coldfires do not use the same mnemonics for the same registers.

e.g. FEC registers
	offset	MPC5200		MCF5484
	======	=======		=======
	000	FEC_ID		n/a
	004	IEVENT		EIR
	008	IMASK		EIMR
	010	R_DES_ACTIVE	n/a
	014	X_DES_ACTIVE	n/a
	024	ECNTRL		ECR
	040	MII_DATA	MDATA
	044	MII_SPEED	MSCR
	064	MIB_CONTROL	MIBC
	084	R_CNTRL		RCR
	088	R_HASH		RHR
	0C4	X_CNTRL		TCR
	0E4	PADDR1		PALR
	0E8	PADDR2		PAHR
	0EC	OP_PAUSE	OPD
	118	IADDR1		IAUR
	11C	IADDR1		IALR
	120	GADDR1		GAUR
	124	GADDR2		GALR
	144	X_WMRK		FECTFWR
	184	RFIFO_DATA	FECRFDR
	188	RFIFO_STATUS	FECRFSR
	18C	RFIFO_CONTROL	FECRFCR
	190	RFIFO_LRF_PTR	FECRLRFP
	194	RFIFO_LWF_PTR	FECRLWFP
	198	RFIFO_ALARM	FECRFAR
	19C	RFIFO_RDPTR	FECRFRP
	1A0	RFIFO_WRPTR	FECRFWP
	1A4	TFIFO_DATA	FECTFDR
	1A8	TFIFO_STATUS	FECTFSR
	1AC	TFIFO_CONTROL	FECTFCR
	1B0	TFIFO_LRF_PTR	FECTLRFP
	1B4	TFIFO_LWF_PTR	FECTLWFP
	1B8	TFIFO_ALARM	FECTFAR
	1BC	TFIFO_RDPTR	FECTFRP
	1C0	TFIFO_WRPTR	FECTFWP
	1C4	RESET_CNTRL	FECFRST
	1C8	XMIT_FSM	FECCTCWR

> Probably the best thing to do is post the patches on the linux kernel
> mailing list then, asking for direction on a dma driver.
>
> I have no problem with it going into the arch/m68k area. So that is
> always an option.

For the dma engines, the similarity is also obvious.  For example, find
below side by side mpc52xx and m54xx definitions for the
main DMA registers :

from mpc52xx.h				from MCD_dma.h
/* SDMA */				/* MCD_DMA */
struct mpc52xx_sdma {			struct dmaRegs { 
 u32 taskBar; /* 0x00 */		        u32 taskbar;
 u32 currentPointer; /* 0x04 */		        u32 currPtr;
 u32 endPointer; /* 0x08 */		        u32 endPtr;
 u32 variablePointer; /* 0x0c */	        u32 varTablePtr;

 u8 IntVect1; /* 0x10 */		        u16 dma_rsvd0;
 u8 IntVect2; /* 0x11 */
 u16 PtdCntrl; /* 0x12 */		        u16 ptdControl;

 u32 IntPend; /* 0x14 */		        u32 intPending;
 u32 IntMask; /* 0x18 */		        u32 intMask;

 u16 tcr[16]; /* 0x1c .. 0x3a */	        u16 taskControl[16];

 u8 ipr[32]; /* 0x3c .. 0x5b */		        u8  priority[32];

 u32 cReqSelect; /* 0x5c */		        u32 initiatorMux;
 u32 task_size0; /* 0x60 */		        u32 taskSize0;
 u32 task_size1; /* 0x64 */		        u32 taskSize1;
 u32 MDEDebug; /* 0x68 */		        u32 dma_rsvd1;
 u32 ADSDebug; /* 0x6c */		        u32 dma_rsvd2;
 u32 Value1; /* 0x70 */			        u32 debugComp1;
 u32 Value2; /* 0x74 */			        u32 debugComp2;
 u32 Control; /* 0x78 */		        u32 debugControl;
 u32 Status; /* 0x7c */			        u32 debugStatus;
 u32 PTDDebug; /* 0x80 */		        u32 ptdDebug;
};					};

^ permalink raw reply

* Re: gianfar driver crash on P1020
From: Avi Tsarfati @ 2012-10-09 12:22 UTC (permalink / raw)
  To: linuxppc-dev

[-- Attachment #1: Type: text/plain, Size: 494 bytes --]

Hi, 

 

I have the same problem as you do. 

Have you found the CPU stuck reason (or fix) in P1020RDB board ?

 

Thanks,

Avi Tsarfati.

 


************************************************************************************
This footnote confirms that this email message has been scanned by
PineApp Mail-SeCure for the presence of malicious code, vandals & computer viruses(187).
************************************************************************************



[-- Attachment #2: Type: text/html, Size: 2608 bytes --]

^ permalink raw reply

* 答复: [RFC PATCH] powerpc/fsl: add timer wakeup source
From: Wang Dongsheng-B40534 @ 2012-10-09 13:56 UTC (permalink / raw)
  To: Wood Scott-B07421
  Cc: linux-pm@vger.kernel.org, Wang Dongsheng,
	linuxppc-dev@lists.ozlabs.org list, Li Yang-R58472
In-Reply-To: <1349729705.3721.8@snotra>

DQo+ID4gPiA+IEknbSBwcmV0dHkgc3VyZSAvcHJvYy8gaXMgTk9UIHdoZXJlIHdlIHdhbnQgdGhp
cyBleHBvc2VkLg0KPiA+ID4NCj4gPiA+IFNob3VsZCBwcm9iYWJseSBnbyB1bmRlciB0aGUgc3lz
ZnMgZGlyZWN0b3J5IG9mIHRoZSBtcGljIGRldmljZS4gIE9yDQo+ID4gPiBiZXR0ZXIsIG1ha2Ug
YSBnZW5lcmljIGludGVyZmFjZSBmb3IgdGltZXItYmFzZWQgc3VzcGVuZCB3YWtldXAgKGlmDQo+
ID4gdGhlcmUNCj4gPiA+IGlzbid0IG9uZSBhbHJlYWR5KS4gIFRoaXMgY3VycmVudCBhcHByb2Fj
aCBzaXRzIGluIGFuIHVucGxlYXNhbnQNCj4gbWlkZGxlDQo+ID4gPiBncm91bmQgYmV0d2VlbiBn
ZW5lcmljIGFuZCBkZXZpY2Utc3BlY2lmaWMuDQo+ID4gPg0KPiA+IC9zeXMvcG93ZXIvd2FrZXVw
X3RpbWVyX3NlY29uZHMgaG93IGFib3V0IHRoaXM/DQo+ID4gSSB0aGluayBpdCBpcyBhIGZyZWVz
Y2FsZSBnZW5lcmljIGludGVyZmFjZSwgdGhpcyBpbnRlcmZhY2UgY29udHJvbCBieQ0KPiA+IEZT
TF9TT0MgJiYgU1VTUEVORC4NCg0KPiBUaGVyZSdzIG5vIHN1Y2ggdGhpbmcgYXMgYSAiRnJlZXNj
YWxlIGdlbmVyaWMgaW50ZXJmYWNlIi4gIExpbnV4IEFQSXMNCj4gYXJlIG5vdCBvcmdhbml6ZWQg
YnkgaGFyZHdhcmUgdmVuZG9yLiAgRWl0aGVyIG1ha2UgYSB0cnVseSBnZW5lcmljDQo+IGludGVy
ZmFjZSwgcmV1c2UgYW4gZXhpc3Rpbmcgb25lLCBvciBkbyBzb21ldGhpbmcgdGhhdCBpcyBhdHRh
Y2hlZCB0bw0KPiB0aGUgc3BlY2lmaWMgZHJpdmVyLg0KVGhhbmtzLCBJIHRoaW5rIGkgY2FuIGNo
YW5nZSBtcGljIHRpbWVyIHJlZ2lzdHJhdGlvbiwgaSB3aWxsIHVzZSBwbGF0Zm9ybV9kcml2ZXJf
cmVnaXN0ZXIuDQpJIHdpbGwgbWVyZ2UgIm1waWMgdGltZXIiIGFuZCAidGltZXIgd2FrZXVwIi4g
SW4gIm1waWMgdGltZXIiIHRoZSB3YWtldXAgZnVuY3Rpb24NCmNvbnRyb2xzIGJ5IFNVU1BFTkQu
IFRoZSBzeXMgcGF0aCBpcyAiL3N5cy9kZXZpY2VzL3NvYzg1NzIuNC9mZmU0MTEwMC50aW1lci93
YWtldXBfc2Vjb25kcyIuDQpkbyB5b3UgaGF2ZSBhbnkgc3VnZ2VzdGlvbnMgZm9yIHRoaXM/IG9y
IGhhdmUgYSBiZXR0ZXIgaWRlYSBhYm91dCB0aGUgc3lzIHBhdGg/DQoNCj4gPiA+IFVzZSBkZXBl
bmRzIHJhdGhlciB0aGFuIGlmL2Vsc2UuICBXaHkgZG8geW91IG5lZWQgRlNMX1dBS0VVUF9TT1VS
Q0U/DQo+ID4gPg0KPiA+IEl0IGxpc3RzIGFsbCB3YWtlIHVwIHNvdXJjZS4gSWYgbGF0ZXIgaGF2
ZSB3YWtldXAgc291cmNlIGNhbiBiZQ0KPiA+IGltcHJvdmVkIGJ5DQo+ID4gaXQgdG8gY29udHJv
bC4gQnV0dG9ucyBldmVudCB3YWtldXAgc291cmNlIHdpbGwgYmUgYWRkZWQgYWZ0ZXIgdGhlDQo+
ID4gdGltZXIuDQoNCj4gSXQgZG9lcyBub3QgbGlzdCBhbGwgd2FrZSB1cCBzb3VyY2VzIC0tIHRo
ZXJlJ3MgYWxzbyBldGhlcm5ldCwgVVNCLCBldGMuDQpmaW5lLCBjaGFuZ2UgdG8gZGVwZW5kcy4g
dGhhbmtzLg0KDQo+ID4gPg0KPiA+ID4gSWYgdGhlIG5ldyB0aW1lIGlzIHplcm8sIGNvbnNpZGVy
IHRoYXQgYSBjYW5jZWxsYXRpb24gb2YgdGhlIHRpbWVyDQo+ID4gYW5kDQo+ID4gPiBkb24ndCBy
ZXF1ZXN0IGEgbmV3IG9uZSBvciByZXR1cm4gLUVJTlZBTC4NCj4gPiA+DQo+ID4gVGhhbmtzLCBJ
IHRoaW5rIGkgc2hvdWxkIGFkZCBjb21tZW50cy4gTGV0IHRoaXMgcGF0Y2ggZWFzeSB0byByZWFk
Lg0KPiA+IEhlcmUgaXMgZ2V0IGEgbmV3IHRpbWVyLg0KPiA+IElmIHRoZSBuZXcgdGltZSBpcyB6
ZXJvLCBjb25zaWRlciB0aGF0IGhhcyBiZWVuIGNoZWNrZWQuDQo+ID4NCj4gPiBpZiAoIXRpbWUu
dHZfc2VjKSB7Li4ufSB0aGlzIGlzIGNoZWNrIHplcm8uDQo+ID4gVGhlICJtcGljX3JlcXVlc3Rf
dGltZXIiIGJlZm9yZSB0aGlzIGNvZGUuDQoNCj4gQWgsIEkgc2VlLiAgV291bGRuJ3QgaXQgYmUg
c2ltcGxlciB0byByZW1vdmUgdGhhdCBibG9jayBhbmQganVzdCB0ZXN0DQo+IHRpbWUudHZfc2Vj
IHdoZW4gcmVxdWVzdGluZyB0aGUgbmV3IHRpbWVyPw0KWWVzLCB3YWtlIHVwIGZ1bmN0aW9uIG9u
bHkgbmVlZCBzZWNvbmRzIGxldmVsLCBhbmQgaXQncyBqdXN0IGhvbGQgYSB0aW1lci4NCmVjaG8g
emVybyB0byBjYW5jZWwsIGFuZCBlY2hvIGEgbmV3IHRpbWUgdG8gdXBkYXRlIHRoZSB0aW1lciB0
aW1lLg==

^ permalink raw reply

* [PATCH 01/20] powerpc/udbg: Remove unused udbg_read()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard

The last user of udbg_read() was removed in 2005, in commit fca5dcd
"Simplify and clean up the xmon terminal I/O".

Given we haven't needed it for 7 years we can probably drop it.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/include/asm/udbg.h |    1 -
 arch/powerpc/kernel/udbg.c      |   23 -----------------------
 2 files changed, 24 deletions(-)

diff --git a/arch/powerpc/include/asm/udbg.h b/arch/powerpc/include/asm/udbg.h
index b303881..5a7510e 100644
--- a/arch/powerpc/include/asm/udbg.h
+++ b/arch/powerpc/include/asm/udbg.h
@@ -21,7 +21,6 @@ extern int (*udbg_getc_poll)(void);
 
 extern void udbg_puts(const char *s);
 extern int udbg_write(const char *s, int n);
-extern int udbg_read(char *buf, int buflen);
 
 extern void register_early_udbg_console(void);
 extern void udbg_printf(const char *fmt, ...)
diff --git a/arch/powerpc/kernel/udbg.c b/arch/powerpc/kernel/udbg.c
index c39c1ca..f974849 100644
--- a/arch/powerpc/kernel/udbg.c
+++ b/arch/powerpc/kernel/udbg.c
@@ -122,29 +122,6 @@ int udbg_write(const char *s, int n)
 	return n - remain;
 }
 
-int udbg_read(char *buf, int buflen)
-{
-	char *p = buf;
-	int i, c;
-
-	if (!udbg_getc)
-		return 0;
-
-	for (i = 0; i < buflen; ++i) {
-		do {
-			c = udbg_getc();
-			if (c == -1 && i == 0)
-				return -1;
-
-		} while (c == 0x11 || c == 0x13);
-		if (c == 0 || c == -1)
-			break;
-		*p++ = c;
-	}
-
-	return i;
-}
-
 #define UDBG_BUFSIZE 256
 void udbg_printf(const char *fmt, ...)
 {
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 02/20] powerpc/xmon: Remove unused xmon_expect() & xmon_read_poll()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

It looks like xmon_expect() was used for doing xmon over a modem (!?),
that code was dropped in 2005 in commit 51d3082 "Unify udbg (#2)".

Once xmon_expect() is gone xmon_read_poll() is unused, drop it too.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/nonstdio.c |   27 ---------------------------
 arch/powerpc/xmon/nonstdio.h |    2 --
 arch/powerpc/xmon/start.c    |    7 -------
 3 files changed, 36 deletions(-)

diff --git a/arch/powerpc/xmon/nonstdio.c b/arch/powerpc/xmon/nonstdio.c
index bfac84f..a225d80 100644
--- a/arch/powerpc/xmon/nonstdio.c
+++ b/arch/powerpc/xmon/nonstdio.c
@@ -23,33 +23,6 @@ static char line[256];
 static char *lineptr;
 static int lineleft;
 
-int xmon_expect(const char *str, unsigned long timeout)
-{
-	int c;
-	unsigned long t0;
-
-	/* assume 25MHz default timebase if tb_ticks_per_sec not set yet */
-	timeout *= tb_ticks_per_sec? tb_ticks_per_sec: 25000000;
-	t0 = get_tbl();
-	do {
-		lineptr = line;
-		for (;;) {
-			c = xmon_read_poll();
-			if (c == -1) {
-				if (get_tbl() - t0 > timeout)
-					return 0;
-				continue;
-			}
-			if (c == '\n')
-				break;
-			if (c != '\r' && lineptr < &line[sizeof(line) - 1])
-				*lineptr++ = c;
-		}
-		*lineptr = 0;
-	} while (strstr(line, str) == NULL);
-	return 1;
-}
-
 int xmon_getchar(void)
 {
 	int c;
diff --git a/arch/powerpc/xmon/nonstdio.h b/arch/powerpc/xmon/nonstdio.h
index 23dd95f..d8cec38 100644
--- a/arch/powerpc/xmon/nonstdio.h
+++ b/arch/powerpc/xmon/nonstdio.h
@@ -9,7 +9,5 @@ extern void xmon_puts(const char *);
 extern char *xmon_gets(char *, int);
 extern void xmon_printf(const char *, ...);
 extern void xmon_map_scc(void);
-extern int xmon_expect(const char *str, unsigned long timeout);
 extern int xmon_write(const void *ptr, int nb);
 extern int xmon_readchar(void);
-extern int xmon_read_poll(void);
diff --git a/arch/powerpc/xmon/start.c b/arch/powerpc/xmon/start.c
index 8864de2..84f3a15 100644
--- a/arch/powerpc/xmon/start.c
+++ b/arch/powerpc/xmon/start.c
@@ -25,10 +25,3 @@ int xmon_readchar(void)
 		return udbg_getc();
 	return -1;
 }
-
-int xmon_read_poll(void)
-{
-	if (udbg_getc_poll)
-		return udbg_getc_poll();
-	return -1;
-}
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 03/20] powerpc/xmon: Remove empty xmon_map_scc()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

This has been empty since 2005, commit 51d3082 "Unify udbg (#2)".

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/nonstdio.h |    1 -
 arch/powerpc/xmon/start.c    |    4 ----
 arch/powerpc/xmon/xmon.c     |    1 -
 3 files changed, 6 deletions(-)

diff --git a/arch/powerpc/xmon/nonstdio.h b/arch/powerpc/xmon/nonstdio.h
index d8cec38..8799ccf 100644
--- a/arch/powerpc/xmon/nonstdio.h
+++ b/arch/powerpc/xmon/nonstdio.h
@@ -8,6 +8,5 @@ extern int xmon_getchar(void);
 extern void xmon_puts(const char *);
 extern char *xmon_gets(char *, int);
 extern void xmon_printf(const char *, ...);
-extern void xmon_map_scc(void);
 extern int xmon_write(const void *ptr, int nb);
 extern int xmon_readchar(void);
diff --git a/arch/powerpc/xmon/start.c b/arch/powerpc/xmon/start.c
index 84f3a15..7769cb5 100644
--- a/arch/powerpc/xmon/start.c
+++ b/arch/powerpc/xmon/start.c
@@ -10,10 +10,6 @@
 #include <asm/udbg.h>
 #include "nonstdio.h"
 
-void xmon_map_scc(void)
-{
-}
-
 int xmon_write(const void *ptr, int nb)
 {
 	return udbg_write(ptr, nb);
diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 3a56a63..67d36ab 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2943,7 +2943,6 @@ static void xmon_init(int enable)
 		__debugger_dabr_match = NULL;
 		__debugger_fault_handler = NULL;
 	}
-	xmon_map_scc();
 }
 
 #ifdef CONFIG_MAGIC_SYSRQ
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 04/20] powerpc/xmon: Make xmon_getchar() static
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

xmon_getchar() is only called from within nonstdio.c, so make it static.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/nonstdio.c |    2 +-
 arch/powerpc/xmon/nonstdio.h |    1 -
 2 files changed, 1 insertion(+), 2 deletions(-)

diff --git a/arch/powerpc/xmon/nonstdio.c b/arch/powerpc/xmon/nonstdio.c
index a225d80..2209485 100644
--- a/arch/powerpc/xmon/nonstdio.c
+++ b/arch/powerpc/xmon/nonstdio.c
@@ -23,7 +23,7 @@ static char line[256];
 static char *lineptr;
 static int lineleft;
 
-int xmon_getchar(void)
+static int xmon_getchar(void)
 {
 	int c;
 
diff --git a/arch/powerpc/xmon/nonstdio.h b/arch/powerpc/xmon/nonstdio.h
index 8799ccf..321284f 100644
--- a/arch/powerpc/xmon/nonstdio.h
+++ b/arch/powerpc/xmon/nonstdio.h
@@ -4,7 +4,6 @@
 #define putchar	xmon_putchar
 
 extern int xmon_putchar(int c);
-extern int xmon_getchar(void);
 extern void xmon_puts(const char *);
 extern char *xmon_gets(char *, int);
 extern void xmon_printf(const char *, ...);
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 05/20] powerpc/xmon: Merge start.c into nonstdio.c
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

The routines in start.c are only ever called from nonstdio.c, so if we
move them in there they can become static which is nice.

I suspect the idea behind the separation was that start.c could be
replaced in order to build xmon in userland. If anyone still cares about
doing that we could handle that with an ifdef or two.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/Makefile   |    2 +-
 arch/powerpc/xmon/nonstdio.c |   14 ++++++++++++++
 arch/powerpc/xmon/nonstdio.h |    2 --
 arch/powerpc/xmon/start.c    |   23 -----------------------
 4 files changed, 15 insertions(+), 26 deletions(-)
 delete mode 100644 arch/powerpc/xmon/start.c

diff --git a/arch/powerpc/xmon/Makefile b/arch/powerpc/xmon/Makefile
index c168c54..b49fdbd 100644
--- a/arch/powerpc/xmon/Makefile
+++ b/arch/powerpc/xmon/Makefile
@@ -6,7 +6,7 @@ GCOV_PROFILE := n
 
 ccflags-$(CONFIG_PPC64) := -mno-minimal-toc
 
-obj-y			+= xmon.o start.o nonstdio.o
+obj-y			+= xmon.o nonstdio.o
 
 ifdef CONFIG_XMON_DISASSEMBLY
 obj-y			+= ppc-dis.o ppc-opc.o
diff --git a/arch/powerpc/xmon/nonstdio.c b/arch/powerpc/xmon/nonstdio.c
index 2209485..942d0f6 100644
--- a/arch/powerpc/xmon/nonstdio.c
+++ b/arch/powerpc/xmon/nonstdio.c
@@ -7,9 +7,23 @@
  *      2 of the License, or (at your option) any later version.
  */
 #include <linux/string.h>
+#include <asm/udbg.h>
 #include <asm/time.h>
 #include "nonstdio.h"
 
+
+static int xmon_write(const void *ptr, int nb)
+{
+	return udbg_write(ptr, nb);
+}
+
+static int xmon_readchar(void)
+{
+	if (udbg_getc)
+		return udbg_getc();
+	return -1;
+}
+
 int xmon_putchar(int c)
 {
 	char ch = c;
diff --git a/arch/powerpc/xmon/nonstdio.h b/arch/powerpc/xmon/nonstdio.h
index 321284f..18a51de 100644
--- a/arch/powerpc/xmon/nonstdio.h
+++ b/arch/powerpc/xmon/nonstdio.h
@@ -7,5 +7,3 @@ extern int xmon_putchar(int c);
 extern void xmon_puts(const char *);
 extern char *xmon_gets(char *, int);
 extern void xmon_printf(const char *, ...);
-extern int xmon_write(const void *ptr, int nb);
-extern int xmon_readchar(void);
diff --git a/arch/powerpc/xmon/start.c b/arch/powerpc/xmon/start.c
deleted file mode 100644
index 7769cb5..0000000
--- a/arch/powerpc/xmon/start.c
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright (C) 1996 Paul Mackerras.
- *
- *      This program is free software; you can redistribute it and/or
- *      modify it under the terms of the GNU General Public License
- *      as published by the Free Software Foundation; either version
- *      2 of the License, or (at your option) any later version.
- */
-#include <asm/machdep.h>
-#include <asm/udbg.h>
-#include "nonstdio.h"
-
-int xmon_write(const void *ptr, int nb)
-{
-	return udbg_write(ptr, nb);
-}
-
-int xmon_readchar(void)
-{
-	if (udbg_getc)
-		return udbg_getc();
-	return -1;
-}
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 06/20] powerpc/xmon: Remove renaming #defines of scanhex() and skipbl()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

We have two #defines that rename scanhex() and skipbl() to
xmon_scanhex() and xmon_skipbl() - but no one ever uses those
names.

So the only effect is to rename the actual symbols in the generated
code, and AFACIS there is no reason to do that, so drop them.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |    3 ---
 1 file changed, 3 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 67d36ab..cc96a71 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -52,9 +52,6 @@
 #include "nonstdio.h"
 #include "dis-asm.h"
 
-#define scanhex	xmon_scanhex
-#define skipbl	xmon_skipbl
-
 #ifdef CONFIG_SMP
 static cpumask_t cpus_in_xmon = CPU_MASK_NONE;
 static unsigned long xmon_taken = 1;
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 07/20] powerpc/xmon: Remove unused #defines
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

Neither REGS_PER_LINE or LAST_VOLATILE are used, nor have they ever
been as far back as I can see.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |    4 ----
 1 file changed, 4 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index cc96a71..abf6be4 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -166,12 +166,8 @@ extern void xmon_leave(void);
 
 #ifdef CONFIG_PPC64
 #define REG		"%.16lx"
-#define REGS_PER_LINE	4
-#define LAST_VOLATILE	13
 #else
 #define REG		"%.8lx"
-#define REGS_PER_LINE	8
-#define LAST_VOLATILE	12
 #endif
 
 #define GETWORD(v)	(((v)[0] << 24) + ((v)[1] << 16) + ((v)[2] << 8) + (v)[3])
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 08/20] powerpc/xmon: Use STACK_FRAME_OVERHEAD in xmon_show_stack()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

We use STACK_FRAME_OVERHEAD in the exception vectors to establish
the exception frame, so it should be good enough to use here.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |   10 ++--------
 1 file changed, 2 insertions(+), 8 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index abf6be4..d940234 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1286,12 +1286,6 @@ static int xmon_depth_to_print = 64;
 #define LRSAVE_OFFSET		(STACK_FRAME_LR_SAVE * sizeof(unsigned long))
 #define MARKER_OFFSET		(STACK_FRAME_MARKER * sizeof(unsigned long))
 
-#ifdef __powerpc64__
-#define REGS_OFFSET		0x70
-#else
-#define REGS_OFFSET		16
-#endif
-
 static void xmon_show_stack(unsigned long sp, unsigned long lr,
 			    unsigned long pc)
 {
@@ -1355,10 +1349,10 @@ static void xmon_show_stack(unsigned long sp, unsigned long lr,
 		   an exception frame. */
 		if (mread(sp + MARKER_OFFSET, &marker, sizeof(unsigned long))
 		    && marker == STACK_FRAME_REGS_MARKER) {
-			if (mread(sp + REGS_OFFSET, &regs, sizeof(regs))
+			if (mread(sp + STACK_FRAME_OVERHEAD, &regs, sizeof(regs))
 			    != sizeof(regs)) {
 				printf("Couldn't read registers at %lx\n",
-				       sp + REGS_OFFSET);
+				       sp + STACK_FRAME_OVERHEAD);
 				break;
 			}
 			printf("--- Exception: %lx %s at ", regs.trap,
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 09/20] powerpc/xmon: Fiddle xmon_depth_to_print logic in xmon_show_stack()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

Currently xmon_depth_to_print is static and global, but it's only
ever used in xmon_show_stack().

At least with a modern compiler it's inlined, so there's no point
in it being static, we could #define it but it's only used in one
place.

By reworking the logic we can drop count and just decrement the
max value as a loop counter. Also switch to a while loop so we
actually print no more than 64 frames as you'd expect based on the
variable name.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |    8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index d940234..1f8d2f1 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1281,21 +1281,19 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
 	catch_memory_errors = 0;
 }
 
-static int xmon_depth_to_print = 64;
-
 #define LRSAVE_OFFSET		(STACK_FRAME_LR_SAVE * sizeof(unsigned long))
 #define MARKER_OFFSET		(STACK_FRAME_MARKER * sizeof(unsigned long))
 
 static void xmon_show_stack(unsigned long sp, unsigned long lr,
 			    unsigned long pc)
 {
+	int max_to_print = 64;
 	unsigned long ip;
 	unsigned long newsp;
 	unsigned long marker;
-	int count = 0;
 	struct pt_regs regs;
 
-	do {
+	while (max_to_print--) {
 		if (sp < PAGE_OFFSET) {
 			if (sp != 0)
 				printf("SP (%lx) is in userspace\n", sp);
@@ -1366,7 +1364,7 @@ static void xmon_show_stack(unsigned long sp, unsigned long lr,
 			break;
 
 		sp = newsp;
-	} while (count++ < xmon_depth_to_print);
+	}
 }
 
 static void backtrace(struct pt_regs *excp)
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 10/20] powerpc/xmon: Factor out the oft-repeated setjmp logic
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

We have over 15 routines that implement essentially the same logic
in terms of catching faults. Pull the logic out into two helper
routines.

The pattern becomes:

	if (start_bus_error_jump() == 0) {
		<do potentially faulting things>

		end_bus_error_jump();
	} else {
		printf("Faulting thing faulted!\n");
	}

Also move the globals next to the functions.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |   33 +++++++++++++++++++++++++++++++--
 1 file changed, 31 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 1f8d2f1..168c5e7 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -72,8 +72,6 @@ static unsigned long ncsum = 4096;
 static int termch;
 static char tmpstr[128];
 
-static long bus_error_jmp[JMP_BUF_LEN];
-static int catch_memory_errors;
 static long *xmon_fault_jmp[NR_CPUS];
 
 /* Breakpoint stuff */
@@ -636,6 +634,37 @@ static int xmon_ipi(struct pt_regs *regs)
 	return 0;
 }
 
+static long bus_error_jmp[JMP_BUF_LEN];
+static int catch_memory_errors;
+
+int start_bus_error_jump(void)
+{
+	int rc;
+
+	catch_memory_errors = 1;
+	sync();
+
+	rc = setjmp(bus_error_jmp);
+	if (rc)
+		catch_memory_errors = 0;
+
+	return rc;
+}
+
+void end_bus_error_jump(void)
+{
+	sync();
+
+	/* Wait a little while to see if we get a machine check */
+	__delay(200);
+
+	/*
+	 * We don't actually clear the jump buffer but setting
+	 * catch_memory_errors to zero means we'll no longer jump to it.
+	 */
+	catch_memory_errors = 0;
+}
+
 static int xmon_fault_handler(struct pt_regs *regs)
 {
 	struct bpt *bp;
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 11/20] powerpc/xmon: Move handle_fault() next to related routines
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |   48 +++++++++++++++++++++++-----------------------
 1 file changed, 24 insertions(+), 24 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 168c5e7..65c3d22 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -665,6 +665,30 @@ void end_bus_error_jump(void)
 	catch_memory_errors = 0;
 }
 
+static int fault_type;
+static int fault_except;
+static char *fault_chars[] = { "--", "**", "##" };
+
+static int handle_fault(struct pt_regs *regs)
+{
+	fault_except = TRAP(regs);
+	switch (TRAP(regs)) {
+	case 0x200:
+		fault_type = 0;
+		break;
+	case 0x300:
+	case 0x380:
+		fault_type = 1;
+		break;
+	default:
+		fault_type = 2;
+	}
+
+	longjmp(bus_error_jmp, 1);
+
+	return 0;
+}
+
 static int xmon_fault_handler(struct pt_regs *regs)
 {
 	struct bpt *bp;
@@ -1755,30 +1779,6 @@ mwrite(unsigned long adrs, void *buf, int size)
 	return n;
 }
 
-static int fault_type;
-static int fault_except;
-static char *fault_chars[] = { "--", "**", "##" };
-
-static int handle_fault(struct pt_regs *regs)
-{
-	fault_except = TRAP(regs);
-	switch (TRAP(regs)) {
-	case 0x200:
-		fault_type = 0;
-		break;
-	case 0x300:
-	case 0x380:
-		fault_type = 1;
-		break;
-	default:
-		fault_type = 2;
-	}
-
-	longjmp(bus_error_jmp, 1);
-
-	return 0;
-}
-
 #define SWAP(a, b, t)	((t) = (a), (a) = (b), (b) = (t))
 
 static void
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 12/20] powerpc/xmon: Do so simple conversions to start/end_bus_error_jump()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |   79 +++++++++++-----------------------------------
 1 file changed, 18 insertions(+), 61 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 65c3d22..45be9ce 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1503,19 +1503,14 @@ static void prregs(struct pt_regs *fp)
 	struct pt_regs regs;
 
 	if (scanhex(&base)) {
-		if (setjmp(bus_error_jmp) == 0) {
-			catch_memory_errors = 1;
-			sync();
+		if (start_bus_error_jump() == 0) {
 			regs = *(struct pt_regs *)base;
-			sync();
-			__delay(200);
+			end_bus_error_jump();
 		} else {
-			catch_memory_errors = 0;
 			printf("*** Error reading registers from "REG"\n",
 			       base);
 			return;
 		}
-		catch_memory_errors = 0;
 		fp = &regs;
 	}
 
@@ -1569,10 +1564,7 @@ static void cacheflush(void)
 	nflush = 1;
 	scanhex(&nflush);
 	nflush = (nflush + L1_CACHE_BYTES - 1) / L1_CACHE_BYTES;
-	if (setjmp(bus_error_jmp) == 0) {
-		catch_memory_errors = 1;
-		sync();
-
+	if (start_bus_error_jump() == 0) {
 		if (cmd != 'i') {
 			for (; nflush > 0; --nflush, adrs += L1_CACHE_BYTES)
 				cflush((void *) adrs);
@@ -1580,11 +1572,9 @@ static void cacheflush(void)
 			for (; nflush > 0; --nflush, adrs += L1_CACHE_BYTES)
 				cinval((void *) adrs);
 		}
-		sync();
-		/* wait a little while to see if we get a machine check */
-		__delay(200);
+
+		end_bus_error_jump();
 	}
-	catch_memory_errors = 0;
 }
 
 static unsigned long
@@ -1710,9 +1700,7 @@ mread(unsigned long adrs, void *buf, int size)
 	char *p, *q;
 
 	n = 0;
-	if (setjmp(bus_error_jmp) == 0) {
-		catch_memory_errors = 1;
-		sync();
+	if (start_bus_error_jump() == 0) {
 		p = (char *)adrs;
 		q = (char *)buf;
 		switch (size) {
@@ -1731,12 +1719,9 @@ mread(unsigned long adrs, void *buf, int size)
 				sync();
 			}
 		}
-		sync();
-		/* wait a little while to see if we get a machine check */
-		__delay(200);
+		end_bus_error_jump();
 		n = size;
 	}
-	catch_memory_errors = 0;
 	return n;
 }
 
@@ -1747,9 +1732,7 @@ mwrite(unsigned long adrs, void *buf, int size)
 	char *p, *q;
 
 	n = 0;
-	if (setjmp(bus_error_jmp) == 0) {
-		catch_memory_errors = 1;
-		sync();
+	if (start_bus_error_jump() == 0) {
 		p = (char *) adrs;
 		q = (char *) buf;
 		switch (size) {
@@ -1768,14 +1751,11 @@ mwrite(unsigned long adrs, void *buf, int size)
 				sync();
 			}
 		}
-		sync();
-		/* wait a little while to see if we get a machine check */
-		__delay(200);
+		end_bus_error_jump();
 		n = size;
 	} else {
 		printf("*** Error writing address %x\n", adrs + n);
 	}
-	catch_memory_errors = 0;
 	return n;
 }
 
@@ -2272,24 +2252,18 @@ dump_log_buf(void)
 	unsigned char buf[128];
 	size_t len;
 
-	if (setjmp(bus_error_jmp) != 0) {
+	if (start_bus_error_jump() != 0) {
 		printf("Error dumping printk buffer!\n");
 		return;
 	}
 
-	catch_memory_errors = 1;
-	sync();
-
 	kmsg_dump_rewind_nolock(&dumper);
 	while (kmsg_dump_get_line_nolock(&dumper, false, buf, sizeof(buf), &len)) {
 		buf[len] = '\0';
 		printf("%s", buf);
 	}
 
-	sync();
-	/* wait a little while to see if we get a machine check */
-	__delay(200);
-	catch_memory_errors = 0;
+	end_bus_error_jump();
 }
 
 /*
@@ -2672,18 +2646,12 @@ static void xmon_print_symbol(unsigned long address, const char *mid,
 	unsigned long offset, size;
 
 	printf(REG, address);
-	if (setjmp(bus_error_jmp) == 0) {
-		catch_memory_errors = 1;
-		sync();
+	if (start_bus_error_jump() == 0) {
 		name = kallsyms_lookup(address, &size, &offset, &modname,
 				       tmpstr);
-		sync();
-		/* wait a little while to see if we get a machine check */
-		__delay(200);
+		end_bus_error_jump();
 	}
 
-	catch_memory_errors = 0;
-
 	if (name) {
 		printf("%s%s+%#lx/%#lx", mid, name, offset, size);
 		if (modname)
@@ -3123,19 +3091,13 @@ static void restart_spus(void)
 #define DUMP_WIDTH	23
 #define DUMP_VALUE(format, field, value)				\
 do {									\
-	if (setjmp(bus_error_jmp) == 0) {				\
-		catch_memory_errors = 1;				\
-		sync();							\
+	if (start_bus_error_jump() == 0) {				\
 		printf("  %-*s = "format"\n", DUMP_WIDTH,		\
 				#field, value);				\
-		sync();							\
-		__delay(200);						\
-	} else {							\
-		catch_memory_errors = 0;				\
+		end_bus_error_jump();					\
+	} else								\
 		printf("  %-*s = *** Error reading field.\n",		\
 					DUMP_WIDTH, #field);		\
-	}								\
-	catch_memory_errors = 0;					\
 } while (0)
 
 #define DUMP_FIELD(obj, format, field)	\
@@ -3187,18 +3149,13 @@ static void dump_spu_ls(unsigned long num, int subcmd)
 {
 	unsigned long offset, addr, ls_addr;
 
-	if (setjmp(bus_error_jmp) == 0) {
-		catch_memory_errors = 1;
-		sync();
+	if (start_bus_error_jump() == 0) {
 		ls_addr = (unsigned long)spu_info[num].spu->local_store;
-		sync();
-		__delay(200);
+		end_bus_error_jump();
 	} else {
-		catch_memory_errors = 0;
 		printf("*** Error: accessing spu info for spu %d\n", num);
 		return;
 	}
-	catch_memory_errors = 0;
 
 	if (scanhex(&offset))
 		addr = ls_addr + offset;
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 13/20] powerpc/xmon: Use start/end_bus_error_jump() in more routines
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

These are not entirely equivalent to the old code. In most cases they
just gain a call to __delay() via end_bus_error_jump().

In symbol_lookup() we also move the printf() outside the protected area,
this should be safe as we are not derefencing the value we lookup, just
printing its value.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |   39 +++++++++++++--------------------------
 1 file changed, 13 insertions(+), 26 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 45be9ce..ddae5cf 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1321,17 +1321,16 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
 	*startp = *endp = 0;
 	if (pc == 0)
 		return;
-	if (setjmp(bus_error_jmp) == 0) {
-		catch_memory_errors = 1;
-		sync();
+
+	if (start_bus_error_jump() == 0) {
 		name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr);
 		if (name != NULL) {
 			*startp = pc - offset;
 			*endp = pc - offset + size;
 		}
-		sync();
+
+		end_bus_error_jump();
 	}
-	catch_memory_errors = 0;
 }
 
 #define LRSAVE_OFFSET		(STACK_FRAME_LR_SAVE * sizeof(unsigned long))
@@ -2016,14 +2015,11 @@ static void dump_one_paca(int cpu)
 {
 	struct paca_struct *p;
 
-	if (setjmp(bus_error_jmp) != 0) {
+	if (start_bus_error_jump() != 0) {
 		printf("*** Error dumping paca for cpu 0x%x!\n", cpu);
 		return;
 	}
 
-	catch_memory_errors = 1;
-	sync();
-
 	p = &paca[cpu];
 
 	printf("paca for cpu 0x%x @ %p:\n", cpu, p);
@@ -2063,8 +2059,7 @@ static void dump_one_paca(int cpu)
 
 #undef DUMP
 
-	catch_memory_errors = 0;
-	sync();
+	end_bus_error_jump();
 }
 
 static void dump_all_pacas(void)
@@ -2402,17 +2397,14 @@ static void proccall(void)
 	}
 	func = (callfunc_t) adrs;
 	ret = 0;
-	if (setjmp(bus_error_jmp) == 0) {
-		catch_memory_errors = 1;
-		sync();
+	if (start_bus_error_jump() == 0) {
 		ret = func(args[0], args[1], args[2], args[3],
 			   args[4], args[5], args[6], args[7]);
-		sync();
+		end_bus_error_jump();
 		printf("return value is %x\n", ret);
 	} else {
 		printf("*** %x exception occurred\n", fault_except);
 	}
-	catch_memory_errors = 0;
 }
 
 /* Input scanning routines */
@@ -2507,13 +2499,10 @@ scanhex(unsigned long *vp)
 		}
 		tmpstr[i++] = 0;
 		*vp = 0;
-		if (setjmp(bus_error_jmp) == 0) {
-			catch_memory_errors = 1;
-			sync();
+		if (start_bus_error_jump() == 0) {
 			*vp = kallsyms_lookup_name(tmpstr);
-			sync();
+			end_bus_error_jump();
 		}
-		catch_memory_errors = 0;
 		if (!(*vp)) {
 			printf("unknown symbol '%s'\n", tmpstr);
 			return 0;
@@ -2620,17 +2609,15 @@ symbol_lookup(void)
 		break;
 	case 's':
 		getstring(tmp, 64);
-		if (setjmp(bus_error_jmp) == 0) {
-			catch_memory_errors = 1;
-			sync();
+		if (start_bus_error_jump() == 0) {
 			addr = kallsyms_lookup_name(tmp);
+			end_bus_error_jump();
+
 			if (addr)
 				printf("%s: %lx\n", tmp, addr);
 			else
 				printf("Symbol '%s' not found.\n", tmp);
-			sync();
 		}
-		catch_memory_errors = 0;
 		termch = 0;
 		break;
 	}
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 14/20] powerpc/xmon: Convert read/write_spr() to use start_bus_error_jump()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

read_spr() and write_spr() were both forgetting to clear catch_memory_errors,
that's fixed now that they use start/end_bus_error_jump().

Also drop the setting of n in both routines, it's never used.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |   22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index ddae5cf..a8188f0 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1599,16 +1599,9 @@ read_spr(int n)
 	store_inst(instrs);
 	store_inst(instrs+1);
 
-	if (setjmp(bus_error_jmp) == 0) {
-		catch_memory_errors = 1;
-		sync();
-
+	if (start_bus_error_jump() == 0) {
 		ret = code();
-
-		sync();
-		/* wait a little while to see if we get a machine check */
-		__delay(200);
-		n = size;
+		end_bus_error_jump();
 	}
 
 	return ret;
@@ -1635,16 +1628,9 @@ write_spr(int n, unsigned long val)
 	store_inst(instrs);
 	store_inst(instrs+1);
 
-	if (setjmp(bus_error_jmp) == 0) {
-		catch_memory_errors = 1;
-		sync();
-
+	if (start_bus_error_jump() == 0) {
 		code(val);
-
-		sync();
-		/* wait a little while to see if we get a machine check */
-		__delay(200);
-		n = size;
+		end_bus_error_jump();
 	}
 }
 
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 15/20] powerpc/xmon: Deindent stop/restart_spus()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

Should be no logic change, use continue to avoid an indent.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |   72 ++++++++++++++++++++++++----------------------
 1 file changed, 38 insertions(+), 34 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index a8188f0..0fefe03 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2994,33 +2994,35 @@ static void stop_spus(void)
 		if (!spu_info[i].spu)
 			continue;
 
-		if (setjmp(bus_error_jmp) == 0) {
-			catch_memory_errors = 1;
-			sync();
+		if (setjmp(bus_error_jmp) != 0) {
+			catch_memory_errors = 0;
+			printf("*** Error stopping spu %.2d\n", i);
+			continue;
+		}
 
-			spu = spu_info[i].spu;
+		catch_memory_errors = 1;
+		sync();
 
-			spu_info[i].saved_spu_runcntl_RW =
-				in_be32(&spu->problem->spu_runcntl_RW);
+		spu = spu_info[i].spu;
 
-			tmp = spu_mfc_sr1_get(spu);
-			spu_info[i].saved_mfc_sr1_RW = tmp;
+		spu_info[i].saved_spu_runcntl_RW =
+			in_be32(&spu->problem->spu_runcntl_RW);
 
-			tmp &= ~MFC_STATE1_MASTER_RUN_CONTROL_MASK;
-			spu_mfc_sr1_set(spu, tmp);
+		tmp = spu_mfc_sr1_get(spu);
+		spu_info[i].saved_mfc_sr1_RW = tmp;
 
-			sync();
-			__delay(200);
+		tmp &= ~MFC_STATE1_MASTER_RUN_CONTROL_MASK;
+		spu_mfc_sr1_set(spu, tmp);
 
-			spu_info[i].stopped_ok = 1;
+		sync();
+		__delay(200);
+
+		spu_info[i].stopped_ok = 1;
+
+		printf("Stopped spu %.2d (was %s)\n", i,
+				spu_info[i].saved_spu_runcntl_RW ?
+				"running" : "stopped");
 
-			printf("Stopped spu %.2d (was %s)\n", i,
-					spu_info[i].saved_spu_runcntl_RW ?
-					"running" : "stopped");
-		} else {
-			catch_memory_errors = 0;
-			printf("*** Error stopping spu %.2d\n", i);
-		}
 		catch_memory_errors = 0;
 	}
 }
@@ -3040,23 +3042,25 @@ static void restart_spus(void)
 			continue;
 		}
 
-		if (setjmp(bus_error_jmp) == 0) {
-			catch_memory_errors = 1;
-			sync();
-
-			spu = spu_info[i].spu;
-			spu_mfc_sr1_set(spu, spu_info[i].saved_mfc_sr1_RW);
-			out_be32(&spu->problem->spu_runcntl_RW,
-					spu_info[i].saved_spu_runcntl_RW);
-
-			sync();
-			__delay(200);
-
-			printf("Restarted spu %.2d\n", i);
-		} else {
+		if (setjmp(bus_error_jmp) != 0) {
 			catch_memory_errors = 0;
 			printf("*** Error restarting spu %.2d\n", i);
+			continue;
 		}
+
+		catch_memory_errors = 1;
+		sync();
+
+		spu = spu_info[i].spu;
+		spu_mfc_sr1_set(spu, spu_info[i].saved_mfc_sr1_RW);
+		out_be32(&spu->problem->spu_runcntl_RW,
+				spu_info[i].saved_spu_runcntl_RW);
+
+		sync();
+		__delay(200);
+
+		printf("Restarted spu %.2d\n", i);
+
 		catch_memory_errors = 0;
 	}
 }
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 16/20] powerpc/xmon: Use start_bus_error_jump() in spu routines
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

Moves the printfs & setting of stopped_ok out of the protected area.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |   22 ++++------------------
 1 file changed, 4 insertions(+), 18 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 0fefe03..abc89a4 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -2994,15 +2994,11 @@ static void stop_spus(void)
 		if (!spu_info[i].spu)
 			continue;
 
-		if (setjmp(bus_error_jmp) != 0) {
-			catch_memory_errors = 0;
+		if (start_bus_error_jump() != 0) {
 			printf("*** Error stopping spu %.2d\n", i);
 			continue;
 		}
 
-		catch_memory_errors = 1;
-		sync();
-
 		spu = spu_info[i].spu;
 
 		spu_info[i].saved_spu_runcntl_RW =
@@ -3014,16 +3010,13 @@ static void stop_spus(void)
 		tmp &= ~MFC_STATE1_MASTER_RUN_CONTROL_MASK;
 		spu_mfc_sr1_set(spu, tmp);
 
-		sync();
-		__delay(200);
+		end_bus_error_jump();
 
 		spu_info[i].stopped_ok = 1;
 
 		printf("Stopped spu %.2d (was %s)\n", i,
 				spu_info[i].saved_spu_runcntl_RW ?
 				"running" : "stopped");
-
-		catch_memory_errors = 0;
 	}
 }
 
@@ -3042,26 +3035,19 @@ static void restart_spus(void)
 			continue;
 		}
 
-		if (setjmp(bus_error_jmp) != 0) {
-			catch_memory_errors = 0;
+		if (start_bus_error_jump() != 0) {
 			printf("*** Error restarting spu %.2d\n", i);
 			continue;
 		}
 
-		catch_memory_errors = 1;
-		sync();
-
 		spu = spu_info[i].spu;
 		spu_mfc_sr1_set(spu, spu_info[i].saved_mfc_sr1_RW);
 		out_be32(&spu->problem->spu_runcntl_RW,
 				spu_info[i].saved_spu_runcntl_RW);
 
-		sync();
-		__delay(200);
+		end_bus_error_jump();
 
 		printf("Restarted spu %.2d\n", i);
-
-		catch_memory_errors = 0;
 	}
 }
 
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 17/20] powerpc/xmon: Make less variables global
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

Move a number of variables into their only user, reducing some of the
global variable clutter. They remain static, so their behaviour across
calls is unchanged.

Also use ARRAY_SIZE for regnames in scanhex().

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |   46 +++++++++++++++++++++-------------------------
 1 file changed, 21 insertions(+), 25 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index abc89a4..c6cd027 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -64,11 +64,7 @@ static int xmon_gate;
 static unsigned long in_xmon __read_mostly = 0;
 
 static unsigned long adrs;
-static int size = 1;
 #define MAX_DUMP (128 * 1024)
-static unsigned long ndump = 64;
-static unsigned long nidump = 16;
-static unsigned long ncsum = 4096;
 static int termch;
 static char tmpstr[128];
 
@@ -1109,6 +1105,7 @@ static unsigned short fcstab[256] = {
 static void
 csum(void)
 {
+	static unsigned long ncsum = 4096;
 	unsigned int i;
 	unsigned short fcs;
 	unsigned char v;
@@ -1634,12 +1631,12 @@ write_spr(int n, unsigned long val)
 	}
 }
 
-static unsigned long regno;
 extern char exc_prolog;
 extern char dec_exc;
 
 static void super_regs(void)
 {
+	static unsigned long regno;
 	int cmd;
 	unsigned long val;
 
@@ -1768,9 +1765,6 @@ byterev(unsigned char *val, int size)
 	}
 }
 
-static int brev;
-static int mnoread;
-
 static char *memex_help_string =
     "Memory examine command usage:\n"
     "m [addr] [flags] examine/change memory\n"
@@ -1811,6 +1805,7 @@ static char *memex_subcmd_help_string =
 static void
 memex(void)
 {
+	static int mnoread, brev, size = 1;
 	int cmd, inc, i, nslash;
 	unsigned long n;
 	unsigned char val[16];
@@ -2087,6 +2082,8 @@ static void dump_pacas(void)
 static void
 dump(void)
 {
+	static unsigned long ndump = 64;
+	static unsigned long nidump = 16;
 	int c;
 
 	c = inchar();
@@ -2253,12 +2250,13 @@ dump_log_buf(void)
 static unsigned long mdest;		/* destination address */
 static unsigned long msrc;		/* source address */
 static unsigned long mval;		/* byte value to set memory to */
-static unsigned long mcount;		/* # bytes to affect */
-static unsigned long mdiffs;		/* max # differences to print */
 
 static void
 memops(int cmd)
 {
+	static unsigned long mcount;		/* # bytes to affect */
+	static unsigned long mdiffs;		/* max # differences to print */
+
 	scanhex((void *)&mdest);
 	if( termch != '\n' )
 		termch = 0;
@@ -2297,12 +2295,12 @@ memdiffs(unsigned char *p1, unsigned char *p2, unsigned nb, unsigned maxpr)
 		printf("Total of %d differences\n", prt);
 }
 
-static unsigned mend;
-static unsigned mask;
-
 static void
 memlocate(void)
 {
+	static unsigned mend;
+	static unsigned mask;
+
 	unsigned a, n;
 	unsigned char val[4];
 
@@ -2330,12 +2328,11 @@ memlocate(void)
 	}
 }
 
-static unsigned long mskip = 0x1000;
-static unsigned long mlim = 0xffffffff;
-
 static void
 memzcan(void)
 {
+	static unsigned long mskip = 0x1000;
+	static unsigned long mlim = 0xffffffff;
 	unsigned char v;
 	unsigned a;
 	int ok, ook;
@@ -2409,8 +2406,10 @@ skipbl(void)
 	return c;
 }
 
-#define N_PTREGS	44
-static char *regnames[N_PTREGS] = {
+int
+scanhex(unsigned long *vp)
+{
+	static char *regnames[] = {
 	"r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7",
 	"r8", "r9", "r10", "r11", "r12", "r13", "r14", "r15",
 	"r16", "r17", "r18", "r19", "r20", "r21", "r22", "r23",
@@ -2422,11 +2421,7 @@ static char *regnames[N_PTREGS] = {
 	"mq",
 #endif
 	"trap", "dar", "dsisr", "res"
-};
-
-int
-scanhex(unsigned long *vp)
-{
+	};
 	int c, d;
 	unsigned long v;
 
@@ -2445,7 +2440,7 @@ scanhex(unsigned long *vp)
 			regname[i] = c;
 		}
 		regname[i] = 0;
-		for (i = 0; i < N_PTREGS; ++i) {
+		for (i = 0; i < ARRAY_SIZE(regnames); ++i) {
 			if (strcmp(regnames[i], regname) == 0) {
 				if (xmon_regs == NULL) {
 					printf("regs not available\n");
@@ -2551,7 +2546,6 @@ getstring(char *s, int size)
 	*s = 0;
 }
 
-static char line[256];
 static char *lineptr;
 
 static void
@@ -2563,6 +2557,8 @@ flush_input(void)
 static int
 inchar(void)
 {
+	static char line[256];
+
 	if (lineptr == NULL || *lineptr == 0) {
 		if (xmon_gets(line, sizeof(line)) == NULL) {
 			lineptr = NULL;
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 18/20] powerpc/xmon: Use kallsyms_lookup_size_offset() in get_function_bounds()
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

We throw away the name so we should use kallsyms_lookup_size_offset(),
which does what we need and nothing more.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |    4 +---
 1 file changed, 1 insertion(+), 3 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index c6cd027..9eb1d34 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -1313,15 +1313,13 @@ static void get_function_bounds(unsigned long pc, unsigned long *startp,
 				unsigned long *endp)
 {
 	unsigned long size, offset;
-	const char *name;
 
 	*startp = *endp = 0;
 	if (pc == 0)
 		return;
 
 	if (start_bus_error_jump() == 0) {
-		name = kallsyms_lookup(pc, &size, &offset, NULL, tmpstr);
-		if (name != NULL) {
+		if (kallsyms_lookup_size_offset(pc, &size, &offset)) {
 			*startp = pc - offset;
 			*endp = pc - offset + size;
 		}
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 19/20] powerpc/xmon: Remove externs for non-existant routines
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

The implementation of both xmon_enter() & xmon_leave() was removed in
commit 51d3082 "Unify udbg (#2)".

I can't find any reference to exc_prolog or dec_exc since the epoch.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/xmon.c |    6 ------
 1 file changed, 6 deletions(-)

diff --git a/arch/powerpc/xmon/xmon.c b/arch/powerpc/xmon/xmon.c
index 9eb1d34..ded6c56 100644
--- a/arch/powerpc/xmon/xmon.c
+++ b/arch/powerpc/xmon/xmon.c
@@ -155,9 +155,6 @@ static void dump_tlb_book3e(void);
 
 static int xmon_no_auto_backtrace;
 
-extern void xmon_enter(void);
-extern void xmon_leave(void);
-
 #ifdef CONFIG_PPC64
 #define REG		"%.16lx"
 #else
@@ -1629,9 +1626,6 @@ write_spr(int n, unsigned long val)
 	}
 }
 
-extern char exc_prolog;
-extern char dec_exc;
-
 static void super_regs(void)
 {
 	static unsigned long regno;
-- 
1.7.9.5

^ permalink raw reply related

* [PATCH 20/20] powerpc/xmon: Fallback to printk() in xmon_printf() if udbg is not setup
From: Michael Ellerman @ 2012-10-09 14:20 UTC (permalink / raw)
  To: linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-1-git-send-email-michael@ellerman.id.au>

It is possible to configure a kernel which has xmon enabled, but has no
udbg backend to provide IO. This can make xmon rather confusing, as it
produces no output, blocks for two seconds, and then returns.

As a last resort we can instead try to printk(), which may deadlock or
otherwise crash, but tries quite hard not to.

Signed-off-by: Michael Ellerman <michael@ellerman.id.au>
---
 arch/powerpc/xmon/nonstdio.c |   10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/arch/powerpc/xmon/nonstdio.c b/arch/powerpc/xmon/nonstdio.c
index 942d0f6..bce3dcf 100644
--- a/arch/powerpc/xmon/nonstdio.c
+++ b/arch/powerpc/xmon/nonstdio.c
@@ -111,13 +111,19 @@ char *xmon_gets(char *str, int nb)
 void xmon_printf(const char *format, ...)
 {
 	va_list args;
-	int n;
 	static char xmon_outbuf[1024];
+	int rc, n;
 
 	va_start(args, format);
 	n = vsnprintf(xmon_outbuf, sizeof(xmon_outbuf), format, args);
 	va_end(args);
-	xmon_write(xmon_outbuf, n);
+
+	rc = xmon_write(xmon_outbuf, n);
+
+	if (n && rc == 0) {
+		/* No udbg hooks, fallback to printk() - dangerous */
+		printk(xmon_outbuf);
+	}
 }
 
 void xmon_puts(const char *str)
-- 
1.7.9.5

^ permalink raw reply related

* RE: [PATCH 06/20] powerpc/xmon: Remove renaming #defines of scanhex() and skipbl()
From: David Laight @ 2012-10-09 14:59 UTC (permalink / raw)
  To: Michael Ellerman, linuxppc-dev; +Cc: Paul Mackerras, Anton Blanchard
In-Reply-To: <1349792447-15714-6-git-send-email-michael@ellerman.id.au>

> We have two #defines that rename scanhex() and skipbl() to
> xmon_scanhex() and xmon_skipbl() - but no one ever uses those
> names.

It looks like they are there for namespace protection.

	David

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox