From owner-svn-src-projects@FreeBSD.ORG Sun Jan 11 20:25:18 2015 Return-Path: Delivered-To: svn-src-projects@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 4DD6B621; Sun, 11 Jan 2015 20:25:18 +0000 (UTC) Received: from d.mail.sonic.net (d.mail.sonic.net [64.142.111.50]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 34347CEB; Sun, 11 Jan 2015 20:25:17 +0000 (UTC) Received: from zeppelin.tachypleus.net (polaris.tachypleus.net [75.101.50.44]) (authenticated bits=0) by d.mail.sonic.net (8.14.9/8.14.9) with ESMTP id t0BKPFZP019047 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-SHA bits=256 verify=NOT); Sun, 11 Jan 2015 12:25:16 -0800 Message-ID: <54B2DC2B.8010209@freebsd.org> Date: Sun, 11 Jan 2015 12:25:15 -0800 From: Nathan Whitehorn User-Agent: Mozilla/5.0 (X11; FreeBSD amd64; rv:31.0) Gecko/20100101 Thunderbird/31.2.0 MIME-Version: 1.0 To: Andrew Turner , src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: Re: svn commit: r277021 - in projects/arm_intrng/sys: arm/arm arm/include dev/fdt powerpc/powerpc References: <201501112016.t0BKGFLQ023144@svn.freebsd.org> In-Reply-To: <201501112016.t0BKGFLQ023144@svn.freebsd.org> Content-Type: text/plain; charset=utf-8; format=flowed Content-Transfer-Encoding: 7bit X-Sonic-CAuth: UmFuZG9tSVY88NDycViyCXki1aJu+T8XU+urwNoH+EnEdsCRxU8f5e2c+3x8LrlaJL0YDICoHDqTFJOHWVd7TLaDA7mkOSWnjmdWDfrQhfo= X-Sonic-ID: C;AhPK88+Z5BGqO9mh1eMT4g== M;MG0P9M+Z5BGqO9mh1eMT4g== X-Spam-Flag: No X-Sonic-Spam-Details: 0.0/5.0 by cerberusd X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sun, 11 Jan 2015 20:25:18 -0000 What is this function for, anyway? I'd much prefer some analog to the nexus method that implements OFW_BUS_MAP_IRQ() if it's just supposed to be a human-readable version of the mapping logic. -Nathan On 01/11/15 12:16, Andrew Turner wrote: > Author: andrew > Date: Sun Jan 11 20:16:14 2015 > New Revision: 277021 > URL: https://svnweb.freebsd.org/changeset/base/277021 > > Log: > Rework describing interrupts to not use a static buffer and to build on > PowerPC with at least the MPC85XX kernel. > > I don't like the name of fdt_describe_irq, it could be called from non-FDT > code. As it's only called from simplebus I'll stick with it for now. > > Modified: > projects/arm_intrng/sys/arm/arm/intr.c > projects/arm_intrng/sys/arm/arm/intrng.c > projects/arm_intrng/sys/arm/include/fdt.h > projects/arm_intrng/sys/arm/include/intr.h > projects/arm_intrng/sys/dev/fdt/fdt_common.h > projects/arm_intrng/sys/dev/fdt/simplebus.c > projects/arm_intrng/sys/powerpc/powerpc/intr_machdep.c > > Modified: projects/arm_intrng/sys/arm/arm/intr.c > ============================================================================== > --- projects/arm_intrng/sys/arm/arm/intr.c Sun Jan 11 20:07:07 2015 (r277020) > +++ projects/arm_intrng/sys/arm/arm/intr.c Sun Jan 11 20:16:14 2015 (r277021) > @@ -126,16 +126,16 @@ arm_fdt_map_irq(phandle_t iparent, pcell > > return (interrupt); > } > -#endif > > -const char * > -arm_describe_irq(int irq) > +int > +fdt_describe_irq(char *buf, u_int len, u_int irq) > { > - static char buffer[8]; > + int rv; > > - sprintf(buffer, "%d", irq); > - return (buffer); > + rv = snprintf(buf, len, "%u", irq); > + return (rv); > } > +#endif > > void > arm_setup_irqhandler(const char *name, driver_filter_t *filt, > > Modified: projects/arm_intrng/sys/arm/arm/intrng.c > ============================================================================== > --- projects/arm_intrng/sys/arm/arm/intrng.c Sun Jan 11 20:07:07 2015 (r277020) > +++ projects/arm_intrng/sys/arm/arm/intrng.c Sun Jan 11 20:16:14 2015 (r277021) > @@ -55,6 +55,8 @@ __FBSDID("$FreeBSD$"); > #include > #include > > +#include > + > #include "pic_if.h" > > #define INTRNAME_LEN (MAXCOMLEN + 1) > @@ -265,7 +267,7 @@ resirq_encode(u_int picidx, u_int irqidx > } > > static u_int > -resirq_decode(int resirq, struct arm_intr_controller **pic, > +resirq_decode(u_int resirq, struct arm_intr_controller **pic, > struct arm_intr_handler **pih) > { > struct arm_intr_controller *ic; > @@ -353,15 +355,12 @@ arm_fdt_map_irq(phandle_t icnode, pcell_ > return (ih->ih_resirq); > } > > -const char * > -arm_describe_irq(int resirq) > +int > +fdt_describe_irq(char *buf, u_int len, u_int resirq) > { > struct arm_intr_controller *ic; > struct arm_intr_handler *ih; > - int irqidx; > - static char buffer[INTRNAME_LEN]; > - > - /* XXX static buffer, can this be called after APs released? */ > + int irqidx, rv; > > irqidx = resirq_decode(resirq, &ic, &ih); > KASSERT(ic != NULL, ("%s: bad resirq 0x%08x", resirq)); > @@ -371,13 +370,13 @@ arm_describe_irq(int resirq) > * IC device name nor interrupt number. All we can do is to > * use its index (fdt names are unbounded length). > */ > - snprintf(buffer, sizeof(buffer), "ic%d.%d", ic->ic_idx, irqidx); > + rv = snprintf(buf, len, "ic%d.%d", ic->ic_idx, irqidx); > } else { > KASSERT(ih != NULL, ("%s: no handler for resirq 0x%08x\n", resirq)); > - snprintf(buffer, sizeof(buffer), "%s.%d", > + rv = snprintf(buf, len, "%s.%d", > device_get_nameunit(ih->ih_ic->ic_dev), ih->ih_hwirq); > } > - return (buffer); > + return (rv); > } > > void > @@ -416,7 +415,7 @@ arm_register_pic(device_t dev, int flags > } > > /* > - * arm_describe_irq() has to print fake names earlier when the device > + * fdt_describe_irq() has to print fake names earlier when the device > * issn't registered yet, emit a string that has the same fake name in > * it, so that earlier output links to this device. > */ > > Modified: projects/arm_intrng/sys/arm/include/fdt.h > ============================================================================== > --- projects/arm_intrng/sys/arm/include/fdt.h Sun Jan 11 20:07:07 2015 (r277020) > +++ projects/arm_intrng/sys/arm/include/fdt.h Sun Jan 11 20:16:14 2015 (r277021) > @@ -47,7 +47,6 @@ > > /* Map phandle/intpin pair to global IRQ number */ > #define FDT_MAP_IRQ(node, pin) (arm_fdt_map_irq(node, pin)) > -#define FDT_DESCRIBE_IRQ(irq) (arm_describe_irq(irq)) > > #else > > @@ -56,7 +55,6 @@ > > /* Map phandle/intpin pair to global IRQ number */ > #define FDT_MAP_IRQ(node, pin) (pin) > -#define FDT_DESCRIBE_IRQ(irq) (arm_describe_irq(irq)) > > #endif /* ARM_INTRNG */ > > > Modified: projects/arm_intrng/sys/arm/include/intr.h > ============================================================================== > --- projects/arm_intrng/sys/arm/include/intr.h Sun Jan 11 20:07:07 2015 (r277020) > +++ projects/arm_intrng/sys/arm/include/intr.h Sun Jan 11 20:16:14 2015 (r277021) > @@ -115,7 +115,6 @@ extern int (*arm_config_irq)(int irq, en > > #endif /* !ARM_INTRNG */ > > -const char *arm_describe_irq(int irq); > void arm_intrnames_init(void); > void arm_irq_memory_barrier(uintptr_t); > > > Modified: projects/arm_intrng/sys/dev/fdt/fdt_common.h > ============================================================================== > --- projects/arm_intrng/sys/dev/fdt/fdt_common.h Sun Jan 11 20:07:07 2015 (r277020) > +++ projects/arm_intrng/sys/dev/fdt/fdt_common.h Sun Jan 11 20:16:14 2015 (r277021) > @@ -79,6 +79,7 @@ extern u_char fdt_static_dtb; > int fdt_addrsize_cells(phandle_t, int *, int *); > u_long fdt_data_get(void *, int); > int fdt_data_to_res(pcell_t *, int, int, u_long *, u_long *); > +int fdt_describe_irq(char *, u_int, u_int); > phandle_t fdt_find_compatible(phandle_t, const char *, int); > phandle_t fdt_depth_search_compatible(phandle_t, const char *, int); > int fdt_get_mem_regions(struct mem_region *, int *, uint32_t *); > > Modified: projects/arm_intrng/sys/dev/fdt/simplebus.c > ============================================================================== > --- projects/arm_intrng/sys/dev/fdt/simplebus.c Sun Jan 11 20:07:07 2015 (r277020) > +++ projects/arm_intrng/sys/dev/fdt/simplebus.c Sun Jan 11 20:16:14 2015 (r277021) > @@ -38,7 +38,7 @@ __FBSDID("$FreeBSD$"); > #include > #include > > -#include > +#include > > struct simplebus_range { > uint64_t bus; > @@ -408,7 +408,8 @@ static int > simplebus_print_irqs(struct resource_list *rl) > { > struct resource_list_entry *rle; > - int printed, retval; > + int err, printed, retval; > + char buf[16]; > > printed = 0; > retval = 0; > @@ -417,8 +418,11 @@ simplebus_print_irqs(struct resource_lis > if (rle->type != SYS_RES_IRQ) > continue; > > - retval += printf("%s", printed ? "," : " irq "); > - retval += printf("%s", FDT_DESCRIBE_IRQ(rle->start)); > + err = fdt_describe_irq(buf, sizeof(buf), rle->start); > + if (err < 0) > + snprintf(buf, sizeof(buf), "???"); > + > + retval += printf("%s%s", printed ? "," : " irq ", buf); > printed++; > } > > > Modified: projects/arm_intrng/sys/powerpc/powerpc/intr_machdep.c > ============================================================================== > --- projects/arm_intrng/sys/powerpc/powerpc/intr_machdep.c Sun Jan 11 20:07:07 2015 (r277020) > +++ projects/arm_intrng/sys/powerpc/powerpc/intr_machdep.c Sun Jan 11 20:16:14 2015 (r277021) > @@ -61,6 +61,7 @@ > */ > > #include "opt_isa.h" > +#include "opt_platform.h" > > #include > #include > @@ -85,6 +86,10 @@ > #include > #include > > +#ifdef FDT > +#include > +#endif > + > #include "pic_if.h" > > #define MAX_STRAY_LOG 5 > @@ -604,3 +609,12 @@ stray: > if (i != NULL) > PIC_MASK(i->pic, i->intline); > } > + > +#ifdef FDT > +int > +fdt_describe_irq(char *buf, u_int len, u_int irq) > +{ > + > + return (snprintf(buf, len, "%u", irq)); > +} > +#endif >