Received: by 10.192.165.148 with SMTP id m20csp2429660imm; Sun, 6 May 2018 14:51:38 -0700 (PDT) X-Google-Smtp-Source: AB8JxZppHn03FAojBIHJfORgG5smc4dm7+ewlbfP+YujMQAoEpkIPdLK4A5Ge3wa6vAnXlBuBtsK X-Received: by 10.98.58.148 with SMTP id v20mr21807433pfj.90.1525643498068; Sun, 06 May 2018 14:51:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1525643498; cv=none; d=google.com; s=arc-20160816; b=DQCoPC6dFT74D2aXtBm3yRD2wkRxYirKaZqH+yZh5TOqqH8+W+s/btklCvYH+uyh/a eoagBnS2JFxeSo09sYXECqt5U/E2g0rmFHHVmxM/S31onjfgl4Sb+kXJa75ztfnsXYph rCFkIQqw72CsU2y8RSXM3SLk7jxgiGfxFQGkDUwcddzEvRMzeIYgGOYzH7O6ZIapttdB 4ib0YQOWqLhghfBHftzlcx6VOy6f43sNI85UfM4+bkTJGrFygocpJ0mKrm2tZP7k6z5z Fi2OVgoiQ3goNUGYd1T/xiuqhNC/V2UgDI4aKr0LhQewCihTqfCBFVojspfRNHBkttvR +KGA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:cc:to:subject:message-id:date:from :references:in-reply-to:mime-version:dkim-signature :arc-authentication-results; bh=PPDWKA/XVOkEWgsk8BGDlaw/4KsHwqawyNjcEaxGi5Q=; b=nt9nOwvrUrZySRYWvH/0kndDR6v+j+y7rK7SxH3O2aTw0RUevyr9j5zX31Aol/JNiS PJ/vOy+WRtQiEvQDUPw3H1QUGMRW6h9Lty7hRFoyDlduzBK6a5g6d40ez2zgqcu45j5M tJMMlTrJskkJnhlqULPHnu+hFH2grZLxd/QpYas32EWCJJT3YRKV+MR53pcnvFXnC7nL vChI+3fgCT/La+58SAd0hy3SvTB5tqSe3FtB0pM7A7eaSGO76Vk1ToBt2tMn9hZgDkoI YrFhfyb3jBDDnLVQiko+DQzodb63iVlkUMNHAiEc7CzVm8HkHxBGFR8BjFtcp720GcyR cw3w== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m1hgoTiQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id t6-v6si16711111pgb.653.2018.05.06.14.51.24; Sun, 06 May 2018 14:51:38 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=m1hgoTiQ; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1751901AbeEFVvQ (ORCPT + 99 others); Sun, 6 May 2018 17:51:16 -0400 Received: from mail-pg0-f68.google.com ([74.125.83.68]:39975 "EHLO mail-pg0-f68.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1751845AbeEFVvN (ORCPT ); Sun, 6 May 2018 17:51:13 -0400 Received: by mail-pg0-f68.google.com with SMTP id l2-v6so18822489pgc.7 for ; Sun, 06 May 2018 14:51:13 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :cc; bh=PPDWKA/XVOkEWgsk8BGDlaw/4KsHwqawyNjcEaxGi5Q=; b=m1hgoTiQXEaz4qe7qWTSaLBc9VrFw/OC8AFNaJ9MAme1tQ7KQe3QaX8hVag4Kcz4gY Hs25T4T5RxV0dJlpXmcW0ZKnIEBqEu5Zk7EImAncVZ6WsDxPJq4c+mqbgAmnh2rIwKGT FH7Ee/FiY6XUsQQnA24HyW+f8Sk0by/Vc0KEwE3Se6Q/ZGlWnMtOuOT/SAUQo0do2QRc pC4GWPEsGsoHZcnWvuAqKMFa5OLMLmsrjcQVMvjyVjEyhsdVcdwII/MWnhnI8V5+ztx4 LyP1rF/YgFDgFAW46J78CgJCn0lvDZVRpyAlZ701cKwbnG61me0jpGS6rd3YiDLn0W4i I0vw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:in-reply-to:references:from:date :message-id:subject:to:cc; bh=PPDWKA/XVOkEWgsk8BGDlaw/4KsHwqawyNjcEaxGi5Q=; b=sJNG8h/TF9caTvg20HNS8UjSG5/4xZAnrjleqdG3tTKe8S7TGY+nktzxfLXN5LPJXG 4P8VEP5/ImCV/RmWI/KyEXYzGv/im5LHNERd/lPayQLw2QaI4Hspxz0hKnRTs2liIivt elMSToCqdLb+Tqg22gLokXhZ+p8emTMzflRr8lkrOXq28yWaZEe0+7OuTHQKnyUxz1Hc KLWc0s2FvuARZr6tBk1Z5yT1rN4p+qHONJlvsoE5P/+B08ordllcWM0cVDvLeq4ulBXc NAwhjC/TrZ16iF1YndgbTNieC5SL9GwRfIOAYrPFXiZT86vltnYGkCUiu593BTh+lQ1m ydiQ== X-Gm-Message-State: ALQs6tA6BfZ0rwPM1wYWtwZ8t1jTFjrqjOma7R1bf9JIU7XnNzyORzv1 NwRC8byxBjQ9ikceLOoHqm3mOp1ICK1pYwoEkQM= X-Received: by 10.98.19.151 with SMTP id 23mr34747963pft.222.1525643472984; Sun, 06 May 2018 14:51:12 -0700 (PDT) MIME-Version: 1.0 Received: by 10.100.164.135 with HTTP; Sun, 6 May 2018 14:51:12 -0700 (PDT) In-Reply-To: <20180506202018.GC8924@kroah.com> References: <5aee5ed3.1c69fb81.19d98.ef06SMTPIN_ADDED_MISSING@mx.google.com> <20180506045530.GA5328@kroah.com> <20180506202018.GC8924@kroah.com> From: Michael Schmitz Date: Mon, 7 May 2018 09:51:12 +1200 Message-ID: Subject: Re: [PATCH] nubus: Unconditionally register bus type To: Greg Kroah-Hartman Cc: Finn Thain , Geert Uytterhoeven , "Linux/m68k" , Linux Kernel Development Content-Type: text/plain; charset="UTF-8" Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Hi Greg, the BUG() was triggered by loading a Mac Nubus network card module on a multiplatform kernel running on an Amiga machine. Up to Finn's Nubus core rewrite (this February), we've seen no errors. Since then, Nubus drivers fail to register because the Nubus bus is only registered on Macs. Can't see link order involved here at all. Safeguarding against this bug could be done by checking a bus-is-registered flag, or checking what machine model the kernel runs on. Simply registering the Nubus bus driver regardless of machine model seemed the easiest way. Cheers, Michael On Mon, May 7, 2018 at 8:20 AM, Greg Kroah-Hartman wrote: > On Sun, May 06, 2018 at 04:00:15PM +1000, Finn Thain wrote: >> On Sat, 5 May 2018, Greg Kroah-Hartman wrote: >> >> > On Sun, May 06, 2018 at 11:47:52AM +1000, Finn Thain wrote: >> > > Loading a NuBus driver module on a non-NuBus machine triggers the >> > > BUG_ON(!drv->bus->p) in driver_register() because the bus does not get >> > > registered unless MACH_IS_MAC(). Avoid this by registering the bus >> > > unconditionally using postcore_initcall(). >> > > >> > > Cc: Greg Kroah-Hartman >> > > Reported-by: Michael Schmitz >> > > Tested-by: Stan Johnson >> > > Fixes: 7f86c765a6a2 ("nubus: Add support for the driver model") >> > > Signed-off-by: Finn Thain >> > > --- >> > > drivers/nubus/bus.c | 3 ++- >> > > drivers/nubus/nubus.c | 5 ----- >> > > include/linux/nubus.h | 1 - >> > > 3 files changed, 2 insertions(+), 7 deletions(-) >> > > >> > > diff --git a/drivers/nubus/bus.c b/drivers/nubus/bus.c >> > > index d306c348c857..27ca9f1a281b 100644 >> > > --- a/drivers/nubus/bus.c >> > > +++ b/drivers/nubus/bus.c >> > > @@ -63,7 +63,7 @@ static struct device nubus_parent = { >> > > .init_name = "nubus", >> > > }; >> > > >> > > -int __init nubus_bus_register(void) >> > > +static int __init nubus_bus_register(void) >> > > { >> > > int err; >> > > >> > > @@ -78,6 +78,7 @@ int __init nubus_bus_register(void) >> > > device_unregister(&nubus_parent); >> > > return err; >> > > } >> > > +postcore_initcall(nubus_bus_register); >> > >> > Why not just have an "bus is registered" flag in your driver register >> > function that refuses to let drivers register with the driver core if it >> > isn't set? >> >> Perhaps that should happen in the core driver_register() function. BUG_ON >> is frowned upon, after all. Would that be acceptable? > > I don't understand what you mean here, perhaps make a patch to show it? > >> I found a few drivers that set a flag the way you describe, which could >> then be simplified. >> >> But that pattern is rare. Most buses use the postcore_initcall() pattern, >> and so my patch took the conventional approach. > > It all depends on link order, not necessarily the postcore stuff. > >> > And then fix your linking error, the bus should come first in link >> > order, before your drivers :) >> > >> >> I didn't encounter any errors. How shall I reproduce this? > > If you have not seen this error, then why change the code at all if it > is working properly? Most busses do not need this as they have their > link order set up correctly, no need to mess with stuff that is not > broken :) > > thanks, > > greg k-h > -- > To unsubscribe from this list: send the line "unsubscribe linux-m68k" in > the body of a message to majordomo@vger.kernel.org > More majordomo info at http://vger.kernel.org/majordomo-info.html