Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp157424imu; Thu, 3 Jan 2019 16:24:38 -0800 (PST) X-Google-Smtp-Source: ALg8bN6kNmhokEqGKZrAS6MohAGZuMrVu8tjCSeqQNkXbxC/QYRvYd8iIN5XEYnHWqQq79PITg92 X-Received: by 2002:a63:dd55:: with SMTP id g21mr18459616pgj.86.1546561478201; Thu, 03 Jan 2019 16:24:38 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1546561478; cv=none; d=google.com; s=arc-20160816; b=DRuyMhhmCv7jU8V7oon+/0cbwOPeD8EXRvSN75/g1vW4whroo4UYvs5vuCUiDFzI6Y dKobkqvcvGHdFO7wCM4pv2ZWF5r61YfuVTE8VAVd6NrIzJKg59Fv9qnEppRCN+YV5VJ+ AOI3xSzoKwZVNbRdXjRygGVomaZJPLQtjA29blf8Nt7b7Y9kWL+oi4U96T5FDLh4ynUf r/IpPniAYBXKlzNmKK6cnplT98Qk2HeMX863of7q2+QvPD6RWdxin/CpQvV0/dPIHYCk gVWIZqEvK3qEsKHdTRVvywrMs4t58pq5ceMOtoG4kzYCl6XIf8SeW81n2dCC9quusdR2 av0w== 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 :in-reply-to:references:mime-version:dkim-signature; bh=ZK2+45qPInifFT6wUVRnlWcgArDYRxqmdLAVW6fKLxA=; b=VyRJhEbPCoilEWnNANA738sXutd3mzM5qI3SS1DJGDfSjgb/tNpbcCgJoob6jy7jlI x83UZBKBO1rcen5ct9ixl2Ec4L+eTrERd57yGxK6y7ks7brteUWc5cNSSuduct5UIKgW lmbxe1H+cM6KUd4F2wuEf3EoNAop5Ku1lkVTbsg8tNJwkXM9LMQh1Ebyeyu09BfN3li9 InHsGiyKR0hQH6nz2LIDk9bTzdMazzoatq17B+izT+kFZQLp8o4alDDQk/cG2hcgfyGU SNVuaPthH1Awjkkdz8EqNmckvZB0Yrjr4cE7nLp/CZtBbCcosfXtHpbkzQex9qyFtbIL paEA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=nlKy865G; 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 i7si12798988pgc.144.2019.01.03.16.24.19; Thu, 03 Jan 2019 16:24:38 -0800 (PST) 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=nlKy865G; 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 S1727564AbfACUF0 (ORCPT + 99 others); Thu, 3 Jan 2019 15:05:26 -0500 Received: from mail-pl1-f193.google.com ([209.85.214.193]:36046 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726036AbfACUF0 (ORCPT ); Thu, 3 Jan 2019 15:05:26 -0500 Received: by mail-pl1-f193.google.com with SMTP id g9so16349323plo.3 for ; Thu, 03 Jan 2019 12:05:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :cc; bh=ZK2+45qPInifFT6wUVRnlWcgArDYRxqmdLAVW6fKLxA=; b=nlKy865GDxuSBhLGyb34fZ54adW3tzoVVx1DuOd6IFKNdoNuKjw0FWzT+XqGBR3ZZt HM+VI/i0WNYL13+TOUIRfbYRLBpbO5GB4UyURSPfrRWNThD7LfnFun2xEtP4NQn+MRak sAwFApe1tfrjDXtq3m35nIrJ74yDjziitWrKsUcWEvAxlAMvIogPQ/qkrzqOkQmFbcjd VNkDPbqQo3oQPpqV/fzrdv2iKnpQn0TieDXFxx/svQKLelu668jevCzvAskSR0CQXiFA S2Fqc11cLoK/G8w173PR0LARSi6Xx31EyoTkvT9aQDqfGKJYScngicTARwpjEkUOJ87C EmQQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:references:in-reply-to:from:date :message-id:subject:to:cc; bh=ZK2+45qPInifFT6wUVRnlWcgArDYRxqmdLAVW6fKLxA=; b=dp3hiQUETbSupR+6qxfvSygqq23/2y8ELoSPkcC36tYt5LMxQ+dIo+f0ZwwSH+p7cn U2M018t0eowwNyjQ4dnT3f+cve7cLPAaSe0L2bzJCTDrP4ovVvpvoUTwti1DH88gKBgO wgm8aPUwo2bXE6i/10syHTVJGBfdnFZ0T/R34EleP+NMSIZEnAd3Gip61w43UawY/ov0 vJufhUCUshpOlw8m/40oAhDF7EmBpd5+/0/Fan4q7gIWopoC9t8CU/nvWMatNUKY8oW4 eqH6hXrF9mVzMFt/Ay4qXtlK9wS8Mr5KiJ9gan3DJTN7mOa8JVOXUv4VVHk+Ad2VeNBA vYFA== X-Gm-Message-State: AJcUukdD8JXVGttwqyNDix0bbGXZt26g1K/eY9hi+eVZbzXFbdd5jC51 5R0vPVQoGJ8E8WLFIopE+AyT2inb5r34fCBfXy0= X-Received: by 2002:a17:902:b943:: with SMTP id h3mr48848590pls.12.1546545924776; Thu, 03 Jan 2019 12:05:24 -0800 (PST) MIME-Version: 1.0 References: <1545282888-38059-1-git-send-email-peng.hao2@zte.com.cn> <1545282888-38059-2-git-send-email-peng.hao2@zte.com.cn> In-Reply-To: <1545282888-38059-2-git-send-email-peng.hao2@zte.com.cn> From: Andy Shevchenko Date: Thu, 3 Jan 2019 22:05:12 +0200 Message-ID: Subject: Re: [PATCH RESEND V5 2/3] misc/pvpanic : add pci interface for pvpanic To: Peng Hao Cc: Greg Kroah-Hartman , Arnd Bergmann , Linux Kernel Mailing List 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 On Thu, Dec 20, 2018 at 6:57 AM Peng Hao wrote: > > Support pvpanic as a pci device in guest kernel. > After my vacation followed by holidays I hardly remember what I suggested. Looking to this code I would recommend to split it in a way how it's done for ChipIdea USB driver, for example. (drivers/usb/chipidea if I'm not mistaken) > Suggested-by: Andy Shevchenko > [Use pcim_* API. - Andy] > Signed-off-by: Peng Hao > --- > drivers/misc/pvpanic.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++-- > 1 file changed, 70 insertions(+), 2 deletions(-) > > diff --git a/drivers/misc/pvpanic.c b/drivers/misc/pvpanic.c > index f84ed30..c30bf62 100644 > --- a/drivers/misc/pvpanic.c > +++ b/drivers/misc/pvpanic.c > @@ -13,9 +13,12 @@ > #include > #include > #include > +#include > #include > #include > > +#define PCI_VENDOR_ID_REDHAT 0x1b36 > +#define PCI_DEVICE_ID_REDHAT_PVPANIC 0x0101 > static void __iomem *base; > > #define PVPANIC_PANICKED (1 << 0) > @@ -172,12 +175,76 @@ static int pvpanic_mmio_remove(struct platform_device *pdev) > .remove = pvpanic_mmio_remove, > }; > > +#ifdef CONFIG_PCI > +static const struct pci_device_id pvpanic_pci_id_tbl[] = { > + { PCI_DEVICE(PCI_VENDOR_ID_REDHAT, PCI_DEVICE_ID_REDHAT_PVPANIC),}, > + {} > +}; > + > +static int pvpanic_pci_probe(struct pci_dev *pdev, > + const struct pci_device_id *ent) > +{ > + int ret; > + > + ret = pcim_enable_device(pdev); > + if (ret < 0) > + return ret; > + > + ret = pcim_iomap_regions(pdev, 1 << 0, pci_name(pdev)); > + if (ret) > + return ret; > + > + base = pcim_iomap_table(pdev)[0]; > + > + atomic_notifier_chain_register(&panic_notifier_list, > + &pvpanic_panic_nb); > + return 0; > +} > + > +static void pvpanic_pci_remove(struct pci_dev *pdev) > +{ > + atomic_notifier_chain_unregister(&panic_notifier_list, > + &pvpanic_panic_nb); > +} > + > +static struct pci_driver pvpanic_pci_driver = { > + .name = "pvpanic-pci", > + .id_table = pvpanic_pci_id_tbl, > + .probe = pvpanic_pci_probe, > + .remove = pvpanic_pci_remove, > +}; > + > +static int pvpanic_register_pci_driver(void) > +{ > + return pci_register_driver(&pvpanic_pci_driver); > +} > + > +static void pvpanic_unregister_pci_driver(void) > +{ > + pci_unregister_driver(&pvpanic_pci_driver); > +} > +#else > +static int pvpanic_register_pci_driver(void) > +{ > + return 0; > +} > + > +static void pvpanic_unregister_pci_driver(void) {} > +#endif > + > static int __init pvpanic_mmio_init(void) > { > + int r1, r2; > + > if (acpi_disabled) > - return platform_driver_register(&pvpanic_mmio_driver); > + r1 = platform_driver_register(&pvpanic_mmio_driver); > + else > + r1 = pvpanic_register_acpi_driver(); > + r2 = pvpanic_register_pci_driver(); > + if (r1 && r2) /* all drivers register failed */ > + return 1; > else > - return pvpanic_register_acpi_driver(); > + return 0; > } > > static void __exit pvpanic_mmio_exit(void) > @@ -186,6 +253,7 @@ static void __exit pvpanic_mmio_exit(void) > platform_driver_unregister(&pvpanic_mmio_driver); > else > pvpanic_unregister_acpi_driver(); > + pvpanic_unregister_pci_driver(); > } > > module_init(pvpanic_mmio_init); > -- > 1.8.3.1 > -- With Best Regards, Andy Shevchenko