All of lore.kernel.org
 help / color / mirror / Atom feed
* Re: [PATCH 09/12] multipathd: merge uevents before proccessing
From: tang.junhui @ 2017-01-04  3:29 UTC (permalink / raw)
  To: Benjamin Marzinski
  Cc: bart.vanassche, dm-devel, mwilck, tang.wenjun3, zhang.kai16
In-Reply-To: <20170104003049.GF2732@octiron.msp.redhat.com>


[-- Attachment #1.1: Type: text/plain, Size: 8198 bytes --]

Hello Ben,

Yes, a *_safe list traversal method can meet the needs,
I will modify it and simplify the codes.

Thanks,
Tang Junhui




发件人:         "Benjamin Marzinski" <bmarzins@redhat.com>
收件人:         tang.junhui@zte.com.cn, 
抄送:   tang.wenjun3@zte.com.cn, zhang.kai16@zte.com.cn, 
dm-devel@redhat.com, bart.vanassche@sandisk.com, mwilck@suse.com
日期:   2017/01/04 08:39
主题:   Re: [dm-devel] [PATCH 09/12] multipathd: merge uevents before 
proccessing
发件人: dm-devel-bounces@redhat.com



On Tue, Dec 27, 2016 at 04:03:26PM +0800, tang.junhui@zte.com.cn wrote:
> From: tang.junhui <tang.junhui@zte.com.cn>
> 
> These uevents are going to be merged:
> 1) uevents come from paths and
> 2) uevents type is same and
> 3) uevents type is addition or deletion and
> 4) uevents wwid is same.

This is just a nit, and I might be missing something subtle here, but it
seems like instead of adding list_for_some_entry_reverse, and then
breaking the abstraction to manually get previous entries, you could
have just added list_for_some_entry_reverse_safe in your earlier patch,
and hid the work of traversing a list while removing elements behind the
well understood abstraction of a *_safe list traversal method.

-Ben

> 
> Change-Id: I05ee057391c092aa0c5f989b7a4f9cb550bb4d98
> Signed-off-by: tang.junhui <tang.junhui@zte.com.cn>
> ---
>  libmultipath/uevent.c | 125 
+++++++++++++++++++++++++++++++++++++++++++++-----
>  1 file changed, 114 insertions(+), 11 deletions(-)
> 
> diff --git a/libmultipath/uevent.c b/libmultipath/uevent.c
> index b0b05e9..114068c 100644
> --- a/libmultipath/uevent.c
> +++ b/libmultipath/uevent.c
> @@ -85,6 +85,20 @@ struct uevent * alloc_uevent (void)
>                return uev;
>  }
> 
> +void
> +uevq_cleanup(struct list_head *tmpq)
> +{
> +              struct uevent *uev, *tmp;
> +
> +              list_for_each_entry_safe(uev, tmp, tmpq, node) {
> +                              list_del_init(&uev->node);
> +
> +                              if (uev->udev)
> + udev_device_unref(uev->udev);
> +                              FREE(uev);
> +              }
> +}
> +
>  bool
>  uevent_can_discard(char *devpath, char *kernel)
>  {
> @@ -125,6 +139,103 @@ uevent_can_discard(char *devpath, char *kernel)
>                return false;
>  }
> 
> +bool
> +merge_need_stop(struct uevent *earlier, struct uevent *later)
> +{
> +              /*
> +               * dm uevent do not try to merge with left uevents
> +               */
> +              if (!strncmp(later->kernel, "dm-", 3))
> +                              return true;
> +
> +              /*
> +               * we can not make a jugement without wwid,
> +               * so it is sensible to stop merging
> +               */
> +              if (!earlier->wwid || !later->wwid)
> +                              return true;
> +              /*
> +               * uevents merging stoped
> +               * when we meet an opposite action uevent from the same 
LUN to AVOID
> +               * "add path1 |remove path1 |add path2 |remove path2 |add 
path3"
> +               * to merge as "remove path1, path2" and "add path1, 
path2, path3"
> +               * OR
> +               * "remove path1 |add path1 |remove path2 |add path2 
|remove path3"
> +               * to merge as "add path1, path2" and "remove path1, 
path2, path3"
> +               * SO
> +               * when we meet a non-change uevent from the same LUN
> +               * with the same wwid and different action
> +               * it would be better to stop merging.
> +               */
> +              if (!strcmp(earlier->wwid, later->wwid) &&
> +                  strcmp(earlier->action, later->action) &&
> +                  strcmp(earlier->action, "change") &&
> +                  strcmp(later->action, "change"))
> +                              return true;
> +
> +              return false;
> +}
> +
> +bool
> +uevent_can_merge(struct uevent *earlier, struct uevent *later)
> +{
> +              /* merge paths uevents
> +               * whose wwids exsit and are same
> +               * and actions are same,
> +               * and actions are addition or deletion
> +               */
> +              if (earlier->wwid && later->wwid &&
> +                  !strcmp(earlier->wwid, later->wwid) &&
> +                  !strcmp(earlier->action, later->action) &&
> +                  strncmp(earlier->action, "change", 6) &&
> +                  strncmp(earlier->kernel, "dm-", 3)) {
> +                              return true;
> +              }
> +
> +              return false;
> +}
> +
> +void
> +uevent_merge(struct uevent *later, struct list_head *tmpq)
> +{
> +              struct uevent *earlier, *temp;
> +              /*
> +               * compare the uevent with earlier uevents
> +               */
> +              list_for_some_entry_reverse(earlier, &later->node, tmpq, 
node) {
> +next_earlier_node:
> +                              if (merge_need_stop(earlier, later))
> +                                              break;
> +                              /*
> +                               * try to merge earlier uevents to the 
later uevent
> +                               */
> +                              if (uevent_can_merge(earlier, later)) {
> +                                              condlog(3, "merged 
uevent: %s-%s-%s with uevent: %s-%s-%s",
> + earlier->action, earlier->kernel, earlier->wwid,
> + later->action, later->kernel, later->wwid);
> +                                              temp = earlier;
> +
> +                                              earlier = 
list_entry(earlier->node.prev, typeof(struct uevent), node);
> +                                              list_move(&temp->node, 
&later->merge_node);
> +
> +                                              if (earlier == 
list_entry(tmpq, typeof(struct uevent), node))
> +                                                              break;
> +                                              else
> +                                                              goto 
next_earlier_node;
> +                              }
> +              }
> +}
> +
> +void
> +merge_uevq(struct list_head *tmpq)
> +{
> +              struct uevent *later;
> +
> +              list_for_each_entry_reverse(later, tmpq, node) {
> +                              uevent_merge(later, tmpq);
> +              }
> +}
> +
>  void
>  service_uevq(struct list_head *tmpq)
>  {
> @@ -136,6 +247,8 @@ service_uevq(struct list_head *tmpq)
>                                if (my_uev_trigger && my_uev_trigger(uev, 
my_trigger_data))
>                                                condlog(0, "uevent 
trigger error");
> 
> +                              uevq_cleanup(&uev->merge_node);
> +
>                                if (uev->udev)
> udev_device_unref(uev->udev);
>                                FREE(uev);
> @@ -150,17 +263,6 @@ static void uevent_cleanup(void *arg)
>                udev_unref(udev);
>  }
> 
> -void
> -uevq_cleanup(struct list_head *tmpq)
> -{
> -              struct uevent *uev, *tmp;
> -
> -              list_for_each_entry_safe(uev, tmp, tmpq, node) {
> -                              list_del_init(&uev->node);
> -                              FREE(uev);
> -              }
> -}
> -
>  /*
>   * Service the uevent queue.
>   */
> @@ -189,6 +291,7 @@ int uevent_dispatch(int (*uev_trigger)(struct uevent 
*, void * trigger_data),
>                                pthread_mutex_unlock(uevq_lockp);
>                                if (!my_uev_trigger)
>                                                break;
> +                              merge_uevq(&uevq_tmp);
>                                service_uevq(&uevq_tmp);
>                }
>                condlog(3, "Terminating uev service queue");
> -- 
> 2.8.1.windows.1
> 

--
dm-devel mailing list
dm-devel@redhat.com
https://www.redhat.com/mailman/listinfo/dm-devel




[-- Attachment #1.2: Type: text/html, Size: 18559 bytes --]

[-- Attachment #2: Type: text/plain, Size: 0 bytes --]



^ permalink raw reply

* Re: [RFC PATCH] virtio_net: XDP support for adjust_head
From: Jason Wang @ 2017-01-04  3:21 UTC (permalink / raw)
  To: John Fastabend, mst; +Cc: john.r.fastabend, netdev, alexei.starovoitov, daniel
In-Reply-To: <586BD734.7020105@gmail.com>



On 2017年01月04日 00:54, John Fastabend wrote:
>>> +    /* Changing the headroom in buffers is a disruptive operation because
>>> +     * existing buffers must be flushed and reallocated. This will happen
>>> +     * when a xdp program is initially added or xdp is disabled by removing
>>> +     * the xdp program.
>>> +     */
>> We probably need reset the device here, but maybe Michale has more ideas. And if
>> we do this, another interesting thing to do is to disable EWMA and always use a
>> single page for each packet, this could almost eliminate linearizing.
> Well with normal MTU 1500 size we should not hit the linearizing case right?

My reply may be not clear, for 1500 I mean for small buffer only.

Thanks

>   The
> question is should we cap the MTU at GOOD_PACKET_LEN vs the current cap of
> (PAGE_SIZE - overhead).
>

^ permalink raw reply

* [PATCH perf/core 0/3] perf-probe: Fix offline module and cross-arch support
From: Masami Hiramatsu @ 2017-01-04  3:27 UTC (permalink / raw)
  To: Arnaldo Carvalho de Melo
  Cc: Masami Hiramatsu, linux-kernel, Jiri Olsa, Peter Zijlstra,
	Ingo Molnar, Namhyung Kim

Hello,

This series fixes some issues on offline module/cross-arch
probe support. While I was debuging arm32 kernel with
cross-arch perf-probe, I found several issues.

- perf-probe didn't show correct probe definition on
  gcc-generated symbols (on both of kernel and module).
- perf-probe didn't show available functions for offline
  module even if full path of the module was given.

This series fixes those issues.

---

Masami Hiramatsu (3):
      perf-probe: Fix --funcs to show correct symbols for offline module
      perf-probe: Fix to probe on gcc generated symbols for offline kernel
      perf-probe: Fix to probe on gcc generated functions in modules


 tools/perf/util/probe-event.c  |  111 +++++++++++++++++++++++++++-------------
 tools/perf/util/probe-finder.c |    2 -
 tools/perf/util/probe-finder.h |    2 +
 3 files changed, 79 insertions(+), 36 deletions(-)

--
Masami Hiramatsu (Linaro)

^ permalink raw reply

* Re: [PATCH] generic/158,304: filter dedupe error message
From: Eryu Guan @ 2017-01-04  3:27 UTC (permalink / raw)
  To: Darrick J. Wong; +Cc: fstests, linux-xfs
In-Reply-To: <20170103200149.GB14031@birch.djwong.org>

On Tue, Jan 03, 2017 at 12:01:49PM -0800, Darrick J. Wong wrote:
> On Fri, Dec 30, 2016 at 12:08:54PM +0800, Eryu Guan wrote:
> > Kernel commit 22725ce4e4a0 ("vfs: fix isize/pos/len checks for reflink &
> > dedupe") added more checks on reflink and dedupe, rejected dedupe past
> > EOF early and explicitly, and causes generic/158 and generic/304 to fail.
> > 
> >   Try dedupe from past EOF
> >  -dedupe: Invalid argument
> >  +XFS_IOC_FILE_EXTENT_SAME: Invalid argument
> >   Try dedupe to past EOF, destination offset beyond EOF
> > 
> > Fix it by replacing fs-specific ioctl in error message to "dedupe".
> > 
> > Signed-off-by: Eryu Guan <eguan@redhat.com>
> > ---
> >  common/reflink        | 7 +++++++
> >  tests/generic/158     | 7 +++++--
> >  tests/generic/158.out | 4 ++--
> >  tests/generic/304     | 9 ++++++---
> >  tests/generic/304.out | 2 +-
> >  5 files changed, 21 insertions(+), 8 deletions(-)
> > 
> > diff --git a/common/reflink b/common/reflink
> > index 64ee04f..7306efd 100644
> > --- a/common/reflink
> > +++ b/common/reflink
> > @@ -241,6 +241,13 @@ _dedupe_range() {
> >  	$XFS_IO_PROG $xfs_io_args -f -c "dedupe $file1 $offset1 $offset2 $len" "$file2"
> >  }
> >  
> > +# Filter fs-specific ioctl in error message to "dedupe"
> > +# e.g. replace XFS_IOC_FILE_EXTENT_SAME with dedupe
> > +_filter_dedupe()
> > +{
> > +	sed -e 's/XFS_IOC_FILE_EXTENT_SAME/dedupe/g'
> > +}
> 
> I sent a patch to the xfs list last month ("xfs_io: prefix dedupe
> command error messages consistently") changing all the error message
> prefixes to "XFS_IOC_FILE_EXTENT_SAME".  Was going to send a patch to
> fix up xfstests too... but evidently didn't.

Ah, didn't notict that patch.. Or I did saw the patch but failed to link
it with this test failure :)

> 
> If you change the sed command to 's/dedupe:/XFS_IOC_FILE_EXTENT_SAME:/g'
> that'll suffice, I think.

Will do. Thanks!

Eryu

^ permalink raw reply

* Re: [Qemu-devel] vhost-user breaks after 96a3d98.
From: Jason Wang @ 2017-01-04  3:26 UTC (permalink / raw)
  To: Michael S. Tsirkin; +Cc: Flavio Leitner, qemu-devel
In-Reply-To: <20170103182332-mutt-send-email-mst@kernel.org>



On 2017年01月04日 00:27, Michael S. Tsirkin wrote:
> On Tue, Jan 03, 2017 at 06:28:18PM +0800, Jason Wang wrote:
>>
>> On 2017年01月03日 11:09, Jason Wang wrote:
>>>
>>> On 2016年12月30日 20:41, Flavio Leitner wrote:
>>>> Hi,
>>>>
>>>> While I was testing vhost-user using OVS 2.5 and DPDK 2.2.0 in the
>>>> host and testpmd dpdk 2.2.0 in the guest, I found that the commit
>>>> below breaks the environment and no packets gets into the guest.
>>>>
>>>> dpdk port --> OVS --> vhost-user --> guest --> testpmd
>>>>                            ^--- drops here         ^--- no packets here.
>>>>
>>>> commit 96a3d98d2cdbd897ff5ab33427aa4cfb94077665
>>>> Author: Jason Wang <jasowang@redhat.com>
>>>> Date:   Mon Aug 1 16:07:58 2016 +0800
>>>>
>>>>       vhost: don't set vring call if no vector
>>>>            We used to set vring call fd unconditionally even if guest
>>>> driver does
>>>>       not use MSIX for this vritqueue at all. This will cause lots of
>>>>       unnecessary userspace access and other checks for drivers does
>>>> not use
>>>>       interrupt at all (e.g virtio-net pmd). So check and clean vring
>>>> call
>>>>       fd if guest does not use any vector for this virtqueue at
>>>>       all.
>>>> [...]
>>>>
>>>> Thanks,
>>> Hi Flavio:
>>>
>>> Thanks for reporting this issue, could this be a bug of vhost-user? (I
>>> believe virito-net pmd does not use interrupt for rx/tx at all)
>>>
>>> Anyway, will try to reproduce it.
>>>
>> Could not reproduce this issue on similar setups (the only difference is I
>> don't create dpdk port) with dpdk 16.11 and ovs.git HEAD. Suspect an issue
>> dpdk. Will try OVS 2.5 + DPDK 2.2.0.
>>
>> Thanks
> Possibly dpdk assumed that call fd must be present unconditionally.
> Limit this patch to when protocol is updated? add a new protocol flag?

If this is a bug of dpdk, I tend to fix it (or just disable this patch 
for vhost-user). I'm not sure whether or not it's worthwhile to add a 
new protocol flag which was used to tell qemu that bug X was fixed.

Thanks

^ permalink raw reply

* Re: [PATCH] radv: Initial implementation of VK_EXT_queue_global_priority
From: Andres Rodriguez @ 2017-01-04  3:26 UTC (permalink / raw)
  To: amd-gfx list
In-Reply-To: <20170104022229.7747-1-andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>


[-- Attachment #1.1: Type: text/plain, Size: 1334 bytes --]

Hey Guys,

One of my first non-trivial contributions to mesa here. Let me know if I've
messed up anything, bad coding style or some patch validation script I
should've run or any other kind of pitfall a newbie might make.

I tried to follow the guidelines over at:
http://www.mesa3d.org/devinfo.html

Although some of them seen to not apply anymore (radv code was tabs instead
of 3 spaces).

Thanks for taking the time to review :)

Regards,
Andres


On Tue, Jan 3, 2017 at 9:22 PM, Andres Rodriguez <andresx7-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:

> This patch series implements VK_EXT_queue_global_priority, a vulkan
> extension
> that focuses on providing scheduling guarantees.
>
> For further information on the use case refer to:
> https://lists.freedesktop.org/archives/amd-gfx/2016-December/004068.html
>
> For some perf data on this initial implementation:
> https://lists.freedesktop.org/archives/amd-gfx/2016-December/004257.html
>
> Test apps available at:
> https://github.com/lostgoat/Vulkan
>
> Related amdgpu and libdrm_amdgpu patches can be found on the amd-gfx
> mailing list.
>
> Additionaly, results for vk-cts -n *semaphore* on an RX480:
>
> Test run totals:
>   Passed:        1821/4046 (45.0%)
>   Failed:        0/4046 (0.0%)
>   Not supported: 2225/4046 (55.0%)
>   Warnings:      0/4046 (0.0%)
>
>

[-- Attachment #1.2: Type: text/html, Size: 2263 bytes --]

[-- Attachment #2: Type: text/plain, Size: 154 bytes --]

_______________________________________________
amd-gfx mailing list
amd-gfx@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/amd-gfx

^ permalink raw reply

* Re: [PATCH 02/10] f2fs: fix wrong tracepoints for op and op_flags
From: Chao Yu @ 2017-01-04  3:25 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel
In-Reply-To: <20161230185117.3832-2-jaegeuk@kernel.org>

On 2016/12/31 2:51, Jaegeuk Kim wrote:
> This patch fixes wrong tracepoints in terms of op and op_flags.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>


------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most 
engaging tech sites, SlashDot.org! http://sdm.link/slashdot

^ permalink raw reply

* Re: [f2fs-dev] [PATCH 02/10] f2fs: fix wrong tracepoints for op and op_flags
From: Chao Yu @ 2017-01-04  3:25 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel
In-Reply-To: <20161230185117.3832-2-jaegeuk@kernel.org>

On 2016/12/31 2:51, Jaegeuk Kim wrote:
> This patch fixes wrong tracepoints in terms of op and op_flags.
> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>

Reviewed-by: Chao Yu <yuchao0@huawei.com>


^ permalink raw reply

* [PATCH 4/4] watchdog: coh901327_wdt: Use dev variable instead of pdev->dev
From: Guenter Roeck @ 2017-01-04  3:25 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Wim Van Sebroeck, linux-arm-kernel, linux-watchdog, linux-kernel,
	Guenter Roeck
In-Reply-To: <1483500343-27113-1-git-send-email-linux@roeck-us.net>

Use a local dev variable instead of dereferencing pdev->dev several
times in the probe function to make the code easier to read.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/coh901327_wdt.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index 986222efe174..38dd60f0cfcc 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -251,60 +251,56 @@ static int __exit coh901327_remove(struct platform_device *pdev)
 
 static int __init coh901327_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	int ret;
 	u16 val;
 	struct resource *res;
 
-	parent = &pdev->dev;
+	parent = dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	virtbase = devm_ioremap_resource(&pdev->dev, res);
+	virtbase = devm_ioremap_resource(dev, res);
 	if (IS_ERR(virtbase))
 		return PTR_ERR(virtbase);
 
-	clk = clk_get(&pdev->dev, NULL);
+	clk = clk_get(dev, NULL);
 	if (IS_ERR(clk)) {
 		ret = PTR_ERR(clk);
-		dev_err(&pdev->dev, "could not get clock\n");
+		dev_err(dev, "could not get clock\n");
 		return ret;
 	}
 	ret = clk_prepare_enable(clk);
 	if (ret) {
-		dev_err(&pdev->dev, "could not prepare and enable clock\n");
+		dev_err(dev, "could not prepare and enable clock\n");
 		goto out_no_clk_enable;
 	}
 
 	val = readw(virtbase + U300_WDOG_SR);
 	switch (val) {
 	case U300_WDOG_SR_STATUS_TIMED_OUT:
-		dev_info(&pdev->dev,
-			"watchdog timed out since last chip reset!\n");
+		dev_info(dev, "watchdog timed out since last chip reset!\n");
 		coh901327_wdt.bootstatus |= WDIOF_CARDRESET;
 		/* Status will be cleared below */
 		break;
 	case U300_WDOG_SR_STATUS_NORMAL:
-		dev_info(&pdev->dev,
-			"in normal status, no timeouts have occurred.\n");
+		dev_info(dev, "in normal status, no timeouts have occurred.\n");
 		break;
 	default:
-		dev_info(&pdev->dev,
-			"contains an illegal status code (%08x)\n", val);
+		dev_info(dev, "contains an illegal status code (%08x)\n", val);
 		break;
 	}
 
 	val = readw(virtbase + U300_WDOG_D2R);
 	switch (val) {
 	case U300_WDOG_D2R_DISABLE_STATUS_DISABLED:
-		dev_info(&pdev->dev, "currently disabled.\n");
+		dev_info(dev, "currently disabled.\n");
 		break;
 	case U300_WDOG_D2R_DISABLE_STATUS_ENABLED:
-		dev_info(&pdev->dev,
-			 "currently enabled! (disabling it now)\n");
+		dev_info(dev, "currently enabled! (disabling it now)\n");
 		coh901327_disable();
 		break;
 	default:
-		dev_err(&pdev->dev,
-			"contains an illegal enable/disable code (%08x)\n",
+		dev_err(dev, "contains an illegal enable/disable code (%08x)\n",
 			val);
 		break;
 	}
@@ -319,16 +315,16 @@ static int __init coh901327_probe(struct platform_device *pdev)
 		goto out_no_irq;
 	}
 
-	ret = watchdog_init_timeout(&coh901327_wdt, margin, &pdev->dev);
+	ret = watchdog_init_timeout(&coh901327_wdt, margin, dev);
 	if (ret < 0)
 		coh901327_wdt.timeout = 60;
 
-	coh901327_wdt.parent = &pdev->dev;
+	coh901327_wdt.parent = dev;
 	ret = watchdog_register_device(&coh901327_wdt);
 	if (ret)
 		goto out_no_wdog;
 
-	dev_info(&pdev->dev, "initialized. timer margin=%d sec\n", margin);
+	dev_info(dev, "initialized. timer margin=%d sec\n", margin);
 	return 0;
 
 out_no_wdog:
-- 
2.7.4


^ permalink raw reply related

* [PATCH 4/4] watchdog: coh901327_wdt: Use dev variable instead of pdev->dev
From: Guenter Roeck @ 2017-01-04  3:25 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1483500343-27113-1-git-send-email-linux@roeck-us.net>

Use a local dev variable instead of dereferencing pdev->dev several
times in the probe function to make the code easier to read.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/coh901327_wdt.c | 34 +++++++++++++++-------------------
 1 file changed, 15 insertions(+), 19 deletions(-)

diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index 986222efe174..38dd60f0cfcc 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -251,60 +251,56 @@ static int __exit coh901327_remove(struct platform_device *pdev)
 
 static int __init coh901327_probe(struct platform_device *pdev)
 {
+	struct device *dev = &pdev->dev;
 	int ret;
 	u16 val;
 	struct resource *res;
 
-	parent = &pdev->dev;
+	parent = dev;
 
 	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	virtbase = devm_ioremap_resource(&pdev->dev, res);
+	virtbase = devm_ioremap_resource(dev, res);
 	if (IS_ERR(virtbase))
 		return PTR_ERR(virtbase);
 
-	clk = clk_get(&pdev->dev, NULL);
+	clk = clk_get(dev, NULL);
 	if (IS_ERR(clk)) {
 		ret = PTR_ERR(clk);
-		dev_err(&pdev->dev, "could not get clock\n");
+		dev_err(dev, "could not get clock\n");
 		return ret;
 	}
 	ret = clk_prepare_enable(clk);
 	if (ret) {
-		dev_err(&pdev->dev, "could not prepare and enable clock\n");
+		dev_err(dev, "could not prepare and enable clock\n");
 		goto out_no_clk_enable;
 	}
 
 	val = readw(virtbase + U300_WDOG_SR);
 	switch (val) {
 	case U300_WDOG_SR_STATUS_TIMED_OUT:
-		dev_info(&pdev->dev,
-			"watchdog timed out since last chip reset!\n");
+		dev_info(dev, "watchdog timed out since last chip reset!\n");
 		coh901327_wdt.bootstatus |= WDIOF_CARDRESET;
 		/* Status will be cleared below */
 		break;
 	case U300_WDOG_SR_STATUS_NORMAL:
-		dev_info(&pdev->dev,
-			"in normal status, no timeouts have occurred.\n");
+		dev_info(dev, "in normal status, no timeouts have occurred.\n");
 		break;
 	default:
-		dev_info(&pdev->dev,
-			"contains an illegal status code (%08x)\n", val);
+		dev_info(dev, "contains an illegal status code (%08x)\n", val);
 		break;
 	}
 
 	val = readw(virtbase + U300_WDOG_D2R);
 	switch (val) {
 	case U300_WDOG_D2R_DISABLE_STATUS_DISABLED:
-		dev_info(&pdev->dev, "currently disabled.\n");
+		dev_info(dev, "currently disabled.\n");
 		break;
 	case U300_WDOG_D2R_DISABLE_STATUS_ENABLED:
-		dev_info(&pdev->dev,
-			 "currently enabled! (disabling it now)\n");
+		dev_info(dev, "currently enabled! (disabling it now)\n");
 		coh901327_disable();
 		break;
 	default:
-		dev_err(&pdev->dev,
-			"contains an illegal enable/disable code (%08x)\n",
+		dev_err(dev, "contains an illegal enable/disable code (%08x)\n",
 			val);
 		break;
 	}
@@ -319,16 +315,16 @@ static int __init coh901327_probe(struct platform_device *pdev)
 		goto out_no_irq;
 	}
 
-	ret = watchdog_init_timeout(&coh901327_wdt, margin, &pdev->dev);
+	ret = watchdog_init_timeout(&coh901327_wdt, margin, dev);
 	if (ret < 0)
 		coh901327_wdt.timeout = 60;
 
-	coh901327_wdt.parent = &pdev->dev;
+	coh901327_wdt.parent = dev;
 	ret = watchdog_register_device(&coh901327_wdt);
 	if (ret)
 		goto out_no_wdog;
 
-	dev_info(&pdev->dev, "initialized. timer margin=%d sec\n", margin);
+	dev_info(dev, "initialized. timer margin=%d sec\n", margin);
 	return 0;
 
 out_no_wdog:
-- 
2.7.4

^ permalink raw reply related

* [PATCH 3/4] watchdog: coh901327_wdt: Use devm_ioremap_resource to map resources
From: Guenter Roeck @ 2017-01-04  3:25 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1483500343-27113-1-git-send-email-linux@roeck-us.net>

Map resources using devm_ioremap_resource() to simplify error handling.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/coh901327_wdt.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index 1385a920df4f..986222efe174 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -68,8 +68,6 @@
 
 /* Default timeout in seconds = 1 minute */
 static unsigned int margin = 60;
-static resource_size_t phybase;
-static resource_size_t physize;
 static int irq;
 static void __iomem *virtbase;
 static struct device *parent;
@@ -248,8 +246,6 @@ static int __exit coh901327_remove(struct platform_device *pdev)
 	free_irq(irq, pdev);
 	clk_disable_unprepare(clk);
 	clk_put(clk);
-	iounmap(virtbase);
-	release_mem_region(phybase, physize);
 	return 0;
 }
 
@@ -259,30 +255,18 @@ static int __init coh901327_probe(struct platform_device *pdev)
 	u16 val;
 	struct resource *res;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENOENT;
-
 	parent = &pdev->dev;
-	physize = resource_size(res);
-	phybase = res->start;
-
-	if (request_mem_region(phybase, physize, DRV_NAME) == NULL) {
-		ret = -EBUSY;
-		goto out;
-	}
 
-	virtbase = ioremap(phybase, physize);
-	if (!virtbase) {
-		ret = -ENOMEM;
-		goto out_no_remap;
-	}
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	virtbase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(virtbase))
+		return PTR_ERR(virtbase);
 
 	clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		ret = PTR_ERR(clk);
 		dev_err(&pdev->dev, "could not get clock\n");
-		goto out_no_clk;
+		return ret;
 	}
 	ret = clk_prepare_enable(clk);
 	if (ret) {
@@ -353,11 +337,6 @@ static int __init coh901327_probe(struct platform_device *pdev)
 	clk_disable_unprepare(clk);
 out_no_clk_enable:
 	clk_put(clk);
-out_no_clk:
-	iounmap(virtbase);
-out_no_remap:
-	release_mem_region(phybase, SZ_4K);
-out:
 	return ret;
 }
 
-- 
2.7.4

^ permalink raw reply related

* [PATCH 3/4] watchdog: coh901327_wdt: Use devm_ioremap_resource to map resources
From: Guenter Roeck @ 2017-01-04  3:25 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Wim Van Sebroeck, linux-arm-kernel, linux-watchdog, linux-kernel,
	Guenter Roeck
In-Reply-To: <1483500343-27113-1-git-send-email-linux@roeck-us.net>

Map resources using devm_ioremap_resource() to simplify error handling.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/coh901327_wdt.c | 31 +++++--------------------------
 1 file changed, 5 insertions(+), 26 deletions(-)

diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index 1385a920df4f..986222efe174 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -68,8 +68,6 @@
 
 /* Default timeout in seconds = 1 minute */
 static unsigned int margin = 60;
-static resource_size_t phybase;
-static resource_size_t physize;
 static int irq;
 static void __iomem *virtbase;
 static struct device *parent;
@@ -248,8 +246,6 @@ static int __exit coh901327_remove(struct platform_device *pdev)
 	free_irq(irq, pdev);
 	clk_disable_unprepare(clk);
 	clk_put(clk);
-	iounmap(virtbase);
-	release_mem_region(phybase, physize);
 	return 0;
 }
 
@@ -259,30 +255,18 @@ static int __init coh901327_probe(struct platform_device *pdev)
 	u16 val;
 	struct resource *res;
 
-	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
-	if (!res)
-		return -ENOENT;
-
 	parent = &pdev->dev;
-	physize = resource_size(res);
-	phybase = res->start;
-
-	if (request_mem_region(phybase, physize, DRV_NAME) == NULL) {
-		ret = -EBUSY;
-		goto out;
-	}
 
-	virtbase = ioremap(phybase, physize);
-	if (!virtbase) {
-		ret = -ENOMEM;
-		goto out_no_remap;
-	}
+	res = platform_get_resource(pdev, IORESOURCE_MEM, 0);
+	virtbase = devm_ioremap_resource(&pdev->dev, res);
+	if (IS_ERR(virtbase))
+		return PTR_ERR(virtbase);
 
 	clk = clk_get(&pdev->dev, NULL);
 	if (IS_ERR(clk)) {
 		ret = PTR_ERR(clk);
 		dev_err(&pdev->dev, "could not get clock\n");
-		goto out_no_clk;
+		return ret;
 	}
 	ret = clk_prepare_enable(clk);
 	if (ret) {
@@ -353,11 +337,6 @@ static int __init coh901327_probe(struct platform_device *pdev)
 	clk_disable_unprepare(clk);
 out_no_clk_enable:
 	clk_put(clk);
-out_no_clk:
-	iounmap(virtbase);
-out_no_remap:
-	release_mem_region(phybase, SZ_4K);
-out:
 	return ret;
 }
 
-- 
2.7.4

^ permalink raw reply related

* [PATCH 2/4] watchdog: coh901327_wdt: Keep clock enabled after loading driver
From: Guenter Roeck @ 2017-01-04  3:25 UTC (permalink / raw)
  To: linux-arm-kernel
In-Reply-To: <1483500343-27113-1-git-send-email-linux@roeck-us.net>

Enabling the clock before accessing chip registers and disabling it
afterwards does not really make sense and only adds complexity to
the driver. In addition to that, a comment int the driver suggests
that it does not serve a useful purpose either.

"The watchdog block is of course always clocked, the
 clk_enable()/clk_disable() calls are mainly for performing reference
 counting higher up in the clock hierarchy."

Just keep the clock enabled instead.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/coh901327_wdt.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index dc97b2fd6c49..1385a920df4f 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -74,11 +74,6 @@ static int irq;
 static void __iomem *virtbase;
 static struct device *parent;
 
-/*
- * The watchdog block is of course always clocked, the
- * clk_enable()/clk_disable() calls are mainly for performing reference
- * counting higher up in the clock hierarchy.
- */
 static struct clk *clk;
 
 /*
@@ -90,7 +85,6 @@ static void coh901327_enable(u16 timeout)
 	unsigned long freq;
 	unsigned long delay_ns;
 
-	clk_enable(clk);
 	/* Restart timer if it is disabled */
 	val = readw(virtbase + U300_WDOG_D2R);
 	if (val == U300_WDOG_D2R_DISABLE_STATUS_DISABLED)
@@ -118,7 +112,6 @@ static void coh901327_enable(u16 timeout)
 	 */
 	(void) readw(virtbase + U300_WDOG_CR);
 	val = readw(virtbase + U300_WDOG_D2R);
-	clk_disable(clk);
 	if (val != U300_WDOG_D2R_DISABLE_STATUS_ENABLED)
 		dev_err(parent,
 			"%s(): watchdog not enabled! D2R value %04x\n",
@@ -129,7 +122,6 @@ static void coh901327_disable(void)
 {
 	u16 val;
 
-	clk_enable(clk);
 	/* Disable the watchdog interrupt if it is active */
 	writew(0x0000U, virtbase + U300_WDOG_IMR);
 	/* If the watchdog is currently enabled, attempt to disable it */
@@ -144,7 +136,6 @@ static void coh901327_disable(void)
 		       virtbase + U300_WDOG_D2R);
 	}
 	val = readw(virtbase + U300_WDOG_D2R);
-	clk_disable(clk);
 	if (val != U300_WDOG_D2R_DISABLE_STATUS_DISABLED)
 		dev_err(parent,
 			"%s(): watchdog not disabled! D2R value %04x\n",
@@ -165,11 +156,9 @@ static int coh901327_stop(struct watchdog_device *wdt_dev)
 
 static int coh901327_ping(struct watchdog_device *wdd)
 {
-	clk_enable(clk);
 	/* Feed the watchdog */
 	writew(U300_WDOG_FR_FEED_RESTART_TIMER,
 	       virtbase + U300_WDOG_FR);
-	clk_disable(clk);
 	return 0;
 }
 
@@ -177,13 +166,11 @@ static int coh901327_settimeout(struct watchdog_device *wdt_dev,
 				unsigned int time)
 {
 	wdt_dev->timeout = time;
-	clk_enable(clk);
 	/* Set new timeout value */
 	writew(time * 100, virtbase + U300_WDOG_TR);
 	/* Feed the dog */
 	writew(U300_WDOG_FR_FEED_RESTART_TIMER,
 	       virtbase + U300_WDOG_FR);
-	clk_disable(clk);
 	return 0;
 }
 
@@ -191,13 +178,11 @@ static unsigned int coh901327_gettimeleft(struct watchdog_device *wdt_dev)
 {
 	u16 val;
 
-	clk_enable(clk);
 	/* Read repeatedly until the value is stable! */
 	val = readw(virtbase + U300_WDOG_CR);
 	while (val & U300_WDOG_CR_VALID_IND)
 		val = readw(virtbase + U300_WDOG_CR);
 	val &= U300_WDOG_CR_COUNT_VALUE_MASK;
-	clk_disable(clk);
 	if (val != 0)
 		val /= 100;
 
@@ -221,13 +206,11 @@ static irqreturn_t coh901327_interrupt(int irq, void *data)
 	 * to prevent a watchdog reset by feeding the watchdog at this
 	 * point.
 	 */
-	clk_enable(clk);
 	val = readw(virtbase + U300_WDOG_IER);
 	if (val == U300_WDOG_IER_WILL_BARK_IRQ_EVENT_IND)
 		writew(U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE,
 		       virtbase + U300_WDOG_IER);
 	writew(0x0000U, virtbase + U300_WDOG_IMR);
-	clk_disable(clk);
 	dev_crit(parent, "watchdog is barking!\n");
 	return IRQ_HANDLED;
 }
@@ -263,7 +246,7 @@ static int __exit coh901327_remove(struct platform_device *pdev)
 	watchdog_unregister_device(&coh901327_wdt);
 	coh901327_disable();
 	free_irq(irq, pdev);
-	clk_unprepare(clk);
+	clk_disable_unprepare(clk);
 	clk_put(clk);
 	iounmap(virtbase);
 	release_mem_region(phybase, physize);
@@ -352,8 +335,6 @@ static int __init coh901327_probe(struct platform_device *pdev)
 		goto out_no_irq;
 	}
 
-	clk_disable(clk);
-
 	ret = watchdog_init_timeout(&coh901327_wdt, margin, &pdev->dev);
 	if (ret < 0)
 		coh901327_wdt.timeout = 60;
-- 
2.7.4

^ permalink raw reply related

* [PATCH 2/4] watchdog: coh901327_wdt: Keep clock enabled after loading driver
From: Guenter Roeck @ 2017-01-04  3:25 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Wim Van Sebroeck, linux-arm-kernel, linux-watchdog, linux-kernel,
	Guenter Roeck
In-Reply-To: <1483500343-27113-1-git-send-email-linux@roeck-us.net>

Enabling the clock before accessing chip registers and disabling it
afterwards does not really make sense and only adds complexity to
the driver. In addition to that, a comment int the driver suggests
that it does not serve a useful purpose either.

"The watchdog block is of course always clocked, the
 clk_enable()/clk_disable() calls are mainly for performing reference
 counting higher up in the clock hierarchy."

Just keep the clock enabled instead.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/coh901327_wdt.c | 21 +--------------------
 1 file changed, 1 insertion(+), 20 deletions(-)

diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index dc97b2fd6c49..1385a920df4f 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -74,11 +74,6 @@ static int irq;
 static void __iomem *virtbase;
 static struct device *parent;
 
-/*
- * The watchdog block is of course always clocked, the
- * clk_enable()/clk_disable() calls are mainly for performing reference
- * counting higher up in the clock hierarchy.
- */
 static struct clk *clk;
 
 /*
@@ -90,7 +85,6 @@ static void coh901327_enable(u16 timeout)
 	unsigned long freq;
 	unsigned long delay_ns;
 
-	clk_enable(clk);
 	/* Restart timer if it is disabled */
 	val = readw(virtbase + U300_WDOG_D2R);
 	if (val == U300_WDOG_D2R_DISABLE_STATUS_DISABLED)
@@ -118,7 +112,6 @@ static void coh901327_enable(u16 timeout)
 	 */
 	(void) readw(virtbase + U300_WDOG_CR);
 	val = readw(virtbase + U300_WDOG_D2R);
-	clk_disable(clk);
 	if (val != U300_WDOG_D2R_DISABLE_STATUS_ENABLED)
 		dev_err(parent,
 			"%s(): watchdog not enabled! D2R value %04x\n",
@@ -129,7 +122,6 @@ static void coh901327_disable(void)
 {
 	u16 val;
 
-	clk_enable(clk);
 	/* Disable the watchdog interrupt if it is active */
 	writew(0x0000U, virtbase + U300_WDOG_IMR);
 	/* If the watchdog is currently enabled, attempt to disable it */
@@ -144,7 +136,6 @@ static void coh901327_disable(void)
 		       virtbase + U300_WDOG_D2R);
 	}
 	val = readw(virtbase + U300_WDOG_D2R);
-	clk_disable(clk);
 	if (val != U300_WDOG_D2R_DISABLE_STATUS_DISABLED)
 		dev_err(parent,
 			"%s(): watchdog not disabled! D2R value %04x\n",
@@ -165,11 +156,9 @@ static int coh901327_stop(struct watchdog_device *wdt_dev)
 
 static int coh901327_ping(struct watchdog_device *wdd)
 {
-	clk_enable(clk);
 	/* Feed the watchdog */
 	writew(U300_WDOG_FR_FEED_RESTART_TIMER,
 	       virtbase + U300_WDOG_FR);
-	clk_disable(clk);
 	return 0;
 }
 
@@ -177,13 +166,11 @@ static int coh901327_settimeout(struct watchdog_device *wdt_dev,
 				unsigned int time)
 {
 	wdt_dev->timeout = time;
-	clk_enable(clk);
 	/* Set new timeout value */
 	writew(time * 100, virtbase + U300_WDOG_TR);
 	/* Feed the dog */
 	writew(U300_WDOG_FR_FEED_RESTART_TIMER,
 	       virtbase + U300_WDOG_FR);
-	clk_disable(clk);
 	return 0;
 }
 
@@ -191,13 +178,11 @@ static unsigned int coh901327_gettimeleft(struct watchdog_device *wdt_dev)
 {
 	u16 val;
 
-	clk_enable(clk);
 	/* Read repeatedly until the value is stable! */
 	val = readw(virtbase + U300_WDOG_CR);
 	while (val & U300_WDOG_CR_VALID_IND)
 		val = readw(virtbase + U300_WDOG_CR);
 	val &= U300_WDOG_CR_COUNT_VALUE_MASK;
-	clk_disable(clk);
 	if (val != 0)
 		val /= 100;
 
@@ -221,13 +206,11 @@ static irqreturn_t coh901327_interrupt(int irq, void *data)
 	 * to prevent a watchdog reset by feeding the watchdog at this
 	 * point.
 	 */
-	clk_enable(clk);
 	val = readw(virtbase + U300_WDOG_IER);
 	if (val == U300_WDOG_IER_WILL_BARK_IRQ_EVENT_IND)
 		writew(U300_WDOG_IER_WILL_BARK_IRQ_ACK_ENABLE,
 		       virtbase + U300_WDOG_IER);
 	writew(0x0000U, virtbase + U300_WDOG_IMR);
-	clk_disable(clk);
 	dev_crit(parent, "watchdog is barking!\n");
 	return IRQ_HANDLED;
 }
@@ -263,7 +246,7 @@ static int __exit coh901327_remove(struct platform_device *pdev)
 	watchdog_unregister_device(&coh901327_wdt);
 	coh901327_disable();
 	free_irq(irq, pdev);
-	clk_unprepare(clk);
+	clk_disable_unprepare(clk);
 	clk_put(clk);
 	iounmap(virtbase);
 	release_mem_region(phybase, physize);
@@ -352,8 +335,6 @@ static int __init coh901327_probe(struct platform_device *pdev)
 		goto out_no_irq;
 	}
 
-	clk_disable(clk);
-
 	ret = watchdog_init_timeout(&coh901327_wdt, margin, &pdev->dev);
 	if (ret < 0)
 		coh901327_wdt.timeout = 60;
-- 
2.7.4

^ permalink raw reply related

* [PATCH 1/4] watchdog: coh901327_wdt: Simplify error handling in probe function
From: Guenter Roeck @ 2017-01-04  3:25 UTC (permalink / raw)
  To: linux-arm-kernel

Checking if there is no error followed by a goto if there is one is
confusing. Reverse the logic.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/coh901327_wdt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index a099b77fc0b9..dc97b2fd6c49 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -360,12 +360,10 @@ static int __init coh901327_probe(struct platform_device *pdev)
 
 	coh901327_wdt.parent = &pdev->dev;
 	ret = watchdog_register_device(&coh901327_wdt);
-	if (ret == 0)
-		dev_info(&pdev->dev,
-			 "initialized. timer margin=%d sec\n", margin);
-	else
+	if (ret)
 		goto out_no_wdog;
 
+	dev_info(&pdev->dev, "initialized. timer margin=%d sec\n", margin);
 	return 0;
 
 out_no_wdog:
-- 
2.7.4

^ permalink raw reply related

* [PATCH 1/4] watchdog: coh901327_wdt: Simplify error handling in probe function
From: Guenter Roeck @ 2017-01-04  3:25 UTC (permalink / raw)
  To: Linus Walleij
  Cc: Wim Van Sebroeck, linux-arm-kernel, linux-watchdog, linux-kernel,
	Guenter Roeck

Checking if there is no error followed by a goto if there is one is
confusing. Reverse the logic.

Signed-off-by: Guenter Roeck <linux@roeck-us.net>
---
 drivers/watchdog/coh901327_wdt.c | 6 ++----
 1 file changed, 2 insertions(+), 4 deletions(-)

diff --git a/drivers/watchdog/coh901327_wdt.c b/drivers/watchdog/coh901327_wdt.c
index a099b77fc0b9..dc97b2fd6c49 100644
--- a/drivers/watchdog/coh901327_wdt.c
+++ b/drivers/watchdog/coh901327_wdt.c
@@ -360,12 +360,10 @@ static int __init coh901327_probe(struct platform_device *pdev)
 
 	coh901327_wdt.parent = &pdev->dev;
 	ret = watchdog_register_device(&coh901327_wdt);
-	if (ret == 0)
-		dev_info(&pdev->dev,
-			 "initialized. timer margin=%d sec\n", margin);
-	else
+	if (ret)
 		goto out_no_wdog;
 
+	dev_info(&pdev->dev, "initialized. timer margin=%d sec\n", margin);
 	return 0;
 
 out_no_wdog:
-- 
2.7.4

^ permalink raw reply related

* Re: [f2fs-dev] [PATCH 01/10] f2fs: reassign new segment for mode=lfs
From: Chao Yu @ 2017-01-04  3:24 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel
In-Reply-To: <20161230185117.3832-1-jaegeuk@kernel.org>

Hi Jaegeuk,

On 2016/12/31 2:51, Jaegeuk Kim wrote:
> Otherwise we can remain wrong curseg->next_blkoff, resulting in fsck failure.

Could you explain more about this case?

Thanks,

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/segment.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index be9e4d244d75..4e5ffe1d97e4 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1428,9 +1428,6 @@ void allocate_new_segments(struct f2fs_sb_info *sbi)
>  	unsigned int old_segno;
>  	int i;
>  
> -	if (test_opt(sbi, LFS))
> -		return;
> -
>  	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
>  		curseg = CURSEG_I(sbi, i);
>  		old_segno = curseg->segno;
> 


^ permalink raw reply

* Re: [PATCH] ceph: set io_pages bdi hint
From: Yan, Zheng @ 2017-01-04  3:25 UTC (permalink / raw)
  To: Andreas Gerstmayr; +Cc: ceph-devel, andreas.gerstmayr, Sage Weil, Ilya Dryomov
In-Reply-To: <1483076488-2690-1-git-send-email-andreas.gerstmayr@catalysts.cc>


> On 30 Dec 2016, at 13:37, Andreas Gerstmayr <andreas.gerstmayr@catalysts.cc> wrote:
> 
> This patch sets the io_pages bdi hint based on the rsize mount option.
> Without this patch large buffered reads (request size > max readahead)
> are processed sequentially in chunks of the readahead size (i.e. read
> requests are sent out up to the readahead size, then the
> do_generic_file_read() function waits until the first page is received).
> 
> This patch removes this cap and enables parallel reads up to the
> specified maximum read size mount option (rsize).
> 
> Signed-off-by: Andreas Gerstmayr <andreas.gerstmayr@catalysts.cc>
> ---
> 
> Feedback is appreciated. Maybe we should apply a sensible default value
> for rsize instead of unlimited?
> 
> Please note: This patch depends on commit #9491ae4, which is not yet
> merged in the testing branch of the ceph-client repository (this commit
> is included in kernel version 4.10-rc1).
> 
> 
> fs/ceph/super.c | 7 +++++++
> 1 file changed, 7 insertions(+)
> 
> diff --git a/fs/ceph/super.c b/fs/ceph/super.c
> index 6bd20d7..3c50477 100644
> --- a/fs/ceph/super.c
> +++ b/fs/ceph/super.c
> @@ -952,6 +952,13 @@ static int ceph_register_bdi(struct super_block *sb,
> 		fsc->backing_dev_info.ra_pages =
> 			VM_MAX_READAHEAD * 1024 / PAGE_SIZE;
> 
> +	if (fsc->mount_options->rsize)
> +		fsc->backing_dev_info.io_pages =
> +			(fsc->mount_options->rsize + PAGE_SIZE - 1)
> +			>> PAGE_SHIFT;
> +	else
> +		fsc->backing_dev_info.io_pages = ULONG_MAX;
> +

unlimited by default does not seem like a good idea. I think we should set CEPH_RSIZE_DEFAULT to reasonable value (such as 64M)


Regards
Yan, Zheng

> 	err = bdi_register(&fsc->backing_dev_info, NULL, "ceph-%ld",
> 			   atomic_long_inc_return(&bdi_seq));
> 	if (!err)
> -- 
> 1.8.3.1
> 


^ permalink raw reply

* Re: [f2fs-dev] [PATCH 01/10] f2fs: reassign new segment for mode=lfs
From: Chao Yu @ 2017-01-04  3:24 UTC (permalink / raw)
  To: Jaegeuk Kim, linux-kernel, linux-fsdevel, linux-f2fs-devel
In-Reply-To: <20161230185117.3832-1-jaegeuk@kernel.org>

Hi Jaegeuk,

On 2016/12/31 2:51, Jaegeuk Kim wrote:
> Otherwise we can remain wrong curseg->next_blkoff, resulting in fsck failure.

Could you explain more about this case?

Thanks,

> 
> Signed-off-by: Jaegeuk Kim <jaegeuk@kernel.org>
> ---
>  fs/f2fs/segment.c | 3 ---
>  1 file changed, 3 deletions(-)
> 
> diff --git a/fs/f2fs/segment.c b/fs/f2fs/segment.c
> index be9e4d244d75..4e5ffe1d97e4 100644
> --- a/fs/f2fs/segment.c
> +++ b/fs/f2fs/segment.c
> @@ -1428,9 +1428,6 @@ void allocate_new_segments(struct f2fs_sb_info *sbi)
>  	unsigned int old_segno;
>  	int i;
>  
> -	if (test_opt(sbi, LFS))
> -		return;
> -
>  	for (i = CURSEG_HOT_DATA; i <= CURSEG_COLD_DATA; i++) {
>  		curseg = CURSEG_I(sbi, i);
>  		old_segno = curseg->segno;
> 


^ permalink raw reply

* [PATCH v5 17/17] net/i40e: flush tunnel filters
From: Beilei Xing @ 2017-01-04  3:23 UTC (permalink / raw)
  To: jingjing.wu, helin.zhang; +Cc: dev
In-Reply-To: <1483500187-124740-1-git-send-email-beilei.xing@intel.com>

This patch adds i40e_tunnel_filter_flush function
to flush all tunnel filters, including filters in
SW and HW.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 37 +++++++++++++++++++++++++++++++++++++
 1 file changed, 37 insertions(+)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 2e696d3..c8eae4f 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -105,6 +105,7 @@ static int i40e_dev_destroy_tunnel_filter(struct i40e_pf *pf,
 					  struct i40e_tunnel_filter *filter);
 static int i40e_fdir_filter_flush(struct i40e_pf *pf);
 static int i40e_ethertype_filter_flush(struct i40e_pf *pf);
+static int i40e_tunnel_filter_flush(struct i40e_pf *pf);
 
 const struct rte_flow_ops i40e_flow_ops = {
 	.validate = i40e_flow_validate,
@@ -1671,6 +1672,14 @@ i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 		return -rte_errno;
 	}
 
+	ret = i40e_tunnel_filter_flush(pf);
+	if (ret) {
+		rte_flow_error_set(error, -ret,
+				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+				   "Failed to flush tunnel flows.");
+		return -rte_errno;
+	}
+
 	return ret;
 }
 
@@ -1733,3 +1742,31 @@ i40e_ethertype_filter_flush(struct i40e_pf *pf)
 
 	return ret;
 }
+
+/* Flush all tunnel filters */
+static int
+i40e_tunnel_filter_flush(struct i40e_pf *pf)
+{
+	struct i40e_tunnel_filter_list
+		*tunnel_list = &pf->tunnel.tunnel_list;
+	struct i40e_tunnel_filter *filter;
+	struct i40e_flow *flow;
+	void *temp;
+	int ret = 0;
+
+	while ((filter = TAILQ_FIRST(tunnel_list))) {
+		ret = i40e_dev_destroy_tunnel_filter(pf, filter);
+		if (ret)
+			return ret;
+	}
+
+	/* Delete tunnel flows in flow list. */
+	TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
+		if (flow->filter_type == RTE_ETH_FILTER_TUNNEL) {
+			TAILQ_REMOVE(&pf->flow_list, flow, node);
+			rte_free(flow);
+		}
+	}
+
+	return ret;
+}
-- 
2.5.5

^ permalink raw reply related

* [PATCH v5 16/17] net/i40e: flush ethertype filters
From: Beilei Xing @ 2017-01-04  3:23 UTC (permalink / raw)
  To: jingjing.wu, helin.zhang; +Cc: dev
In-Reply-To: <1483500187-124740-1-git-send-email-beilei.xing@intel.com>

This patch adds i40e_ethertype_filter_flush function
to flush all ethertype filters, including filters in
SW and HW.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 41 ++++++++++++++++++++++++++++++++++++++++-
 1 file changed, 40 insertions(+), 1 deletion(-)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index bc8a76c..2e696d3 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -104,6 +104,7 @@ static int i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
 static int i40e_dev_destroy_tunnel_filter(struct i40e_pf *pf,
 					  struct i40e_tunnel_filter *filter);
 static int i40e_fdir_filter_flush(struct i40e_pf *pf);
+static int i40e_ethertype_filter_flush(struct i40e_pf *pf);
 
 const struct rte_flow_ops i40e_flow_ops = {
 	.validate = i40e_flow_validate,
@@ -1655,10 +1656,20 @@ i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
 	int ret;
 
 	ret = i40e_fdir_filter_flush(pf);
-	if (ret)
+	if (ret) {
 		rte_flow_error_set(error, -ret,
 				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
 				   "Failed to flush FDIR flows.");
+		return -rte_errno;
+	}
+
+	ret = i40e_ethertype_filter_flush(pf);
+	if (ret) {
+		rte_flow_error_set(error, -ret,
+				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+				   "Failed to ethertype flush flows.");
+		return -rte_errno;
+	}
 
 	return ret;
 }
@@ -1694,3 +1705,31 @@ i40e_fdir_filter_flush(struct i40e_pf *pf)
 
 	return ret;
 }
+
+/* Flush all ethertype filters */
+static int
+i40e_ethertype_filter_flush(struct i40e_pf *pf)
+{
+	struct i40e_ethertype_filter_list
+		*ethertype_list = &pf->ethertype.ethertype_list;
+	struct i40e_ethertype_filter *filter;
+	struct i40e_flow *flow;
+	void *temp;
+	int ret = 0;
+
+	while ((filter = TAILQ_FIRST(ethertype_list))) {
+		ret = i40e_dev_destroy_ethertype_filter(pf, filter);
+		if (ret)
+			return ret;
+	}
+
+	/* Delete ethertype flows in flow list. */
+	TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
+		if (flow->filter_type == RTE_ETH_FILTER_ETHERTYPE) {
+			TAILQ_REMOVE(&pf->flow_list, flow, node);
+			rte_free(flow);
+		}
+	}
+
+	return ret;
+}
-- 
2.5.5

^ permalink raw reply related

* [PATCH v5 15/17] net/i40e: add flow flush function
From: Beilei Xing @ 2017-01-04  3:23 UTC (permalink / raw)
  To: jingjing.wu, helin.zhang; +Cc: dev
In-Reply-To: <1483500187-124740-1-git-send-email-beilei.xing@intel.com>

This patch adds i40e_flow_flush function to flush all
filters for users. And flow director flush function
is involved first.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_ethdev.h |  1 +
 drivers/net/i40e/i40e_fdir.c   |  4 +---
 drivers/net/i40e/i40e_flow.c   | 51 ++++++++++++++++++++++++++++++++++++++++++
 3 files changed, 53 insertions(+), 3 deletions(-)

diff --git a/drivers/net/i40e/i40e_ethdev.h b/drivers/net/i40e/i40e_ethdev.h
index b33910d..57fd796 100644
--- a/drivers/net/i40e/i40e_ethdev.h
+++ b/drivers/net/i40e/i40e_ethdev.h
@@ -788,6 +788,7 @@ int i40e_add_del_fdir_filter(struct rte_eth_dev *dev,
 int i40e_dev_tunnel_filter_set(struct i40e_pf *pf,
 			       struct rte_eth_tunnel_filter_conf *tunnel_filter,
 			       uint8_t add);
+int i40e_fdir_flush(struct rte_eth_dev *dev);
 
 /* I40E_DEV_PRIVATE_TO */
 #define I40E_DEV_PRIVATE_TO_PF(adapter) \
diff --git a/drivers/net/i40e/i40e_fdir.c b/drivers/net/i40e/i40e_fdir.c
index 91d91aa..67d63ff 100644
--- a/drivers/net/i40e/i40e_fdir.c
+++ b/drivers/net/i40e/i40e_fdir.c
@@ -119,8 +119,6 @@ static int i40e_fdir_filter_programming(struct i40e_pf *pf,
 			enum i40e_filter_pctype pctype,
 			const struct rte_eth_fdir_filter *filter,
 			bool add);
-static int i40e_fdir_flush(struct rte_eth_dev *dev);
-
 static int i40e_fdir_filter_convert(const struct rte_eth_fdir_filter *input,
 			 struct i40e_fdir_filter *filter);
 static struct i40e_fdir_filter *
@@ -1325,7 +1323,7 @@ i40e_fdir_filter_programming(struct i40e_pf *pf,
  * i40e_fdir_flush - clear all filters of Flow Director table
  * @pf: board private structure
  */
-static int
+int
 i40e_fdir_flush(struct rte_eth_dev *dev)
 {
 	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 2674c2c..bc8a76c 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -68,6 +68,8 @@ static struct rte_flow *i40e_flow_create(struct rte_eth_dev *dev,
 					 const struct rte_flow_item pattern[],
 					 const struct rte_flow_action actions[],
 					 struct rte_flow_error *error);
+static int i40e_flow_flush(struct rte_eth_dev *dev,
+			   struct rte_flow_error *error);
 static int i40e_flow_destroy(struct rte_eth_dev *dev,
 			     struct rte_flow *flow,
 			     struct rte_flow_error *error);
@@ -101,11 +103,13 @@ static int i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
 				     struct i40e_ethertype_filter *filter);
 static int i40e_dev_destroy_tunnel_filter(struct i40e_pf *pf,
 					  struct i40e_tunnel_filter *filter);
+static int i40e_fdir_filter_flush(struct i40e_pf *pf);
 
 const struct rte_flow_ops i40e_flow_ops = {
 	.validate = i40e_flow_validate,
 	.create = i40e_flow_create,
 	.destroy = i40e_flow_destroy,
+	.flush = i40e_flow_flush,
 };
 
 union i40e_filter_t cons_filter;
@@ -1643,3 +1647,50 @@ i40e_dev_destroy_tunnel_filter(struct i40e_pf *pf,
 
 	return ret;
 }
+
+static int
+i40e_flow_flush(struct rte_eth_dev *dev, struct rte_flow_error *error)
+{
+	struct i40e_pf *pf = I40E_DEV_PRIVATE_TO_PF(dev->data->dev_private);
+	int ret;
+
+	ret = i40e_fdir_filter_flush(pf);
+	if (ret)
+		rte_flow_error_set(error, -ret,
+				   RTE_FLOW_ERROR_TYPE_HANDLE, NULL,
+				   "Failed to flush FDIR flows.");
+
+	return ret;
+}
+
+static int
+i40e_fdir_filter_flush(struct i40e_pf *pf)
+{
+	struct rte_eth_dev *dev = pf->adapter->eth_dev;
+	struct i40e_fdir_info *fdir_info = &pf->fdir;
+	struct i40e_fdir_filter *fdir_filter;
+	struct i40e_flow *flow;
+	void *temp;
+	int ret;
+
+	ret = i40e_fdir_flush(dev);
+	if (!ret) {
+		/* Delete FDIR filters in FDIR list. */
+		while ((fdir_filter = TAILQ_FIRST(&fdir_info->fdir_list))) {
+			ret = i40e_sw_fdir_filter_del(pf,
+						      &fdir_filter->fdir.input);
+			if (ret < 0)
+				return ret;
+		}
+
+		/* Delete FDIR flows in flow list. */
+		TAILQ_FOREACH_SAFE(flow, &pf->flow_list, node, temp) {
+			if (flow->filter_type == RTE_ETH_FILTER_FDIR) {
+				TAILQ_REMOVE(&pf->flow_list, flow, node);
+				rte_free(flow);
+			}
+		}
+	}
+
+	return ret;
+}
-- 
2.5.5

^ permalink raw reply related

* [PATCH v5 14/17] net/i40e: destroy flow directory filter
From: Beilei Xing @ 2017-01-04  3:23 UTC (permalink / raw)
  To: jingjing.wu, helin.zhang; +Cc: dev
In-Reply-To: <1483500187-124740-1-git-send-email-beilei.xing@intel.com>

This patch supports destroying a flow directory filter
for users.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index f334844..2674c2c 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -1552,6 +1552,10 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
 		ret = i40e_dev_destroy_tunnel_filter(pf,
 			     (struct i40e_tunnel_filter *)pmd_flow->rule);
 		break;
+	case RTE_ETH_FILTER_FDIR:
+		ret = i40e_add_del_fdir_filter(dev,
+		       &((struct i40e_fdir_filter *)pmd_flow->rule)->fdir, 0);
+		break;
 	default:
 		PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
 			    filter_type);
-- 
2.5.5

^ permalink raw reply related

* [PATCH v5 13/17] net/i40e: destroy tunnel filter
From: Beilei Xing @ 2017-01-04  3:23 UTC (permalink / raw)
  To: jingjing.wu, helin.zhang; +Cc: dev
In-Reply-To: <1483500187-124740-1-git-send-email-beilei.xing@intel.com>

This patch adds i40e_dev_destroy_tunnel_filter function
to destroy a tunnel filter for users.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 41 +++++++++++++++++++++++++++++++++++++++++
 1 file changed, 41 insertions(+)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index 2940058..f334844 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -99,6 +99,8 @@ static int i40e_parse_attr(const struct rte_flow_attr *attr,
 			   struct rte_flow_error *error);
 static int i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
 				     struct i40e_ethertype_filter *filter);
+static int i40e_dev_destroy_tunnel_filter(struct i40e_pf *pf,
+					  struct i40e_tunnel_filter *filter);
 
 const struct rte_flow_ops i40e_flow_ops = {
 	.validate = i40e_flow_validate,
@@ -1546,6 +1548,10 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
 		ret = i40e_dev_destroy_ethertype_filter(pf,
 			(struct i40e_ethertype_filter *)pmd_flow->rule);
 		break;
+	case RTE_ETH_FILTER_TUNNEL:
+		ret = i40e_dev_destroy_tunnel_filter(pf,
+			     (struct i40e_tunnel_filter *)pmd_flow->rule);
+		break;
 	default:
 		PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
 			    filter_type);
@@ -1598,3 +1604,38 @@ i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
 
 	return ret;
 }
+
+static int
+i40e_dev_destroy_tunnel_filter(struct i40e_pf *pf,
+			       struct i40e_tunnel_filter *filter)
+{
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	struct i40e_vsi *vsi = pf->main_vsi;
+	struct i40e_aqc_add_remove_cloud_filters_element_data cld_filter;
+	struct i40e_tunnel_rule *tunnel_rule = &pf->tunnel;
+	struct i40e_tunnel_filter *node;
+	int ret = 0;
+
+	memset(&cld_filter, 0, sizeof(cld_filter));
+	ether_addr_copy((struct ether_addr *)&filter->input.outer_mac,
+			(struct ether_addr *)&cld_filter.outer_mac);
+	ether_addr_copy((struct ether_addr *)&filter->input.inner_mac,
+			(struct ether_addr *)&cld_filter.inner_mac);
+	cld_filter.inner_vlan = filter->input.inner_vlan;
+	cld_filter.flags = filter->input.flags;
+	cld_filter.tenant_id = filter->input.tenant_id;
+	cld_filter.queue_number = filter->queue;
+
+	ret = i40e_aq_remove_cloud_filters(hw, vsi->seid,
+					   &cld_filter, 1);
+	if (ret < 0)
+		return ret;
+
+	node = i40e_sw_tunnel_filter_lookup(tunnel_rule, &filter->input);
+	if (!node)
+		return -EINVAL;
+
+	ret = i40e_sw_tunnel_filter_del(pf, &node->input);
+
+	return ret;
+}
-- 
2.5.5

^ permalink raw reply related

* [PATCH v5 12/17] net/i40e: destroy ethertype filter
From: Beilei Xing @ 2017-01-04  3:23 UTC (permalink / raw)
  To: jingjing.wu, helin.zhang; +Cc: dev
In-Reply-To: <1483500187-124740-1-git-send-email-beilei.xing@intel.com>

This patch adds i40e_dev_destroy_ethertype_filter function
to destroy a ethertype filter for users.

Signed-off-by: Beilei Xing <beilei.xing@intel.com>
---
 drivers/net/i40e/i40e_flow.c | 42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/drivers/net/i40e/i40e_flow.c b/drivers/net/i40e/i40e_flow.c
index ece9f89..2940058 100644
--- a/drivers/net/i40e/i40e_flow.c
+++ b/drivers/net/i40e/i40e_flow.c
@@ -49,6 +49,7 @@
 
 #include "i40e_logs.h"
 #include "base/i40e_type.h"
+#include "base/i40e_prototype.h"
 #include "i40e_ethdev.h"
 
 #define I40E_IPV4_TC_SHIFT	4
@@ -96,6 +97,8 @@ static int i40e_parse_tunnel_act(struct rte_eth_dev *dev,
 				 struct rte_eth_tunnel_filter_conf *filter);
 static int i40e_parse_attr(const struct rte_flow_attr *attr,
 			   struct rte_flow_error *error);
+static int i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
+				     struct i40e_ethertype_filter *filter);
 
 const struct rte_flow_ops i40e_flow_ops = {
 	.validate = i40e_flow_validate,
@@ -1539,6 +1542,10 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
 	int ret = 0;
 
 	switch (filter_type) {
+	case RTE_ETH_FILTER_ETHERTYPE:
+		ret = i40e_dev_destroy_ethertype_filter(pf,
+			(struct i40e_ethertype_filter *)pmd_flow->rule);
+		break;
 	default:
 		PMD_DRV_LOG(WARNING, "Filter type (%d) not supported",
 			    filter_type);
@@ -1556,3 +1563,38 @@ i40e_flow_destroy(struct rte_eth_dev *dev,
 
 	return ret;
 }
+
+static int
+i40e_dev_destroy_ethertype_filter(struct i40e_pf *pf,
+				  struct i40e_ethertype_filter *filter)
+{
+	struct i40e_hw *hw = I40E_PF_TO_HW(pf);
+	struct i40e_ethertype_rule *ethertype_rule = &pf->ethertype;
+	struct i40e_ethertype_filter *node;
+	struct i40e_control_filter_stats stats;
+	uint16_t flags = 0;
+	int ret = 0;
+
+	if (!(filter->flags & RTE_ETHTYPE_FLAGS_MAC))
+		flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_IGNORE_MAC;
+	if (filter->flags & RTE_ETHTYPE_FLAGS_DROP)
+		flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_DROP;
+	flags |= I40E_AQC_ADD_CONTROL_PACKET_FLAGS_TO_QUEUE;
+
+	memset(&stats, 0, sizeof(stats));
+	ret = i40e_aq_add_rem_control_packet_filter(hw,
+				    filter->input.mac_addr.addr_bytes,
+				    filter->input.ether_type,
+				    flags, pf->main_vsi->seid,
+				    filter->queue, 0, &stats, NULL);
+	if (ret < 0)
+		return ret;
+
+	node = i40e_sw_ethertype_filter_lookup(ethertype_rule, &filter->input);
+	if (!node)
+		return -EINVAL;
+
+	ret = i40e_sw_ethertype_filter_del(pf, &node->input);
+
+	return ret;
+}
-- 
2.5.5

^ permalink raw reply related


This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.