* Re: [PATCH 02/21] mm: make early_pfn_to_nid() and related defintions close to each other
From: Baoquan He @ 2020-04-21 9:33 UTC (permalink / raw)
To: Mike Rapoport
Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
linux-riscv, Greg Ungerer, linux-arch, linux-s390, linux-snps-arc,
linux-c6x-dev, Brian Cain, Jonathan Corbet, linux-sh,
Helge Deller, x86, Russell King, Ley Foon Tan, Mike Rapoport,
Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
linux-mips, uclinux-h8-devel, linux-xtensa, linux-alpha, linux-um,
linux-m68k, Tony Luck, Greentime Hu, Paul Walmsley,
Stafford Horne, Guan Xuetao, Hoan Tran, Michal Simek,
Thomas Bogendoerfer, Yoshinori Sato, Nick Hu, linux-mm,
Vineet Gupta, linux-kernel, openrisc, Richard Weinberger,
Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200421084935.GB14260@kernel.org>
On 04/21/20 at 11:49am, Mike Rapoport wrote:
> On Tue, Apr 21, 2020 at 10:24:35AM +0800, Baoquan He wrote:
> > On 04/12/20 at 10:48pm, Mike Rapoport wrote:
> > > From: Mike Rapoport <rppt@linux.ibm.com>
> > >
> > > The early_pfn_to_nid() and it's helper __early_pfn_to_nid() are spread
> > > around include/linux/mm.h, include/linux/mmzone.h and mm/page_alloc.c.
> > >
> > > Drop unused stub for __early_pfn_to_nid() and move its actual generic
> > > implementation close to its users.
> > >
> > > Signed-off-by: Mike Rapoport <rppt@linux.ibm.com>
> > > ---
> > > include/linux/mm.h | 4 ++--
> > > include/linux/mmzone.h | 9 --------
> > > mm/page_alloc.c | 51 +++++++++++++++++++++---------------------
> > > 3 files changed, 27 insertions(+), 37 deletions(-)
> > >
> > > diff --git a/include/linux/mm.h b/include/linux/mm.h
> > > index 5a323422d783..a404026d14d4 100644
> > > --- a/include/linux/mm.h
> > > +++ b/include/linux/mm.h
> > > @@ -2388,9 +2388,9 @@ extern void sparse_memory_present_with_active_regions(int nid);
> > >
> > > #if !defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP) && \
> > > !defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID)
> > > -static inline int __early_pfn_to_nid(unsigned long pfn,
> > > - struct mminit_pfnnid_cache *state)
> > > +static inline int early_pfn_to_nid(unsigned long pfn)
> > > {
> > > + BUILD_BUG_ON(IS_ENABLED(CONFIG_NUMA));
> > > return 0;
> > > }
> >
> > It's better to make a separate patch to drop __early_pfn_to_nid() here.
>
> Not sure it's really worth it.
> This patch anyway only moves the code around without any actual changes.
OK, it's fine to me.
^ permalink raw reply
* Re: [PATCH v2, RESEND] misc: new driver sram_uapi for user level SRAM access
From: Greg KH @ 2020-04-21 9:34 UTC (permalink / raw)
To: 王文虎
Cc: robh, arnd, Randy Dunlap, linux-kernel, Scott Wood, kernel,
linuxppc-dev
In-Reply-To: <AB6A-gBhCLyx5bgBRPuIiqp1.3.1587460187094.Hmail.wenhu.wang@vivo.com>
On Tue, Apr 21, 2020 at 05:09:47PM +0800, 王文虎 wrote:
> Hi, Greg, Arnd,
>
> Thank you for your comments first, and then really very very very sorry
> for driving Greg to sigh and I hope there would be chance to share Moutai
> (rather than whisky, we drink it much, a kind of Baijiu), after the virus.
>
> Back to the comments, I'd like to do a bit of documentation or explanation first,
> which should have been done early or else there would not be so much to explain:
> 1. What I have been trying to do is to access the Freescale Cache-SRAM device form
> user level;
> 2. I implemented it using UIO, which was thought of non-proper;
I still think that using uio is the best way to do this, and never said
it was "non-proper". All we got bogged down in was the DT
representation of stuff from what I remember. That should be worked
through.
thanks,
greg k-h
^ permalink raw reply
* Re: [PATCH] i2c: powermac: Simplify reading the "reg" and "i2c-address" property
From: Wolfram Sang @ 2020-04-21 9:37 UTC (permalink / raw)
To: Aishwarya R, Erhard F.
Cc: Kate Stewart, linux-kernel, Richard Fontana, Paul Mackerras,
linux-i2c, Greg Kroah-Hartman, Thomas Gleixner, linuxppc-dev
In-Reply-To: <20200415131916.23555-1-aishwaryarj100@gmail.com>
[-- Attachment #1: Type: text/plain, Size: 750 bytes --]
On Wed, Apr 15, 2020 at 06:49:14PM +0530, Aishwarya R wrote:
> >> Use of_property_read_u32 to read the "reg" and "i2c-address" property
> >> instead of using of_get_property to check the return values.
> >>
> >> Signed-off-by: Aishwarya R <aishwaryarj100@gmail.com>
>
> > This is quite a fragile driver. Have you tested it on HW?
>
> This change is not tested with the Hardware.
> But of_property_read_u32 is better here than generic of_get_property.
> This make sure that value read properly independent of system endianess.
This driver is only used on PPC_BE. And it is *very* fragile. The gain
is not enough for me to accept it without testing. Maybe Erhard (CCed)
is interested. If not, you may find someone on the ppc lists.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply
* Re: [PATCH 03/21] mm: remove CONFIG_HAVE_MEMBLOCK_NODE_MAP option
From: Baoquan He @ 2020-04-21 9:45 UTC (permalink / raw)
To: Mike Rapoport
Cc: Rich Felker, linux-ia64, linux-doc, Catalin Marinas,
Heiko Carstens, Michal Hocko, James E.J. Bottomley, Max Filippov,
Guo Ren, linux-csky, linux-parisc, sparclinux, linux-hexagon,
linux-riscv, Greg Ungerer, linux-arch, linux-s390, linux-snps-arc,
linux-c6x-dev, Brian Cain, Jonathan Corbet, linux-sh,
Helge Deller, x86, Russell King, Ley Foon Tan, Mike Rapoport,
Geert Uytterhoeven, linux-arm-kernel, Mark Salter, Matt Turner,
linux-mips, uclinux-h8-devel, linux-xtensa, linux-alpha, linux-um,
linux-m68k, Tony Luck, Greentime Hu, Paul Walmsley,
Stafford Horne, Guan Xuetao, Hoan Tran, Michal Simek,
Thomas Bogendoerfer, Yoshinori Sato, Nick Hu, linux-mm,
Vineet Gupta, linux-kernel, openrisc, Richard Weinberger,
Andrew Morton, linuxppc-dev, David S. Miller
In-Reply-To: <20200421090908.GC14260@kernel.org>
On 04/21/20 at 12:09pm, Mike Rapoport wrote:
> > > diff --git a/mm/memory_hotplug.c b/mm/memory_hotplug.c
> > > index fc0aad0bc1f5..e67dc501576a 100644
> > > --- a/mm/memory_hotplug.c
> > > +++ b/mm/memory_hotplug.c
> > > @@ -1372,11 +1372,7 @@ check_pages_isolated_cb(unsigned long start_pfn, unsigned long nr_pages,
> > >
> > > static int __init cmdline_parse_movable_node(char *p)
> > > {
> > > -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
> > > movable_node_enabled = true;
> > > -#else
> > > - pr_warn("movable_node parameter depends on CONFIG_HAVE_MEMBLOCK_NODE_MAP to work properly\n");
> > > -#endif
> >
> > Wondering if this change will impact anything. Before, those ARCHes with
> > CONFIG_HAVE_MEMBLOCK_NODE_MAP support movable_node. With this patch
> > applied, those ARCHes which don't support CONFIG_HAVE_MEMBLOCK_NODE_MAP
> > can also have 'movable_node' specified in kernel cmdline.
> >
> > > return 0;
> > > }
> > > early_param("movable_node", cmdline_parse_movable_node);
> > > diff --git a/mm/page_alloc.c b/mm/page_alloc.c
> > > index 1ac775bfc9cf..4530e9cfd9f7 100644
> > > --- a/mm/page_alloc.c
> > > +++ b/mm/page_alloc.c
> > > @@ -335,7 +335,6 @@ static unsigned long nr_kernel_pages __initdata;
> > > static unsigned long nr_all_pages __initdata;
> > > static unsigned long dma_reserve __initdata;
> > >
> > > -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
> > > static unsigned long arch_zone_lowest_possible_pfn[MAX_NR_ZONES] __initdata;
> > > static unsigned long arch_zone_highest_possible_pfn[MAX_NR_ZONES] __initdata;
> > > static unsigned long required_kernelcore __initdata;
> >
> > Does it mean those ARCHes which don't support
> > CONFIG_HAVE_MEMBLOCK_NODE_MAP before, will have 'kernelcore=' and
> > 'movablecore=' now, and will have MOVABLE zone?
>
> I hesitated a lot about whether to hide the kernelcore/movablecore and
> related code behind an #ifdef.
> In the end I've decided to keep the code compiled unconditionally as it
> is anyway __init and no sane person would pass "kernelcore=" to the
> kernel on a UMA system.
I see. Then maybe can do something if someone complains about it
in the future, e.g warn out with a message in
cmdline_parse_movable_node(), cmdline_parse_kernelcore().
>
> > > @@ -348,7 +347,6 @@ static bool mirrored_kernelcore __meminitdata;
> > > /* movable_zone is the "real" zone pages in ZONE_MOVABLE are taken from */
> > > int movable_zone;
> > > EXPORT_SYMBOL(movable_zone);
> > > -#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
> > >
> > > #if MAX_NUMNODES > 1
> > > unsigned int nr_node_ids __read_mostly = MAX_NUMNODES;
> > > @@ -1499,8 +1497,7 @@ void __free_pages_core(struct page *page, unsigned int order)
> > > __free_pages(page, order);
> > > }
> > >
> > > -#if defined(CONFIG_HAVE_ARCH_EARLY_PFN_TO_NID) || \
> > > - defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP)
> > > +#ifdef CONFIG_NEED_MULTIPLE_NODES
> > >
> > > static struct mminit_pfnnid_cache early_pfnnid_cache __meminitdata;
> > >
> > > @@ -1542,7 +1539,7 @@ int __meminit early_pfn_to_nid(unsigned long pfn)
> > >
> > > return nid;
> > > }
> > > -#endif
> > > +#endif /* CONFIG_NEED_MULTIPLE_NODES */
> > >
> > > #ifdef CONFIG_NODES_SPAN_OTHER_NODES
> > > /* Only safe to use early in boot when initialisation is single-threaded */
> > > @@ -5924,7 +5921,6 @@ void __ref build_all_zonelists(pg_data_t *pgdat)
> > > static bool __meminit
> > > overlap_memmap_init(unsigned long zone, unsigned long *pfn)
> > > {
> > > -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
> > > static struct memblock_region *r;
> > >
> > > if (mirrored_kernelcore && zone == ZONE_MOVABLE) {
> > > @@ -5940,7 +5936,6 @@ overlap_memmap_init(unsigned long zone, unsigned long *pfn)
> > > return true;
> > > }
> > > }
> > > -#endif
> > > return false;
> > > }
> > >
> > > @@ -6573,8 +6568,7 @@ static unsigned long __init zone_absent_pages_in_node(int nid,
> > > return nr_absent;
> > > }
> > >
> > > -#else /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
> > > -static inline unsigned long __init zone_spanned_pages_in_node(int nid,
> > > +static inline unsigned long __init compat_zone_spanned_pages_in_node(int nid,
> >
> > Is it compact zone which has continuous memory region, and the
> > compat here is typo? Or it's compatible zone? The name seems a little
> > confusing, or I miss something.
>
> It's 'compat' from 'compatibility'. This is kinda "the old way" and the
> version that was defined when CONFIG_HAVE_MEMBLOCK_NODE_MAP=y is the
> "new way", so I picked 'compat' for backwards compatibility.
> Anyway, it will go away later in pacth 19.
Got it, thanks for telling.
>
> > > unsigned long zone_type,
> > > unsigned long node_start_pfn,
> > > unsigned long node_end_pfn,
> > > @@ -6593,7 +6587,7 @@ static inline unsigned long __init zone_spanned_pages_in_node(int nid,
> > > return zones_size[zone_type];
> > > }
> > >
> > > -static inline unsigned long __init zone_absent_pages_in_node(int nid,
> > > +static inline unsigned long __init compat_zone_absent_pages_in_node(int nid,
> > > unsigned long zone_type,
> > > unsigned long node_start_pfn,
> > > unsigned long node_end_pfn,
> > > @@ -6605,13 +6599,12 @@ static inline unsigned long __init zone_absent_pages_in_node(int nid,
> > > return zholes_size[zone_type];
> > > }
> > >
> > > -#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
> > > -
> > > static void __init calculate_node_totalpages(struct pglist_data *pgdat,
> > > unsigned long node_start_pfn,
> > > unsigned long node_end_pfn,
> > > unsigned long *zones_size,
> > > - unsigned long *zholes_size)
> > > + unsigned long *zholes_size,
> > > + bool compat)
> > > {
> > > unsigned long realtotalpages = 0, totalpages = 0;
> > > enum zone_type i;
> > > @@ -6619,17 +6612,38 @@ static void __init calculate_node_totalpages(struct pglist_data *pgdat,
> > > for (i = 0; i < MAX_NR_ZONES; i++) {
> > > struct zone *zone = pgdat->node_zones + i;
> > > unsigned long zone_start_pfn, zone_end_pfn;
> > > + unsigned long spanned, absent;
> > > unsigned long size, real_size;
> > >
> > > - size = zone_spanned_pages_in_node(pgdat->node_id, i,
> > > - node_start_pfn,
> > > - node_end_pfn,
> > > - &zone_start_pfn,
> > > - &zone_end_pfn,
> > > - zones_size);
> > > - real_size = size - zone_absent_pages_in_node(pgdat->node_id, i,
> > > - node_start_pfn, node_end_pfn,
> > > - zholes_size);
> > > + if (compat) {
> > > + spanned = compat_zone_spanned_pages_in_node(
> > > + pgdat->node_id, i,
> > > + node_start_pfn,
> > > + node_end_pfn,
> > > + &zone_start_pfn,
> > > + &zone_end_pfn,
> > > + zones_size);
> > > + absent = compat_zone_absent_pages_in_node(
> > > + pgdat->node_id, i,
> > > + node_start_pfn,
> > > + node_end_pfn,
> > > + zholes_size);
> > > + } else {
> > > + spanned = zone_spanned_pages_in_node(pgdat->node_id, i,
> > > + node_start_pfn,
> > > + node_end_pfn,
> > > + &zone_start_pfn,
> > > + &zone_end_pfn,
> > > + zones_size);
> > > + absent = zone_absent_pages_in_node(pgdat->node_id, i,
> > > + node_start_pfn,
> > > + node_end_pfn,
> > > + zholes_size);
> > > + }
> > > +
> > > + size = spanned;
> > > + real_size = size - absent;
> > > +
> > > if (size)
> > > zone->zone_start_pfn = zone_start_pfn;
> > > else
> > > @@ -6929,10 +6943,8 @@ static void __ref alloc_node_mem_map(struct pglist_data *pgdat)
> > > */
> > > if (pgdat == NODE_DATA(0)) {
> > > mem_map = NODE_DATA(0)->node_mem_map;
> > > -#if defined(CONFIG_HAVE_MEMBLOCK_NODE_MAP) || defined(CONFIG_FLATMEM)
> > > if (page_to_pfn(mem_map) != pgdat->node_start_pfn)
> > > mem_map -= offset;
> > > -#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
> > > }
> > > #endif
> > > }
> > > @@ -6949,9 +6961,10 @@ static inline void pgdat_set_deferred_range(pg_data_t *pgdat)
> > > static inline void pgdat_set_deferred_range(pg_data_t *pgdat) {}
> > > #endif
> > >
> > > -void __init free_area_init_node(int nid, unsigned long *zones_size,
> > > - unsigned long node_start_pfn,
> > > - unsigned long *zholes_size)
> > > +static void __init __free_area_init_node(int nid, unsigned long *zones_size,
> > > + unsigned long node_start_pfn,
> > > + unsigned long *zholes_size,
> > > + bool compat)
> > > {
> > > pg_data_t *pgdat = NODE_DATA(nid);
> > > unsigned long start_pfn = 0;
> > > @@ -6963,16 +6976,16 @@ void __init free_area_init_node(int nid, unsigned long *zones_size,
> > > pgdat->node_id = nid;
> > > pgdat->node_start_pfn = node_start_pfn;
> > > pgdat->per_cpu_nodestats = NULL;
> > > -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
> > > - get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
> > > - pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
> > > - (u64)start_pfn << PAGE_SHIFT,
> > > - end_pfn ? ((u64)end_pfn << PAGE_SHIFT) - 1 : 0);
> > > -#else
> > > - start_pfn = node_start_pfn;
> > > -#endif
> > > + if (!compat) {
> > > + get_pfn_range_for_nid(nid, &start_pfn, &end_pfn);
> > > + pr_info("Initmem setup node %d [mem %#018Lx-%#018Lx]\n", nid,
> > > + (u64)start_pfn << PAGE_SHIFT,
> > > + end_pfn ? ((u64)end_pfn << PAGE_SHIFT) - 1 : 0);
> > > + } else {
> > > + start_pfn = node_start_pfn;
> > > + }
> > > calculate_node_totalpages(pgdat, start_pfn, end_pfn,
> > > - zones_size, zholes_size);
> > > + zones_size, zholes_size, compat);
> > >
> > > alloc_node_mem_map(pgdat);
> > > pgdat_set_deferred_range(pgdat);
> > > @@ -6980,6 +6993,14 @@ void __init free_area_init_node(int nid, unsigned long *zones_size,
> > > free_area_init_core(pgdat);
> > > }
> > >
> > > +void __init free_area_init_node(int nid, unsigned long *zones_size,
> > > + unsigned long node_start_pfn,
> > > + unsigned long *zholes_size)
> > > +{
> > > + __free_area_init_node(nid, zones_size, node_start_pfn, zholes_size,
> > > + true);
> > > +}
> > > +
> > > #if !defined(CONFIG_FLAT_NODE_MEM_MAP)
> > > /*
> > > * Initialize all valid struct pages in the range [spfn, epfn) and mark them
> > > @@ -7063,8 +7084,6 @@ static inline void __init init_unavailable_mem(void)
> > > }
> > > #endif /* !CONFIG_FLAT_NODE_MEM_MAP */
> > >
> > > -#ifdef CONFIG_HAVE_MEMBLOCK_NODE_MAP
> > > -
> > > #if MAX_NUMNODES > 1
> > > /*
> > > * Figure out the number of possible node ids.
> > > @@ -7493,8 +7512,8 @@ void __init free_area_init_nodes(unsigned long *max_zone_pfn)
> > > init_unavailable_mem();
> > > for_each_online_node(nid) {
> > > pg_data_t *pgdat = NODE_DATA(nid);
> > > - free_area_init_node(nid, NULL,
> > > - find_min_pfn_for_node(nid), NULL);
> > > + __free_area_init_node(nid, NULL,
> > > + find_min_pfn_for_node(nid), NULL, false);
> > >
> > > /* Any memory on that node */
> > > if (pgdat->node_present_pages)
> > > @@ -7559,8 +7578,6 @@ static int __init cmdline_parse_movablecore(char *p)
> > > early_param("kernelcore", cmdline_parse_kernelcore);
> > > early_param("movablecore", cmdline_parse_movablecore);
> > >
> > > -#endif /* CONFIG_HAVE_MEMBLOCK_NODE_MAP */
> > > -
> > > void adjust_managed_page_count(struct page *page, long count)
> > > {
> > > atomic_long_add(count, &page_zone(page)->managed_pages);
> > > --
> > > 2.25.1
> > >
> >
>
> --
> Sincerely yours,
> Mike.
>
^ permalink raw reply
* Re: [PATCH] ASoC: fsl_esai: Remove expensive print in irq handler
From: Mark Brown @ 2020-04-21 9:51 UTC (permalink / raw)
To: Shengjiu Wang
Cc: alsa-devel, timur, Xiubo.Lee, linuxppc-dev, tiwai, perex,
nicoleotsuka, festevam, linux-kernel
In-Reply-To: <1587458483-2166-1-git-send-email-shengjiu.wang@nxp.com>
[-- Attachment #1: Type: text/plain, Size: 844 bytes --]
On Tue, Apr 21, 2020 at 04:41:23PM +0800, Shengjiu Wang wrote:
> Use dev_dbg instead of dev_err in irq handler, the dev_err
> is expensive, we don't need the message to be printed everytime,
> which is almost a debug option.
> if (esr & ESAI_ESR_RFF_MASK)
> - dev_warn(&pdev->dev, "isr: Receiving overrun\n");
> + dev_dbg(&pdev->dev, "isr: Receiving overrun\n");
>
> if (esr & ESAI_ESR_TFE_MASK)
> - dev_warn(&pdev->dev, "isr: Transmission underrun\n");
> + dev_dbg(&pdev->dev, "isr: Transmission underrun\n");
These are error messages which would suggest a problem that'd lead to
data corruption, it seems bad not to try to flag that to the user -
surely we've got bigger problems than performance if this happens?
Perhaps convert to a ratelimited print if the issue is that when errors
happen they happen a lot?
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 488 bytes --]
^ permalink raw reply
* Re: [musl] Powerpc Linux 'scv' system call ABI proposal take 2
From: Florian Weimer @ 2020-04-21 9:57 UTC (permalink / raw)
To: Nicholas Piggin
Cc: libc-dev, Rich Felker, Nicholas Piggin via Libc-alpha,
linuxppc-dev, musl
In-Reply-To: <20200420211751.GF23945@port70.net>
* Szabolcs Nagy:
> * Nicholas Piggin <npiggin@gmail.com> [2020-04-20 12:08:36 +1000]:
>> Excerpts from Rich Felker's message of April 20, 2020 11:29 am:
>> > Also, allowing patching of executable pages is generally frowned upon
>> > these days because W^X is a desirable hardening property.
>>
>> Right, it would want be write-protected after being patched.
>
> "frowned upon" means that users may have to update
> their security policy setting in pax, selinux, apparmor,
> seccomp bpf filters and who knows what else that may
> monitor and flag W&X mprotect.
>
> libc update can break systems if the new libc does W&X.
It's possible to map over pre-compiled alternative implementations,
though. Basically, we would do the patching and build time and store
the results in the file.
It works best if the variance is concentrated on a few pages, and
there are very few alternatives. For example, having two syscall APIs
and supporting threading and no-threading versions would need four
code versions in total, which is likely excessive.
^ permalink raw reply
* Re: [PATCH v2,RESEND] misc: new driver sram_uapi for user level SRAM access
From: 王文虎 @ 2020-04-21 10:03 UTC (permalink / raw)
To: Greg KH
Cc: robh, arnd, Randy Dunlap, linux-kernel, Scott Wood, kernel,
linuxppc-dev
In-Reply-To: <20200421093427.GC725219@kroah.com>
>On Tue, Apr 21, 2020 at 05:09:47PM +0800, 王文虎 wrote:
>> Hi, Greg, Arnd,
>>
>> Thank you for your comments first, and then really very very very sorry
>> for driving Greg to sigh and I hope there would be chance to share Moutai
>> (rather than whisky, we drink it much, a kind of Baijiu), after the virus.
>>
>> Back to the comments, I'd like to do a bit of documentation or explanation first,
>> which should have been done early or else there would not be so much to explain:
>> 1. What I have been trying to do is to access the Freescale Cache-SRAM device form
>> user level;
>> 2. I implemented it using UIO, which was thought of non-proper;
>
>I still think that using uio is the best way to do this, and never said
>it was "non-proper". All we got bogged down in was the DT
>representation of stuff from what I remember. That should be worked
>through.
>
>thanks,
>
>greg k-h
Surely, but so how would things go? Scott said not fit for him. And he was
gonna to write a new patch(Oh, that is what I have been doing.....,and I really
donot think he need to do it)
This is the final version using UIO, and even Christophe had Reviewed-by,
https://lore.kernel.org/patchwork/patch/1226225/
If no ending reaches, I have to make a step forward to keep working with
the misc device version.
Thanks, and regards,
Wenhu
^ permalink raw reply
* Re: [PATCH] ASoC: fsl_esai: Remove expensive print in irq handler
From: Shengjiu Wang @ 2020-04-21 10:51 UTC (permalink / raw)
To: Mark Brown
Cc: Linux-ALSA, Timur Tabi, Xiubo Li, Fabio Estevam, Shengjiu Wang,
Takashi Iwai, linux-kernel, Nicolin Chen, linuxppc-dev
In-Reply-To: <20200421095139.GA4540@sirena.org.uk>
Hi
On Tue, Apr 21, 2020 at 5:53 PM Mark Brown <broonie@kernel.org> wrote:
>
> On Tue, Apr 21, 2020 at 04:41:23PM +0800, Shengjiu Wang wrote:
> > Use dev_dbg instead of dev_err in irq handler, the dev_err
> > is expensive, we don't need the message to be printed everytime,
> > which is almost a debug option.
>
> > if (esr & ESAI_ESR_RFF_MASK)
> > - dev_warn(&pdev->dev, "isr: Receiving overrun\n");
> > + dev_dbg(&pdev->dev, "isr: Receiving overrun\n");
> >
> > if (esr & ESAI_ESR_TFE_MASK)
> > - dev_warn(&pdev->dev, "isr: Transmission underrun\n");
> > + dev_dbg(&pdev->dev, "isr: Transmission underrun\n");
>
> These are error messages which would suggest a problem that'd lead to
> data corruption, it seems bad not to try to flag that to the user -
> surely we've got bigger problems than performance if this happens?
> Perhaps convert to a ratelimited print if the issue is that when errors
> happen they happen a lot?
Thanks for review, I will rethink about this.
best regards
wang shengjiu
^ permalink raw reply
* Re: [PATCH AUTOSEL 5.4 69/78] powerpc/powernv/ioda: Fix ref count for devices with their own PE
From: Frederic Barrat @ 2020-04-21 11:02 UTC (permalink / raw)
To: Sasha Levin, linux-kernel, stable; +Cc: linuxppc-dev, Andrew Donnellan
In-Reply-To: <20200418144047.9013-69-sashal@kernel.org>
Le 18/04/2020 à 16:40, Sasha Levin a écrit :
> From: Frederic Barrat <fbarrat@linux.ibm.com>
>
> [ Upstream commit 05dd7da76986937fb288b4213b1fa10dbe0d1b33 ]
This shouldn't be backported to stable.
Fred
> The pci_dn structure used to store a pointer to the struct pci_dev, so
> taking a reference on the device was required. However, the pci_dev
> pointer was later removed from the pci_dn structure, but the reference
> was kept for the npu device.
> See commit 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary
> pcidev from pci_dn").
>
> We don't need to take a reference on the device when assigning the PE
> as the struct pnv_ioda_pe is cleaned up at the same time as
> the (physical) device is released. Doing so prevents the device from
> being released, which is a problem for opencapi devices, since we want
> to be able to remove them through PCI hotplug.
>
> Now the ugly part: nvlink npu devices are not meant to be
> released. Because of the above, we've always leaked a reference and
> simply removing it now is dangerous and would likely require more
> work. There's currently no release device callback for nvlink devices
> for example. So to be safe, this patch leaks a reference on the npu
> device, but only for nvlink and not opencapi.
>
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Link: https://lore.kernel.org/r/20191121134918.7155-2-fbarrat@linux.ibm.com
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> arch/powerpc/platforms/powernv/pci-ioda.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 058223233088e..e9cda7e316a50 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -1062,14 +1062,13 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)
> return NULL;
> }
>
> - /* NOTE: We get only one ref to the pci_dev for the pdn, not for the
> - * pointer in the PE data structure, both should be destroyed at the
> - * same time. However, this needs to be looked at more closely again
> - * once we actually start removing things (Hotplug, SR-IOV, ...)
> + /* NOTE: We don't get a reference for the pointer in the PE
> + * data structure, both the device and PE structures should be
> + * destroyed at the same time. However, removing nvlink
> + * devices will need some work.
> *
> * At some point we want to remove the PDN completely anyways
> */
> - pci_dev_get(dev);
> pdn->pe_number = pe->pe_number;
> pe->flags = PNV_IODA_PE_DEV;
> pe->pdev = dev;
> @@ -1084,7 +1083,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)
> pnv_ioda_free_pe(pe);
> pdn->pe_number = IODA_INVALID_PE;
> pe->pdev = NULL;
> - pci_dev_put(dev);
> return NULL;
> }
>
> @@ -1205,6 +1203,14 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)
> struct pci_controller *hose = pci_bus_to_host(npu_pdev->bus);
> struct pnv_phb *phb = hose->private_data;
>
> + /*
> + * Intentionally leak a reference on the npu device (for
> + * nvlink only; this is not an opencapi path) to make sure it
> + * never goes away, as it's been the case all along and some
> + * work is needed otherwise.
> + */
> + pci_dev_get(npu_pdev);
> +
> /*
> * Due to a hardware errata PE#0 on the NPU is reserved for
> * error handling. This means we only have three PEs remaining
> @@ -1228,7 +1234,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)
> */
> dev_info(&npu_pdev->dev,
> "Associating to existing PE %x\n", pe_num);
> - pci_dev_get(npu_pdev);
> npu_pdn = pci_get_pdn(npu_pdev);
> rid = npu_pdev->bus->number << 8 | npu_pdn->devfn;
> npu_pdn->pe_number = pe_num;
>
^ permalink raw reply
* Re: [PATCH AUTOSEL 5.4 70/78] pci/hotplug/pnv-php: Remove erroneous warning
From: Frederic Barrat @ 2020-04-21 11:03 UTC (permalink / raw)
To: Sasha Levin, linux-kernel, stable
Cc: linux-pci, linuxppc-dev, Andrew Donnellan, Alastair D'Silva
In-Reply-To: <20200418144047.9013-70-sashal@kernel.org>
Le 18/04/2020 à 16:40, Sasha Levin a écrit :
> From: Frederic Barrat <fbarrat@linux.ibm.com>
>
> [ Upstream commit 658ab186dd22060408d94f5c5a6d02d809baba44 ]
This doesn't need to be backported to stable.
Fred
> On powernv, when removing a device through hotplug, the following
> warning is logged:
>
> Invalid refcount <.> on <...>
>
> It may be incorrect, the refcount may be set to a higher value than 1
> and be valid. of_detach_node() can drop more than one reference. As it
> doesn't seem trivial to assert the correct value, let's remove the
> warning.
>
> Reviewed-by: Alastair D'Silva <alastair@d-silva.org>
> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Link: https://lore.kernel.org/r/20191121134918.7155-7-fbarrat@linux.ibm.com
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> drivers/pci/hotplug/pnv_php.c | 6 ------
> 1 file changed, 6 deletions(-)
>
> diff --git a/drivers/pci/hotplug/pnv_php.c b/drivers/pci/hotplug/pnv_php.c
> index d7b2b47bc33eb..6037983c6e46b 100644
> --- a/drivers/pci/hotplug/pnv_php.c
> +++ b/drivers/pci/hotplug/pnv_php.c
> @@ -151,17 +151,11 @@ static void pnv_php_rmv_pdns(struct device_node *dn)
> static void pnv_php_detach_device_nodes(struct device_node *parent)
> {
> struct device_node *dn;
> - int refcount;
>
> for_each_child_of_node(parent, dn) {
> pnv_php_detach_device_nodes(dn);
>
> of_node_put(dn);
> - refcount = kref_read(&dn->kobj.kref);
> - if (refcount != 1)
> - pr_warn("Invalid refcount %d on <%pOF>\n",
> - refcount, dn);
> -
> of_detach_node(dn);
> }
> }
>
^ permalink raw reply
* Re: [PATCH AUTOSEL 5.4 71/78] ocxl: Add PCI hotplug dependency to Kconfig
From: Frederic Barrat @ 2020-04-21 11:05 UTC (permalink / raw)
To: Sasha Levin, linux-kernel, stable
Cc: linuxppc-dev, Andrew Donnellan, Alastair D'Silva
In-Reply-To: <20200418144047.9013-71-sashal@kernel.org>
Le 18/04/2020 à 16:40, Sasha Levin a écrit :
> From: Frederic Barrat <fbarrat@linux.ibm.com>
>
> [ Upstream commit 49ce94b8677c7d7a15c4d7cbbb9ff1cd8387827b ]
This shouldn't be backported to stable.
Fred
> The PCI hotplug framework is used to update the devices when a new
> image is written to the FPGA.
>
> Reviewed-by: Alastair D'Silva <alastair@d-silva.org>
> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Link: https://lore.kernel.org/r/20191121134918.7155-12-fbarrat@linux.ibm.com
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> drivers/misc/ocxl/Kconfig | 1 +
> 1 file changed, 1 insertion(+)
>
> diff --git a/drivers/misc/ocxl/Kconfig b/drivers/misc/ocxl/Kconfig
> index 1916fa65f2f2a..2d2266c1439ef 100644
> --- a/drivers/misc/ocxl/Kconfig
> +++ b/drivers/misc/ocxl/Kconfig
> @@ -11,6 +11,7 @@ config OCXL
> tristate "OpenCAPI coherent accelerator support"
> depends on PPC_POWERNV && PCI && EEH
> select OCXL_BASE
> + select HOTPLUG_PCI_POWERNV
> default m
> help
> Select this option to enable the ocxl driver for Open
>
^ permalink raw reply
* Re: [PATCH AUTOSEL 4.19 41/47] powerpc/powernv/ioda: Fix ref count for devices with their own PE
From: Frederic Barrat @ 2020-04-21 11:06 UTC (permalink / raw)
To: Sasha Levin, linux-kernel, stable; +Cc: linuxppc-dev, Andrew Donnellan
In-Reply-To: <20200418144227.9802-41-sashal@kernel.org>
Le 18/04/2020 à 16:42, Sasha Levin a écrit :
> From: Frederic Barrat <fbarrat@linux.ibm.com>
>
> [ Upstream commit 05dd7da76986937fb288b4213b1fa10dbe0d1b33 ]
Like for kernel 5.4, the patches 41, 42, 43 of this series are not
desirable for stable.
Fred
> The pci_dn structure used to store a pointer to the struct pci_dev, so
> taking a reference on the device was required. However, the pci_dev
> pointer was later removed from the pci_dn structure, but the reference
> was kept for the npu device.
> See commit 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary
> pcidev from pci_dn").
>
> We don't need to take a reference on the device when assigning the PE
> as the struct pnv_ioda_pe is cleaned up at the same time as
> the (physical) device is released. Doing so prevents the device from
> being released, which is a problem for opencapi devices, since we want
> to be able to remove them through PCI hotplug.
>
> Now the ugly part: nvlink npu devices are not meant to be
> released. Because of the above, we've always leaked a reference and
> simply removing it now is dangerous and would likely require more
> work. There's currently no release device callback for nvlink devices
> for example. So to be safe, this patch leaks a reference on the npu
> device, but only for nvlink and not opencapi.
>
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Link: https://lore.kernel.org/r/20191121134918.7155-2-fbarrat@linux.ibm.com
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> arch/powerpc/platforms/powernv/pci-ioda.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index ecd211c5f24a5..19cd6affdd5fb 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -1071,14 +1071,13 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)
> return NULL;
> }
>
> - /* NOTE: We get only one ref to the pci_dev for the pdn, not for the
> - * pointer in the PE data structure, both should be destroyed at the
> - * same time. However, this needs to be looked at more closely again
> - * once we actually start removing things (Hotplug, SR-IOV, ...)
> + /* NOTE: We don't get a reference for the pointer in the PE
> + * data structure, both the device and PE structures should be
> + * destroyed at the same time. However, removing nvlink
> + * devices will need some work.
> *
> * At some point we want to remove the PDN completely anyways
> */
> - pci_dev_get(dev);
> pdn->pe_number = pe->pe_number;
> pe->flags = PNV_IODA_PE_DEV;
> pe->pdev = dev;
> @@ -1093,7 +1092,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)
> pnv_ioda_free_pe(pe);
> pdn->pe_number = IODA_INVALID_PE;
> pe->pdev = NULL;
> - pci_dev_put(dev);
> return NULL;
> }
>
> @@ -1213,6 +1211,14 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)
> struct pci_controller *hose = pci_bus_to_host(npu_pdev->bus);
> struct pnv_phb *phb = hose->private_data;
>
> + /*
> + * Intentionally leak a reference on the npu device (for
> + * nvlink only; this is not an opencapi path) to make sure it
> + * never goes away, as it's been the case all along and some
> + * work is needed otherwise.
> + */
> + pci_dev_get(npu_pdev);
> +
> /*
> * Due to a hardware errata PE#0 on the NPU is reserved for
> * error handling. This means we only have three PEs remaining
> @@ -1236,7 +1242,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)
> */
> dev_info(&npu_pdev->dev,
> "Associating to existing PE %x\n", pe_num);
> - pci_dev_get(npu_pdev);
> npu_pdn = pci_get_pdn(npu_pdev);
> rid = npu_pdev->bus->number << 8 | npu_pdn->devfn;
> npu_pdn->pe_number = pe_num;
>
^ permalink raw reply
* Re: [PATCH AUTOSEL 5.5 71/75] powerpc/powernv/ioda: Fix ref count for devices with their own PE
From: Frederic Barrat @ 2020-04-21 11:07 UTC (permalink / raw)
To: Sasha Levin, linux-kernel, stable; +Cc: linuxppc-dev, Andrew Donnellan
In-Reply-To: <20200418140910.8280-71-sashal@kernel.org>
Le 18/04/2020 à 16:09, Sasha Levin a écrit :
> From: Frederic Barrat <fbarrat@linux.ibm.com>
>
> [ Upstream commit 05dd7da76986937fb288b4213b1fa10dbe0d1b33 ]
Like for other stable kernels, patches 71, 72, 73 of this series are not
desirable for stable.
Fred
> The pci_dn structure used to store a pointer to the struct pci_dev, so
> taking a reference on the device was required. However, the pci_dev
> pointer was later removed from the pci_dn structure, but the reference
> was kept for the npu device.
> See commit 902bdc57451c ("powerpc/powernv/idoa: Remove unnecessary
> pcidev from pci_dn").
>
> We don't need to take a reference on the device when assigning the PE
> as the struct pnv_ioda_pe is cleaned up at the same time as
> the (physical) device is released. Doing so prevents the device from
> being released, which is a problem for opencapi devices, since we want
> to be able to remove them through PCI hotplug.
>
> Now the ugly part: nvlink npu devices are not meant to be
> released. Because of the above, we've always leaked a reference and
> simply removing it now is dangerous and would likely require more
> work. There's currently no release device callback for nvlink devices
> for example. So to be safe, this patch leaks a reference on the npu
> device, but only for nvlink and not opencapi.
>
> Signed-off-by: Frederic Barrat <fbarrat@linux.ibm.com>
> Reviewed-by: Andrew Donnellan <ajd@linux.ibm.com>
> Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
> Link: https://lore.kernel.org/r/20191121134918.7155-2-fbarrat@linux.ibm.com
> Signed-off-by: Sasha Levin <sashal@kernel.org>
> ---
> arch/powerpc/platforms/powernv/pci-ioda.c | 19 ++++++++++++-------
> 1 file changed, 12 insertions(+), 7 deletions(-)
>
> diff --git a/arch/powerpc/platforms/powernv/pci-ioda.c b/arch/powerpc/platforms/powernv/pci-ioda.c
> index 67e4628dd5274..b4afabe20744a 100644
> --- a/arch/powerpc/platforms/powernv/pci-ioda.c
> +++ b/arch/powerpc/platforms/powernv/pci-ioda.c
> @@ -1062,14 +1062,13 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)
> return NULL;
> }
>
> - /* NOTE: We get only one ref to the pci_dev for the pdn, not for the
> - * pointer in the PE data structure, both should be destroyed at the
> - * same time. However, this needs to be looked at more closely again
> - * once we actually start removing things (Hotplug, SR-IOV, ...)
> + /* NOTE: We don't get a reference for the pointer in the PE
> + * data structure, both the device and PE structures should be
> + * destroyed at the same time. However, removing nvlink
> + * devices will need some work.
> *
> * At some point we want to remove the PDN completely anyways
> */
> - pci_dev_get(dev);
> pdn->pe_number = pe->pe_number;
> pe->flags = PNV_IODA_PE_DEV;
> pe->pdev = dev;
> @@ -1084,7 +1083,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_dev_PE(struct pci_dev *dev)
> pnv_ioda_free_pe(pe);
> pdn->pe_number = IODA_INVALID_PE;
> pe->pdev = NULL;
> - pci_dev_put(dev);
> return NULL;
> }
>
> @@ -1205,6 +1203,14 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)
> struct pci_controller *hose = pci_bus_to_host(npu_pdev->bus);
> struct pnv_phb *phb = hose->private_data;
>
> + /*
> + * Intentionally leak a reference on the npu device (for
> + * nvlink only; this is not an opencapi path) to make sure it
> + * never goes away, as it's been the case all along and some
> + * work is needed otherwise.
> + */
> + pci_dev_get(npu_pdev);
> +
> /*
> * Due to a hardware errata PE#0 on the NPU is reserved for
> * error handling. This means we only have three PEs remaining
> @@ -1228,7 +1234,6 @@ static struct pnv_ioda_pe *pnv_ioda_setup_npu_PE(struct pci_dev *npu_pdev)
> */
> dev_info(&npu_pdev->dev,
> "Associating to existing PE %x\n", pe_num);
> - pci_dev_get(npu_pdev);
> npu_pdn = pci_get_pdn(npu_pdev);
> rid = npu_pdev->bus->number << 8 | npu_pdn->devfn;
> npu_pdn->pe_number = pe_num;
>
^ permalink raw reply
* Re: [PATCH 2/8] fs: extract simple_pin/release_fs to separate files
From: Frederic Barrat @ 2020-04-21 11:19 UTC (permalink / raw)
To: Emanuele Giuseppe Esposito, linux-nfs
Cc: Song Liu, linux-usb, bpf, Rafael J. Wysocki, David Airlie,
Heiko Carstens, Alexei Starovoitov, dri-devel, J. Bruce Fields,
Joseph Qi, Hugh Dickins, Paul Mackerras, John Johansen, netdev,
linux-s390, Christoph Hellwig, Andrew Donnellan, Matthew Garrett,
linux-efi, Arnd Bergmann, Daniel Borkmann, Christian Borntraeger,
linux-rdma, Mark Fasheh, Anton Vorontsov, John Fastabend,
James Morris, Ard Biesheuvel, Jason Gunthorpe, Doug Ledford,
oprofile-list, Yonghong Song, Ian Kent, Andrii Nakryiko,
Alexey Dobriyan, Serge E. Hallyn, Robert Richter,
Thomas Zimmermann, Vasily Gorbik, Tony Luck, Kees Cook,
James E.J. Bottomley, autofs, Maarten Lankhorst, Uma Krishnan,
Maxime Ripard, Manoj N. Kumar, Alexander Viro, Jakub Kicinski,
KP Singh, Trond Myklebust, Matthew R. Ochs, David S. Miller,
Felipe Balbi, Mike Marciniszyn, Iurii Zaikin, linux-scsi,
Martin K. Petersen, linux-mm, Greg Kroah-Hartman,
Dennis Dalessandro, Miklos Szeredi, linux-security-module,
linux-kernel, Anna Schumaker, Luis Chamberlain, Chuck Lever,
Jeremy Kerr, Daniel Vetter, Colin Cross, linux-fsdevel,
Paolo Bonzini, Andrew Morton, Mike Kravetz, linuxppc-dev,
Martin KaFai Lau, ocfs2-devel, Joel Becker
In-Reply-To: <20200414124304.4470-3-eesposit@redhat.com>
> diff --git a/drivers/misc/cxl/Kconfig b/drivers/misc/cxl/Kconfig
> index 39eec9031487..a62795079d9c 100644
> --- a/drivers/misc/cxl/Kconfig
> +++ b/drivers/misc/cxl/Kconfig
> @@ -19,6 +19,7 @@ config CXL
> select CXL_BASE
> select CXL_AFU_DRIVER_OPS
> select CXL_LIB
> + select SIMPLEFS
> default m
> help
> Select this option to enable driver support for IBM Coherent
> diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
> index b493de962153..0b8f8de7475a 100644
> --- a/drivers/misc/cxl/api.c
> +++ b/drivers/misc/cxl/api.c
> @@ -9,6 +9,7 @@
> #include <misc/cxl.h>
> #include <linux/module.h>
> #include <linux/mount.h>
> +#include <linux/simplefs.h>
> #include <linux/pseudo_fs.h>
> #include <linux/sched/mm.h>
> #include <linux/mmu_context.h>
> diff --git a/drivers/misc/ocxl/Kconfig b/drivers/misc/ocxl/Kconfig
> index 2d2266c1439e..ddd9245fff3d 100644
> --- a/drivers/misc/ocxl/Kconfig
> +++ b/drivers/misc/ocxl/Kconfig
> @@ -12,6 +12,7 @@ config OCXL
> depends on PPC_POWERNV && PCI && EEH
> select OCXL_BASE
> select HOTPLUG_PCI_POWERNV
> + select SIMPLEFS
It's not clear to me the Kconfig updated is needed for the ocxl driver.
I think it's only needed for the cxl driver.
Fred
^ permalink raw reply
* Re: [PATCH 2/8] fs: extract simple_pin/release_fs to separate files
From: Emanuele Giuseppe Esposito @ 2020-04-21 11:26 UTC (permalink / raw)
To: Frederic Barrat, linux-nfs
Cc: Song Liu, linux-usb, bpf, Rafael J. Wysocki, David Airlie,
Heiko Carstens, Alexei Starovoitov, dri-devel, J. Bruce Fields,
Joseph Qi, Hugh Dickins, Paul Mackerras, John Johansen, netdev,
linux-s390, Christoph Hellwig, Andrew Donnellan, Matthew Garrett,
linux-efi, Arnd Bergmann, Daniel Borkmann, Christian Borntraeger,
linux-rdma, Mark Fasheh, Anton Vorontsov, John Fastabend,
James Morris, Ard Biesheuvel, Jason Gunthorpe, Doug Ledford,
oprofile-list, Yonghong Song, Ian Kent, Andrii Nakryiko,
Alexey Dobriyan, Serge E. Hallyn, Robert Richter,
Thomas Zimmermann, Vasily Gorbik, Tony Luck, Kees Cook,
James E.J. Bottomley, autofs, Maarten Lankhorst, Uma Krishnan,
Maxime Ripard, Manoj N. Kumar, Alexander Viro, Jakub Kicinski,
KP Singh, Trond Myklebust, Matthew R. Ochs, David S. Miller,
Felipe Balbi, Mike Marciniszyn, Iurii Zaikin, linux-scsi,
Martin K. Petersen, linux-mm, Greg Kroah-Hartman,
Dennis Dalessandro, Miklos Szeredi, linux-security-module,
linux-kernel, Anna Schumaker, Luis Chamberlain, Chuck Lever,
Jeremy Kerr, Daniel Vetter, Colin Cross, linux-fsdevel,
Paolo Bonzini, Andrew Morton, Mike Kravetz, linuxppc-dev,
Martin KaFai Lau, ocfs2-devel, Joel Becker
In-Reply-To: <7abfdd3b-dbbe-52ab-df53-95e9f86d39cd@linux.ibm.com>
On 4/21/20 1:19 PM, Frederic Barrat wrote:
>
>
>> diff --git a/drivers/misc/cxl/Kconfig b/drivers/misc/cxl/Kconfig
>> index 39eec9031487..a62795079d9c 100644
>> --- a/drivers/misc/cxl/Kconfig
>> +++ b/drivers/misc/cxl/Kconfig
>> @@ -19,6 +19,7 @@ config CXL
>> select CXL_BASE
>> select CXL_AFU_DRIVER_OPS
>> select CXL_LIB
>> + select SIMPLEFS
>> default m
>> help
>> Select this option to enable driver support for IBM Coherent
>> diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
>> index b493de962153..0b8f8de7475a 100644
>> --- a/drivers/misc/cxl/api.c
>> +++ b/drivers/misc/cxl/api.c
>> @@ -9,6 +9,7 @@
>> #include <misc/cxl.h>
>> #include <linux/module.h>
>> #include <linux/mount.h>
>> +#include <linux/simplefs.h>
>> #include <linux/pseudo_fs.h>
>> #include <linux/sched/mm.h>
>> #include <linux/mmu_context.h>
>> diff --git a/drivers/misc/ocxl/Kconfig b/drivers/misc/ocxl/Kconfig
>> index 2d2266c1439e..ddd9245fff3d 100644
>> --- a/drivers/misc/ocxl/Kconfig
>> +++ b/drivers/misc/ocxl/Kconfig
>> @@ -12,6 +12,7 @@ config OCXL
>> depends on PPC_POWERNV && PCI && EEH
>> select OCXL_BASE
>> select HOTPLUG_PCI_POWERNV
>> + select SIMPLEFS
>
>
> It's not clear to me the Kconfig updated is needed for the ocxl driver.
> I think it's only needed for the cxl driver.
I am going to get rid of the separate simplefs.c file and related
Kconfig entry and put everything in fs/libfs.c, so this file (together
with many others touched in this patch) won't be modified in v2.
Thanks,
Emanuele
^ permalink raw reply
* Re: crash in cpuidle_enter_state with 5.7-rc1
From: Michael Ellerman @ 2020-04-21 12:21 UTC (permalink / raw)
To: Michal Suchánek; +Cc: linuxppc-dev
In-Reply-To: <20200420194132.GM25468@kitsune.suse.cz>
Michal Suchánek <msuchanek@suse.de> writes:
> On Mon, Apr 20, 2020 at 08:50:30AM +0200, Michal Suchánek wrote:
>> On Mon, Apr 20, 2020 at 04:15:39PM +1000, Michael Ellerman wrote:
>> > Michal Suchánek <msuchanek@suse.de> writes:
> ...
>> >
>> >
>> > And I've just hit it with your config on a machine here, but the crash
>> > is different:
>> That does not look like it.
>> You don't have this part in the stack trace:
>> > [ 1.234899] [c000000007597420] [0000000000000000] 0x0
>> > [ 1.234908] [c000000007597720] [0000000000000a6d] 0xa6d
>> > [ 1.234919] [c000000007597a20] [0000000000000000] 0x0
>> > [ 1.234931] [c000000007597d20] [0000000000000004] 0x4
>> which is somewhat random but at least on such line is always present in
>> the traces I get. Also I always get crash in cpuidle_enter_state
> ..
>> > I'm going to guess it's STRICT_KERNEL_RWX that's at fault.
>> I can try without that as well.
>
> Can't reproduce without STRICT_KERNEL_RWX either.
I've reproduced something similar all the way back to v5.5, though it
seems harder to hit - sometimes 5 boots will succeed before one fails.
Are you testing on top of PowerVM or KVM?
cheers
^ permalink raw reply
* Re: crash in cpuidle_enter_state with 5.7-rc1
From: Michal Suchánek @ 2020-04-21 12:37 UTC (permalink / raw)
To: Michael Ellerman; +Cc: linuxppc-dev
In-Reply-To: <87sggxghb3.fsf@mpe.ellerman.id.au>
On Tue, Apr 21, 2020 at 10:21:52PM +1000, Michael Ellerman wrote:
> Michal Suchánek <msuchanek@suse.de> writes:
> > On Mon, Apr 20, 2020 at 08:50:30AM +0200, Michal Suchánek wrote:
> >> On Mon, Apr 20, 2020 at 04:15:39PM +1000, Michael Ellerman wrote:
> >> > Michal Suchánek <msuchanek@suse.de> writes:
> > ...
> >> >
> >> >
> >> > And I've just hit it with your config on a machine here, but the crash
> >> > is different:
> >> That does not look like it.
> >> You don't have this part in the stack trace:
> >> > [ 1.234899] [c000000007597420] [0000000000000000] 0x0
> >> > [ 1.234908] [c000000007597720] [0000000000000a6d] 0xa6d
> >> > [ 1.234919] [c000000007597a20] [0000000000000000] 0x0
> >> > [ 1.234931] [c000000007597d20] [0000000000000004] 0x4
> >> which is somewhat random but at least on such line is always present in
> >> the traces I get. Also I always get crash in cpuidle_enter_state
> > ..
> >> > I'm going to guess it's STRICT_KERNEL_RWX that's at fault.
> >> I can try without that as well.
> >
> > Can't reproduce without STRICT_KERNEL_RWX either.
>
> I've reproduced something similar all the way back to v5.5, though it
> seems harder to hit - sometimes 5 boots will succeed before one fails.
I only tried 3 times because I do not have automation in place to
capture these early crashes. I suppose I could tell the kernel to not
reboot on panic and try rebooting several times.
>
> Are you testing on top of PowerVM or KVM?
PowerVM.
Thanks
Michal
^ permalink raw reply
* Re: [PATCH 1/2] powerpc: Add base support for ISA v3.1
From: Michael Ellerman @ 2020-04-21 12:39 UTC (permalink / raw)
To: Segher Boessenkool, Alistair Popple; +Cc: mikey, linuxppc-dev, npiggin
In-Reply-To: <20200403153208.GI26902@gate.crashing.org>
Segher Boessenkool <segher@kernel.crashing.org> writes:
> Hi!
>
> On Fri, Apr 03, 2020 at 03:10:54PM +1100, Alistair Popple wrote:
>> +#define PCR_ARCH_300 0x10 /* Architecture 3.00 */
>
> It's called 3.0, not 3.00?
It should actually be 3.0B shouldn't it?
cheers
^ permalink raw reply
* Re: [PATCH 1/3] kexec: Prevent removal of memory in use by a loaded kexec image
From: David Hildenbrand @ 2020-04-21 13:29 UTC (permalink / raw)
To: Baoquan He, Andrew Morton
Cc: piliu, Anshuman Khandual, Catalin Marinas, Bhupesh Sharma,
linuxppc-dev, kexec, Russell King - ARM Linux admin, linux-mm,
James Morse, Eric W. Biederman, Will Deacon, linux-arm-kernel
In-Reply-To: <2525cc9c-3566-6275-105b-7f4af8f980bc@redhat.com>
>> ACPI SRAT is embeded into efi, need read out the rsdp pointer. If we don't
>> pass the efi, it won't get the SRAT table correctly, if I remember
>> correctly. Yeah, I remeber kvm guest can get memory hotplugged with
>> ACPI only, this won't happen on bare metal though. Need check carefully.
>> I have been using kvm guest with uefi firmwire recently.
>
> Yeah, I can imagine that bare metal is different. kvm only uses ACPI.
>
> I'm also asking because of virtio-mem. Memory added via virtio-mem is
> not part of any efi tables or whatsoever. So I assume the kexec kernel
> will not detect it automatically (good!), instead load the virtio-mem
> driver and let it add memory back to the system.
>
> I should probably play with kexec and virtio-mem once I have some spare
> cycles ... to find out what's broken and needs to be addressed :)
FWIW, I just gave virtio-mem and kexec/kdump a try.
a) kdump seems to work. Memory added by virtio-mem is getting dumped.
The kexec kernel only uses memory in the crash region. The virtio-mem
driver properly bails out due to is_kdump_kernel().
b) "kexec -s -l" seems to work fine. For now, the kernel does not seem
to get placed on virtio-mem memory (pure luck due to the left-to-right
search). Memory added by virtio-mem is not getting added to the e820
map. Once the virtio-mem driver comes back up in the kexec kernel, the
right memory is readded.
c) "kexec -c -l" does not work properly. All memory added by virtio-mem
is added to the e820 map, which is wrong. Memory that should not be
touched will be touched by the kexec kernel. I assume kexec-tools just
goes ahead and adds anything it can find in /proc/iomem (or
/sys/firmware/memmap/) to the e820 map of the new kernel.
Due to c), I assume all hotplugged memory (e.g., ACPI DIMMs) is
similarly added to the e820 map and, therefore, won't be able to be
onlined MOVABLE easily.
At least for virtio-mem, I would either have to
a) Not support "kexec -c -l". A viable option if we would be planning on
not supporting it either way in the long term. I could block this
in-kernel somehow eventually.
b) Teach kexec-tools to leave virtio-mem added memory alone. E.g., by
indicating it in /proc/iomem in a special way ("System RAM
(hotplugged)"/"System RAM (virtio-mem)").
Baoquan, any opinion on that?
--
Thanks,
David / dhildenb
^ permalink raw reply
* Re: [PATCH v5 0/5] Track and expose idle PURR and SPURR ticks
From: Nathan Lynch @ 2020-04-21 13:30 UTC (permalink / raw)
To: Gautham R. Shenoy
Cc: Gautham R. Shenoy, Tyrel Datwyler, linux-kernel, Kamalesh Babulal,
Naveen N. Rao, Vaidyanathan Srinivasan, linuxppc-dev
In-Reply-To: <1586249263-14048-1-git-send-email-ego@linux.vnet.ibm.com>
"Gautham R. Shenoy" <ego@linux.vnet.ibm.com> writes:
> This is the fifth version of the patches to track and expose idle PURR
> and SPURR ticks. These patches are required by tools such as lparstat
> to compute system utilization for capacity planning purposes.
>
> The previous versions can be found here:
> v4: https://lkml.org/lkml/2020/3/27/323
> v3: https://lkml.org/lkml/2020/3/11/331
> v2: https://lkml.org/lkml/2020/2/21/21
> v1: https://lore.kernel.org/patchwork/cover/1159341/
>
> They changes from v4 are:
>
> - As suggested by Naveen, moved the functions read_this_idle_purr()
> and read_this_idle_spurr() from Patch 2 and Patch 3 respectively
> to Patch 4 where it is invoked.
>
> - Dropped Patch 6 which cached the values of purr, spurr,
> idle_purr, idle_spurr in order to minimize the number of IPIs
> sent.
>
> - Updated the dates for the idle_purr, idle_spurr in the
> Documentation Patch 5.
LGTM
Acked-by: Nathan Lynch <nathanl@linux.ibm.com>
Thanks.
^ permalink raw reply
* Re: [PATCH] KVM: PPC: Book3S HV: read ibm,secure-memory nodes
From: Michael Ellerman @ 2020-04-21 13:34 UTC (permalink / raw)
To: Laurent Dufour, kvm-ppc, linuxppc-dev
Cc: Alexey Kardashevskiy, paulus, linux-kernel
In-Reply-To: <20200416162715.45846-1-ldufour@linux.ibm.com>
Hi Laurent,
Laurent Dufour <ldufour@linux.ibm.com> writes:
> The newly introduced ibm,secure-memory nodes supersede the
> ibm,uv-firmware's property secure-memory-ranges.
Is either documented in a device tree binding document anywhere?
cheers
> Firmware will no more expose the secure-memory-ranges property so first
> read the new one and if not found rollback to the older one.
>
> Signed-off-by: Laurent Dufour <ldufour@linux.ibm.com>
> ---
> arch/powerpc/kvm/book3s_hv_uvmem.c | 14 ++++++++++++++
> 1 file changed, 14 insertions(+)
>
> diff --git a/arch/powerpc/kvm/book3s_hv_uvmem.c b/arch/powerpc/kvm/book3s_hv_uvmem.c
> index 53b88cae3e73..ad950f8996e0 100644
> --- a/arch/powerpc/kvm/book3s_hv_uvmem.c
> +++ b/arch/powerpc/kvm/book3s_hv_uvmem.c
> @@ -735,6 +735,20 @@ static u64 kvmppc_get_secmem_size(void)
> const __be32 *prop;
> u64 size = 0;
>
> + /*
> + * First try the new ibm,secure-memory nodes which supersede the
> + * secure-memory-ranges property.
> + * If we found somes, no need to read the deprecated one.
> + */
> + for_each_compatible_node(np, NULL, "ibm,secure-memory") {
> + prop = of_get_property(np, "reg", &len);
> + if (!prop)
> + continue;
> + size += of_read_number(prop + 2, 2);
> + }
> + if (size)
> + return size;
> +
> np = of_find_compatible_node(NULL, NULL, "ibm,uv-firmware");
> if (!np)
> goto out;
> --
> 2.26.1
^ permalink raw reply
* Re: [PATCH] KVM: PPC: Book3S HV: read ibm,secure-memory nodes
From: Oliver O'Halloran @ 2020-04-21 13:43 UTC (permalink / raw)
To: Michael Ellerman
Cc: Alexey Kardashevskiy, Linux Kernel Mailing List, kvm-ppc,
Paul Mackerras, Laurent Dufour, linuxppc-dev
In-Reply-To: <87k129gdx8.fsf@mpe.ellerman.id.au>
On Tue, Apr 21, 2020 at 11:37 PM Michael Ellerman <mpe@ellerman.id.au> wrote:
>
> Hi Laurent,
>
> Laurent Dufour <ldufour@linux.ibm.com> writes:
> > The newly introduced ibm,secure-memory nodes supersede the
> > ibm,uv-firmware's property secure-memory-ranges.
>
> Is either documented in a device tree binding document anywhere?
>
> cheers
>
> > Firmware will no more expose the secure-memory-ranges property so first
> > read the new one and if not found rollback to the older one.
There's some in Ryan's UV support series for skiboot:
https://patchwork.ozlabs.org/project/skiboot/patch/20200227204023.22125-2-grimm@linux.ibm.com/
...which is also marked RFC. Cool.
Oliver
^ permalink raw reply
* [PATCH v2 0/7] libfs: group and simplify linux fs code
From: Emanuele Giuseppe Esposito @ 2020-04-21 13:51 UTC (permalink / raw)
To: linux-fsdevel
Cc: Rafael J. Wysocki, David Airlie, dri-devel, Christoph Hellwig,
Andrew Donnellan, Emanuele Giuseppe Esposito, linux-scsi,
James Morris, Serge E. Hallyn, Daniel Vetter, Arnd Bergmann,
James E.J. Bottomley, Maarten Lankhorst, Maxime Ripard,
Manoj N. Kumar, Alexander Viro, Matthew R. Ochs, Uma Krishnan,
John Johansen, Martin K. Petersen, Greg Kroah-Hartman,
linux-kernel, linux-security-module, Thomas Zimmermann,
Frederic Barrat, Paolo Bonzini, linuxppc-dev, Joel Becker
libfs.c has many functions that are useful to implement dentry and inode
operations, but not many at the filesystem level. As a result, code to
create files and inodes has a lot of duplication, to the point that
tracefs has copied several hundred lines from debugfs.
The main two libfs.c functions for filesystems are simple_pin_fs and
simple_release_fs, which hide a somewhat complicated locking sequence
that is needed to serialize vfs_kern_mount and mntget. In this series,
my aim is to add functions that create dentries and inodes of various
kinds (either anonymous inodes, or directory/file/symlink). These
functions take the code that was duplicated across debugfs and tracefs
and move it to libfs.c.
In order to limit the number of arguments to the new functions, the
series first creates a data type that is passed to both
simple_pin_fs/simple_release_fs and the new creation functions. The new
struct, introduced in patch 2, simply groups the "mount" and "count"
arguments to simple_pin_fs and simple_release_fs.
Patches 1-4 are preparations to introduce the new simple_fs struct and
new functions that are useful in the remainder of the series. Patch 5
introduces the dentry and inode creation functions. Patch 6-7 can then
adopt them in debugfs and tracefs.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
v1->v2: rename simple_new_inode in new_inode_current_time,
more detailed explanations, put all common code in fs/libfs.c
Emanuele Giuseppe Esposito (7):
apparmor: just use vfs_kern_mount to make .null
libfs: wrap simple_pin_fs/simple_release_fs arguments in a struct
libfs: introduce new_inode_current_time
libfs: add alloc_anon_inode wrapper
libfs: add file creation functions
debugfs: switch to simplefs inode creation API
tracefs: switch to simplefs inode creation API
drivers/gpu/drm/drm_drv.c | 11 +-
drivers/misc/cxl/api.c | 13 +-
drivers/scsi/cxlflash/ocxl_hw.c | 14 +-
fs/binfmt_misc.c | 9 +-
fs/configfs/mount.c | 10 +-
fs/debugfs/inode.c | 158 +++--------------
fs/libfs.c | 299 ++++++++++++++++++++++++++++++--
fs/tracefs/inode.c | 96 ++--------
include/linux/fs.h | 31 +++-
security/apparmor/apparmorfs.c | 38 ++--
security/inode.c | 11 +-
11 files changed, 399 insertions(+), 291 deletions(-)
--
2.25.2
^ permalink raw reply
* [PATCH v2 1/7] apparmor: just use vfs_kern_mount to make .null
From: Emanuele Giuseppe Esposito @ 2020-04-21 13:51 UTC (permalink / raw)
To: linux-fsdevel
Cc: Rafael J. Wysocki, David Airlie, dri-devel, Christoph Hellwig,
Andrew Donnellan, Emanuele Giuseppe Esposito, linux-scsi,
James Morris, Serge E. Hallyn, Daniel Vetter, Arnd Bergmann,
James E.J. Bottomley, Maarten Lankhorst, Maxime Ripard,
Manoj N. Kumar, Alexander Viro, Matthew R. Ochs, Uma Krishnan,
John Johansen, Martin K. Petersen, Greg Kroah-Hartman,
linux-kernel, linux-security-module, Thomas Zimmermann,
Frederic Barrat, Paolo Bonzini, linuxppc-dev, Joel Becker
In-Reply-To: <20200421135119.30007-1-eesposit@redhat.com>
aa_mk_null_file is using simple_pin_fs/simple_release_fs with local
variables as arguments, for what would amount to a simple
vfs_kern_mount/mntput pair if everything was inlined. Just use
the normal filesystem API since the reference counting is not needed
here (it is a local variable and always 0 on entry and on exit).
There is no functional change intended.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
security/apparmor/apparmorfs.c | 13 +++++++------
1 file changed, 7 insertions(+), 6 deletions(-)
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 280741fc0f5f..36f848734902 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -2525,14 +2525,15 @@ struct path aa_null;
static int aa_mk_null_file(struct dentry *parent)
{
- struct vfsmount *mount = NULL;
+ struct file_system_type *type = parent->d_sb->s_type;
+ struct vfsmount *mount;
struct dentry *dentry;
struct inode *inode;
- int count = 0;
- int error = simple_pin_fs(parent->d_sb->s_type, &mount, &count);
+ int error;
- if (error)
- return error;
+ mount = vfs_kern_mount(type, SB_KERNMOUNT, type->name, NULL);
+ if (IS_ERR(mount))
+ return PTR_ERR(mount);
inode_lock(d_inode(parent));
dentry = lookup_one_len(NULL_FILE_NAME, parent, strlen(NULL_FILE_NAME));
@@ -2561,7 +2562,7 @@ static int aa_mk_null_file(struct dentry *parent)
dput(dentry);
out:
inode_unlock(d_inode(parent));
- simple_release_fs(&mount, &count);
+ mntput(mount);
return error;
}
--
2.25.2
^ permalink raw reply related
* [PATCH v2 2/7] libfs: wrap simple_pin_fs/simple_release_fs arguments in a struct
From: Emanuele Giuseppe Esposito @ 2020-04-21 13:51 UTC (permalink / raw)
To: linux-fsdevel
Cc: Rafael J. Wysocki, David Airlie, dri-devel, Christoph Hellwig,
Andrew Donnellan, Emanuele Giuseppe Esposito, linux-scsi,
James Morris, Serge E. Hallyn, Daniel Vetter, Arnd Bergmann,
James E.J. Bottomley, Maarten Lankhorst, Maxime Ripard,
Manoj N. Kumar, Alexander Viro, Matthew R. Ochs, Uma Krishnan,
John Johansen, Martin K. Petersen, Greg Kroah-Hartman,
linux-kernel, linux-security-module, Thomas Zimmermann,
Frederic Barrat, Paolo Bonzini, linuxppc-dev, Joel Becker
In-Reply-To: <20200421135119.30007-1-eesposit@redhat.com>
Simplify passing the count and mount to simple_pin_fs and
simple_release_fs by wrapping them in the simple_fs struct,
in preparation for adding more high level operations to
fs/libfs.c
There is no functional change intended.
Signed-off-by: Emanuele Giuseppe Esposito <eesposit@redhat.com>
---
drivers/gpu/drm/drm_drv.c | 11 ++++----
drivers/misc/cxl/api.c | 13 +++++-----
drivers/scsi/cxlflash/ocxl_hw.c | 14 +++++-----
fs/binfmt_misc.c | 9 +++----
fs/configfs/mount.c | 10 +++-----
fs/debugfs/inode.c | 22 ++++++++--------
fs/libfs.c | 45 +++++++++++++++++++++++++--------
fs/tracefs/inode.c | 18 ++++++-------
include/linux/fs.h | 10 ++++++--
security/apparmor/apparmorfs.c | 25 +++++++++---------
security/inode.c | 11 ++++----
11 files changed, 103 insertions(+), 85 deletions(-)
diff --git a/drivers/gpu/drm/drm_drv.c b/drivers/gpu/drm/drm_drv.c
index 7b1a628d1f6e..e29424d64874 100644
--- a/drivers/gpu/drm/drm_drv.c
+++ b/drivers/gpu/drm/drm_drv.c
@@ -514,8 +514,7 @@ EXPORT_SYMBOL(drm_dev_unplug);
* iput(), but this way you'd end up with a new vfsmount for each inode.
*/
-static int drm_fs_cnt;
-static struct vfsmount *drm_fs_mnt;
+static struct simple_fs drm_fs;
static int drm_fs_init_fs_context(struct fs_context *fc)
{
@@ -534,15 +533,15 @@ static struct inode *drm_fs_inode_new(void)
struct inode *inode;
int r;
- r = simple_pin_fs(&drm_fs_type, &drm_fs_mnt, &drm_fs_cnt);
+ r = simple_pin_fs(&drm_fs, &drm_fs_type);
if (r < 0) {
DRM_ERROR("Cannot mount pseudo fs: %d\n", r);
return ERR_PTR(r);
}
- inode = alloc_anon_inode(drm_fs_mnt->mnt_sb);
+ inode = alloc_anon_inode(drm_fs.mount->mnt_sb);
if (IS_ERR(inode))
- simple_release_fs(&drm_fs_mnt, &drm_fs_cnt);
+ simple_release_fs(&drm_fs);
return inode;
}
@@ -551,7 +550,7 @@ static void drm_fs_inode_free(struct inode *inode)
{
if (inode) {
iput(inode);
- simple_release_fs(&drm_fs_mnt, &drm_fs_cnt);
+ simple_release_fs(&drm_fs);
}
}
diff --git a/drivers/misc/cxl/api.c b/drivers/misc/cxl/api.c
index b493de962153..67e4808bce49 100644
--- a/drivers/misc/cxl/api.c
+++ b/drivers/misc/cxl/api.c
@@ -31,8 +31,7 @@
#define CXL_PSEUDO_FS_MAGIC 0x1697697f
-static int cxl_fs_cnt;
-static struct vfsmount *cxl_vfs_mount;
+static struct simple_fs cxl_fs;
static int cxl_fs_init_fs_context(struct fs_context *fc)
{
@@ -50,7 +49,7 @@ static struct file_system_type cxl_fs_type = {
void cxl_release_mapping(struct cxl_context *ctx)
{
if (ctx->kernelapi && ctx->mapping)
- simple_release_fs(&cxl_vfs_mount, &cxl_fs_cnt);
+ simple_release_fs(&cxl_fs);
}
static struct file *cxl_getfile(const char *name,
@@ -66,20 +65,20 @@ static struct file *cxl_getfile(const char *name,
if (fops->owner && !try_module_get(fops->owner))
return ERR_PTR(-ENOENT);
- rc = simple_pin_fs(&cxl_fs_type, &cxl_vfs_mount, &cxl_fs_cnt);
+ rc = simple_pin_fs(&cxl_fs, &cxl_fs_type);
if (rc < 0) {
pr_err("Cannot mount cxl pseudo filesystem: %d\n", rc);
file = ERR_PTR(rc);
goto err_module;
}
- inode = alloc_anon_inode(cxl_vfs_mount->mnt_sb);
+ inode = alloc_anon_inode(cxl_fs.mount->mnt_sb);
if (IS_ERR(inode)) {
file = ERR_CAST(inode);
goto err_fs;
}
- file = alloc_file_pseudo(inode, cxl_vfs_mount, name,
+ file = alloc_file_pseudo(inode, cxl_fs.mount, name,
flags & (O_ACCMODE | O_NONBLOCK), fops);
if (IS_ERR(file))
goto err_inode;
@@ -91,7 +90,7 @@ static struct file *cxl_getfile(const char *name,
err_inode:
iput(inode);
err_fs:
- simple_release_fs(&cxl_vfs_mount, &cxl_fs_cnt);
+ simple_release_fs(&cxl_fs);
err_module:
module_put(fops->owner);
return file;
diff --git a/drivers/scsi/cxlflash/ocxl_hw.c b/drivers/scsi/cxlflash/ocxl_hw.c
index 7018cd802569..7fa98dd4fa28 100644
--- a/drivers/scsi/cxlflash/ocxl_hw.c
+++ b/drivers/scsi/cxlflash/ocxl_hw.c
@@ -29,8 +29,7 @@
#define OCXLFLASH_FS_MAGIC 0x1697698f
-static int ocxlflash_fs_cnt;
-static struct vfsmount *ocxlflash_vfs_mount;
+static struct simple_fs ocxlflash_fs;
static int ocxlflash_fs_init_fs_context(struct fs_context *fc)
{
@@ -51,7 +50,7 @@ static struct file_system_type ocxlflash_fs_type = {
static void ocxlflash_release_mapping(struct ocxlflash_context *ctx)
{
if (ctx->mapping)
- simple_release_fs(&ocxlflash_vfs_mount, &ocxlflash_fs_cnt);
+ simple_release_fs(&ocxlflash_fs);
ctx->mapping = NULL;
}
@@ -79,15 +78,14 @@ static struct file *ocxlflash_getfile(struct device *dev, const char *name,
goto err1;
}
- rc = simple_pin_fs(&ocxlflash_fs_type, &ocxlflash_vfs_mount,
- &ocxlflash_fs_cnt);
+ rc = simple_pin_fs(&ocxlflash_fs, &ocxlflash_fs_type);
if (unlikely(rc < 0)) {
dev_err(dev, "%s: Cannot mount ocxlflash pseudofs rc=%d\n",
__func__, rc);
goto err2;
}
- inode = alloc_anon_inode(ocxlflash_vfs_mount->mnt_sb);
+ inode = alloc_anon_inode(ocxlflash_fs.mount->mnt_sb);
if (IS_ERR(inode)) {
rc = PTR_ERR(inode);
dev_err(dev, "%s: alloc_anon_inode failed rc=%d\n",
@@ -95,7 +93,7 @@ static struct file *ocxlflash_getfile(struct device *dev, const char *name,
goto err3;
}
- file = alloc_file_pseudo(inode, ocxlflash_vfs_mount, name,
+ file = alloc_file_pseudo(inode, ocxlflash_fs.mount, name,
flags & (O_ACCMODE | O_NONBLOCK), fops);
if (IS_ERR(file)) {
rc = PTR_ERR(file);
@@ -110,7 +108,7 @@ static struct file *ocxlflash_getfile(struct device *dev, const char *name,
err4:
iput(inode);
err3:
- simple_release_fs(&ocxlflash_vfs_mount, &ocxlflash_fs_cnt);
+ simple_release_fs(&ocxlflash_fs);
err2:
module_put(fops->owner);
err1:
diff --git a/fs/binfmt_misc.c b/fs/binfmt_misc.c
index cdb45829354d..3cff446f222b 100644
--- a/fs/binfmt_misc.c
+++ b/fs/binfmt_misc.c
@@ -64,8 +64,7 @@ typedef struct {
static DEFINE_RWLOCK(entries_lock);
static struct file_system_type bm_fs_type;
-static struct vfsmount *bm_mnt;
-static int entry_count;
+static struct simple_fs bm_fs;
/*
* Max length of the register string. Determined by:
@@ -623,7 +622,7 @@ static void kill_node(Node *e)
drop_nlink(d_inode(dentry));
d_drop(dentry);
dput(dentry);
- simple_release_fs(&bm_mnt, &entry_count);
+ simple_release_fs(&bm_fs);
}
/* /<entry> */
@@ -718,7 +717,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
if (!inode)
goto out2;
- err = simple_pin_fs(&bm_fs_type, &bm_mnt, &entry_count);
+ err = simple_pin_fs(&bm_fs, &bm_fs_type);
if (err) {
iput(inode);
inode = NULL;
@@ -732,7 +731,7 @@ static ssize_t bm_register_write(struct file *file, const char __user *buffer,
if (IS_ERR(f)) {
err = PTR_ERR(f);
pr_notice("register: failed to install interpreter file %s\n", e->interpreter);
- simple_release_fs(&bm_mnt, &entry_count);
+ simple_release_fs(&bm_fs);
iput(inode);
inode = NULL;
goto out2;
diff --git a/fs/configfs/mount.c b/fs/configfs/mount.c
index 0c6e8cf61953..9fb2791e5eed 100644
--- a/fs/configfs/mount.c
+++ b/fs/configfs/mount.c
@@ -24,9 +24,8 @@
/* Random magic number */
#define CONFIGFS_MAGIC 0x62656570
-static struct vfsmount *configfs_mount = NULL;
+static struct simple_fs configfs_fs;
struct kmem_cache *configfs_dir_cachep;
-static int configfs_mnt_count = 0;
static void configfs_free_inode(struct inode *inode)
@@ -123,14 +122,13 @@ MODULE_ALIAS_FS("configfs");
struct dentry *configfs_pin_fs(void)
{
- int err = simple_pin_fs(&configfs_fs_type, &configfs_mount,
- &configfs_mnt_count);
- return err ? ERR_PTR(err) : configfs_mount->mnt_root;
+ int err = simple_pin_fs(&configfs_fs, &configfs_fs_type);
+ return err ? ERR_PTR(err) : configfs_fs.mount->mnt_root;
}
void configfs_release_fs(void)
{
- simple_release_fs(&configfs_mount, &configfs_mnt_count);
+ simple_release_fs(&configfs_fs);
}
diff --git a/fs/debugfs/inode.c b/fs/debugfs/inode.c
index b7f2e971ecbc..5dbb74a23e7c 100644
--- a/fs/debugfs/inode.c
+++ b/fs/debugfs/inode.c
@@ -32,8 +32,7 @@
#define DEBUGFS_DEFAULT_MODE 0700
-static struct vfsmount *debugfs_mount;
-static int debugfs_mount_count;
+static struct simple_fs debugfs;
static bool debugfs_registered;
/*
@@ -297,7 +296,7 @@ struct dentry *debugfs_lookup(const char *name, struct dentry *parent)
return NULL;
if (!parent)
- parent = debugfs_mount->mnt_root;
+ parent = debugfs.mount->mnt_root;
dentry = lookup_positive_unlocked(name, parent, strlen(name));
if (IS_ERR(dentry))
@@ -316,8 +315,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
if (IS_ERR(parent))
return parent;
- error = simple_pin_fs(&debug_fs_type, &debugfs_mount,
- &debugfs_mount_count);
+ error = simple_pin_fs(&debugfs, &debug_fs_type);
if (error) {
pr_err("Unable to pin filesystem for file '%s'\n", name);
return ERR_PTR(error);
@@ -329,7 +327,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
* have around.
*/
if (!parent)
- parent = debugfs_mount->mnt_root;
+ parent = debugfs.mount->mnt_root;
inode_lock(d_inode(parent));
if (unlikely(IS_DEADDIR(d_inode(parent))))
@@ -349,7 +347,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
if (IS_ERR(dentry)) {
inode_unlock(d_inode(parent));
- simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+ simple_release_fs(&debugfs);
}
return dentry;
@@ -359,7 +357,7 @@ static struct dentry *failed_creating(struct dentry *dentry)
{
inode_unlock(d_inode(dentry->d_parent));
dput(dentry);
- simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+ simple_release_fs(&debugfs);
return ERR_PTR(-ENOMEM);
}
@@ -676,9 +674,9 @@ static void __debugfs_file_removed(struct dentry *dentry)
static void remove_one(struct dentry *victim)
{
- if (d_is_reg(victim))
+ if (d_is_reg(victim))
__debugfs_file_removed(victim);
- simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+ simple_release_fs(&debugfs);
}
/**
@@ -699,9 +697,9 @@ void debugfs_remove(struct dentry *dentry)
if (IS_ERR_OR_NULL(dentry))
return;
- simple_pin_fs(&debug_fs_type, &debugfs_mount, &debugfs_mount_count);
+ simple_pin_fs(&debugfs, &debug_fs_type);
simple_recursive_removal(dentry, remove_one);
- simple_release_fs(&debugfs_mount, &debugfs_mount_count);
+ simple_release_fs(&debugfs);
}
EXPORT_SYMBOL_GPL(debugfs_remove);
diff --git a/fs/libfs.c b/fs/libfs.c
index 3759fbacf522..54e07ae986ca 100644
--- a/fs/libfs.c
+++ b/fs/libfs.c
@@ -665,39 +665,64 @@ EXPORT_SYMBOL(simple_fill_super);
static DEFINE_SPINLOCK(pin_fs_lock);
-int simple_pin_fs(struct file_system_type *type, struct vfsmount **mount, int *count)
+/**
+ * simple_pin_fs - generic function to pin (mount if needed,
+ * otherwise add a reference to the mount) a filesystem
+ * @fs: a pointer to a the simple_fs struct containing a struct vfs_mount
+ * pointer (that can be NULL) and a counter.
+ * @type: a pointer to the file system type used by vfs_kern_mount.
+ *
+ * This function sets fs->mount if NULL, by calling vfs_kern_mount
+ * on @type.
+ * It also takes care of incrementing the reference counter.
+ *
+ * This function will return 0 in case of success, and PTR_ERR(-ERROR)
+ * if vfs_kern_mount fails.
+ **/
+int simple_pin_fs(struct simple_fs *fs, struct file_system_type *type)
{
struct vfsmount *mnt = NULL;
spin_lock(&pin_fs_lock);
- if (unlikely(!*mount)) {
+ if (unlikely(!fs->mount)) {
spin_unlock(&pin_fs_lock);
mnt = vfs_kern_mount(type, SB_KERNMOUNT, type->name, NULL);
if (IS_ERR(mnt))
return PTR_ERR(mnt);
spin_lock(&pin_fs_lock);
- if (!*mount)
- *mount = mnt;
+ if (!fs->mount)
+ fs->mount = mnt;
}
- mntget(*mount);
- ++*count;
+ mntget(fs->mount);
+ ++fs->count;
spin_unlock(&pin_fs_lock);
mntput(mnt);
return 0;
}
EXPORT_SYMBOL(simple_pin_fs);
-void simple_release_fs(struct vfsmount **mount, int *count)
+/**
+ * simple_release_fs - decrements the reference counter and unmounts the
+ * file system.
+ * @fs: a pointer to a struct simple_fs containing the reference counter
+ * and vfs_mount pointer
+ *
+ * This function decrements the refcount of the given file system and
+ * if 0 sets the mount pointer to NULL.
+ **/
+void simple_release_fs(struct simple_fs *fs)
{
struct vfsmount *mnt;
spin_lock(&pin_fs_lock);
- mnt = *mount;
- if (!--*count)
- *mount = NULL;
+ mnt = fs->mount;
+ if (!--fs->count)
+ fs->mount = NULL;
spin_unlock(&pin_fs_lock);
mntput(mnt);
}
EXPORT_SYMBOL(simple_release_fs);
+
+
/**
* simple_read_from_buffer - copy data from the buffer to user space
* @to: the user space buffer to read to
diff --git a/fs/tracefs/inode.c b/fs/tracefs/inode.c
index 0ee8c6dfb036..370eb38ff1ad 100644
--- a/fs/tracefs/inode.c
+++ b/fs/tracefs/inode.c
@@ -24,8 +24,7 @@
#define TRACEFS_DEFAULT_MODE 0700
-static struct vfsmount *tracefs_mount;
-static int tracefs_mount_count;
+static struct simple_fs tracefs;
static bool tracefs_registered;
static ssize_t default_read_file(struct file *file, char __user *buf,
@@ -316,8 +315,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
pr_debug("tracefs: creating file '%s'\n",name);
- error = simple_pin_fs(&trace_fs_type, &tracefs_mount,
- &tracefs_mount_count);
+ error = simple_pin_fs(&tracefs, &trace_fs_type);
if (error)
return ERR_PTR(error);
@@ -327,7 +325,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
* have around.
*/
if (!parent)
- parent = tracefs_mount->mnt_root;
+ parent = tracefs.mount->mnt_root;
inode_lock(parent->d_inode);
if (unlikely(IS_DEADDIR(parent->d_inode)))
@@ -341,7 +339,7 @@ static struct dentry *start_creating(const char *name, struct dentry *parent)
if (IS_ERR(dentry)) {
inode_unlock(parent->d_inode);
- simple_release_fs(&tracefs_mount, &tracefs_mount_count);
+ simple_release_fs(&tracefs);
}
return dentry;
@@ -351,7 +349,7 @@ static struct dentry *failed_creating(struct dentry *dentry)
{
inode_unlock(dentry->d_parent->d_inode);
dput(dentry);
- simple_release_fs(&tracefs_mount, &tracefs_mount_count);
+ simple_release_fs(&tracefs);
return NULL;
}
@@ -504,7 +502,7 @@ __init struct dentry *tracefs_create_instance_dir(const char *name,
static void remove_one(struct dentry *victim)
{
- simple_release_fs(&tracefs_mount, &tracefs_mount_count);
+ simple_release_fs(&tracefs);
}
/**
@@ -520,9 +518,9 @@ void tracefs_remove(struct dentry *dentry)
if (IS_ERR_OR_NULL(dentry))
return;
- simple_pin_fs(&trace_fs_type, &tracefs_mount, &tracefs_mount_count);
+ simple_pin_fs(&tracefs, &trace_fs_type);
simple_recursive_removal(dentry, remove_one);
- simple_release_fs(&tracefs_mount, &tracefs_mount_count);
+ simple_release_fs(&tracefs);
}
/**
diff --git a/include/linux/fs.h b/include/linux/fs.h
index 4f6f59b4f22a..a3691c132b3a 100644
--- a/include/linux/fs.h
+++ b/include/linux/fs.h
@@ -3363,8 +3363,14 @@ struct tree_descr { const char *name; const struct file_operations *ops; int mod
struct dentry *d_alloc_name(struct dentry *, const char *);
extern int simple_fill_super(struct super_block *, unsigned long,
const struct tree_descr *);
-extern int simple_pin_fs(struct file_system_type *, struct vfsmount **mount, int *count);
-extern void simple_release_fs(struct vfsmount **mount, int *count);
+
+struct simple_fs {
+ struct vfsmount *mount;
+ int count;
+};
+
+extern int simple_pin_fs(struct simple_fs *, struct file_system_type *);
+extern void simple_release_fs(struct simple_fs *);
extern ssize_t simple_read_from_buffer(void __user *to, size_t count,
loff_t *ppos, const void *from, size_t available);
diff --git a/security/apparmor/apparmorfs.c b/security/apparmor/apparmorfs.c
index 36f848734902..00f0158fb1e1 100644
--- a/security/apparmor/apparmorfs.c
+++ b/security/apparmor/apparmorfs.c
@@ -140,8 +140,7 @@ static int mangle_name(const char *name, char *target)
*/
#define AAFS_NAME "apparmorfs"
-static struct vfsmount *aafs_mnt;
-static int aafs_count;
+static struct simple_fs aafs;
static int aafs_show_path(struct seq_file *seq, struct dentry *dentry)
@@ -273,7 +272,7 @@ static struct dentry *aafs_create(const char *name, umode_t mode,
if (!(mode & S_IFMT))
mode = (mode & S_IALLUGO) | S_IFREG;
- error = simple_pin_fs(&aafs_ops, &aafs_mnt, &aafs_count);
+ error = simple_pin_fs(&aafs, &aafs_ops);
if (error)
return ERR_PTR(error);
@@ -303,7 +302,7 @@ static struct dentry *aafs_create(const char *name, umode_t mode,
fail_lock:
inode_unlock(dir);
- simple_release_fs(&aafs_mnt, &aafs_count);
+ simple_release_fs(&aafs);
return ERR_PTR(error);
}
@@ -395,7 +394,7 @@ static void aafs_remove(struct dentry *dentry)
dput(dentry);
}
inode_unlock(dir);
- simple_release_fs(&aafs_mnt, &aafs_count);
+ simple_release_fs(&aafs);
}
@@ -1824,7 +1823,7 @@ static int ns_mkdir_op(struct inode *dir, struct dentry *dentry, umode_t mode)
* for pin_fs
*/
inode_unlock(dir);
- error = simple_pin_fs(&aafs_ops, &aafs_mnt, &aafs_count);
+ error = simple_pin_fs(&aafs, &aafs_ops);
mutex_lock_nested(&parent->lock, parent->level);
inode_lock_nested(dir, I_MUTEX_PARENT);
if (error)
@@ -1845,7 +1844,7 @@ static int ns_mkdir_op(struct inode *dir, struct dentry *dentry, umode_t mode)
aa_put_ns(ns); /* list ref remains */
out_pin:
if (error)
- simple_release_fs(&aafs_mnt, &aafs_count);
+ simple_release_fs(&aafs);
out:
mutex_unlock(&parent->lock);
aa_put_ns(parent);
@@ -2580,7 +2579,7 @@ static const char *policy_get_link(struct dentry *dentry,
return ERR_PTR(-ECHILD);
ns = aa_get_current_ns();
- path.mnt = mntget(aafs_mnt);
+ path.mnt = mntget(aafs.mount);
path.dentry = dget(ns_dir(ns));
error = nd_jump_link(&path);
aa_put_ns(ns);
@@ -2631,10 +2630,10 @@ static int __init aa_create_aafs(void)
}
/* setup apparmorfs used to virtualize policy/ */
- aafs_mnt = kern_mount(&aafs_ops);
- if (IS_ERR(aafs_mnt))
+ aafs.mount = kern_mount(&aafs_ops);
+ if (IS_ERR(aafs.mount))
panic("can't set apparmorfs up\n");
- aafs_mnt->mnt_sb->s_flags &= ~SB_NOUSER;
+ aafs.mount->mnt_sb->s_flags &= ~SB_NOUSER;
/* Populate fs tree. */
error = entry_create_dir(&aa_sfs_entry, NULL);
@@ -2667,8 +2666,8 @@ static int __init aa_create_aafs(void)
/* policy tree referenced by magic policy symlink */
mutex_lock_nested(&root_ns->lock, root_ns->level);
- error = __aafs_ns_mkdir(root_ns, aafs_mnt->mnt_root, ".policy",
- aafs_mnt->mnt_root);
+ error = __aafs_ns_mkdir(root_ns, aafs.mount->mnt_root, ".policy",
+ aafs.mount->mnt_root);
mutex_unlock(&root_ns->lock);
if (error)
goto error;
diff --git a/security/inode.c b/security/inode.c
index 6c326939750d..8a1bee35470a 100644
--- a/security/inode.c
+++ b/security/inode.c
@@ -22,8 +22,7 @@
#include <linux/lsm_hooks.h>
#include <linux/magic.h>
-static struct vfsmount *mount;
-static int mount_count;
+static struct simple_fs securityfs;
static void securityfs_free_inode(struct inode *inode)
{
@@ -118,12 +117,12 @@ static struct dentry *securityfs_create_dentry(const char *name, umode_t mode,
pr_debug("securityfs: creating file '%s'\n",name);
- error = simple_pin_fs(&fs_type, &mount, &mount_count);
+ error = simple_pin_fs(&securityfs, &fs_type);
if (error)
return ERR_PTR(error);
if (!parent)
- parent = mount->mnt_root;
+ parent = securityfs.mount->mnt_root;
dir = d_inode(parent);
@@ -168,7 +167,7 @@ static struct dentry *securityfs_create_dentry(const char *name, umode_t mode,
dentry = ERR_PTR(error);
out:
inode_unlock(dir);
- simple_release_fs(&mount, &mount_count);
+ simple_release_fs(&securityfs);
return dentry;
}
@@ -309,7 +308,7 @@ void securityfs_remove(struct dentry *dentry)
dput(dentry);
}
inode_unlock(dir);
- simple_release_fs(&mount, &mount_count);
+ simple_release_fs(&securityfs);
}
EXPORT_SYMBOL_GPL(securityfs_remove);
--
2.25.2
^ permalink raw reply related
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox