[PATCH v3 2/3] dt-bindings: fpga: Add bindings for ZynqMP fpga driver

2019-02-10 Thread Nava kishore Manne
Add documentation to describe Xilinx ZynqMP fpga driver
bindings.

Signed-off-by: Nava kishore Manne 
---
Changes for v3:
-Created patches on top of 5.0-rc5.
 No functional changes.
Changes for v2:
-Removed "" separators.
Changes for v1:
-Created a Seperate(New) DT binding file as
 suggested by Rob.

Changes for RFC-V2:
-Moved pcap node as a child to firwmare
 node as suggested by Rob.

 .../devicetree/bindings/fpga/xlnx,zynqmp-pcap-fpga.txt  | 13 +
 1 file changed, 13 insertions(+)
 create mode 100644 
Documentation/devicetree/bindings/fpga/xlnx,zynqmp-pcap-fpga.txt

diff --git a/Documentation/devicetree/bindings/fpga/xlnx,zynqmp-pcap-fpga.txt 
b/Documentation/devicetree/bindings/fpga/xlnx,zynqmp-pcap-fpga.txt
new file mode 100644
index 000..1f6f588
--- /dev/null
+++ b/Documentation/devicetree/bindings/fpga/xlnx,zynqmp-pcap-fpga.txt
@@ -0,0 +1,13 @@
+Device Tree zynqmp-fpga bindings for the Zynq Ultrascale+ MPSoC controlled
+using ZynqMP SoC firmware interface
+For Bitstream configuration on ZynqMp Soc uses processor configuration
+port(PCAP) to configure the programmable logic(PL) through PS by using
+FW interface.
+
+Required properties:
+- compatible: should contain "xlnx,zynqmp-pcap-fpga"
+
+Example:
+   zynqmp_pcap: pcap {
+   compatible = "xlnx,zynqmp-pcap-fpga";
+   };
-- 
2.7.4



Re: [5.0-rc5 regression] "scsi: kill off the legacy IO path" causes 5 minute delay during boot on Sun Blade 2500

2019-02-10 Thread James Bottomley
On Sun, 2019-02-10 at 09:05 -0700, Jens Axboe wrote:
> On 2/10/19 8:44 AM, James Bottomley wrote:
> > On Sun, 2019-02-10 at 10:17 +0100, Mikael Pettersson wrote:
> > > On Sat, Feb 9, 2019 at 7:19 PM James Bottomley
> > >  wrote:
> > 
> > [...]
> > > > I think the reason for this is that the block mq path doesn't
> > > > feed
> > > > the kernel entropy pool correctly, hence the need to install an
> > > > entropy gatherer for systems that don't have other good random
> > > > number sources.
> > > 
> > > That does sound plausible, I admit I didn't even consider the
> > > possibility that the old block I/O path also was an entropy
> > > source.
> > 
> > In theory, the new one should be as well since the rotational
> > entropy
> > collector is on the SCSI completion path.   I'd seen the same
> > problem
> > but had assumed it was something someone had done to our internal
> > entropy pool and thus hadn't bisected it.
> 
> The difference is that the old stack included ADD_RANDOM by default,
> so this check:
> 
>   if (blk_queue_add_random(q))
>   add_disk_randomness(req->rq_disk);
> 
> in scsi_end_request() would be true, and we'd add the randomness. For
> sd, it seems to set it just fine for non-rotational drives. Could
> this be because other devices don't? Maybe the below makes a
> difference.

No, in both we set it per the rotational parameters of the disk in 

sd.c:sd_read_block_characteristics()

rot = get_unaligned_be16(&buffer[4]);

if (rot == 1) {

blk_queue_flag_set(QUEUE_FLAG_NONROT, q);

blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q);
} else {

blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);

blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q);
}


That check wasn't changed by the code removal.

Although I suspect it should be unconditional: even SSDs have what
would appear as seek latencies at least during writes depending on the
time taken to find an erased block or even trigger garbage collection. 
The entropy collector is good at taking something completely regular
and spotting the inconsistencies, so it won't matter that loads of
"seeks" are deterministic.

James



Re: [PATCH 2/5] genirq/affinity: allow driver to setup managed IRQ's affinity

2019-02-10 Thread Thomas Gleixner
Ming,

On Fri, 25 Jan 2019, Ming Lei wrote:

> This patch introduces callback of .setup_affinity into 'struct
> irq_affinity', so that:

Please see Documentation/process/submitting-patches.rst. Search for 'This
patch' 

> 
> 1) allow drivers to customize the affinity for managed IRQ, for
> example, now NVMe has special requirement for read queues & poll
> queues

That's nothing new and already handled today.

> 2) 6da4b3ab9a6e9 ("genirq/affinity: Add support for allocating interrupt 
> sets")
> makes pci_alloc_irq_vectors_affinity() a bit difficult to use for
> allocating interrupt sets: 'max_vecs' is required to same with 'min_vecs'.

So it's a bit difficult, but you fail to explain why it's not sufficient.

> With this patch, driver can implement their own .setup_affinity to
> customize the affinity, then the above thing can be solved easily.

Well, I don't really understand what is solved easily and you are merily
describing the fact that the new callback allows drivers to customize
something. What's the rationale? If it's just the 'bit difficult' part,
then what is the reason for not making the core functionality easier to use
instead of moving stuff into driver space again?

NVME is not special and all this achieves is that all drivers writers will
claim that their device is special and needs its own affinity setter
routine. The whole point of having the generic code is to exactly avoid
that. If it has shortcomings, then they need to be addressed, but not
worked around with random driver callbacks.

Thanks,

tglx


Re: [5.0-rc5 regression] "scsi: kill off the legacy IO path" causes 5 minute delay during boot on Sun Blade 2500

2019-02-10 Thread Jens Axboe
On 2/10/19 9:25 AM, James Bottomley wrote:
> On Sun, 2019-02-10 at 09:05 -0700, Jens Axboe wrote:
>> On 2/10/19 8:44 AM, James Bottomley wrote:
>>> On Sun, 2019-02-10 at 10:17 +0100, Mikael Pettersson wrote:
 On Sat, Feb 9, 2019 at 7:19 PM James Bottomley
  wrote:
>>>
>>> [...]
> I think the reason for this is that the block mq path doesn't
> feed
> the kernel entropy pool correctly, hence the need to install an
> entropy gatherer for systems that don't have other good random
> number sources.

 That does sound plausible, I admit I didn't even consider the
 possibility that the old block I/O path also was an entropy
 source.
>>>
>>> In theory, the new one should be as well since the rotational
>>> entropy
>>> collector is on the SCSI completion path.   I'd seen the same
>>> problem
>>> but had assumed it was something someone had done to our internal
>>> entropy pool and thus hadn't bisected it.
>>
>> The difference is that the old stack included ADD_RANDOM by default,
>> so this check:
>>
>>  if (blk_queue_add_random(q))
>>  add_disk_randomness(req->rq_disk);
>>
>> in scsi_end_request() would be true, and we'd add the randomness. For
>> sd, it seems to set it just fine for non-rotational drives. Could
>> this be because other devices don't? Maybe the below makes a
>> difference.
> 
> No, in both we set it per the rotational parameters of the disk in 
> 
> sd.c:sd_read_block_characteristics()
> 
>   rot = get_unaligned_be16(&buffer[4]);
> 
>   if (rot == 1) {
>   
>   blk_queue_flag_set(QUEUE_FLAG_NONROT, q);
>   
>   blk_queue_flag_clear(QUEUE_FLAG_ADD_RANDOM, q);
>   } else {
>   
>   blk_queue_flag_clear(QUEUE_FLAG_NONROT, q);
>   
>   blk_queue_flag_set(QUEUE_FLAG_ADD_RANDOM, q);
>   }
> 
> 
> That check wasn't changed by the code removal.

As I said above, for sd. This isn't true for non-disks.

> Although I suspect it should be unconditional: even SSDs have what
> would appear as seek latencies at least during writes depending on the
> time taken to find an erased block or even trigger garbage collection. 
> The entropy collector is good at taking something completely regular
> and spotting the inconsistencies, so it won't matter that loads of
> "seeks" are deterministic.

The reason it isn't is that it's of limited use for SSDs where it's a
lot more predictable. And they are also a lot faster, which means the
adding randomness is more problematic from an efficiency pov.

-- 
Jens Axboe



Re: [PATCH 4/5] nvme-pci: simplify nvme_setup_irqs() via .setup_affinity callback

2019-02-10 Thread Thomas Gleixner
On Fri, 25 Jan 2019, Ming Lei wrote:

> Use the callback of .setup_affinity() to re-caculate number
> of queues, and build irqs affinity with help of irq_build_affinity().
> 
> Then nvme_setup_irqs() gets simplified a lot.

I'm pretty sure you can achieve the same by reworking the core code without
that callback.
 
> + /* Fill out vectors at the beginning that don't need affinity */
> + for (curvec = 0; curvec < affd->pre_vectors; curvec++)
> + cpumask_copy(&masks[curvec].mask, cpu_possible_mask);

cpu_possible_mask is wrong.  Why are you deliberately trying to make this
special? There is absolutely no reason to do so.

These interrupts are not managed and therefore the initial affinity has to
be irq_default_affinity. Setting them to cpu_possible_mask can and probably
will evade a well thought out default affinity mask, which was set to
isolate a set of cores from general purpose interrupts.

This is exactly the thing which happens with driver special stuff and which
needs to be avoided. There is nothing special about this NVME setup and
yes, I can see why the current core code is a bit tedious to work with, but
that does not justify that extra driver magic by any means.

Thanks,

tglx



Re: [PATCH] leds: pwm: fix max_brightness works abnormal when active_low

2019-02-10 Thread Pavel Machek
On Sun 2019-02-10 20:37:09, Yisheng Xie wrote:
> When leds-pwm is active_low, smaller number of  duty kept in led_dat
> means less brighness, so we should disable pwm when led_dat->duty is
> equal to period instead of zero, which means max_brightness.

Will all pwm drivers leave the signal 'low' when pwm is disabled? Not
tristate or something?

Plus please use temporary variable. This is really hard to read.

Or maybe

   led_dat->active_low * new_duty == led_dat->period

?
Pavel

> Signed-off-by: Yisheng Xie 
> ---
>  drivers/leds/leds-pwm.c | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/drivers/leds/leds-pwm.c b/drivers/leds/leds-pwm.c
> index df80c89..07fb772 100644
> --- a/drivers/leds/leds-pwm.c
> +++ b/drivers/leds/leds-pwm.c
> @@ -41,7 +41,7 @@ static void __led_pwm_set(struct led_pwm_data *led_dat)
>  
>   pwm_config(led_dat->pwm, new_duty, led_dat->period);
>  
> - if (new_duty == 0)
> + if (led_dat->active_low ? new_duty == led_dat->period : new_duty == 0)
>   pwm_disable(led_dat->pwm);
>   else
>   pwm_enable(led_dat->pwm);

-- 
(english) http://www.livejournal.com/~pavelmachek
(cesky, pictures) 
http://atrey.karlin.mff.cuni.cz/~pavel/picture/horses/blog.html


signature.asc
Description: Digital signature


Re: [PATCH v2] exec: don't force_sigsegv processes with a pending fatal signal

2019-02-10 Thread Eric W. Biederman
Ivan Delalande  writes:

> Hi Eric,
>
> On Thu, Feb 07, 2019 at 11:13:59PM -0600, Eric W. Biederman wrote:
>> I just noticed this.  From  my patch queue that I intend to send to
>> Linus tomorrow. I think this change fixes your issue of getting
>> the SIGSEGV instead of the already pending fatal signal.
>> 
>> So I think this fixes your issue without any other code changes.
>> Ivan can you verify that the patch below is enough?
>
> I was having issues with just this patch applied on top of v5.0-rc5 or
> the latest master: defunct processes accumulating, exiting processes
> that would hang forever, and some kernel functions eating all the CPU
> (setup_sigcontext, common_interrupt, __clear_user, do_signal…).
>
> But using your user-namespace.git/for-linus worked great and I've been
> running my reproducer for a few hours now without issue. I'll probably
> keep it running over the week-end as it has been unreliable at times,
> but it looks promising so far.

Sounds.  Thank you for finding my tree, and thank you for testing.

> A difference I've noticed with your tree (unrelated to my issue here but
> that you may want to look at) is when I run my reproducer under
> strace -f, I'm now getting quite a lot of "Exit of unknown pid 12345
> ignored" warnings from strace, which I've never seen with mainline.
> My reproducer simply fork-exec tail processes in a loop, and tries to
> sigkill them in the parent with a variable delay.

What was your base tree?

My best guess is that your SIGKILL is getting there before strace
realizes the process has been forked.  If we can understand the race
it is probably worth fixing.

Any chance you can post your reproducer.

It is possible it is my most recent fixes, or it is possible something
changed from the tree you were testing and the tree you are working
on.

Eric


[PATCH] spi: gpio: Advertise support for SPI_CS_HIGH

2019-02-10 Thread Jonathan Neuschäfer
The spi-gpio driver already handles different chip select polarities,
but so far this was not advertised in master->mode_bits.

This patch fixes mmc_spi on top of spi_gpio, which is useful in some
testing scenarios.

Signed-off-by: Jonathan Neuschäfer 
---
 drivers/spi/spi-gpio.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/spi/spi-gpio.c b/drivers/spi/spi-gpio.c
index a4aee26028cd..3e98c1a0ba6d 100644
--- a/drivers/spi/spi-gpio.c
+++ b/drivers/spi/spi-gpio.c
@@ -428,7 +428,8 @@ static int spi_gpio_probe(struct platform_device *pdev)
return status;
 
master->bits_per_word_mask = SPI_BPW_RANGE_MASK(1, 32);
-   master->mode_bits = SPI_3WIRE | SPI_3WIRE_HIZ | SPI_CPHA | SPI_CPOL;
+   master->mode_bits = SPI_3WIRE | SPI_3WIRE_HIZ | SPI_CPHA | SPI_CPOL |
+   SPI_CS_HIGH;
master->flags = master_flags;
master->bus_num = pdev->id;
/* The master needs to think there is a chipselect even if not 
connected */
-- 
2.20.1



[PATCH] tty/nozomi: use pci_iomap instead of ioremap_nocache

2019-02-10 Thread Hugo Lefeuvre
Use pci_iomap instead of ioremap_nocache in nozomi_card_init(). This
is a cleaner way to do PCI MMIO (performs additional checks) and
allows to drop the manual call to pci_resource_start.

pci_iomap relies on ioremap for MMIO and thus has uncached behavior.

Signed-off-by: Hugo Lefeuvre 
---
 drivers/tty/nozomi.c | 10 +-
 1 file changed, 1 insertion(+), 9 deletions(-)

diff --git a/drivers/tty/nozomi.c b/drivers/tty/nozomi.c
index fed820e9ab9d..3214e22e79f3 100644
--- a/drivers/tty/nozomi.c
+++ b/drivers/tty/nozomi.c
@@ -1317,7 +1317,6 @@ static void remove_sysfs_files(struct nozomi *dc)
 static int nozomi_card_init(struct pci_dev *pdev,
  const struct pci_device_id *ent)
 {
-   resource_size_t start;
int ret;
struct nozomi *dc = NULL;
int ndev_idx;
@@ -1357,17 +1356,10 @@ static int nozomi_card_init(struct pci_dev *pdev,
goto err_disable_device;
}
 
-   start = pci_resource_start(dc->pdev, 0);
-   if (start == 0) {
-   dev_err(&pdev->dev, "No I/O address for card detected\n");
-   ret = -ENODEV;
-   goto err_rel_regs;
-   }
-
/* Find out what card type it is */
nozomi_get_card_type(dc);
 
-   dc->base_addr = ioremap_nocache(start, dc->card_type);
+   dc->base_addr = pci_iomap(dc->pdev, 0, dc->card_type);
if (!dc->base_addr) {
dev_err(&pdev->dev, "Unable to map card MMIO\n");
ret = -ENODEV;
-- 
2.20.1


[PATCH] docs: process: Remove outdated info about -git patches

2019-02-10 Thread Jonathan Neuschäfer
As can be seen by clicking around the timeline on web.archive.org[1],
there were no -git patches/tarballs on kernel.org since release 3.1.

[1]: https://web.archive.org/web/2003073843/http://www.kernel.org/

Signed-off-by: Jonathan Neuschäfer 
---
 Documentation/process/howto.rst | 9 -
 1 file changed, 9 deletions(-)

diff --git a/Documentation/process/howto.rst b/Documentation/process/howto.rst
index 58b2f46c4f98..00c8ddd2ed2c 100644
--- a/Documentation/process/howto.rst
+++ b/Documentation/process/howto.rst
@@ -302,15 +302,6 @@ The file 
:ref:`Documentation/process/stable-kernel-rules.rst 

Re: [PATCHv4 10/13] node: Add memory caching attributes

2019-02-10 Thread Jonathan Cameron
On Sat, 9 Feb 2019 09:20:53 +0100
Brice Goglin  wrote:

> Hello Keith
> 
> Could we ever have a single side cache in front of two NUMA nodes ? I
> don't see a way to find that out in the current implementation. Would we
> have an "id" and/or "nodemap" bitmask in the sidecache structure ?

This is certainly a possible thing for hardware to do.

ACPI IIRC doesn't provide any means of representing that - your best
option is to represent it as two different entries, one for each of the
memory nodes.  Interesting question of whether you would then claim
they were half as big each, or the full size.  Of course, there are
other possible ways to get this info beyond HMAT, so perhaps the interface
should allow it to be exposed if available?

Also, don't know if it's just me, but calling these sidecaches is
downright confusing.  In ACPI at least they are always
specifically referred to as Memory Side Caches.
I'd argue there should even by a hyphen Memory-Side Caches, the point
being that that they are on the memory side of the interconnected
rather than the processor side.  Of course an implementation
choice might be to put them off to the side (as implied by sidecaches)
in some sense, but it's not the only one.

 :)

Jonathan

> 
> Thanks
> 
> Brice
> 
> 
> 
> Le 16/01/2019 à 18:58, Keith Busch a écrit :
> > System memory may have side caches to help improve access speed to
> > frequently requested address ranges. While the system provided cache is
> > transparent to the software accessing these memory ranges, applications
> > can optimize their own access based on cache attributes.
> >
> > Provide a new API for the kernel to register these memory side caches
> > under the memory node that provides it.
> >
> > The new sysfs representation is modeled from the existing cpu cacheinfo
> > attributes, as seen from /sys/devices/system/cpu/cpuX/side_cache/.
> > Unlike CPU cacheinfo, though, the node cache level is reported from
> > the view of the memory. A higher number is nearer to the CPU, while
> > lower levels are closer to the backing memory. Also unlike CPU cache,
> > it is assumed the system will handle flushing any dirty cached memory
> > to the last level on a power failure if the range is persistent memory.
> >
> > The attributes we export are the cache size, the line size, associativity,
> > and write back policy.
> >
> > Signed-off-by: Keith Busch 
> > ---
> >  drivers/base/node.c  | 142 
> > +++
> >  include/linux/node.h |  39 ++
> >  2 files changed, 181 insertions(+)
> >
> > diff --git a/drivers/base/node.c b/drivers/base/node.c
> > index 1e909f61e8b1..7ff3ed566d7d 100644
> > --- a/drivers/base/node.c
> > +++ b/drivers/base/node.c
> > @@ -191,6 +191,146 @@ void node_set_perf_attrs(unsigned int nid, struct 
> > node_hmem_attrs *hmem_attrs,
> > pr_info("failed to add performance attribute group to node 
> > %d\n",
> > nid);
> >  }
> > +
> > +struct node_cache_info {
> > +   struct device dev;
> > +   struct list_head node;
> > +   struct node_cache_attrs cache_attrs;
> > +};
> > +#define to_cache_info(device) container_of(device, struct node_cache_info, 
> > dev)
> > +
> > +#define CACHE_ATTR(name, fmt)  
> > \
> > +static ssize_t name##_show(struct device *dev, 
> > \
> > +  struct device_attribute *attr,   \
> > +  char *buf)   \
> > +{  \
> > +   return sprintf(buf, fmt "\n", to_cache_info(dev)->cache_attrs.name);\
> > +}  \
> > +DEVICE_ATTR_RO(name);
> > +
> > +CACHE_ATTR(size, "%llu")
> > +CACHE_ATTR(level, "%u")
> > +CACHE_ATTR(line_size, "%u")
> > +CACHE_ATTR(associativity, "%u")
> > +CACHE_ATTR(write_policy, "%u")
> > +
> > +static struct attribute *cache_attrs[] = {
> > +   &dev_attr_level.attr,
> > +   &dev_attr_associativity.attr,
> > +   &dev_attr_size.attr,
> > +   &dev_attr_line_size.attr,
> > +   &dev_attr_write_policy.attr,
> > +   NULL,
> > +};
> > +ATTRIBUTE_GROUPS(cache);
> > +
> > +static void node_cache_release(struct device *dev)
> > +{
> > +   kfree(dev);
> > +}
> > +
> > +static void node_cacheinfo_release(struct device *dev)
> > +{
> > +   struct node_cache_info *info = to_cache_info(dev);
> > +   kfree(info);
> > +}
> > +
> > +static void node_init_cache_dev(struct node *node)
> > +{
> > +   struct device *dev;
> > +
> > +   dev = kzalloc(sizeof(*dev), GFP_KERNEL);
> > +   if (!dev)
> > +   return;
> > +
> > +   dev->parent = &node->dev;
> > +   dev->release = node_cache_release;
> > +   if (dev_set_name(dev, "side_cache"))
> > +   goto free_dev;
> > +
> > +   if (device_register(dev))
> > +   goto free_name;
> > +
> > +   pm_runtime_no_callbacks(dev);
> > +   node->cache_dev = dev;
> > +  

[PATCH v2] blk-sysfs: Rework documention of __blk_release_queue

2019-02-10 Thread Marcos Paulo de Souza
The Notes section of the comment was removed, because now
blk_release_queue can only be executed from blk_cleanup_queue (being
called when the q->kobj reaches zero), and also blk_init_queue was removed
in a1ce35fa4985.

Signed-off-by: Marcos Paulo de Souza 
---
 Changes from v1:
 * Typos, suggested by Jens Axboe

 block/blk-sysfs.c | 19 +++
 1 file changed, 7 insertions(+), 12 deletions(-)

diff --git a/block/blk-sysfs.c b/block/blk-sysfs.c
index 590d1ef2f961..94e1b052abbc 100644
--- a/block/blk-sysfs.c
+++ b/block/blk-sysfs.c
@@ -817,21 +817,16 @@ static void blk_free_queue_rcu(struct rcu_head *rcu_head)
 }
 
 /**
- * __blk_release_queue - release a request queue when it is no longer needed
+ * __blk_release_queue - release a request queue
  * @work: pointer to the release_work member of the request queue to be 
released
  *
  * Description:
- * blk_release_queue is the counterpart of blk_init_queue(). It should be
- * called when a request queue is being released; typically when a block
- * device is being de-registered. Its primary task it to free the queue
- * itself.
- *
- * Notes:
- * The low level driver must have finished any outstanding requests first
- * via blk_cleanup_queue().
- *
- * Although blk_release_queue() may be called with preemption disabled,
- * __blk_release_queue() may sleep.
+ * This function is called when a block device is being unregistered. The
+ * process of releasing a request queue starts with blk_cleanup_queue, 
which
+ * set the appropriate flags and then calls blk_put_queue, that decrements
+ * the reference counter of the request queue. Once the reference counter
+ * of the request queue reaches zero, blk_release_queue is called to 
release
+ * all allocated resources of the request queue.
  */
 static void __blk_release_queue(struct work_struct *work)
 {
-- 
2.16.4



Re: [PATCH v2] blk-sysfs: Rework documention of __blk_release_queue

2019-02-10 Thread Jens Axboe
On 2/10/19 10:22 AM, Marcos Paulo de Souza wrote:
> The Notes section of the comment was removed, because now
> blk_release_queue can only be executed from blk_cleanup_queue (being
> called when the q->kobj reaches zero), and also blk_init_queue was removed
> in a1ce35fa4985.

Thanks, applied.

-- 
Jens Axboe



[PATCH] mmc: spi: Fix card detection during probe

2019-02-10 Thread Jonathan Neuschäfer
When using the mmc_spi driver with a card-detect pin, I noticed that the
card was not detected immediately after probe, but only after it was
unplugged and plugged back in (and the CD IRQ fired).

The call tree looks something like this:

mmc_spi_probe
  mmc_add_host
mmc_start_host
  _mmc_detect_change
mmc_schedule_delayed_work(&host->detect, 0)
  mmc_rescan
host->bus_ops->detect(host)
  mmc_detect
_mmc_detect_card_removed
  host->ops->get_cd(host)
mmc_gpio_get_cd -> -ENOSYS (ctx->cd_gpio not set)
  mmc_gpiod_request_cd
ctx->cd_gpio = desc

To fix this issue, call mmc_detect_change after the card-detect GPIO/IRQ
is registered.

Signed-off-by: Jonathan Neuschäfer 
---
 drivers/mmc/host/mmc_spi.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/drivers/mmc/host/mmc_spi.c b/drivers/mmc/host/mmc_spi.c
index 10ba46b728e8..8ade14fb2148 100644
--- a/drivers/mmc/host/mmc_spi.c
+++ b/drivers/mmc/host/mmc_spi.c
@@ -1450,6 +1450,7 @@ static int mmc_spi_probe(struct spi_device *spi)
mmc->caps &= ~MMC_CAP_NEEDS_POLL;
mmc_gpiod_request_cd_irq(mmc);
}
+   mmc_detect_change(mmc, 0);
 
/* Index 1 is write protect/read only */
status = mmc_gpiod_request_ro(mmc, NULL, 1, false, 0, NULL);
-- 
2.20.1



Re: [PATCH] Input: matrix_keypad - use flush_delayed_work()

2019-02-10 Thread Sven Van Asbroeck
Hi Dmitry,

On Thu, Feb 7, 2019 at 5:46 PM Dmitry Torokhov
 wrote:
>
> We should be using flush_delayed_work() instead of flush_work() in
> matrix_keypad_stop() to ensure that we are not missing work that is
> scheduled but not yet put in the workqueue (i.e. its delay timer has not
> expired yet).
>

Could the following scenario cause a use-after-free?
(I am adding comments on lines starting with -->)

a) user closes the device handle:

static void matrix_keypad_stop(struct input_dev *dev)
{
struct matrix_keypad *keypad = input_get_drvdata(dev);

spin_lock_irq(&keypad->lock);
keypad->stopped = true;
spin_unlock_irq(&keypad->lock);

flush_work(&keypad->work.work);
-->
--> new interrupt comes in, and schedules new delayed keypad->work (1)
-->
/*
 * matrix_keypad_scan() will leave IRQs enabled;
 * we should disable them now.
 */
disable_row_irqs(keypad);
}

b) user removes the keypad, or unloads the module:

static int matrix_keypad_remove(struct platform_device *pdev)
{
struct matrix_keypad *keypad = platform_get_drvdata(pdev);

matrix_keypad_free_gpio(keypad);
input_unregister_device(keypad->input_dev);
kfree(keypad);

-->
--> delayed keypad->work scheduled at (1) above executes anywhere past here,
--> and causes a user-after-free.
-->

return 0;
}


Re: [PATCH v4 15/16] block: sed-opal: don't repeat opal_discovery0 in each steps array

2019-02-10 Thread David Kozub

On Fri, 8 Feb 2019, Derrick, Jonathan wrote:


On Mon, 2019-02-04 at 23:44 +0100, David Kozub wrote:

On Mon, 4 Feb 2019, Christoph Hellwig wrote:


+   /* first do a discovery0 */
+   error = opal_discovery0_step(dev);

+   for (state = 0; !error && state < n_steps; state++)
+   error = execute_step(dev, &steps[state], state);
+
+   /*
+* For each OPAL command the first step in steps starts some sort of
+* session. If an error occurred in the initial discovery0 or if an
+* error occurred in the first step (and thus stopping the loop with
+* state == 1) then there was an error before or during the attempt to
+* start a session. Therefore we shouldn't attempt to terminate a
+* session, as one has not yet been created.
+*/
+   if (error && state > 1)
+   end_opal_session_error(dev);

return error;


The flow here is a little too condensed for my taste.  Why not the
plain obvoious, if a little longer:

error = error = opal_discovery0_step(dev);
if (error)
return error;

for (state = 0; state < n_steps; state++) {
error = execute_step(dev, &steps[state], state);
if (error)
goto out_error;
}

return 0;

out_error:
if (state > 1)
end_opal_session_error(dev);
return error;


No problem, I can use this version. But I think there is a minor issue -
the same one I hit in my original change, just from the other direction:

If the loop succeds for the 0-th element of steps, and then fails for the
1st element, then state equals 1 yet the session has been started, so we
should close it.

I think the condition in out_error should be if (state > 0).

Best regards,
David

Looks good with Christoph's suggestion (for 14/16) and your state check fix


Reviewed-by: Jon Derrick 


Hi Jon,

What suggestion by Christoph you have in mind? I don't see any for 14/16. 
Currently, in my git repo, for this patch, I applied Christoph suggestion 
for this (15/16) patch + the "state > 0" fix. Is this what you mean?


Best regards,
David


[PATCH net-next v2 01/16] Documentation: networking: switchdev: Update port parent ID section

2019-02-10 Thread Florian Fainelli
Update the section about switchdev drivers having to implement a
switchdev_port_attr_get() function to return
SWITCHDEV_ATTR_ID_PORT_PARENT_ID since that is no longer valid after
commit bccb30254a4a ("net: Get rid of
SWITCHDEV_ATTR_ID_PORT_PARENT_ID").

Fixes: bccb30254a4a ("net: Get rid of SWITCHDEV_ATTR_ID_PORT_PARENT_ID")
Acked-by: Jiri Pirko 
Signed-off-by: Florian Fainelli 
---
 Documentation/networking/switchdev.txt | 10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Documentation/networking/switchdev.txt 
b/Documentation/networking/switchdev.txt
index f3244d87512a..ea90243340a9 100644
--- a/Documentation/networking/switchdev.txt
+++ b/Documentation/networking/switchdev.txt
@@ -92,11 +92,11 @@ device.
 Switch ID
 ^
 
-The switchdev driver must implement the switchdev op switchdev_port_attr_get
-for SWITCHDEV_ATTR_ID_PORT_PARENT_ID for each port netdev, returning the same
-physical ID for each port of a switch.  The ID must be unique between switches
-on the same system.  The ID does not need to be unique between switches on
-different systems.
+The switchdev driver must implement the net_device operation
+ndo_get_port_parent_id for each port netdev, returning the same physical ID for
+each port of a switch. The ID must be unique between switches on the same
+system. The ID does not need to be unique between switches on different
+systems.
 
 The switch ID is used to locate ports on a switch and to know if aggregated
 ports belong to the same switch.
-- 
2.19.1



[PATCH net-next v2 12/16] mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-10 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare mlxsw to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
mlxsw_sp_port_attr_set() call.

Signed-off-by: Florian Fainelli 
---
 .../ethernet/mellanox/mlxsw/spectrum_switchdev.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 6b09d68671cf..39a99db040bd 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -3410,6 +3410,20 @@ mlxsw_sp_switchdev_handle_vxlan_obj_del(struct 
net_device *vxlan_dev,
}
 }
 
+static int
+mlxsw_sp_switchdev_port_attr_set_event(unsigned long event,
+   struct net_device *dev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err;
+
+   err = mlxsw_sp_port_attr_set(dev, port_attr_info->attr,
+port_attr_info->trans);
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int mlxsw_sp_switchdev_blocking_event(struct notifier_block *unused,
 unsigned long event, void *ptr)
 {
@@ -3433,6 +3447,8 @@ static int mlxsw_sp_switchdev_blocking_event(struct 
notifier_block *unused,
mlxsw_sp_port_dev_check,
mlxsw_sp_port_obj_del);
return notifier_from_errno(err);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return mlxsw_sp_switchdev_port_attr_set_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.19.1



[PATCH net-next v2 03/16] staging: fsl-dpaa2: ethsw: Check bridge port flags during set

2019-02-10 Thread Florian Fainelli
In preparation for removing SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
have ethsw check that the bridge port flags that are being set are
supported.

Acked-by: Jiri Pirko 
Signed-off-by: Florian Fainelli 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index e559f4c25cf7..6228c4375835 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -680,8 +680,11 @@ static int port_attr_br_flags_set(struct net_device 
*netdev,
struct ethsw_port_priv *port_priv = netdev_priv(netdev);
int err = 0;
 
-   if (switchdev_trans_ph_prepare(trans))
+   if (switchdev_trans_ph_prepare(trans)) {
+   if (flags & ~(BR_LEARNING | BR_FLOOD))
+   return -EOPNOTSUPP;
return 0;
+   }
 
/* Learning is enabled per switch */
err = ethsw_set_learning(port_priv->ethsw_data, flags & BR_LEARNING);
-- 
2.19.1



[PATCH net-next v2 00/16] net: Remove switchdev_ops

2019-02-10 Thread Florian Fainelli
Hi all,

This patch series finishes by the removal of switchdev_ops. To get there
we need to do a few things:

- get rid of the one and only call to switchdev_port_attr_get() which is
  used to fetch the device's bridge port flags capabilities, instead we
  can just check what flags are being programmed during the prepare
  phase

- once we get rid of getting switchdev port attributes we convert the
  setting of such attributes using a blocking notifier

And then remove switchdev_ops completely.

Please review and let me know what you think!

Changes in v2:
- fixed bisectability issues in patch #15
- added Acked-by from Jiri where necessary
- fixed a few minor issues according to Jiri's feedback:
- rename port_attr_event -> port_attr_set_event
- moved SWITCHDEV_PORT_ATTR_SET closer to other blocking events

Florian Fainelli (16):
  Documentation: networking: switchdev: Update port parent ID section
  mlxsw: spectrum: Check bridge flags during prepare phase
  staging: fsl-dpaa2: ethsw: Check bridge port flags during set
  net: dsa: Add setter for SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS
  rocker: Check bridge flags during prepare phase
  net: bridge: Stop calling switchdev_port_attr_get()
  net: Remove SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT
  net: Get rid of switchdev_port_attr_get()
  switchdev: Add SWITCHDEV_PORT_ATTR_SET
  rocker: Handle SWITCHDEV_PORT_ATTR_SET
  net: dsa: Handle SWITCHDEV_PORT_ATTR_SET
  mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_SET
  net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_SET
  staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_SET
  net: switchdev: Replace port attr set SDO with a notification
  net: Remove switchdev_ops

 Documentation/networking/switchdev.txt| 15 ++-
 .../net/ethernet/mellanox/mlxsw/spectrum.c| 12 ---
 .../net/ethernet/mellanox/mlxsw/spectrum.h|  2 -
 .../mellanox/mlxsw/spectrum_switchdev.c   | 69 --
 drivers/net/ethernet/mscc/ocelot.c| 21 +++-
 drivers/net/ethernet/rocker/rocker_main.c | 95 ---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c   | 48 --
 include/linux/netdevice.h |  3 -
 include/net/switchdev.h   | 36 ++-
 net/bridge/br_switchdev.c | 20 +---
 net/dsa/dsa_priv.h|  3 +
 net/dsa/port.c| 10 ++
 net/dsa/slave.c   | 40 
 net/switchdev/switchdev.c | 92 +-
 14 files changed, 170 insertions(+), 296 deletions(-)

-- 
2.19.1



[PATCH net-next v2 09/16] switchdev: Add SWITCHDEV_PORT_ATTR_SET

2019-02-10 Thread Florian Fainelli
In preparation for allowing switchdev enabled drivers to veto specific
attribute settings from within the context of the caller, introduce a
new switchdev notifier type for port attributes.

Suggested-by: Ido Schimmel 
Acked-by: Jiri Pirko 
Signed-off-by: Florian Fainelli 
---
 include/net/switchdev.h | 8 
 1 file changed, 8 insertions(+)

diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 96cd3e795f7f..7bc6a004d32a 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -135,6 +135,7 @@ enum switchdev_notifier_type {
 
SWITCHDEV_PORT_OBJ_ADD, /* Blocking. */
SWITCHDEV_PORT_OBJ_DEL, /* Blocking. */
+   SWITCHDEV_PORT_ATTR_SET, /* Blocking. */
 
SWITCHDEV_VXLAN_FDB_ADD_TO_BRIDGE,
SWITCHDEV_VXLAN_FDB_DEL_TO_BRIDGE,
@@ -163,6 +164,13 @@ struct switchdev_notifier_port_obj_info {
bool handled;
 };
 
+struct switchdev_notifier_port_attr_info {
+   struct switchdev_notifier_info info; /* must be first */
+   const struct switchdev_attr *attr;
+   struct switchdev_trans *trans;
+   bool handled;
+};
+
 static inline struct net_device *
 switchdev_notifier_info_to_dev(const struct switchdev_notifier_info *info)
 {
-- 
2.19.1



[PATCH net-next v2 02/16] mlxsw: spectrum: Check bridge flags during prepare phase

2019-02-10 Thread Florian Fainelli
In preparation for getting rid of switchdev_port_attr_get(), have mlxsw
check for the bridge flags being set through switchdev_port_attr_set()
with the SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS attribute identifier.

Acked-by: Jiri Pirko 
Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c | 5 -
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 95e37de3e48f..468a6d513074 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -623,8 +623,11 @@ static int mlxsw_sp_port_attr_br_flags_set(struct 
mlxsw_sp_port *mlxsw_sp_port,
struct mlxsw_sp_bridge_port *bridge_port;
int err;
 
-   if (switchdev_trans_ph_prepare(trans))
+   if (switchdev_trans_ph_prepare(trans)) {
+   if (brport_flags & ~(BR_LEARNING | BR_FLOOD | BR_MCAST_FLOOD))
+   return -EOPNOTSUPP;
return 0;
+   }
 
bridge_port = mlxsw_sp_bridge_port_find(mlxsw_sp_port->mlxsw_sp->bridge,
orig_dev);
-- 
2.19.1



[PATCH net-next v2 08/16] net: Get rid of switchdev_port_attr_get()

2019-02-10 Thread Florian Fainelli
With the bridge no longer calling switchdev_port_attr_get() to obtain
the supported bridge port flags from a driver but instead trying to set
the bridge port flags directly and relying on driver to reject
unsupported configurations, we can effectively get rid of
switchdev_port_attr_get() entirely since this was the only place where
it was called.

Acked-by: Jiri Pirko 
Signed-off-by: Florian Fainelli 
---
 Documentation/networking/switchdev.txt|  5 ++-
 .../mellanox/mlxsw/spectrum_switchdev.c   | 32 ---
 drivers/net/ethernet/rocker/rocker_main.c | 30 -
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c   | 19 ---
 include/net/switchdev.h   |  8 -
 net/dsa/slave.c   |  7 
 6 files changed, 2 insertions(+), 99 deletions(-)

diff --git a/Documentation/networking/switchdev.txt 
b/Documentation/networking/switchdev.txt
index ea90243340a9..327afe754230 100644
--- a/Documentation/networking/switchdev.txt
+++ b/Documentation/networking/switchdev.txt
@@ -233,9 +233,8 @@ the bridge's FDB.  It's possible, but not optimal, to 
enable learning on the
 device port and on the bridge port, and disable learning_sync.
 
 To support learning and learning_sync port attributes, the driver implements
-switchdev op switchdev_port_attr_get/set for
-SWITCHDEV_ATTR_PORT_ID_BRIDGE_FLAGS. The driver should initialize the 
attributes
-to the hardware defaults.
+switchdev op switchdev_port_attr_set for SWITCHDEV_ATTR_PORT_ID_BRIDGE_FLAGS.
+The driver should initialize the attributes to the hardware defaults.
 
 FDB Ageing
 ^^
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 8242a373f6e7..6b09d68671cf 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -431,37 +431,6 @@ static void mlxsw_sp_bridge_vlan_put(struct 
mlxsw_sp_bridge_vlan *bridge_vlan)
mlxsw_sp_bridge_vlan_destroy(bridge_vlan);
 }
 
-static void mlxsw_sp_port_bridge_flags_get(struct mlxsw_sp_bridge *bridge,
-  struct net_device *dev,
-  unsigned long *brport_flags)
-{
-   struct mlxsw_sp_bridge_port *bridge_port;
-
-   bridge_port = mlxsw_sp_bridge_port_find(bridge, dev);
-   if (WARN_ON(!bridge_port))
-   return;
-
-   memcpy(brport_flags, &bridge_port->flags, sizeof(*brport_flags));
-}
-
-static int mlxsw_sp_port_attr_get(struct net_device *dev,
- struct switchdev_attr *attr)
-{
-   struct mlxsw_sp_port *mlxsw_sp_port = netdev_priv(dev);
-   struct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;
-
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
-   mlxsw_sp_port_bridge_flags_get(mlxsw_sp->bridge, attr->orig_dev,
-  &attr->u.brport_flags);
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-
-   return 0;
-}
-
 static int
 mlxsw_sp_port_bridge_vlan_stp_set(struct mlxsw_sp_port *mlxsw_sp_port,
  struct mlxsw_sp_bridge_vlan *bridge_vlan,
@@ -1957,7 +1926,6 @@ static struct mlxsw_sp_port *mlxsw_sp_lag_rep_port(struct 
mlxsw_sp *mlxsw_sp,
 }
 
 static const struct switchdev_ops mlxsw_sp_port_switchdev_ops = {
-   .switchdev_port_attr_get= mlxsw_sp_port_attr_get,
.switchdev_port_attr_set= mlxsw_sp_port_attr_set,
 };
 
diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 375c4c908bea..ff3f14504f4f 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -1606,17 +1606,6 @@ rocker_world_port_attr_bridge_flags_set(struct 
rocker_port *rocker_port,
trans);
 }
 
-static int
-rocker_world_port_attr_bridge_flags_get(const struct rocker_port *rocker_port,
-   unsigned long *p_brport_flags)
-{
-   struct rocker_world_ops *wops = rocker_port->rocker->wops;
-
-   if (!wops->port_attr_bridge_flags_get)
-   return -EOPNOTSUPP;
-   return wops->port_attr_bridge_flags_get(rocker_port, p_brport_flags);
-}
-
 static int
 rocker_world_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port,
  u32 ageing_time,
@@ -2064,24 +2053,6 @@ static const struct net_device_ops 
rocker_port_netdev_ops = {
  * swdev interface
  /
 
-static int rocker_port_attr_get(struct net_device *dev,
-   struct switchdev_attr *attr)
-{
-   const struct rocker_port *rocker_port = netdev_priv(dev);
-   int err = 0;
-
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLA

[PATCH net-next v2 05/16] rocker: Check bridge flags during prepare phase

2019-02-10 Thread Florian Fainelli
In preparation for getting rid of switchdev_port_attr_get(), have rocker
check for the bridge flags being set through switchdev_port_attr_set()
with the SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS attribute identifier.

Acked-by: Jiri Pirko 
Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/rocker/rocker_main.c | 40 ++-
 1 file changed, 25 insertions(+), 15 deletions(-)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 66f72f8c46e5..8657313b6f30 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -1565,18 +1565,42 @@ static int rocker_world_port_attr_stp_state_set(struct 
rocker_port *rocker_port,
return wops->port_attr_stp_state_set(rocker_port, state);
 }
 
+static int
+rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port *
+   rocker_port,
+   unsigned long *
+   p_brport_flags_support)
+{
+   struct rocker_world_ops *wops = rocker_port->rocker->wops;
+
+   if (!wops->port_attr_bridge_flags_support_get)
+   return -EOPNOTSUPP;
+   return wops->port_attr_bridge_flags_support_get(rocker_port,
+   p_brport_flags_support);
+}
+
 static int
 rocker_world_port_attr_bridge_flags_set(struct rocker_port *rocker_port,
unsigned long brport_flags,
struct switchdev_trans *trans)
 {
struct rocker_world_ops *wops = rocker_port->rocker->wops;
+   unsigned long brport_flags_s;
+   int err;
 
if (!wops->port_attr_bridge_flags_set)
return -EOPNOTSUPP;
 
-   if (switchdev_trans_ph_prepare(trans))
+   if (switchdev_trans_ph_prepare(trans)) {
+   err = 
rocker_world_port_attr_bridge_flags_support_get(rocker_port,
+ &brport_flags_s);
+   if (err)
+   return err;
+
+   if (brport_flags & ~brport_flags_s)
+   return -EOPNOTSUPP;
return 0;
+   }
 
return wops->port_attr_bridge_flags_set(rocker_port, brport_flags,
trans);
@@ -1593,20 +1617,6 @@ rocker_world_port_attr_bridge_flags_get(const struct 
rocker_port *rocker_port,
return wops->port_attr_bridge_flags_get(rocker_port, p_brport_flags);
 }
 
-static int
-rocker_world_port_attr_bridge_flags_support_get(const struct rocker_port *
-   rocker_port,
-   unsigned long *
-   p_brport_flags_support)
-{
-   struct rocker_world_ops *wops = rocker_port->rocker->wops;
-
-   if (!wops->port_attr_bridge_flags_support_get)
-   return -EOPNOTSUPP;
-   return wops->port_attr_bridge_flags_support_get(rocker_port,
-   p_brport_flags_support);
-}
-
 static int
 rocker_world_port_attr_bridge_ageing_time_set(struct rocker_port *rocker_port,
  u32 ageing_time,
-- 
2.19.1



[PATCH net-next v2 16/16] net: Remove switchdev_ops

2019-02-10 Thread Florian Fainelli
Now that we have converted all possible callers to using a switchdev
notifier for attributes we do not have a need for implementing
switchdev_ops anymore, and this can be removed from all drivers the
net_device structure.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/mellanox/mlxsw/spectrum.c | 12 
 drivers/net/ethernet/mellanox/mlxsw/spectrum.h |  2 --
 .../mellanox/mlxsw/spectrum_switchdev.c| 12 
 drivers/net/ethernet/mscc/ocelot.c |  5 -
 drivers/net/ethernet/rocker/rocker_main.c  |  5 -
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c|  5 -
 include/linux/netdevice.h  |  3 ---
 include/net/switchdev.h| 18 --
 net/dsa/slave.c|  5 -
 9 files changed, 67 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
index 7c9745cecbbd..619965abab43 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.c
@@ -3220,7 +3220,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port,
}
mlxsw_sp_port->default_vlan = mlxsw_sp_port_vlan;
 
-   mlxsw_sp_port_switchdev_init(mlxsw_sp_port);
mlxsw_sp->ports[local_port] = mlxsw_sp_port;
err = register_netdev(dev);
if (err) {
@@ -3237,7 +3236,6 @@ static int mlxsw_sp_port_create(struct mlxsw_sp 
*mlxsw_sp, u8 local_port,
 
 err_register_netdev:
mlxsw_sp->ports[local_port] = NULL;
-   mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
mlxsw_sp_port_vlan_destroy(mlxsw_sp_port_vlan);
 err_port_vlan_create:
 err_port_pvid_set:
@@ -3280,7 +3278,6 @@ static void mlxsw_sp_port_remove(struct mlxsw_sp 
*mlxsw_sp, u8 local_port)
mlxsw_core_port_clear(mlxsw_sp->core, local_port, mlxsw_sp);
unregister_netdev(mlxsw_sp_port->dev); /* This calls ndo_stop */
mlxsw_sp->ports[local_port] = NULL;
-   mlxsw_sp_port_switchdev_fini(mlxsw_sp_port);
mlxsw_sp_port_vlan_flush(mlxsw_sp_port, true);
mlxsw_sp_port_nve_fini(mlxsw_sp_port);
mlxsw_sp_tc_qdisc_fini(mlxsw_sp_port);
@@ -4001,12 +3998,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
goto err_span_init;
}
 
-   err = mlxsw_sp_switchdev_init(mlxsw_sp);
-   if (err) {
-   dev_err(mlxsw_sp->bus_info->dev, "Failed to initialize 
switchdev\n");
-   goto err_switchdev_init;
-   }
-
err = mlxsw_sp_counter_pool_init(mlxsw_sp);
if (err) {
dev_err(mlxsw_sp->bus_info->dev, "Failed to init counter 
pool\n");
@@ -4077,8 +4068,6 @@ static int mlxsw_sp_init(struct mlxsw_core *mlxsw_core,
 err_afa_init:
mlxsw_sp_counter_pool_fini(mlxsw_sp);
 err_counter_pool_init:
-   mlxsw_sp_switchdev_fini(mlxsw_sp);
-err_switchdev_init:
mlxsw_sp_span_fini(mlxsw_sp);
 err_span_init:
mlxsw_sp_lag_fini(mlxsw_sp);
@@ -4141,7 +4130,6 @@ static void mlxsw_sp_fini(struct mlxsw_core *mlxsw_core)
mlxsw_sp_nve_fini(mlxsw_sp);
mlxsw_sp_afa_fini(mlxsw_sp);
mlxsw_sp_counter_pool_fini(mlxsw_sp);
-   mlxsw_sp_switchdev_fini(mlxsw_sp);
mlxsw_sp_span_fini(mlxsw_sp);
mlxsw_sp_lag_fini(mlxsw_sp);
mlxsw_sp_buffers_fini(mlxsw_sp);
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
index ceebc91f4f1d..82e3e6dc81a1 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h
@@ -375,8 +375,6 @@ u32 mlxsw_sp_bytes_cells(const struct mlxsw_sp *mlxsw_sp, 
u32 bytes);
 /* spectrum_switchdev.c */
 int mlxsw_sp_switchdev_init(struct mlxsw_sp *mlxsw_sp);
 void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp);
-void mlxsw_sp_port_switchdev_init(struct mlxsw_sp_port *mlxsw_sp_port);
-void mlxsw_sp_port_switchdev_fini(struct mlxsw_sp_port *mlxsw_sp_port);
 int mlxsw_sp_rif_fdb_op(struct mlxsw_sp *mlxsw_sp, const char *mac, u16 fid,
bool adding);
 void
diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 39a99db040bd..a3a3c14c7886 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -1925,10 +1925,6 @@ static struct mlxsw_sp_port 
*mlxsw_sp_lag_rep_port(struct mlxsw_sp *mlxsw_sp,
return NULL;
 }
 
-static const struct switchdev_ops mlxsw_sp_port_switchdev_ops = {
-   .switchdev_port_attr_set= mlxsw_sp_port_attr_set,
-};
-
 static int
 mlxsw_sp_bridge_8021q_port_join(struct mlxsw_sp_bridge_device *bridge_device,
struct mlxsw_sp_bridge_port *bridge_port,
@@ -3536,11 +3532,3 @@ void mlxsw_sp_switchdev_fini(struct mlxsw_sp *mlxsw_sp)
kfree(mlxsw_sp->bridge);

[PATCH net-next v2 11/16] net: dsa: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-10 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare DSA to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
dsa_slave_port_attr_set() call.

Signed-off-by: Florian Fainelli 
---
 net/dsa/slave.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index d8eb33979368..ee4b94c5e68e 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -1547,6 +1547,20 @@ dsa_slave_switchdev_port_obj_event(unsigned long event,
return notifier_from_errno(err);
 }
 
+static int
+dsa_slave_switchdev_port_attr_set_event(unsigned long event,
+   struct net_device *netdev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err;
+
+   err = dsa_slave_port_attr_set(netdev, port_attr_info->attr,
+ port_attr_info->trans);
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int dsa_slave_switchdev_blocking_event(struct notifier_block *unused,
  unsigned long event, void *ptr)
 {
@@ -1559,6 +1573,8 @@ static int dsa_slave_switchdev_blocking_event(struct 
notifier_block *unused,
case SWITCHDEV_PORT_OBJ_ADD: /* fall through */
case SWITCHDEV_PORT_OBJ_DEL:
return dsa_slave_switchdev_port_obj_event(event, dev, ptr);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return dsa_slave_switchdev_port_attr_set_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.19.1



[PATCH net-next v2 07/16] net: Remove SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT

2019-02-10 Thread Florian Fainelli
Now that we have converted the bridge code and the drivers to check for
bridge port(s) flags at the time we try to set them, there is no need
for a get() -> set() sequence anymore and
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT therefore becomes unused.

Acked-by: Jiri Pirko 
Signed-off-by: Florian Fainelli 
---
 .../net/ethernet/mellanox/mlxsw/spectrum_switchdev.c   |  4 
 drivers/net/ethernet/rocker/rocker_main.c  |  4 
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c|  3 ---
 include/net/switchdev.h|  2 --
 net/dsa/slave.c| 10 +-
 5 files changed, 1 insertion(+), 22 deletions(-)

diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c 
b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
index 468a6d513074..8242a373f6e7 100644
--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c
@@ -455,10 +455,6 @@ static int mlxsw_sp_port_attr_get(struct net_device *dev,
mlxsw_sp_port_bridge_flags_get(mlxsw_sp->bridge, attr->orig_dev,
   &attr->u.brport_flags);
break;
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
-   attr->u.brport_flags_support = BR_LEARNING | BR_FLOOD |
-  BR_MCAST_FLOOD;
-   break;
default:
return -EOPNOTSUPP;
}
diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index 8657313b6f30..375c4c908bea 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2075,10 +2075,6 @@ static int rocker_port_attr_get(struct net_device *dev,
err = rocker_world_port_attr_bridge_flags_get(rocker_port,
  
&attr->u.brport_flags);
break;
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
-   err = 
rocker_world_port_attr_bridge_flags_support_get(rocker_port,
- 
&attr->u.brport_flags_support);
-   break;
default:
return -EOPNOTSUPP;
}
diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index 6228c4375835..79635d1091df 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -651,9 +651,6 @@ static int swdev_port_attr_get(struct net_device *netdev,
(port_priv->ethsw_data->learning ? BR_LEARNING : 0) |
(port_priv->flood ? BR_FLOOD : 0);
break;
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
-   attr->u.brport_flags_support = BR_LEARNING | BR_FLOOD;
-   break;
default:
return -EOPNOTSUPP;
}
diff --git a/include/net/switchdev.h b/include/net/switchdev.h
index 5e87b54c5dc5..e2083824e577 100644
--- a/include/net/switchdev.h
+++ b/include/net/switchdev.h
@@ -45,7 +45,6 @@ enum switchdev_attr_id {
SWITCHDEV_ATTR_ID_UNDEFINED,
SWITCHDEV_ATTR_ID_PORT_STP_STATE,
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
-   SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
SWITCHDEV_ATTR_ID_PORT_MROUTER,
SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME,
SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING,
@@ -62,7 +61,6 @@ struct switchdev_attr {
union {
u8 stp_state;   /* PORT_STP_STATE */
unsigned long brport_flags; /* PORT_BRIDGE_FLAGS */
-   unsigned long brport_flags_support; /* 
PORT_BRIDGE_FLAGS_SUPPORT */
bool mrouter;   /* PORT_MROUTER */
clock_t ageing_time;/* BRIDGE_AGEING_TIME */
bool vlan_filtering;/* 
BRIDGE_VLAN_FILTERING */
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 9b499ba88aa7..7b33be6f1954 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -385,15 +385,7 @@ static int dsa_slave_get_port_parent_id(struct net_device 
*dev,
 static int dsa_slave_port_attr_get(struct net_device *dev,
   struct switchdev_attr *attr)
 {
-   switch (attr->id) {
-   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT:
-   attr->u.brport_flags_support = 0;
-   break;
-   default:
-   return -EOPNOTSUPP;
-   }
-
-   return 0;
+   return -EOPNOTSUPP;
 }
 
 static inline netdev_tx_t dsa_slave_netpoll_send_skb(struct net_device *dev,
-- 
2.19.1



[PATCH net-next v2 10/16] rocker: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-10 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare rocker to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
rocker_port_attr_set call.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/rocker/rocker_main.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/rocker/rocker_main.c 
b/drivers/net/ethernet/rocker/rocker_main.c
index ff3f14504f4f..b94f940dc7b5 100644
--- a/drivers/net/ethernet/rocker/rocker_main.c
+++ b/drivers/net/ethernet/rocker/rocker_main.c
@@ -2811,6 +2811,20 @@ rocker_switchdev_port_obj_event(unsigned long event, 
struct net_device *netdev,
return notifier_from_errno(err);
 }
 
+static int
+rocker_switchdev_port_attr_set_event(unsigned long event, struct net_device 
*netdev,
+struct switchdev_notifier_port_attr_info
+*port_attr_info)
+{
+   int err;
+
+   err = rocker_port_attr_set(netdev, port_attr_info->attr,
+  port_attr_info->trans);
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int rocker_switchdev_blocking_event(struct notifier_block *unused,
   unsigned long event, void *ptr)
 {
@@ -2823,6 +2837,8 @@ static int rocker_switchdev_blocking_event(struct 
notifier_block *unused,
case SWITCHDEV_PORT_OBJ_ADD:
case SWITCHDEV_PORT_OBJ_DEL:
return rocker_switchdev_port_obj_event(event, dev, ptr);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return rocker_switchdev_port_attr_set_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.19.1



[PATCH net-next v2 04/16] net: dsa: Add setter for SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS

2019-02-10 Thread Florian Fainelli
In preparation for removing SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
add support for a function that processes the
SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS attribute and returns not supported
for any flag set, since DSA does not currently support toggling those
bridge port attributes (yet).

Acked-by: Jiri Pirko 
Signed-off-by: Florian Fainelli 
---
 net/dsa/dsa_priv.h |  3 +++
 net/dsa/port.c | 10 ++
 net/dsa/slave.c|  4 
 3 files changed, 17 insertions(+)

diff --git a/net/dsa/dsa_priv.h b/net/dsa/dsa_priv.h
index 1f4972dab9f2..97594f0b6efb 100644
--- a/net/dsa/dsa_priv.h
+++ b/net/dsa/dsa_priv.h
@@ -150,6 +150,9 @@ int dsa_port_vlan_filtering(struct dsa_port *dp, bool 
vlan_filtering,
struct switchdev_trans *trans);
 int dsa_port_ageing_time(struct dsa_port *dp, clock_t ageing_clock,
 struct switchdev_trans *trans);
+int dsa_port_bridge_port_flags_set(struct dsa_port *dp,
+  unsigned long brport_flags,
+  struct switchdev_trans *trans);
 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
 u16 vid);
 int dsa_port_fdb_del(struct dsa_port *dp, const unsigned char *addr,
diff --git a/net/dsa/port.c b/net/dsa/port.c
index 2d7e01b23572..2ce3752203cf 100644
--- a/net/dsa/port.c
+++ b/net/dsa/port.c
@@ -177,6 +177,16 @@ int dsa_port_ageing_time(struct dsa_port *dp, clock_t 
ageing_clock,
return dsa_port_notify(dp, DSA_NOTIFIER_AGEING_TIME, &info);
 }
 
+int dsa_port_bridge_port_flags_set(struct dsa_port *dp,
+  unsigned long brport_flags,
+  struct switchdev_trans *trans)
+{
+   if (brport_flags)
+   return -EOPNOTSUPP;
+
+   return 0;
+}
+
 int dsa_port_fdb_add(struct dsa_port *dp, const unsigned char *addr,
 u16 vid)
 {
diff --git a/net/dsa/slave.c b/net/dsa/slave.c
index 2e5e7c04821b..9b499ba88aa7 100644
--- a/net/dsa/slave.c
+++ b/net/dsa/slave.c
@@ -295,6 +295,10 @@ static int dsa_slave_port_attr_set(struct net_device *dev,
case SWITCHDEV_ATTR_ID_BRIDGE_AGEING_TIME:
ret = dsa_port_ageing_time(dp, attr->u.ageing_time, trans);
break;
+   case SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS:
+   ret = dsa_port_bridge_port_flags_set(dp, attr->u.brport_flags,
+trans);
+   break;
default:
ret = -EOPNOTSUPP;
break;
-- 
2.19.1



[PATCH net-next v2 15/16] net: switchdev: Replace port attr set SDO with a notification

2019-02-10 Thread Florian Fainelli
Drop switchdev_ops.switchdev_port_attr_set. Drop the uses of this field
from all clients, which were migrated to use switchdev notification in
the previous patches.

Add a new function switchdev_port_attr_notify() that sends the switchdev
notifications SWITCHDEV_PORT_ATTR_SET.

Drop __switchdev_port_attr_set() and update switchdev_port_attr_set()
likewise.

Signed-off-by: Florian Fainelli 
---
 net/switchdev/switchdev.c | 92 ++-
 1 file changed, 22 insertions(+), 70 deletions(-)

diff --git a/net/switchdev/switchdev.c b/net/switchdev/switchdev.c
index 7e1357db33d7..fab96d978924 100644
--- a/net/switchdev/switchdev.c
+++ b/net/switchdev/switchdev.c
@@ -174,81 +174,31 @@ static int switchdev_deferred_enqueue(struct net_device 
*dev,
return 0;
 }
 
-/**
- * switchdev_port_attr_get - Get port attribute
- *
- * @dev: port device
- * @attr: attribute to get
- */
-int switchdev_port_attr_get(struct net_device *dev, struct switchdev_attr 
*attr)
+static int switchdev_port_attr_notify(enum switchdev_notifier_type nt,
+ struct net_device *dev,
+ const struct switchdev_attr *attr,
+ struct switchdev_trans *trans)
 {
-   const struct switchdev_ops *ops = dev->switchdev_ops;
-   struct net_device *lower_dev;
-   struct list_head *iter;
-   struct switchdev_attr first = {
-   .id = SWITCHDEV_ATTR_ID_UNDEFINED
-   };
-   int err = -EOPNOTSUPP;
+   int err;
+   int rc;
 
-   if (ops && ops->switchdev_port_attr_get)
-   return ops->switchdev_port_attr_get(dev, attr);
+   struct switchdev_notifier_port_attr_info attr_info = {
+   .attr = attr,
+   .trans = trans,
+   .handled = false,
+   };
 
-   if (attr->flags & SWITCHDEV_F_NO_RECURSE)
+   rc = call_switchdev_blocking_notifiers(nt, dev, &attr_info.info, NULL);
+   err = notifier_to_errno(rc);
+   if (err) {
+   WARN_ON(!attr_info.handled);
return err;
-
-   /* Switch device port(s) may be stacked under
-* bond/team/vlan dev, so recurse down to get attr on
-* each port.  Return -ENODATA if attr values don't
-* compare across ports.
-*/
-
-   netdev_for_each_lower_dev(dev, lower_dev, iter) {
-   err = switchdev_port_attr_get(lower_dev, attr);
-   if (err)
-   break;
-   if (first.id == SWITCHDEV_ATTR_ID_UNDEFINED)
-   first = *attr;
-   else if (memcmp(&first, attr, sizeof(*attr)))
-   return -ENODATA;
}
 
-   return err;
-}
-EXPORT_SYMBOL_GPL(switchdev_port_attr_get);
-
-static int __switchdev_port_attr_set(struct net_device *dev,
-const struct switchdev_attr *attr,
-struct switchdev_trans *trans)
-{
-   const struct switchdev_ops *ops = dev->switchdev_ops;
-   struct net_device *lower_dev;
-   struct list_head *iter;
-   int err = -EOPNOTSUPP;
-
-   if (ops && ops->switchdev_port_attr_set) {
-   err = ops->switchdev_port_attr_set(dev, attr, trans);
-   goto done;
-   }
-
-   if (attr->flags & SWITCHDEV_F_NO_RECURSE)
-   goto done;
-
-   /* Switch device port(s) may be stacked under
-* bond/team/vlan dev, so recurse down to set attr on
-* each port.
-*/
-
-   netdev_for_each_lower_dev(dev, lower_dev, iter) {
-   err = __switchdev_port_attr_set(lower_dev, attr, trans);
-   if (err)
-   break;
-   }
-
-done:
-   if (err == -EOPNOTSUPP && attr->flags & SWITCHDEV_F_SKIP_EOPNOTSUPP)
-   err = 0;
+   if (!attr_info.handled)
+   return -EOPNOTSUPP;
 
-   return err;
+   return 0;
 }
 
 static int switchdev_port_attr_set_now(struct net_device *dev,
@@ -267,7 +217,8 @@ static int switchdev_port_attr_set_now(struct net_device 
*dev,
 */
 
trans.ph_prepare = true;
-   err = __switchdev_port_attr_set(dev, attr, &trans);
+   err = switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_SET, dev, attr,
+&trans);
if (err) {
/* Prepare phase failed: abort the transaction.  Any
 * resources reserved in the prepare phase are
@@ -286,7 +237,8 @@ static int switchdev_port_attr_set_now(struct net_device 
*dev,
 */
 
trans.ph_prepare = false;
-   err = __switchdev_port_attr_set(dev, attr, &trans);
+   err = switchdev_port_attr_notify(SWITCHDEV_PORT_ATTR_SET, dev, attr,
+&trans);
WARN(err, "%s: Commit of attribute (id=%d) failed.\n",
 dev->name, attr->id);
switchdev_trans_items_warn_destroy(dev, &

[PATCH net-next v2 14/16] staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-10 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare ethsw to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
swdev_port_attr_set() call.

Signed-off-by: Florian Fainelli 
---
 drivers/staging/fsl-dpaa2/ethsw/ethsw.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c 
b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
index b195b09e0d1d..8baa503d9a6a 100644
--- a/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
+++ b/drivers/staging/fsl-dpaa2/ethsw/ethsw.c
@@ -1092,6 +1092,20 @@ ethsw_switchdev_port_obj_event(unsigned long event, 
struct net_device *netdev,
return notifier_from_errno(err);
 }
 
+static int
+ethsw_switchdev_port_attr_set_event(unsigned long event,
+   struct net_device *netdev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err;
+
+   err = swdev_port_attr_set(netdev, port_attr_info->attr,
+ port_attr_info->trans);
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int port_switchdev_blocking_event(struct notifier_block *unused,
 unsigned long event, void *ptr)
 {
@@ -1104,6 +1118,8 @@ static int port_switchdev_blocking_event(struct 
notifier_block *unused,
case SWITCHDEV_PORT_OBJ_ADD: /* fall through */
case SWITCHDEV_PORT_OBJ_DEL:
return ethsw_switchdev_port_obj_event(event, dev, ptr);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return ethsw_switchdev_port_attr_set_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.19.1



[PATCH net-next v2 06/16] net: bridge: Stop calling switchdev_port_attr_get()

2019-02-10 Thread Florian Fainelli
Now that all switchdev drivers have been converted to checking the
bridge port flags during the prepare phase of the
switchdev_port_attr_set(), we can move straight to trying to set the
desired flag through SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS.

Acked-by: Jiri Pirko 
Signed-off-by: Florian Fainelli 
---
 net/bridge/br_switchdev.c | 20 +++-
 1 file changed, 3 insertions(+), 17 deletions(-)

diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
index db9e8ab96d48..939f300522c5 100644
--- a/net/bridge/br_switchdev.c
+++ b/net/bridge/br_switchdev.c
@@ -64,29 +64,15 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
 {
struct switchdev_attr attr = {
.orig_dev = p->dev,
-   .id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
+   .id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
+   .flags = SWITCHDEV_F_DEFER,
+   .u.brport_flags = flags,
};
int err;
 
if (mask & ~BR_PORT_FLAGS_HW_OFFLOAD)
return 0;
 
-   err = switchdev_port_attr_get(p->dev, &attr);
-   if (err == -EOPNOTSUPP)
-   return 0;
-   if (err)
-   return err;
-
-   /* Check if specific bridge flag attribute offload is supported */
-   if (!(attr.u.brport_flags_support & mask)) {
-   br_warn(p->br, "bridge flag offload is not supported %u(%s)\n",
-   (unsigned int)p->port_no, p->dev->name);
-   return -EOPNOTSUPP;
-   }
-
-   attr.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS;
-   attr.flags = SWITCHDEV_F_DEFER;
-   attr.u.brport_flags = flags;
err = switchdev_port_attr_set(p->dev, &attr);
if (err) {
br_warn(p->br, "error setting offload flag on port %u(%s)\n",
-- 
2.19.1



[PATCH net-next v2 13/16] net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_SET

2019-02-10 Thread Florian Fainelli
Following patches will change the way we communicate getting or setting
a port's attribute and use a blocking notifier to perform those tasks.

Prepare ocelot to support receiving notifier events targeting
SWITCHDEV_PORT_ATTR_SET and simply translate that into the existing
ocelot_port_attr_set() call.

Signed-off-by: Florian Fainelli 
---
 drivers/net/ethernet/mscc/ocelot.c | 16 
 1 file changed, 16 insertions(+)

diff --git a/drivers/net/ethernet/mscc/ocelot.c 
b/drivers/net/ethernet/mscc/ocelot.c
index 195306d05bcd..1dda4dd4c073 100644
--- a/drivers/net/ethernet/mscc/ocelot.c
+++ b/drivers/net/ethernet/mscc/ocelot.c
@@ -1582,6 +1582,20 @@ struct notifier_block ocelot_netdevice_nb __read_mostly 
= {
 };
 EXPORT_SYMBOL(ocelot_netdevice_nb);
 
+static int
+ocelot_switchdev_port_attr_set_event(unsigned long event,
+   struct net_device *netdev,
+   struct switchdev_notifier_port_attr_info *port_attr_info)
+{
+   int err;
+
+   err = ocelot_port_attr_set(netdev, port_attr_info->attr,
+  port_attr_info->trans);
+
+   port_attr_info->handled = true;
+   return notifier_from_errno(err);
+}
+
 static int ocelot_switchdev_blocking_event(struct notifier_block *unused,
   unsigned long event, void *ptr)
 {
@@ -1600,6 +1614,8 @@ static int ocelot_switchdev_blocking_event(struct 
notifier_block *unused,
ocelot_netdevice_dev_check,
ocelot_port_obj_del);
return notifier_from_errno(err);
+   case SWITCHDEV_PORT_ATTR_SET:
+   return ocelot_switchdev_port_attr_set_event(event, dev, ptr);
}
 
return NOTIFY_DONE;
-- 
2.19.1



Re: [RFC v1 0/3] Address potential user-after-free on module unload

2019-02-10 Thread Sven Van Asbroeck
Hi Miguel,

On Thu, Feb 7, 2019 at 11:30 PM Miguel Ojeda
 wrote:
>
> Similarly, in drivers/auxdisplay/ht16k33.c, the cancel_delayed_work()
> is there, instead of cancel_delayed_work_sync(). Having the script
> suggest this change would be useful, too (i.e. instead of the devm_
> change, assuming the cancel_delayed_work() is already there).
>

For relatively straightforward problems, I'd say yes.

However, the problems flagged by this script are not trivial at all.
In many cases, the missing _sync is just a symptom of general
synchronization issues on disconnect(), and simply adding it
will not fix the problem. Sometimes, it's just a false positive.


Re: [RFC PATCH v1 14/16] powerpc/32: implement fast entry for syscalls on non BOOKE

2019-02-10 Thread christophe leroy




Le 08/02/2019 à 13:52, Christophe Leroy a écrit :

This patch implements a fast entry for syscalls.

Syscalls don't have to preserve non volatile registers except LR.

This patch then implement a fast entry for syscalls, where
volatile registers get clobbered.

As this entry is dedicated to syscall it always sets MSR_EE
and warns in case MSR_EE was previously off

It also assumes that the call is always from user, system calls are
unexpected from kernel.

The overall series improves null_syscall selftest by 12,5% on an 83xx
and by 17% on a 8xx.

Signed-off-by: Christophe Leroy 


The following addition is required to avoid build failure on 40x as 
global_dbcr0 is going to be accessed from head_40x.S


diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 85f1fc88c237..987f0fafc999 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -1247,6 +1247,7 @@ load_dbcr0:

.section .bss
.align  4
+   .global global_dbcr0
 global_dbcr0:
.space  8*NR_CPUS
.previous

Christophe


---
  arch/powerpc/kernel/entry_32.S | 42 +
  arch/powerpc/kernel/head_32.S  |  3 +-
  arch/powerpc/kernel/head_32.h  | 85 --
  arch/powerpc/kernel/head_40x.S |  3 +-
  arch/powerpc/kernel/head_8xx.S |  3 +-
  5 files changed, 126 insertions(+), 10 deletions(-)

diff --git a/arch/powerpc/kernel/entry_32.S b/arch/powerpc/kernel/entry_32.S
index 1e11528d45ae..137bd2103051 100644
--- a/arch/powerpc/kernel/entry_32.S
+++ b/arch/powerpc/kernel/entry_32.S
@@ -335,6 +335,46 @@ stack_ovf:
SYNC
RFI
  
+#ifndef CONFIG_BOOKE	/* to be removed once BOOKE uses fast syscall entry */

+#ifdef CONFIG_TRACE_IRQFLAGS
+trace_syscall_entry_irq_off:
+   /*
+* The trace_hardirqs_off will use CALLER_ADDR0 and CALLER_ADDR1.
+* If from user mode there is only one stack frame on the stack, and
+* accessing CALLER_ADDR1 will cause oops. So we need create a dummy
+* stack frame to make trace_hardirqs_on happy.
+*
+*/
+   stwur1,-32(r1)
+
+   /*
+* Syscall shouldn't happen while interrupts are disabled,
+* so let's do a warning here.
+*/
+0: trap
+   EMIT_BUG_ENTRY 0b,__FILE__,__LINE__, BUGFLAG_WARNING
+   bl  trace_hardirqs_on
+
+   addir1,r1,32
+
+   /* Now enable for real */
+   LOAD_MSR_KERNEL(r10, MSR_KERNEL | MSR_EE)
+   mtmsr   r10
+
+   REST_GPR(0, r1)
+   REST_4GPRS(3, r1)
+   REST_2GPRS(7, r1)
+   b   DoSyscall
+#endif /* CONFIG_TRACE_IRQFLAGS */
+
+   .globl  transfer_to_syscall
+transfer_to_syscall:
+#ifdef CONFIG_TRACE_IRQFLAGS
+   andi.   r12,r9,MSR_EE
+   beq-trace_syscall_entry_irq_off
+#endif /* CONFIG_TRACE_IRQFLAGS */
+#endif /* !CONFIG_BOOKE */
+
  /*
   * Handle a system call.
   */
@@ -346,9 +386,11 @@ _GLOBAL(DoSyscall)
stw r3,ORIG_GPR3(r1)
li  r12,0
stw r12,RESULT(r1)
+#ifdef CONFIG_BOOKE/* to be removed once BOOKE uses fast syscall entry */
lwz r11,_CCR(r1)/* Clear SO bit in CR */
rlwinm  r11,r11,0,4,2
stw r11,_CCR(r1)
+#endif
  
  #ifdef CONFIG_TRACE_IRQFLAGS

/* Make sure interrupts are enabled */
diff --git a/arch/powerpc/kernel/head_32.S b/arch/powerpc/kernel/head_32.S
index 3a1df9edf6da..7576e1374a69 100644
--- a/arch/powerpc/kernel/head_32.S
+++ b/arch/powerpc/kernel/head_32.S
@@ -368,8 +368,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_FPU_UNAVAILABLE)
. = 0xc00
DO_KVM  0xc00
  SystemCall:
-   EXCEPTION_PROLOG
-   EXC_XFER_SYS(0xc00, DoSyscall)
+   SYSCALL_ENTRY   0xc00
  
  /* Single step - not used on 601 */

EXCEPTION(0xd00, SingleStep, single_step_exception, EXC_XFER_STD)
diff --git a/arch/powerpc/kernel/head_32.h b/arch/powerpc/kernel/head_32.h
index 14cb0af2f494..4a692553651f 100644
--- a/arch/powerpc/kernel/head_32.h
+++ b/arch/powerpc/kernel/head_32.h
@@ -73,6 +73,87 @@
SAVE_2GPRS(7, r11)
  .endm
  
+.macro SYSCALL_ENTRY trapno

+   mfspr   r12,SPRN_SPRG_THREAD
+   mfcrr10
+   lwz r11,TASK_STACK-THREAD(r12)
+   mflrr9
+   addir11,r11,THREAD_SIZE - INT_FRAME_SIZE
+   rlwinm  r10,r10,0,4,2   /* Clear SO bit in CR */
+   tophys(r11,r11)
+   stw r10,_CCR(r11)   /* save registers */
+   mfspr   r10,SPRN_SRR0
+   stw r9,_LINK(r11)
+   mfspr   r9,SPRN_SRR1
+   stw r1,GPR1(r11)
+   stw r1,0(r11)
+   tovirt(r1,r11)  /* set new kernel sp */
+   stw r10,_NIP(r11)
+#ifdef CONFIG_40x
+   rlwinm  r9,r9,0,14,12   /* clear MSR_WE (necessary?) */
+#else
+   LOAD_MSR_KERNEL(r10, MSR_KERNEL & ~(MSR_IR|MSR_DR)) /* can take 
exceptions */
+   MTMSRD(r10) /* (except for mach check in rtas) */
+#endif
+   lis r10,STACK_FRAME_REGS_MARKER@ha /* exc

[PATCH] MAINTAINERS: use tab instead of spaces

2019-02-10 Thread Lukas Bulwahn
Mimi Zohar used spaces instead of a tab when adding Jarkko Sakkinen as
further maintainer to the KEYS-TRUSTED section entry. So, we rectify this
with this commit.

The issue was detected when writing a script that parses MAINTAINERS.

Fixes: 34bccd61b139 ("MAINTAINERS: add Jarkko as maintainer for trusted keys")
Signed-off-by: Lukas Bulwahn 
---
Mimi, please pick up this patch. Thanks.

 MAINTAINERS | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index bf4965d6d5de..31950caabcaf 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8405,7 +8405,7 @@ F:security/keys/encrypted-keys/
 
 KEYS-TRUSTED
 M: James Bottomley 
-M:  Jarkko Sakkinen 
+M: Jarkko Sakkinen 
 M: Mimi Zohar 
 L: linux-integr...@vger.kernel.org
 L: keyri...@vger.kernel.org
-- 
2.17.1



Re: [PATCH] x86: make set_pmd_at() paravirt aware

2019-02-10 Thread Linus Torvalds
On Sat, Feb 9, 2019 at 11:41 PM Juergen Gross  wrote:
>
> Make set_pmd_at() paravirt aware by just letting it use set_pmd().

Well, that was simpler than I worried.

Just checking: Is this purely an x86 issue? ARM is ok perhaps because
there's no PV support?

 Linus


Re: [PATCH] MAINTAINERS: use tab instead of spaces

2019-02-10 Thread Randy Dunlap
On 2/10/19 10:10 AM, Lukas Bulwahn wrote:
> Mimi Zohar used spaces instead of a tab when adding Jarkko Sakkinen as
> further maintainer to the KEYS-TRUSTED section entry. So, we rectify this
> with this commit.
> 
> The issue was detected when writing a script that parses MAINTAINERS.
> 
> Fixes: 34bccd61b139 ("MAINTAINERS: add Jarkko as maintainer for trusted keys")
> Signed-off-by: Lukas Bulwahn 
> ---
> Mimi, please pick up this patch. Thanks.
> 
>  MAINTAINERS | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index bf4965d6d5de..31950caabcaf 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -8405,7 +8405,7 @@ F:  security/keys/encrypted-keys/
>  
>  KEYS-TRUSTED
>  M:   James Bottomley 
> -M:  Jarkko Sakkinen 
> +M:   Jarkko Sakkinen 
>  M:   Mimi Zohar 

Just checking:  is that email address correct (@linuxibm.com)?

Guess I'll see if it bounces.

>  L:   linux-integr...@vger.kernel.org
>  L:   keyri...@vger.kernel.org
> 


-- 
~Randy


possible deadlock in pipe_lock (2)

2019-02-10 Thread syzbot

Hello,

syzbot found the following crash on:

HEAD commit:74e96711e337 Merge tag 'platform-drivers-x86-v5.0-2' of gi..
git tree:   upstream
console output: https://syzkaller.appspot.com/x/log.txt?x=11225b2740
kernel config:  https://syzkaller.appspot.com/x/.config?x=8f00801d7b7c4fe6
dashboard link: https://syzkaller.appspot.com/bug?extid=31d8b84465a7cbfd8515
compiler:   gcc (GCC) 9.0.0 20181231 (experimental)

Unfortunately, I don't have any reproducer for this crash yet.

IMPORTANT: if you fix the bug, please add the following tag to the commit:
Reported-by: syzbot+31d8b84465a7cbfd8...@syzkaller.appspotmail.com

kvm [15406]: vcpu0, guest rIP: 0xfff0 kvm_set_msr_common:  
MSR_IA32_DEBUGCTLMSR 0x3, nop

==
WARNING: possible circular locking dependency detected
5.0.0-rc5+ #63 Not tainted
--
overlayfs: filesystem on './file0' not supported as upperdir
syz-executor.2/15417 is trying to acquire lock:
dcbcd11f (&pipe->mutex/1){+.+.}, at: pipe_lock_nested fs/pipe.c:62  
[inline]
dcbcd11f (&pipe->mutex/1){+.+.}, at: pipe_lock+0x6e/0x80  
fs/pipe.c:70


but task is already holding lock:
kobject: 'loop0' (d9cc93a0): kobject_uevent_env
c13db9a0 (sb_writers#3){.+.+}, at: file_start_write  
include/linux/fs.h:2816 [inline]
c13db9a0 (sb_writers#3){.+.+}, at: do_splice+0xceb/0x1330  
fs/splice.c:1151


which lock already depends on the new lock.


the existing dependency chain (in reverse order) is:
kobject: 'loop0' (d9cc93a0): fill_kobj_path: path  
= '/devices/virtual/block/loop0'


-> #2 (sb_writers#3){.+.+}:
   percpu_down_read_preempt_disable include/linux/percpu-rwsem.h:36  
[inline]

   percpu_down_read include/linux/percpu-rwsem.h:59 [inline]
   __sb_start_write+0x20b/0x360 fs/super.c:1389
   sb_start_write include/linux/fs.h:1603 [inline]
   mnt_want_write+0x3f/0xc0 fs/namespace.c:357
   ovl_want_write+0x76/0xa0 fs/overlayfs/util.c:24
   ovl_setattr+0xdd/0x950 fs/overlayfs/inode.c:30
   notify_change+0xad9/0xfb0 fs/attr.c:334
kobject: 'loop5' (a501efc5): kobject_uevent_env
   do_truncate+0x158/0x220 fs/open.c:63
   handle_truncate fs/namei.c:3008 [inline]
   do_last fs/namei.c:3424 [inline]
   path_openat+0x2cc6/0x4690 fs/namei.c:3534
   do_filp_open+0x1a1/0x280 fs/namei.c:3564
   do_sys_open+0x3fe/0x5d0 fs/open.c:1063
   __do_sys_openat fs/open.c:1090 [inline]
   __se_sys_openat fs/open.c:1084 [inline]
   __x64_sys_openat+0x9d/0x100 fs/open.c:1084
   do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
kobject: 'loop5' (a501efc5): fill_kobj_path: path  
= '/devices/virtual/block/loop5'

   entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #1 (&ovl_i_mutex_key[depth]){+.+.}:
   down_write+0x38/0x90 kernel/locking/rwsem.c:70
   inode_lock include/linux/fs.h:757 [inline]
   ovl_write_iter+0x148/0xc20 fs/overlayfs/file.c:231
   call_write_iter include/linux/fs.h:1863 [inline]
   new_sync_write fs/read_write.c:474 [inline]
   __vfs_write+0x613/0x8e0 fs/read_write.c:487
kobject: 'loop4' (9e2b886d): kobject_uevent_env
   __kernel_write+0x110/0x3b0 fs/read_write.c:506
   write_pipe_buf+0x15d/0x1f0 fs/splice.c:797
   splice_from_pipe_feed fs/splice.c:503 [inline]
   __splice_from_pipe+0x39a/0x7e0 fs/splice.c:627
   splice_from_pipe+0x108/0x170 fs/splice.c:662
   default_file_splice_write+0x3c/0x90 fs/splice.c:809
   do_splice_from fs/splice.c:851 [inline]
   do_splice+0x644/0x1330 fs/splice.c:1152
   __do_sys_splice fs/splice.c:1419 [inline]
   __se_sys_splice fs/splice.c:1399 [inline]
   __x64_sys_splice+0x2c6/0x330 fs/splice.c:1399
kobject: 'loop4' (9e2b886d): fill_kobj_path: path  
= '/devices/virtual/block/loop4'

   do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
   entry_SYSCALL_64_after_hwframe+0x49/0xbe

-> #0 (&pipe->mutex/1){+.+.}:
   lock_acquire+0x16f/0x3f0 kernel/locking/lockdep.c:3841
   __mutex_lock_common kernel/locking/mutex.c:925 [inline]
   __mutex_lock+0xf7/0x1310 kernel/locking/mutex.c:1072
   mutex_lock_nested+0x16/0x20 kernel/locking/mutex.c:1087
   pipe_lock_nested fs/pipe.c:62 [inline]
   pipe_lock+0x6e/0x80 fs/pipe.c:70
   iter_file_splice_write+0x18b/0xbe0 fs/splice.c:700
   do_splice_from fs/splice.c:851 [inline]
   do_splice+0x644/0x1330 fs/splice.c:1152
   __do_sys_splice fs/splice.c:1419 [inline]
   __se_sys_splice fs/splice.c:1399 [inline]
   __x64_sys_splice+0x2c6/0x330 fs/splice.c:1399
   do_syscall_64+0x103/0x610 arch/x86/entry/common.c:290
   entry_SYSCALL_64_after_hwframe+0x49/0xbe

other info that might help us debug this:

Chain exists of:
  &pipe->mutex/1 --> &ovl_i_mutex_key[depth] --> sb_writers#3

 Possible unsafe locking scenario:

   CPU0CPU1
  

Re: [PATCH] MAINTAINERS: use tab instead of spaces

2019-02-10 Thread James Bottomley
On Sun, 2019-02-10 at 19:10 +0100, Lukas Bulwahn wrote:
> Mimi Zohar used spaces instead of a tab when adding Jarkko Sakkinen
> as
> further maintainer to the KEYS-TRUSTED section entry. So, we rectify
> this
> with this commit.
> 
> The issue was detected when writing a script that parses MAINTAINERS.
> 
> Fixes: 34bccd61b139 ("MAINTAINERS: add Jarkko as maintainer for
> trusted keys")
> Signed-off-by: Lukas Bulwahn 

This isn't really a bug, is it?

We have no formatting requirements for the MAINTAINERS file and the
section owner is free to align with tabs, spaces or nothing as they see
fit.  Most use a single tab, but a couple don't. The only real thing
that cares is get_maintainers.pl and it uses \s* as the parse regexp,
so it doesn't care either.

Now, we could possibly agree the file looks better with a single space
or a single tab between the tag and the value and thus we should be
doing this, but we'd need to agree on that and update the tag
description accordingly.

James



Re: [PATCH v4 10/16] block: sed-opal: add ioctl for done-mark of shadow mbr

2019-02-10 Thread Scott Bauer
On Fri, Feb 08, 2019 at 12:44:14AM +, Derrick, Jonathan wrote:
> On Thu, 2019-02-07 at 23:56 +0100, David Kozub wrote:
> > On Mon, 4 Feb 2019, Christoph Hellwig wrote:
> > > >  static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
> > > >   struct opal_mbr_data 
> > > > *opal_mbr)
> > > >  {
> > > > +   u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE
> > > > +   ? OPAL_TRUE : OPAL_FALSE;
> > > > const struct opal_step mbr_steps[] = {
> > > > { opal_discovery0, },
> > > > { start_admin1LSP_opal_session, &opal_mbr->key },
> > > > -   { set_mbr_done, &opal_mbr->enable_disable },
> > > > +   { set_mbr_done, &token },

> > Am I missing something here? This seems wrong to me. And I think this 
> > patch actually changes it by introducing:
> > 
> > +u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE
> > +? OPAL_TRUE : OPAL_FALSE;
> > 
> > which is essentially a negation (map 0 to 1 and 1 to 0).

Agreed the original code did the opposite of what the user wanted, looks like
when I authored it I messed up that enum which set everything off.



> > With regard to the new IOC_OPAL_MBR_STATUS: I find the usage of 
> > OPAL_MBR_ENABLE/DISABLE for this confusing: what should passing 
> > OPAL_MBR_ENABLE do? Should it enable the shadow MBR? Or should it 
> > enable the MBR-done flag? I think the implementation in this patch 
> > interprets OPAL_MBR_ENABLE as 'set the "done" flag to true', thus hiding 
> > the shadow MBR. But this is not obvious looking at the IOCTL name.

For the new ioctl I think we should just add a new enum with the correct
nomenclature.  So OPAL_MBR_DONE, OPAL_MBR_NOT_DONE.


> In order to keep the userspace interface consistent, I'll ACK your
> change in this patch, unless Scott can fill me in on why this looks
> wrong but is actually right.

I think it is just wrong. 


> 
> We have 7 bytes in the opal_mbr_data struct we could use for DONE/NOT
> DONE. I'm not sure how to go about keeping it consistent with old uapi,
> although arguably opal_enable_disable_shadow_mbr is already doing the
> wrong thing with DONE and ENABLE so it's low impact.

Can we keep the old mbr struct the same and just add a new struct with new enums
for the new done ioctl? I think this will keep the new ioctl cleaner instead
of trying to apply older, some what incorrectly named, enums.

Lastly someone will need to backport his

> > > > +   u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE
> > > > +   ? OPAL_TRUE : OPAL_FALSE;

to stable so we can fix up my broken coding in older kernels.


I can do that or, if David wants to do that that's fine... just want to 
coordinate.









Re: [GIT PULL] x86 fixes

2019-02-10 Thread pr-tracker-bot
The pull request you sent on Sun, 10 Feb 2019 10:13:40 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-urgent-for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/aadaa8061189a9e5d8a1327b328453d663e8cbc9

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] locking fixes

2019-02-10 Thread pr-tracker-bot
The pull request you sent on Sun, 10 Feb 2019 09:53:31 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
> locking-urgent-for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/d2a6aae99f5fa2f1e7e400bd2f17c1d42c50312a

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] IRQ fixes

2019-02-10 Thread pr-tracker-bot
The pull request you sent on Sun, 10 Feb 2019 10:08:57 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git irq-urgent-for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/73a4c52184141943146ebbf07de4dca27141f21c

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [PATCH] MAINTAINERS: use tab instead of spaces

2019-02-10 Thread Lukas Bulwahn
On Sun, Feb 10, 2019 at 7:22 PM Randy Dunlap  wrote:
>
> On 2/10/19 10:10 AM, Lukas Bulwahn wrote:
> >  M:   James Bottomley 
> > -M:  Jarkko Sakkinen 
> > +M:   Jarkko Sakkinen 
> >  M:   Mimi Zohar 
>
> Just checking:  is that email address correct (@linuxibm.com)?
>
> Guess I'll see if it bounces.
>

Yes, it bounces. A follow-up patch is coming in a minute.

Lukas


Re: [GIT PULL] perf fixes

2019-02-10 Thread pr-tracker-bot
The pull request you sent on Sun, 10 Feb 2019 10:01:09 +0100:

> git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git 
> perf-urgent-for-linus

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/212146f0800e151bd61b98fb6fe4b8b6778a649a

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [GIT PULL] dmaengine fixes for v5.0-rc6

2019-02-10 Thread pr-tracker-bot
The pull request you sent on Sun, 10 Feb 2019 20:47:22 +0530:

> git://git.infradead.org/users/vkoul/slave-dma.git tags/dmaengine-fix-5.0-rc6

has been merged into torvalds/linux.git:
https://git.kernel.org/torvalds/c/68d94a8424352d723e4991de4745ce6795b23069

Thank you!

-- 
Deet-doot-dot, I am a bot.
https://korg.wiki.kernel.org/userdoc/prtracker


Re: [RFC PATCH 1/4] X.509: Parse public key parameters from x509 for akcipher

2019-02-10 Thread Vitaly Chikunov
On Sun, Feb 10, 2019 at 12:42:40AM +0300, Vitaly Chikunov wrote:
> On Sun, Jan 06, 2019 at 04:36:05PM +0300, Vitaly Chikunov wrote:
> > Some public key algorithms (like ECDSA) keep in parameters field
> > important data such as digest and curve OIDs (possibly more for
> > different ECDSA variants). Thus, just setting a public key (as
> > for RSA) is not enough.
> > 
> > Introduce set_params() callback for akcipher which will be used to
> > pass DER encoded parameters array, with additional argument of
> > algorithm OID.
> > 
> > This is done with the intent of adding support for EC-RDSA (ISO/IEC
> > 14888-3:2018, RFC 7091, and basically ECDSA variant) public keys (which
> > will be finally used in IMA subsystem). Thus, also oid_registry.h is
> > updated.
> > 
> > Rationale:
> > 
> > - For such keys just setting public key without parameters is
> >   meaningless, so it would be possible to add parameters in
> >   crypto_akcipher_set_pub_key (and .set_pub_key) calls. But, this will
> >   needlessly change API for RSA akcipher. Also, additional callback
> >   making it possible to pass parameters after
> >   crypto_akcipher_set_priv_key (and .set_priv_key) in the future.
> >
> > - Algorithm OID is passed to be validated in .set_params callback,
> >   otherwise, it could have the wrong value.
> > 
> > - Particular algorithm OIDs are checked in x509_note_params, (because
> >   this is called from AlgorithmIdentifier (ASN.1) parser, which is
> >   called multiple times, as it's used multiple times in X.509
> >   certificate), to distinguish a public key call from a signature call.
> > 
> > Signed-off-by: Vitaly Chikunov 
> > ---
> 
> > @@ -263,6 +274,11 @@ int public_key_verify_signature(const struct 
> > public_key *pkey,
> >if (pkey->key_is_private)
> >ret = crypto_akcipher_set_priv_key(tfm,
> >   pkey->key, pkey->keylen);
> >else
> >ret = crypto_akcipher_set_pub_key(tfm,
> >  pkey->key, pkey->keylen);
> >if (ret)
> >goto error_free_req;
> > +   ret = crypto_akcipher_set_params(tfm, pkey->algo, pkey->params,
> > +pkey->paramlen);
> 
> Nobody said anything if this is a good idea to call set_params after
> set_{pub,priv}_key and not before.
> 
> When `struct crypto_akcipher' is allocated ctx data is never zeroed,
> thus either call will be the first to zero ctx, making these calls not
> swappable in the future.
> 
> Also, algorithm parameters could be interpreted without knowing the key,
> but the key cannot be interpreted without knowing the parameters.

>From the other point of view, set_params may never be called or
implemented. So, making it called first and move memory zeroing
into set_params may create more complications than simplicity.

Making both callbacks callable in any order also will not make
things simpler. (Need to be prepared to be called in different
order.)

Maybe it's better to make memzero in akcipher_request_alloc() and allow
optional call to crypto_akcipher_set_params() strictly before
crypto_akcipher_set_{pub,priv}_key(), so, set_{pub,priv}_key will
already know everything to set the key properly. set_params may not be
implemented if akcipher does not need it (as with RSA).

> 
> > +   if (ret)
> > +   goto error_free_req;
> > +
> > ret = -ENOMEM;
> > outlen = crypto_akcipher_maxsize(tfm);
> > output = kmalloc(outlen, GFP_KERNEL);


Re: [PATCH] x86: make set_pmd_at() paravirt aware

2019-02-10 Thread Juergen Gross
On 10/02/2019 19:14, Linus Torvalds wrote:
> On Sat, Feb 9, 2019 at 11:41 PM Juergen Gross  wrote:
>>
>> Make set_pmd_at() paravirt aware by just letting it use set_pmd().
> 
> Well, that was simpler than I worried.
> 
> Just checking: Is this purely an x86 issue? ARM is ok perhaps because
> there's no PV support?

Correct.


Juergen


Re: [PATCH 4/5] nvme-pci: simplify nvme_setup_irqs() via .setup_affinity callback

2019-02-10 Thread Thomas Gleixner
On Fri, 25 Jan 2019, Ming Lei wrote:
> +static int nvme_setup_affinity(const struct irq_affinity *affd,
> +struct irq_affinity_desc *masks,
> +unsigned int nmasks)
> +{
> + struct nvme_dev *dev = affd->priv;
> + int affvecs = nmasks - affd->pre_vectors - affd->post_vectors;
> + int curvec, usedvecs;
> + int i;
> +
> + nvme_calc_io_queues(dev, nmasks);

So this is the only NVME specific information. Everything else can be done
in generic code. So what you really want is:

struct affd {
...
+   calc_sets(struct affd *, unsigned int nvecs);
...
}

And sets want to be actually inside of the affinity descriptor structure:

unsigned int num_sets;
unsigned int set_vectors[MAX_SETS];

We surely can define a sensible maximum of sets for now. If that ever turns
out to be insufficient, then struct affd might become to large for the
stack, but for now, using e.g. 8, there is no need to do so.

So then the logic in the generic code becomes exactly the same as what you
added to nvme_setup_affinity():

if (affd->calc_sets) {
affd->calc_sets(affd, nvecs);
} else if (!affd->num_sets) {
affd->num_sets = 1;
affd->set_vectors[0] = affvecs;
}

for (i = 0; i < affd->num_sets; i++) {

}

See?

Thanks,

tglx


Re: [PATCH v2] module: Cure the MODULE_LICENSE "GPL" vs. "GPL v2" bogosity

2019-02-10 Thread Thomas Gleixner
On Sat, 9 Feb 2019, Philippe Ombredanne wrote:
> > + * Both "GPL v2" and "GPL" (the latter also in dual licensed strings) are
> > + * merily stating that the module is licensed under the GPL v2, but are not
> 
> Nit: did you mean merely (as mere/just) ? or merily/merrily (as in
> cheerfully/happily) ? :D

Bah. merely of course.

Jon, want me to resend?

Thanks,

tglx


[PATCH] MAINTAINERS: rectify two issues in KEYS-TRUSTED entry

2019-02-10 Thread Lukas Bulwahn
Mimi Zohar used spaces instead of a tab when adding Jarkko Sakkinen as
further maintainer to the KEYS-TRUSTED section entry. Paul McKenney also
introduced a typo in Mimi Zohar's email address in the KEYS-TRUSTED section
entry.

The two issues were detected when writing a script that parses MAINTAINERS.

Fixes: 34bccd61b139 ("MAINTAINERS: add Jarkko as maintainer for trusted keys")
Fixes: 1dfddcdb95c4 ("MAINTAINERS: Update from @linux.vnet.ibm.com to 
@linux.ibm.com")

Signed-off-by: Lukas Bulwahn 
---
Mimi, please pick up this patch instead of
  "[PATCH] MAINTAINERS: use tab instead of spaces". Thanks.

 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index bf4965d6d5de..b4b62ea78eeb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8405,8 +8405,8 @@ F:security/keys/encrypted-keys/
 
 KEYS-TRUSTED
 M: James Bottomley 
-M:  Jarkko Sakkinen 
-M: Mimi Zohar 
+M: Jarkko Sakkinen 
+M: Mimi Zohar 
 L: linux-integr...@vger.kernel.org
 L: keyri...@vger.kernel.org
 S: Supported
-- 
2.17.1



Re: mtd: spi-nor: cadence-quadspi: write upto 8-bytes data in STIG mode

2019-02-10 Thread Boris Brezillon
From: Boris Brezillon 

On Mon, 2019-01-28 at 05:02:29 UTC, Purna Chandra Mandal wrote:
> cadence-quadspi controller allows upto eight bytes of data to
> be written in software Triggered Instruction generator (STIG) mode
> of operation. Lower 4 bytes are written through writedatalower and
> upper 4 bytes by writedataupper register.
> 
> This patch allows all the 8 bytes to be written.
> 
> Signed-off-by: Purna Chandra Mandal 
> Reviewed-by: Tudor Ambarus 
> Reviewed-by: Vignesh R 

Applied to http://git.infradead.org/linux-mtd.git spi-nor/next, thanks.

Boris


[PATCH] MAINTAINERS: rectify two issues in KEYS-TRUSTED entry

2019-02-10 Thread Lukas Bulwahn
Mimi Zohar used spaces instead of a tab when adding Jarkko Sakkinen as
further maintainer to the KEYS-TRUSTED section entry. Paul McKenney also
introduced a typo in Mimi Zohar's email address in the KEYS-TRUSTED section
entry.

The two issues were detected when writing a script that parses MAINTAINERS.

Fixes: 34bccd61b139 ("MAINTAINERS: add Jarkko as maintainer for trusted keys")
Fixes: 1dfddcdb95c4 ("MAINTAINERS: Update from @linux.vnet.ibm.com to 
@linux.ibm.com")

Signed-off-by: Lukas Bulwahn 
---
Mimi, please pick up this patch instead of
  "[PATCH] MAINTAINERS: use tab instead of spaces". Thanks.

 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index bf4965d6d5de..b4b62ea78eeb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8405,8 +8405,8 @@ F:security/keys/encrypted-keys/
 
 KEYS-TRUSTED
 M: James Bottomley 
-M:  Jarkko Sakkinen 
-M: Mimi Zohar 
+M: Jarkko Sakkinen 
+M: Mimi Zohar 
 L: linux-integr...@vger.kernel.org
 L: keyri...@vger.kernel.org
 S: Supported
-- 
2.17.1



[PATCH] MAINTAINERS: rectify two issues in KEYS-TRUSTED entry

2019-02-10 Thread Lukas Bulwahn
Mimi Zohar used spaces instead of a tab when adding Jarkko Sakkinen as
further maintainer to the KEYS-TRUSTED section entry. Paul McKenney also
introduced a typo in Mimi Zohar's email address in the KEYS-TRUSTED section
entry.

The two issues were detected when writing a script that parses MAINTAINERS.

Fixes: 34bccd61b139 ("MAINTAINERS: add Jarkko as maintainer for trusted keys")
Fixes: 1dfddcdb95c4 ("MAINTAINERS: Update from @linux.vnet.ibm.com to 
@linux.ibm.com")

Signed-off-by: Lukas Bulwahn 
---
Mimi, please pick up this patch instead of
  "[PATCH] MAINTAINERS: use tab instead of spaces". Thanks.

 MAINTAINERS | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/MAINTAINERS b/MAINTAINERS
index bf4965d6d5de..b4b62ea78eeb 100644
--- a/MAINTAINERS
+++ b/MAINTAINERS
@@ -8405,8 +8405,8 @@ F:security/keys/encrypted-keys/
 
 KEYS-TRUSTED
 M: James Bottomley 
-M:  Jarkko Sakkinen 
-M: Mimi Zohar 
+M: Jarkko Sakkinen 
+M: Mimi Zohar 
 L: linux-integr...@vger.kernel.org
 L: keyri...@vger.kernel.org
 S: Supported
-- 
2.17.1



Its Very Consequential Please

2019-02-10 Thread AbdWabbo Maddah
-- 
Dear,
I had sent you a mail but i don't think you received it that's why am
writing you again. It is important you get back to me as soon as you
can.
Abdwabbo Maddah


[tip:irq/core] genirq/affinity: Move allocation of 'node_to_cpumask' to irq_build_affinity_masks()

2019-02-10 Thread tip-bot for Ming Lei
Commit-ID:  347253c42d7c673aa2a659d756bc7ff893459247
Gitweb: https://git.kernel.org/tip/347253c42d7c673aa2a659d756bc7ff893459247
Author: Ming Lei 
AuthorDate: Fri, 25 Jan 2019 17:53:43 +0800
Committer:  Thomas Gleixner 
CommitDate: Sun, 10 Feb 2019 19:53:55 +0100

genirq/affinity: Move allocation of 'node_to_cpumask' to 
irq_build_affinity_masks()

'node_to_cpumask' is just one temparay variable for irq_build_affinity_masks(),
so move it into irq_build_affinity_masks().

No functioanl change.

Signed-off-by: Ming Lei 
Signed-off-by: Thomas Gleixner 
Reviewed-by: Bjorn Helgaas 
Cc: Christoph Hellwig 
Cc: Jens Axboe 
Cc: linux-bl...@vger.kernel.org
Cc: Sagi Grimberg 
Cc: linux-n...@lists.infradead.org
Cc: linux-...@vger.kernel.org
Link: https://lkml.kernel.org/r/20190125095347.17950-2-ming@redhat.com

---
 kernel/irq/affinity.c | 27 +--
 1 file changed, 13 insertions(+), 14 deletions(-)

diff --git a/kernel/irq/affinity.c b/kernel/irq/affinity.c
index 45b68b4ea48b..118b66d64a53 100644
--- a/kernel/irq/affinity.c
+++ b/kernel/irq/affinity.c
@@ -175,18 +175,22 @@ out:
  */
 static int irq_build_affinity_masks(const struct irq_affinity *affd,
int startvec, int numvecs, int firstvec,
-   cpumask_var_t *node_to_cpumask,
struct irq_affinity_desc *masks)
 {
int curvec = startvec, nr_present, nr_others;
int ret = -ENOMEM;
cpumask_var_t nmsk, npresmsk;
+   cpumask_var_t *node_to_cpumask;
 
if (!zalloc_cpumask_var(&nmsk, GFP_KERNEL))
return ret;
 
if (!zalloc_cpumask_var(&npresmsk, GFP_KERNEL))
-   goto fail;
+   goto fail_nmsk;
+
+   node_to_cpumask = alloc_node_to_cpumask();
+   if (!node_to_cpumask)
+   goto fail_npresmsk;
 
ret = 0;
/* Stabilize the cpumasks */
@@ -217,9 +221,12 @@ static int irq_build_affinity_masks(const struct 
irq_affinity *affd,
if (nr_present < numvecs)
WARN_ON(nr_present + nr_others < numvecs);
 
+   free_node_to_cpumask(node_to_cpumask);
+
+ fail_npresmsk:
free_cpumask_var(npresmsk);
 
- fail:
+ fail_nmsk:
free_cpumask_var(nmsk);
return ret;
 }
@@ -236,7 +243,6 @@ irq_create_affinity_masks(int nvecs, const struct 
irq_affinity *affd)
 {
int affvecs = nvecs - affd->pre_vectors - affd->post_vectors;
int curvec, usedvecs;
-   cpumask_var_t *node_to_cpumask;
struct irq_affinity_desc *masks = NULL;
int i, nr_sets;
 
@@ -247,13 +253,9 @@ irq_create_affinity_masks(int nvecs, const struct 
irq_affinity *affd)
if (nvecs == affd->pre_vectors + affd->post_vectors)
return NULL;
 
-   node_to_cpumask = alloc_node_to_cpumask();
-   if (!node_to_cpumask)
-   return NULL;
-
masks = kcalloc(nvecs, sizeof(*masks), GFP_KERNEL);
if (!masks)
-   goto outnodemsk;
+   return NULL;
 
/* Fill out vectors at the beginning that don't need affinity */
for (curvec = 0; curvec < affd->pre_vectors; curvec++)
@@ -271,11 +273,10 @@ irq_create_affinity_masks(int nvecs, const struct 
irq_affinity *affd)
int ret;
 
ret = irq_build_affinity_masks(affd, curvec, this_vecs,
-   curvec, node_to_cpumask, masks);
+   curvec, masks);
if (ret) {
kfree(masks);
-   masks = NULL;
-   goto outnodemsk;
+   return NULL;
}
curvec += this_vecs;
usedvecs += this_vecs;
@@ -293,8 +294,6 @@ irq_create_affinity_masks(int nvecs, const struct 
irq_affinity *affd)
for (i = affd->pre_vectors; i < nvecs - affd->post_vectors; i++)
masks[i].is_managed = 1;
 
-outnodemsk:
-   free_node_to_cpumask(node_to_cpumask);
return masks;
 }
 


Re: [PATCH net-next v2 06/16] net: bridge: Stop calling switchdev_port_attr_get()

2019-02-10 Thread Ido Schimmel
On Sun, Feb 10, 2019 at 09:50:55AM -0800, Florian Fainelli wrote:
> Now that all switchdev drivers have been converted to checking the
> bridge port flags during the prepare phase of the
> switchdev_port_attr_set(), we can move straight to trying to set the
> desired flag through SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS.
> 
> Acked-by: Jiri Pirko 
> Signed-off-by: Florian Fainelli 
> ---
>  net/bridge/br_switchdev.c | 20 +++-
>  1 file changed, 3 insertions(+), 17 deletions(-)
> 
> diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
> index db9e8ab96d48..939f300522c5 100644
> --- a/net/bridge/br_switchdev.c
> +++ b/net/bridge/br_switchdev.c
> @@ -64,29 +64,15 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
>  {
>   struct switchdev_attr attr = {
>   .orig_dev = p->dev,
> - .id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
> + .id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
> + .flags = SWITCHDEV_F_DEFER,

How does this work? You defer the operation, so the driver cannot veto
it. This is why we have SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT
which is not deferred.

> + .u.brport_flags = flags,
>   };
>   int err;
>  
>   if (mask & ~BR_PORT_FLAGS_HW_OFFLOAD)
>   return 0;
>  
> - err = switchdev_port_attr_get(p->dev, &attr);
> - if (err == -EOPNOTSUPP)
> - return 0;
> - if (err)
> - return err;
> -
> - /* Check if specific bridge flag attribute offload is supported */
> - if (!(attr.u.brport_flags_support & mask)) {
> - br_warn(p->br, "bridge flag offload is not supported %u(%s)\n",
> - (unsigned int)p->port_no, p->dev->name);
> - return -EOPNOTSUPP;
> - }
> -
> - attr.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS;
> - attr.flags = SWITCHDEV_F_DEFER;
> - attr.u.brport_flags = flags;
>   err = switchdev_port_attr_set(p->dev, &attr);
>   if (err) {
>   br_warn(p->br, "error setting offload flag on port %u(%s)\n",
> -- 
> 2.19.1
> 


Re: [PATCH] MAINTAINERS: use tab instead of spaces

2019-02-10 Thread lukas.bulwahn



On Sun, 10 Feb 2019, James Bottomley wrote:

> On Sun, 2019-02-10 at 19:10 +0100, Lukas Bulwahn wrote:
> > Mimi Zohar used spaces instead of a tab when adding Jarkko Sakkinen
> > as
> > further maintainer to the KEYS-TRUSTED section entry. So, we rectify
> > this
> > with this commit.
> > 
> > The issue was detected when writing a script that parses MAINTAINERS.
> > 
> > Fixes: 34bccd61b139 ("MAINTAINERS: add Jarkko as maintainer for
> > trusted keys")
> > Signed-off-by: Lukas Bulwahn 
> 
> This isn't really a bug, is it?
> 
> We have no formatting requirements for the MAINTAINERS file and the
> section owner is free to align with tabs, spaces or nothing as they see
> fit.  Most use a single tab, but a couple don't. The only real thing
> that cares is get_maintainers.pl and it uses \s* as the parse regexp,
> so it doesn't care either.
> 
> Now, we could possibly agree the file looks better with a single space
> or a single tab between the tag and the value and thus we should be
> doing this, but we'd need to agree on that and update the tag
> description accordingly.
> 

It was the only line in MAINTAINERS remaining that used spaces instead of 
a single tab. So, even if there is not an explicit formatting requirement, 
changing a single line to have it consistent in one format seemed 
reasonable to me.

I just sent a new patch that also corrected the email address; 
unfortunately, I was distracted and sent it out wrong twice before
getting Mimi's email right on the third try.

Please ignore this patch and consider the patch:

MAINTAINERS: rectify two issues in KEYS-TRUSTED entry

Thanks,

Lukas


Re: [PATCH v3 08/10] x86/setcpuid: Add kernel option setcpuid

2019-02-10 Thread Thomas Gleixner
On Tue, 5 Feb 2019, Peter Zijlstra wrote:
> On Tue, Feb 05, 2019 at 07:19:16AM -0800, Dave Hansen wrote:
> > On 2/5/19 12:48 AM, Peter Zijlstra wrote:
> > This isn't something we want everybody and their grandma to turn on;
> > it's a rather specialized feature.  It's really only for folks that care
> > about the latency incurred across the entire system on split lock
> > operations.
> 
> That really should be everyone. That split lock stuff is horrible. There
> is no real down-side to having it always enabled. Code that breaks is
> bad code you want fixed anyway.
> 
> Like I said elsewhere, I wish it would #AC for any unaligned LOCK
> prefix, not just cross-line. I see why we'd not want to traditional RISC
> #AC for every load/store, but atomics really had better be aligned.

Right, we should really make this default enabled.

> > > Is this some transient state; where a few (early) models will not have
> > > the enumeration sorted but all later models will have it all neat and
> > > tidy?
> > 
> > From my understanding, it's not just an early stepping.  It's a
> > generational thing.  The current generation lacks the enumeration and
> > the next generation will get it.  Both have the silicon to implement the
> > feature itself.
> 
> I never said stepping, in fact I explicitly said model.
> 
> > > If so, we can easily do the FMS solution for this.
> > 
> > Yeah, we can.  I honestly forget why we didn't do FMS. :)
> 
> Right so FMS is fairly horrible; but when it is a stop-gap for a limited
> number of models it's waaay better than dodgy cmdline things.

One or two is fine. And _IF_ we get the enumeration sorted before we merge
that, then we can declare the FM list as immutable :)
 
> We could of course try to wrmsr_safe() detect the feature; but that
> might be a problem is the MSR exists on any other models and has a
> different meaning.

Well, yes, but that would be pretty stupid.

Thanks,

tglx



Information !!!

2019-02-10 Thread Mr. Frank Yacouba
Dear friend,

I know that this letter may be a very big surprise to you, My name is
Mr. Frank Yacouba, Head of file Department in Africa Develop bank
Burkina Faso. I need your sincere cooperation to transfer the sum of
$15 million U.S.A dollars to your bank account.

I want you stand as next of kin to the deceased. I agree 40% for you
and 60% for me. Upon receipt of your reply, I will send to you by
email the text of the application. I will not fail to bring to your
notice that this transaction is hitch free and that you should not
entertain any atom of fear as all required arrangements have been made
for the transfer.
PLEASE FILE THIS FORM.
1) Your Full Name
2) Your Cell Phone Number...
3) Your Country...
4) Your Occupation

I am waiting for your immediate response.

Yours faithfully,
Mr.Frank Yacouba
E-mail:bissappa...@yandex.com


X450LCP lost abillity to turn the screen off

2019-02-10 Thread Marcos Paulo de Souza
Hi,

Since 5.0.0-rc4 I vefiried that my ASUS laptop cannot turn the screen of
anymore. There were several commits in 5.0 merge window touching this
functionality like:

  71b12beaf12f platform/x86: asus-nb-wmi: Drop mapping of 0x33 and 0x34 scan 
codes
  b3f2f3799a97 platform/x86: asus-nb-wmi: Map 0x35 to KEY_SCREENLOCK
  78f3ac76d9e5 platform/x86: asus-wmi: Tell the EC the OS will handle the 
display off hotkey

I didn't have time to track it down, and my previous working kernel was 4.12
(default in openSUSE Leap 15), but I hope I will be able to test older kernels 
this week.

-- 
Thanks,
Marcos


Re: [PATCH net-next v2 06/16] net: bridge: Stop calling switchdev_port_attr_get()

2019-02-10 Thread Florian Fainelli
Le 2/10/19 à 11:05 AM, Ido Schimmel a écrit :
> On Sun, Feb 10, 2019 at 09:50:55AM -0800, Florian Fainelli wrote:
>> Now that all switchdev drivers have been converted to checking the
>> bridge port flags during the prepare phase of the
>> switchdev_port_attr_set(), we can move straight to trying to set the
>> desired flag through SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS.
>>
>> Acked-by: Jiri Pirko 
>> Signed-off-by: Florian Fainelli 
>> ---
>>  net/bridge/br_switchdev.c | 20 +++-
>>  1 file changed, 3 insertions(+), 17 deletions(-)
>>
>> diff --git a/net/bridge/br_switchdev.c b/net/bridge/br_switchdev.c
>> index db9e8ab96d48..939f300522c5 100644
>> --- a/net/bridge/br_switchdev.c
>> +++ b/net/bridge/br_switchdev.c
>> @@ -64,29 +64,15 @@ int br_switchdev_set_port_flag(struct net_bridge_port *p,
>>  {
>>  struct switchdev_attr attr = {
>>  .orig_dev = p->dev,
>> -.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT,
>> +.id = SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS,
>> +.flags = SWITCHDEV_F_DEFER,
> 
> How does this work? You defer the operation, so the driver cannot veto
> it. This is why we have SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT
> which is not deferred.

I missed that indeed, how would you feel about splitting the attribute
setting into different phases:

- checking that the attribute setting is supported (caller context, so
possibly atomic)
- allocating and committing resources (deferred context)

For pretty much any DSA driver, we will have to be in sleepable context
anyway because of MDIO, SPI, I2C, whatever transport layer.

Not sure how to best approach this now...
-- 
Florian


Re: [PATCH] mm/gup.c: Remove unused write variable

2019-02-10 Thread Thomas Gleixner
Ira,

On Sat, 9 Feb 2019, ira.we...@intel.com wrote:

nice patch. Just a few nitpicks vs. the subject and the change log.

> Subject: [PATCH] mm/gup.c: Remove unused write variable

We usually avoid filenames in the subsystem prefix. mm/gup: is sufficient.

But what's a bit more confusing is 'write variable'. You are not removing a
variable, you are removing a unused function argument. That's two different
things.

> write is unused in gup_fast_permitted so remove it.

When referencing functions please use brackets so it's clear that you talk
about a function, i.e. gup_fast_permitted().

So the correct subject line would be:

  Subject: [PATCH] mm/gup: Remove write argument from gup_fast_permitted()

Thanks,

tglx


[PATCH] libertas_tf: fix signal reporting

2019-02-10 Thread Lubomir Rintel
Instead of exposing the signal-to-noise ration, calculate the actual signal
level taking the noise floor into account.

Also, flip the SIGNAL_DBM bit on, so that mac80211 exposes the signal
level along with the station info in scan results. This fills
NetworkManager's "nmcli d wifi output" output with colors, bars and joy.

Signed-off-by: Lubomir Rintel 
---
 drivers/net/wireless/marvell/libertas_tf/main.c | 3 ++-
 1 file changed, 2 insertions(+), 1 deletion(-)

diff --git a/drivers/net/wireless/marvell/libertas_tf/main.c 
b/drivers/net/wireless/marvell/libertas_tf/main.c
index c71ad87cdc44..f93b400db949 100644
--- a/drivers/net/wireless/marvell/libertas_tf/main.c
+++ b/drivers/net/wireless/marvell/libertas_tf/main.c
@@ -562,7 +562,7 @@ int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb)
stats.flag |= RX_FLAG_FAILED_FCS_CRC;
stats.freq = priv->cur_freq;
stats.band = NL80211_BAND_2GHZ;
-   stats.signal = prxpd->snr;
+   stats.signal = prxpd->snr - prxpd->nf;
priv->noise = prxpd->nf;
/* Marvell rate index has a hole at value 4 */
if (prxpd->rx_rate > 4)
@@ -626,6 +626,7 @@ struct lbtf_private *lbtf_add_card(void *card, struct 
device *dmdev)
 
hw->queues = 1;
ieee80211_hw_set(hw, HOST_BROADCAST_PS_BUFFERING);
+   ieee80211_hw_set(hw, SIGNAL_DBM);
hw->extra_tx_headroom = sizeof(struct txpd);
memcpy(priv->channels, lbtf_channels, sizeof(lbtf_channels));
memcpy(priv->rates, lbtf_rates, sizeof(lbtf_rates));
-- 
2.20.1



[PATCH] libertas_tf: lower the debug level of command trace

2019-02-10 Thread Lubomir Rintel
Logging each and every command response is way too much for INFO level.
Silence this, unless CONFIG_LIBERTAS_THINFIRM_DEBUG has been enabled.

Signed-off-by: Lubomir Rintel 
---
 drivers/net/wireless/marvell/libertas_tf/cmd.c | 7 +++
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas_tf/cmd.c 
b/drivers/net/wireless/marvell/libertas_tf/cmd.c
index 909ac3685010..64b147dd2432 100644
--- a/drivers/net/wireless/marvell/libertas_tf/cmd.c
+++ b/drivers/net/wireless/marvell/libertas_tf/cmd.c
@@ -737,10 +737,9 @@ int lbtf_process_rx_command(struct lbtf_private *priv)
respcmd = le16_to_cpu(resp->command);
result = le16_to_cpu(resp->result);
 
-   if (net_ratelimit())
-   pr_info("libertastf: cmd response 0x%04x, seq %d, size %d\n",
-   respcmd, le16_to_cpu(resp->seqnum),
-   le16_to_cpu(resp->size));
+   lbtf_deb_cmd("libertastf: cmd response 0x%04x, seq %d, size %d\n",
+respcmd, le16_to_cpu(resp->seqnum),
+le16_to_cpu(resp->size));
 
if (resp->seqnum != priv->cur_cmd->cmdbuf->seqnum) {
spin_unlock_irqrestore(&priv->driver_lock, flags);
-- 
2.20.1



[PATCH] libertas_tf: don't set URB_ZERO_PACKET on IN USB transfer

2019-02-10 Thread Lubomir Rintel
It doesn't make sense and the USB core warns on each submit of such
URB, easily flooding the message buffer with tracebacks.

Analogous issue was fixed in regular libertas driver in commit 6528d8804780
("libertas: don't set URB_ZERO_PACKET on IN USB transfer").

Cc: sta...@vger.kernel.org
Signed-off-by: Lubomir Rintel 
---
 drivers/net/wireless/marvell/libertas_tf/if_usb.c | 2 --
 1 file changed, 2 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c 
b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
index 789337ea676a..6ede6168bd85 100644
--- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
@@ -433,8 +433,6 @@ static int __if_usb_submit_rx_urb(struct if_usb_card *cardp,
  skb_tail_pointer(skb),
  MRVDRV_ETH_RX_PACKET_BUFFER_SIZE, callbackfn, cardp);
 
-   cardp->rx_urb->transfer_flags |= URB_ZERO_PACKET;
-
lbtf_deb_usb2(&cardp->udev->dev, "Pointer for rx_urb %p\n",
cardp->rx_urb);
ret = usb_submit_urb(cardp->rx_urb, GFP_ATOMIC);
-- 
2.20.1



[PATCH] libertas_tf: move the banner to a more appropriate place

2019-02-10 Thread Lubomir Rintel
Also, turn it to a dev_info() to make checkpatch.pl happy.

Signed-off-by: Lubomir Rintel 
---
 drivers/net/wireless/marvell/libertas_tf/main.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/wireless/marvell/libertas_tf/main.c 
b/drivers/net/wireless/marvell/libertas_tf/main.c
index 1d45da187b9b..c71ad87cdc44 100644
--- a/drivers/net/wireless/marvell/libertas_tf/main.c
+++ b/drivers/net/wireless/marvell/libertas_tf/main.c
@@ -318,7 +318,6 @@ static int lbtf_op_start(struct ieee80211_hw *hw)
goto err_prog_firmware;
}
 
-   printk(KERN_INFO "libertastf: Marvell WLAN 802.11 thinfirm adapter\n");
lbtf_deb_leave(LBTF_DEB_MACOPS);
return 0;
 
@@ -649,6 +648,7 @@ struct lbtf_private *lbtf_add_card(void *card, struct 
device *dmdev)
if (ieee80211_register_hw(hw))
goto err_init_adapter;
 
+   dev_info(dmdev, "libertastf: Marvell WLAN 802.11 thinfirm adapter\n");
goto done;
 
 err_init_adapter:
-- 
2.20.1



[PATCH 2/3] libertas_tf: don't defer firmware loading until start()

2019-02-10 Thread Lubomir Rintel
In order to be able to get a MAC address before we register the device
with ieee80211 we'll need to load the firmware way earlier.

There seems to be one problem with this: the device seems to start
with radio enabled and starts sending in frames right after the firmware
load finishes. This might be a firmware bug. Disable the radio as soon
as possible.

Signed-off-by: Lubomir Rintel 
---
 .../net/wireless/marvell/libertas_tf/if_usb.c | 24 +--
 .../marvell/libertas_tf/libertas_tf.h |  5 +--
 .../net/wireless/marvell/libertas_tf/main.c   | 41 +++
 3 files changed, 38 insertions(+), 32 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c 
b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
index 7a5a1a85dcf7..a4b9ede70705 100644
--- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
@@ -42,14 +42,14 @@ MODULE_DEVICE_TABLE(usb, if_usb_table);
 
 static void if_usb_receive(struct urb *urb);
 static void if_usb_receive_fwload(struct urb *urb);
-static int if_usb_prog_firmware(struct if_usb_card *cardp);
+static int if_usb_prog_firmware(struct lbtf_private *priv);
 static int if_usb_host_to_card(struct lbtf_private *priv, uint8_t type,
   uint8_t *payload, uint16_t nb);
 static int usb_tx_block(struct if_usb_card *cardp, uint8_t *payload,
uint16_t nb, u8 data);
 static void if_usb_free(struct if_usb_card *cardp);
 static int if_usb_submit_rx_urb(struct if_usb_card *cardp);
-static int if_usb_reset_device(struct if_usb_card *cardp);
+static int if_usb_reset_device(struct lbtf_private *priv);
 
 /**
  *  if_usb_wrike_bulk_callback -  call back to handle URB status
@@ -222,13 +222,11 @@ static int if_usb_probe(struct usb_interface *intf,
goto dealloc;
}
 
+   cardp->boot2_version = udev->descriptor.bcdDevice;
priv = lbtf_add_card(cardp, &udev->dev, &if_usb_ops);
if (!priv)
goto dealloc;
 
-   cardp->priv = priv;
-   cardp->boot2_version = udev->descriptor.bcdDevice;
-
usb_get_dev(udev);
usb_set_intfdata(intf, cardp);
 
@@ -253,7 +251,7 @@ static void if_usb_disconnect(struct usb_interface *intf)
 
lbtf_deb_enter(LBTF_DEB_MAIN);
 
-   if_usb_reset_device(cardp);
+   if_usb_reset_device(priv);
 
if (priv)
lbtf_remove_card(priv);
@@ -336,8 +334,9 @@ static int if_usb_send_fw_pkt(struct if_usb_card *cardp)
return 0;
 }
 
-static int if_usb_reset_device(struct if_usb_card *cardp)
+static int if_usb_reset_device(struct lbtf_private *priv)
 {
+   struct if_usb_card *cardp = priv->card;
struct cmd_ds_802_11_reset *cmd = cardp->ep_out_buf + 4;
int ret;
 
@@ -808,14 +807,17 @@ static int check_fwfile_format(const u8 *data, u32 totlen)
 }
 
 
-static int if_usb_prog_firmware(struct if_usb_card *cardp)
+static int if_usb_prog_firmware(struct lbtf_private *priv)
 {
+   struct if_usb_card *cardp = priv->card;
int i = 0;
static int reset_count = 10;
int ret = 0;
 
lbtf_deb_enter(LBTF_DEB_USB);
 
+   cardp->priv = priv;
+
kernel_param_lock(THIS_MODULE);
ret = request_firmware(&cardp->fw, lbtf_fw_name, &cardp->udev->dev);
if (ret < 0) {
@@ -851,7 +853,7 @@ static int if_usb_prog_firmware(struct if_usb_card *cardp)
 
if (cardp->bootcmdresp <= 0) {
if (--reset_count >= 0) {
-   if_usb_reset_device(cardp);
+   if_usb_reset_device(priv);
goto restart;
}
return -1;
@@ -880,7 +882,7 @@ static int if_usb_prog_firmware(struct if_usb_card *cardp)
if (!cardp->fwdnldover) {
pr_info("failed to load fw, resetting device!\n");
if (--reset_count >= 0) {
-   if_usb_reset_device(cardp);
+   if_usb_reset_device(priv);
goto restart;
}
 
@@ -889,8 +891,6 @@ static int if_usb_prog_firmware(struct if_usb_card *cardp)
goto release_fw;
}
 
-   cardp->priv->fw_ready = 1;
-
  release_fw:
release_firmware(cardp->fw);
cardp->fw = NULL;
diff --git a/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h 
b/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h
index 11d5ff68bc5e..3ed1fbe28798 100644
--- a/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h
+++ b/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h
@@ -177,8 +177,8 @@ struct lbtf_ops {
/** Hardware access */
int (*hw_host_to_card)(struct lbtf_private *priv, u8 type,
   u8 *payload, u16 nb);
-   int (*hw_prog_firmware)(struct if_usb_card *cardp);
-   int (*hw_reset_device)(struct if_usb_card *cardp);
+   int (*hw_prog_firmware)(struct lbtf_private *priv);
+   int (*hw_reset_devic

[PATCH 0/3] libertas_tf: fix setting the hardware address

2019-02-10 Thread Lubomir Rintel
Hi,

this short patchset addresses a problem with libertas_tf driver, where
the driver registers the interface without having the MAC address set,
only setting it when the interface is brought up. That is generally too
late, and it confuses NetworkManager.

Some restructuring is needed first, done in first two patches.

Tested on an OLPC XO laptop.

Cheers,
Lubo




[PATCH 1/3] libertas_tf: move hardware callbacks to a separate structure

2019-02-10 Thread Lubomir Rintel
We'll need to talk to the firmware to get a hardware address before
device is registered with ieee80211 subsystem at the end of
lbtf_add_card(). Hooking the callbacks after that is too late.

Signed-off-by: Lubomir Rintel 
---
 drivers/net/wireless/marvell/libertas_tf/cmd.c  |  2 +-
 .../net/wireless/marvell/libertas_tf/if_usb.c   | 12 +++-
 .../wireless/marvell/libertas_tf/libertas_tf.h  | 17 +++--
 drivers/net/wireless/marvell/libertas_tf/main.c | 10 ++
 4 files changed, 25 insertions(+), 16 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas_tf/cmd.c 
b/drivers/net/wireless/marvell/libertas_tf/cmd.c
index 64b147dd2432..130f578daafd 100644
--- a/drivers/net/wireless/marvell/libertas_tf/cmd.c
+++ b/drivers/net/wireless/marvell/libertas_tf/cmd.c
@@ -256,7 +256,7 @@ static void lbtf_submit_command(struct lbtf_private *priv,
 command, le16_to_cpu(cmd->seqnum), cmdsize);
lbtf_deb_hex(LBTF_DEB_CMD, "DNLD_CMD", (void *) cmdnode->cmdbuf, 
cmdsize);
 
-   ret = priv->hw_host_to_card(priv, MVMS_CMD, (u8 *) cmd, cmdsize);
+   ret = priv->ops->hw_host_to_card(priv, MVMS_CMD, (u8 *)cmd, cmdsize);
spin_unlock_irqrestore(&priv->driver_lock, flags);
 
if (ret) {
diff --git a/drivers/net/wireless/marvell/libertas_tf/if_usb.c 
b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
index 6ede6168bd85..7a5a1a85dcf7 100644
--- a/drivers/net/wireless/marvell/libertas_tf/if_usb.c
+++ b/drivers/net/wireless/marvell/libertas_tf/if_usb.c
@@ -131,6 +131,12 @@ static void if_usb_fw_timeo(struct timer_list *t)
lbtf_deb_leave(LBTF_DEB_USB);
 }
 
+static const struct lbtf_ops if_usb_ops = {
+   .hw_host_to_card = if_usb_host_to_card,
+   .hw_prog_firmware = if_usb_prog_firmware,
+   .hw_reset_device = if_usb_reset_device,
+};
+
 /**
  *  if_usb_probe - sets the configuration values
  *
@@ -216,15 +222,11 @@ static int if_usb_probe(struct usb_interface *intf,
goto dealloc;
}
 
-   priv = lbtf_add_card(cardp, &udev->dev);
+   priv = lbtf_add_card(cardp, &udev->dev, &if_usb_ops);
if (!priv)
goto dealloc;
 
cardp->priv = priv;
-
-   priv->hw_host_to_card = if_usb_host_to_card;
-   priv->hw_prog_firmware = if_usb_prog_firmware;
-   priv->hw_reset_device = if_usb_reset_device;
cardp->boot2_version = udev->descriptor.bcdDevice;
 
usb_get_dev(udev);
diff --git a/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h 
b/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h
index ad77b92d0b41..11d5ff68bc5e 100644
--- a/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h
+++ b/drivers/net/wireless/marvell/libertas_tf/libertas_tf.h
@@ -173,10 +173,19 @@ struct channel_range {
 
 struct if_usb_card;
 
+struct lbtf_ops {
+   /** Hardware access */
+   int (*hw_host_to_card)(struct lbtf_private *priv, u8 type,
+  u8 *payload, u16 nb);
+   int (*hw_prog_firmware)(struct if_usb_card *cardp);
+   int (*hw_reset_device)(struct if_usb_card *cardp);
+};
+
 /** Private structure for the MV device */
 struct lbtf_private {
void *card;
struct ieee80211_hw *hw;
+   const struct lbtf_ops *ops;
 
/* Command response buffer */
u8 cmd_resp_buff[LBS_UPLD_SIZE];
@@ -188,11 +197,6 @@ struct lbtf_private {
 
struct work_struct cmd_work;
struct work_struct tx_work;
-   /** Hardware access */
-   int (*hw_host_to_card) (struct lbtf_private *priv, u8 type, u8 
*payload, u16 nb);
-   int (*hw_prog_firmware) (struct if_usb_card *cardp);
-   int (*hw_reset_device) (struct if_usb_card *cardp);
-
 
/** Wlan adapter data structure*/
/** STATUS variables */
@@ -486,7 +490,8 @@ void lbtf_cmd_response_rx(struct lbtf_private *priv);
 /* main.c */
 struct chan_freq_power *lbtf_get_region_cfp_table(u8 region,
int *cfp_no);
-struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev);
+struct lbtf_private *lbtf_add_card(void *card, struct device *dmdev,
+  const struct lbtf_ops *ops);
 int lbtf_remove_card(struct lbtf_private *priv);
 int lbtf_start_card(struct lbtf_private *priv);
 int lbtf_rx(struct lbtf_private *priv, struct sk_buff *skb);
diff --git a/drivers/net/wireless/marvell/libertas_tf/main.c 
b/drivers/net/wireless/marvell/libertas_tf/main.c
index f93b400db949..8ed3cd158cf5 100644
--- a/drivers/net/wireless/marvell/libertas_tf/main.c
+++ b/drivers/net/wireless/marvell/libertas_tf/main.c
@@ -281,7 +281,7 @@ static void lbtf_tx_work(struct work_struct *work)
BUG_ON(priv->tx_skb);
spin_lock_irq(&priv->driver_lock);
priv->tx_skb = skb;
-   err = priv->hw_host_to_card(priv, MVMS_DAT, skb->data, skb->len);
+   err = priv->ops->hw_host_to_card(priv, MVMS_DAT, skb->data, skb->len);
spin_unlock_irq(&priv->driver_lock);
if (err) {
dev_kfree_sk

[PATCH 3/3] libertas_tf: get the MAC address before registering the device

2019-02-10 Thread Lubomir Rintel
The start() callback is too late for this: NetworkManager would already
have seen the hardware, thinking 00:00:00:00:00:00 is its permanent
address.

Signed-off-by: Lubomir Rintel 
---
 .../net/wireless/marvell/libertas_tf/main.c   | 57 ---
 1 file changed, 11 insertions(+), 46 deletions(-)

diff --git a/drivers/net/wireless/marvell/libertas_tf/main.c 
b/drivers/net/wireless/marvell/libertas_tf/main.c
index b4bd3047eb4e..da53da71987e 100644
--- a/drivers/net/wireless/marvell/libertas_tf/main.c
+++ b/drivers/net/wireless/marvell/libertas_tf/main.c
@@ -125,37 +125,6 @@ static void lbtf_cmd_work(struct work_struct *work)
lbtf_deb_leave(LBTF_DEB_CMD);
 }
 
-/**
- *  lbtf_setup_firmware: initialize firmware.
- *
- *  @privA pointer to struct lbtf_private structure
- *
- *  Returns: 0 on success.
- */
-static int lbtf_setup_firmware(struct lbtf_private *priv)
-{
-   int ret = -1;
-
-   lbtf_deb_enter(LBTF_DEB_FW);
-   /*
-* Read priv address from HW
-*/
-   eth_broadcast_addr(priv->current_addr);
-   ret = lbtf_update_hw_spec(priv);
-   if (ret) {
-   ret = -1;
-   goto done;
-   }
-
-   lbtf_set_mac_control(priv);
-   lbtf_set_radio_control(priv);
-
-   ret = 0;
-done:
-   lbtf_deb_leave_args(LBTF_DEB_FW, "ret: %d", ret);
-   return ret;
-}
-
 /**
  *  This function handles the timeout of command sending.
  *  It will re-send the same command again.
@@ -289,30 +258,17 @@ static void lbtf_tx_work(struct work_struct *work)
 static int lbtf_op_start(struct ieee80211_hw *hw)
 {
struct lbtf_private *priv = hw->priv;
-   int ret = -1;
 
lbtf_deb_enter(LBTF_DEB_MACOPS);
 
-   /* poke the firmware */
priv->capability = WLAN_CAPABILITY_SHORT_PREAMBLE;
priv->radioon = RADIO_ON;
priv->mac_control = CMD_ACT_MAC_RX_ON | CMD_ACT_MAC_TX_ON;
-   ret = lbtf_setup_firmware(priv);
-   if (ret)
-   goto err_setup_firmware;
-
-   if ((priv->fwrelease < LBTF_FW_VER_MIN) ||
-   (priv->fwrelease > LBTF_FW_VER_MAX)) {
-   ret = -1;
-   goto err_setup_firmware;
-   }
+   lbtf_set_mac_control(priv);
+   lbtf_set_radio_control(priv);
 
lbtf_deb_leave(LBTF_DEB_MACOPS);
return 0;
-
-err_setup_firmware:
-   lbtf_deb_leave_args(LBTF_DEB_MACOPS, "fw setup error; ret=%d", ret);
-   return ret;
 }
 
 static void lbtf_op_stop(struct ieee80211_hw *hw)
@@ -649,6 +605,15 @@ struct lbtf_private *lbtf_add_card(void *card, struct 
device *dmdev,
goto err_init_adapter;
}
 
+   eth_broadcast_addr(priv->current_addr);
+   if (lbtf_update_hw_spec(priv))
+   goto err_init_adapter;
+
+   if (priv->fwrelease < LBTF_FW_VER_MIN ||
+   priv->fwrelease > LBTF_FW_VER_MAX) {
+   goto err_init_adapter;
+   }
+
/* The firmware seems to start with the radio enabled. Turn it
 * off before an actual mac80211 start callback is invoked.
 */
-- 
2.20.1



Re: [PATCH v4 13/16] block: sed-opal: check size of shadow mbr

2019-02-10 Thread David Kozub

On Fri, 8 Feb 2019, Derrick, Jonathan wrote:


On Fri, 2019-02-01 at 21:50 +0100, David Kozub wrote:

From: Jonas Rabenstein 

Check whether the shadow mbr does fit in the provided space on the
target. Also a proper firmware should handle this case and return an
error we may prevent problems or even damage with crappy firmwares.

Signed-off-by: Jonas Rabenstein 
Reviewed-by: Scott Bauer 
---
 block/opal_proto.h | 16 
 block/sed-opal.c   | 39 +++
 2 files changed, 55 insertions(+)

diff --git a/block/opal_proto.h b/block/opal_proto.h
index b6e352cfe982..5e8df3245eb0 100644
--- a/block/opal_proto.h
+++ b/block/opal_proto.h
@@ -106,6 +106,7 @@ enum opal_uid {
OPAL_ENTERPRISE_BANDMASTER0_UID,
OPAL_ENTERPRISE_ERASEMASTER_UID,
/* tables */
+   OPAL_TABLE_TABLE,
OPAL_LOCKINGRANGE_GLOBAL,
OPAL_LOCKINGRANGE_ACE_RDLOCKED,
OPAL_LOCKINGRANGE_ACE_WRLOCKED,
@@ -160,6 +161,21 @@ enum opal_token {
OPAL_STARTCOLUMN = 0x03,
OPAL_ENDCOLUMN = 0x04,
OPAL_VALUES = 0x01,
+   /* table table */
+   OPAL_TABLE_UID = 0x00,
+   OPAL_TABLE_NAME = 0x01,
+   OPAL_TABLE_COMMON = 0x02,
+   OPAL_TABLE_TEMPLATE = 0x03,
+   OPAL_TABLE_KIND = 0x04,
+   OPAL_TABLE_COLUMN = 0x05,
+   OPAL_TABLE_COLUMNS = 0x06,
+   OPAL_TABLE_ROWS = 0x07,
+   OPAL_TABLE_ROWS_FREE = 0x08,
+   OPAL_TABLE_ROW_BYTES = 0x09,
+   OPAL_TABLE_LASTID = 0x0A,
+   OPAL_TABLE_MIN = 0x0B,
+   OPAL_TABLE_MAX = 0x0C,
+
/* authority table */
OPAL_PIN = 0x03,
/* locking tokens */
diff --git a/block/sed-opal.c b/block/sed-opal.c
index 2459ac4d523b..3493bb979978 100644
--- a/block/sed-opal.c
+++ b/block/sed-opal.c
@@ -139,6 +139,8 @@ static const u8 opaluid[][OPAL_UID_LENGTH] = {

/* tables */

+   [OPAL_TABLE_TABLE]
+   { 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x01 },
[OPAL_LOCKINGRANGE_GLOBAL] =
{ 0x00, 0x00, 0x08, 0x02, 0x00, 0x00, 0x00, 0x01 },
[OPAL_LOCKINGRANGE_ACE_RDLOCKED] =
@@ -1120,6 +1122,29 @@ static int generic_get_column(struct opal_dev *dev, 
const u8 *table,
return finalize_and_send(dev, parse_and_check_status);
 }

+/*
+ * see TCG SAS 5.3.2.3 for a description of the available columns
+ *
+ * the result is provided in dev->resp->tok[4]
+ */
+static int generic_get_table_info(struct opal_dev *dev, enum opal_uid table,
+ u64 column)
+{
+   u8 uid[OPAL_UID_LENGTH];
+   const unsigned int half = OPAL_UID_LENGTH/2;
+
+   /* sed-opal UIDs can be split in two halves:
+*  first:  actual table index
+*  second: relative index in the table
+* so we have to get the first half of the OPAL_TABLE_TABLE and use the
+* first part of the target table as relative index into that table
+*/
+   memcpy(uid, opaluid[OPAL_TABLE_TABLE], half);
+   memcpy(uid+half, opaluid[table], half);
+
+   return generic_get_column(dev, uid, column);
+}
+
 static int gen_key(struct opal_dev *dev, void *data)
 {
u8 uid[OPAL_UID_LENGTH];
@@ -1535,6 +1560,20 @@ static int write_shadow_mbr(struct opal_dev *dev, void 
*data)
u64 len;
int err = 0;

+   /* do we fit in the available shadow mbr space? */
+   err = generic_get_table_info(dev, OPAL_MBR, OPAL_TABLE_ROWS);

Wouldn't you need to multiply this by result from OPAL_TABLE_ROWBYTES?
What does ROWBYTES return for you?


Hi Jon,

reading the spec[1], I think it defines the MBR table to be a "byte table" 
(see 5.7.2.6 MBR (Byte Table)). For byte tables, it says (see 3.2.5.1 
Kinds of Tables) "A byte table has one unnamed column of type bytes_1." I 
think this implies that each row is 1 byte and so number of rows = size of 
table in rows.


When I actually try to get OPAL_TABLE_ROWS abd OPAL_TABLE_ROWBYTES of the 
MBR table from a Samsung 840 EVO, I get:

* OPAL_TABLE_ROWS 134217728 which is 128 MiB
* OPAL_TABLE_ROWBYTES 0

I'm not sure if I'm doing something wrong here. I just added:

err = generic_get_table_info(dev, OPAL_MBR, OPAL_TABLE_ROW_BYTES);
if (err) {
pr_debug("MBR: could not get shadow row bytes size\n");
return err;
}

row_bytes = response_get_u64(&dev->parsed, 4);

Best regards,
David

[1] 
https://trustedcomputinggroup.org/wp-content/uploads/TCG_Storage_Architecture_Core_Spec_v2.01_r1.00.pdf


[PATCH v1] clk: qcom: Make common clk_hw registrations

2019-02-10 Thread Jeffrey Hugo
Several clock controller drivers define a list of clk_hw devices, and then
register those devices in probe() before using common code to process the
rest of initialization.  Extend the common code to accept a list of clk_hw
devices to process, thus eliminating many duplicate implementations.

Signed-off-by: Jeffrey Hugo 
---
 drivers/clk/qcom/common.c   |  8 
 drivers/clk/qcom/common.h   |  2 ++
 drivers/clk/qcom/gcc-ipq8074.c  | 10 ++
 drivers/clk/qcom/gcc-mdm9615.c  | 11 ++-
 drivers/clk/qcom/gcc-msm8996.c  | 10 ++
 drivers/clk/qcom/gcc-msm8998.c  | 10 ++
 drivers/clk/qcom/gcc-qcs404.c   |  9 ++---
 drivers/clk/qcom/gcc-sdm660.c   | 11 +++
 drivers/clk/qcom/mmcc-msm8996.c | 10 ++
 9 files changed, 29 insertions(+), 52 deletions(-)

diff --git a/drivers/clk/qcom/common.c b/drivers/clk/qcom/common.c
index 0a48ed5..a6b2f861 100644
--- a/drivers/clk/qcom/common.c
+++ b/drivers/clk/qcom/common.c
@@ -231,6 +231,8 @@ int qcom_cc_really_probe(struct platform_device *pdev,
struct gdsc_desc *scd;
size_t num_clks = desc->num_clks;
struct clk_regmap **rclks = desc->clks;
+   size_t num_clk_hws = desc->num_clk_hws;
+   struct clk_hw **clk_hws = desc->clk_hws;
 
cc = devm_kzalloc(dev, sizeof(*cc), GFP_KERNEL);
if (!cc)
@@ -269,6 +271,12 @@ int qcom_cc_really_probe(struct platform_device *pdev,
 
qcom_cc_drop_protected(dev, cc);
 
+   for (i = 0; i < num_clk_hws; i++) {
+   ret = devm_clk_hw_register(dev, clk_hws[i]);
+   if (ret)
+   return ret;
+   }
+
for (i = 0; i < num_clks; i++) {
if (!rclks[i])
continue;
diff --git a/drivers/clk/qcom/common.h b/drivers/clk/qcom/common.h
index 4aa33ee..1e2a8bd 100644
--- a/drivers/clk/qcom/common.h
+++ b/drivers/clk/qcom/common.h
@@ -27,6 +27,8 @@ struct qcom_cc_desc {
size_t num_resets;
struct gdsc **gdscs;
size_t num_gdscs;
+   struct clk_hw **clk_hws;
+   size_t num_clk_hws;
 };
 
 /**
diff --git a/drivers/clk/qcom/gcc-ipq8074.c b/drivers/clk/qcom/gcc-ipq8074.c
index 505c626..0e32892 100644
--- a/drivers/clk/qcom/gcc-ipq8074.c
+++ b/drivers/clk/qcom/gcc-ipq8074.c
@@ -4715,18 +4715,12 @@ enum {
.num_clks = ARRAY_SIZE(gcc_ipq8074_clks),
.resets = gcc_ipq8074_resets,
.num_resets = ARRAY_SIZE(gcc_ipq8074_resets),
+   .clk_hws = gcc_ipq8074_hws,
+   .num_clk_hws = ARRAY_SIZE(gcc_ipq8074_hws),
 };
 
 static int gcc_ipq8074_probe(struct platform_device *pdev)
 {
-   int ret, i;
-
-   for (i = 0; i < ARRAY_SIZE(gcc_ipq8074_hws); i++) {
-   ret = devm_clk_hw_register(&pdev->dev, gcc_ipq8074_hws[i]);
-   if (ret)
-   return ret;
-   }
-
return qcom_cc_probe(pdev, &gcc_ipq8074_desc);
 }
 
diff --git a/drivers/clk/qcom/gcc-mdm9615.c b/drivers/clk/qcom/gcc-mdm9615.c
index 849046f..8c6d931 100644
--- a/drivers/clk/qcom/gcc-mdm9615.c
+++ b/drivers/clk/qcom/gcc-mdm9615.c
@@ -1702,6 +1702,8 @@ enum {
.num_clks = ARRAY_SIZE(gcc_mdm9615_clks),
.resets = gcc_mdm9615_resets,
.num_resets = ARRAY_SIZE(gcc_mdm9615_resets),
+   .clk_hws = gcc_mdm9615_hws,
+   .num_clk_hws = ARRAY_SIZE(gcc_mdm9615_hws),
 };
 
 static const struct of_device_id gcc_mdm9615_match_table[] = {
@@ -1712,21 +1714,12 @@ enum {
 
 static int gcc_mdm9615_probe(struct platform_device *pdev)
 {
-   struct device *dev = &pdev->dev;
struct regmap *regmap;
-   int ret;
-   int i;
 
regmap = qcom_cc_map(pdev, &gcc_mdm9615_desc);
if (IS_ERR(regmap))
return PTR_ERR(regmap);
 
-   for (i = 0; i < ARRAY_SIZE(gcc_mdm9615_hws); i++) {
-   ret = devm_clk_hw_register(dev, gcc_mdm9615_hws[i]);
-   if (ret)
-   return ret;
-   }
-
return qcom_cc_really_probe(pdev, &gcc_mdm9615_desc, regmap);
 }
 
diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c
index 9d13617..4632b92 100644
--- a/drivers/clk/qcom/gcc-msm8996.c
+++ b/drivers/clk/qcom/gcc-msm8996.c
@@ -3656,6 +3656,8 @@ enum {
.num_resets = ARRAY_SIZE(gcc_msm8996_resets),
.gdscs = gcc_msm8996_gdscs,
.num_gdscs = ARRAY_SIZE(gcc_msm8996_gdscs),
+   .clk_hws = gcc_msm8996_hws,
+   .num_clk_hws = ARRAY_SIZE(gcc_msm8996_hws),
 };
 
 static const struct of_device_id gcc_msm8996_match_table[] = {
@@ -3666,8 +3668,6 @@ enum {
 
 static int gcc_msm8996_probe(struct platform_device *pdev)
 {
-   struct device *dev = &pdev->dev;
-   int i, ret;
struct regmap *regmap;
 
regmap = qcom_cc_map(pdev, &gcc_msm8996_desc);
@@ -3680,12 +3680,6 @@ static int gcc_msm8996_probe(struct platform_device 
*pdev)
 */
regmap_update_bits(regmap, 0x52008, BIT(21), BIT(21));
 
-   for (i = 0; i < ARRAY_SIZE(gcc_msm8996_hws); i++) {
-  

linux-next: Fixes tag needs some work in the net tree

2019-02-10 Thread Stephen Rothwell
Hi all,

In commit

  ccc8ca9b90ac ("net/smc: fix byte_order for rx_curs_confirmed")

Fixes tag

  Fixes: b8649efad879 ("net/smc: fix sender_free computation") (net-tree)

has these problem(s):

  - The trailing '(net-tree)' is unexpected

-- 
Cheers,
Stephen Rothwell


pgp5Cm1mOG5MA.pgp
Description: OpenPGP digital signature


Re: [PATCH net] sctp: make sctp_setsockopt_events() less strict about the option length

2019-02-10 Thread Marcelo Ricardo Leitner
On Sun, Feb 10, 2019 at 10:46:16AM -0200, Marcelo Ricardo Leitner wrote:
> On Sat, Feb 09, 2019 at 03:12:17PM -0800, David Miller wrote:
> > From: Marcelo Ricardo Leitner 
> > Date: Wed, 6 Feb 2019 18:37:54 -0200
> > 
> > > On Wed, Feb 06, 2019 at 12:14:30PM -0800, Julien Gomes wrote:
> > >> Make sctp_setsockopt_events() able to accept sctp_event_subscribe
> > >> structures longer than the current definitions.
> > >> 
> > >> This should prevent unjustified setsockopt() failures due to struct
> > >> sctp_event_subscribe extensions (as in 4.11 and 4.12) when using
> > >> binaries that should be compatible, but were built with later kernel
> > >> uapi headers.
> > > 
> > > Not sure if we support backwards compatibility like this?
> > 
> > What a complete mess we have here.
> > 
> > Use new socket option numbers next time, do not change the size and/or
> > layout of existing socket options.
> 
> What about reusing the same socket option, but defining a new struct?
> Say, MYSOCKOPT supports struct mysockopt, struct mysockopt2, struct
> mysockopt3...
> 
> That way we have a clear definition of the user's intent.
> 
> > 
> > This whole thread, if you read it, is basically "if we compatability
> > this way, that breaks, and if we do compatability this other way oh
> > shit this other thing doesn't work."
> > 
> > I think we really need to specifically check for the difference sizes
> > that existed one by one, clear out the part not given by the user, and
> > backport this as far back as possible in a way that in the older kernels
> > we see if the user is actually trying to use the new features and if so
> > error out.
> 
> I'm afraid clearing out may not be enough, though seems it's the best
> we can do so far. If the struct is allocated but not fully initialized
> via a memset, but by setting its fields one by one, the remaining new
> fields will be left uninitinialized.

Need to clarify the "clearing out", I think it was meant differently.
It was more about on how to ensure that the 16-bytes long of the v3
supplied to a v1-only kernel is compatible with the 12-bytes long v1.
The kernel would have to check the trailing 4 bytes after v1-size and
make sure they are all zeroed in order for the old kernel to accept it
as a v1. But, as I said above, there are situations that this will not
be enough.

> 
> > 
> > Which, btw, is terrible behavior.  Newly compiled apps should work on
> > older kernels if they don't try to use the new features, and if they
> 
> One use case here is: a given distro is using kernel X and app Foo is
> built against it. Then upgrades to X+1, Foo is patched to fix an issue
> and is rebuilt against X+1. The user upgrades Foo package but for
> whatever reason, doesn't upgrade kernel or reboot the system. Here,
> Foo doesn't work anymore until the new kernel is also running.
> 
> > can the ones that want to try to use the new features should be able
> > to fall back when that feature isn't available in a non-ambiguous
> > and precisely defined way.
> > 
> > The fact that the use of the new feature is hidden in the new
> > structure elements is really rotten.
> > 
> > This patch, at best, needs some work and definitely a longer and more
> > detailed commit message.
> 

We have issues on read path too. 52ccb8e90c0a ("[SCTP]: Update
SCTP_PEER_ADDR_PARAMS socket option to the latest api draft.")
extended struct sctp_paddrparams and its getsockopt goes with:

sctp_getsockopt_peer_addr_params()
...
if (len < sizeof(struct sctp_paddrparams))
return -EINVAL;
len = sizeof(struct sctp_paddrparams);

By then, we didn't have the /uapi/ folder yet. There may other cases.


linux-next: Fixes tag needs some work in the fbdev tree

2019-02-10 Thread Stephen Rothwell
Hi Bartlomiej,

In commit

  7d7e58d30e04 ("dt-bindings: display: ssd1307fb: Remove reset-active-low from 
examples")

Fixes tag

  Fixes: 519b4db ("fbdev: ssd1307fb: Remove reset-active-low from the DT 
binding document")

has these problem(s):

  - SHA1 should be at least 12 digits long
Can be fixed by setting core.abbrev to 12 (or more) or (for git v2.11
or later) just making sure it is not set (or set to "auto").

-- 
Cheers,
Stephen Rothwell


pgpz_x2ex8TMs.pgp
Description: OpenPGP digital signature


Re: [PATCH v4 10/16] block: sed-opal: add ioctl for done-mark of shadow mbr

2019-02-10 Thread David Kozub

On Sun, 10 Feb 2019, Scott Bauer wrote:


On Fri, Feb 08, 2019 at 12:44:14AM +, Derrick, Jonathan wrote:

On Thu, 2019-02-07 at 23:56 +0100, David Kozub wrote:

On Mon, 4 Feb 2019, Christoph Hellwig wrote:

 static int opal_enable_disable_shadow_mbr(struct opal_dev *dev,
  struct opal_mbr_data *opal_mbr)
 {
+   u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE
+   ? OPAL_TRUE : OPAL_FALSE;
const struct opal_step mbr_steps[] = {
{ opal_discovery0, },
{ start_admin1LSP_opal_session, &opal_mbr->key },
-   { set_mbr_done, &opal_mbr->enable_disable },
+   { set_mbr_done, &token },



Am I missing something here? This seems wrong to me. And I think this
patch actually changes it by introducing:

+u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE
+? OPAL_TRUE : OPAL_FALSE;

which is essentially a negation (map 0 to 1 and 1 to 0).


Agreed the original code did the opposite of what the user wanted, looks like
when I authored it I messed up that enum which set everything off.




With regard to the new IOC_OPAL_MBR_STATUS: I find the usage of
OPAL_MBR_ENABLE/DISABLE for this confusing: what should passing
OPAL_MBR_ENABLE do? Should it enable the shadow MBR? Or should it
enable the MBR-done flag? I think the implementation in this patch
interprets OPAL_MBR_ENABLE as 'set the "done" flag to true', thus hiding
the shadow MBR. But this is not obvious looking at the IOCTL name.


For the new ioctl I think we should just add a new enum with the correct
nomenclature.  So OPAL_MBR_DONE, OPAL_MBR_NOT_DONE.



In order to keep the userspace interface consistent, I'll ACK your
change in this patch, unless Scott can fill me in on why this looks
wrong but is actually right.


I think it is just wrong.




We have 7 bytes in the opal_mbr_data struct we could use for DONE/NOT
DONE. I'm not sure how to go about keeping it consistent with old uapi,
although arguably opal_enable_disable_shadow_mbr is already doing the
wrong thing with DONE and ENABLE so it's low impact.


Can we keep the old mbr struct the same and just add a new struct with new enums
for the new done ioctl? I think this will keep the new ioctl cleaner instead
of trying to apply older, some what incorrectly named, enums.


I like this proposal, I'll try to implement it. Although currently I plan 
to first re-submit the cleanup parts, as suggested by Christoph[1]. So 
this will happen after that.



Lastly someone will need to backport his


+   u8 token = opal_mbr->enable_disable == OPAL_MBR_ENABLE
+   ? OPAL_TRUE : OPAL_FALSE;


to stable so we can fix up my broken coding in older kernels.


I can do that or, if David wants to do that that's fine... just want to 
coordinate.


I'm quite busy juggling patches in this series. If you can find the time, 
please do it.


Best regards,
David

[1] https://lore.kernel.org/lkml/20190204150415.go31...@infradead.org/



Re: [GIT PULL 1/2] arch: System call unification and cleanup

2019-02-10 Thread Thomas Gleixner
On Sat, 9 Feb 2019, Arnd Bergmann wrote:

> The following changes since commit 1c7fc5cbc33980acd13d668f1c8f0313d6ae9fd8:
> 
>   Linux 5.0-rc2 (2019-01-14 10:41:12 +1200)
> 
> are available in the Git repository at:
> 
>   git://git.kernel.org:/pub/scm/linux/kernel/git/arnd/playground.git
> tags/y2038-syscall-cleanup

Went over the lot with a fine comb. This looks really good. Nice work!

Pulled into tip timers/2038

Thanks,

tglx


linux-next: Signed-off-by missing for commit in the wireless-drivers-next tree

2019-02-10 Thread Stephen Rothwell
Hi all,

Commit

  768ec4c012ac ("ath10k: update HOST capability qmi message")

is missing a Signed-off-by from its author.

-- 
Cheers,
Stephen Rothwell


pgpVWPxik8hec.pgp
Description: OpenPGP digital signature


Re: ext4 corruption on alpha with 4.20.0-09062-gd8372ba8ce28

2019-02-10 Thread Meelis Roos

02.01.19 17:52 I wrote:


I have noticed ext4 filesystem corruption on two of my test alphas with 
4.20.0-09062-gd8372ba8ce28.


Retried it, still happens with 5.0.0-rc5-00358-gdf3865f8f568 - rsync of emerge 
--sync just fail with nothing in dmesg.
 

On AlphaServer DS10:
[10749.664418] EXT4-fs error (device sda2): __ext4_iget:5052: inode #1853093: 
block 1: comm rsync: invalid block

On AlphaServer DS10L:
[ 5325.064656] EXT4-fs error (device sda2): htree_dirblock_to_tree:1007: inode 
#1191951: block 4731728: comm rm: bad entry in directory: directory entry 
overrun - offset=76, inode=417080, rec_len=61816, name_len=35, size=4096
[ 5325.069539] EXT4-fs error (device sda2): htree_dirblock_to_tree:1007: inode 
#1191951: block 4731728: comm rm: bad entry in directory: directory entry 
overrun - offset=76, inode=417080, rec_len=61816, name_len=35, size=4096
[ 5325.077351] EXT4-fs error (device sda2): ext4_empty_dir:2718: inode 
#1191951: block 4731728: comm rm: bad entry in directory: directory entry 
overrun - offset=76, inode=417080, rec_len=61816, name_len=35, size=4096

Two other alphas, PC-164 and Eiger, worked fine with the same kernel version 
(different kernel configs according to hardware).

The details:
4.20 worked fine, with gentoo emerge package update after bootup.
Next, 4.20.0-06428-g00c569b567c7 worked fine, with gentoo emerge after bootup.
Next, 4.20.0-09062-gd8372ba8ce28 booted up fine but rsync and rm during start 
of gentoo emerge errored out like above.

So the corruption _might_ have happened during bootup of previous kernel but it 
looks more likely that only the latest kernel with blk-mq introduced the 
problems. mq-deadline is in use on all the alphas.

DS10 has Symbios 53C896 SCSI (sym2 driver), DS10L has QLogic ISP1040, so they 
are different. Working Eiger and PC164 have sym2 based scsi controllers too.


--
Meelis Roos 


Re: [PATCH] MAINTAINERS: rectify two issues in KEYS-TRUSTED entry

2019-02-10 Thread Paul E. McKenney
On Sun, Feb 10, 2019 at 08:00:09PM +0100, Lukas Bulwahn wrote:
> Mimi Zohar used spaces instead of a tab when adding Jarkko Sakkinen as
> further maintainer to the KEYS-TRUSTED section entry. Paul McKenney also
> introduced a typo in Mimi Zohar's email address in the KEYS-TRUSTED section
> entry.
> 
> The two issues were detected when writing a script that parses MAINTAINERS.
> 
> Fixes: 34bccd61b139 ("MAINTAINERS: add Jarkko as maintainer for trusted keys")
> Fixes: 1dfddcdb95c4 ("MAINTAINERS: Update from @linux.vnet.ibm.com to 
> @linux.ibm.com")
> 
> Signed-off-by: Lukas Bulwahn 

Good catch!

Reviewed-by: Paul E. McKenney 

> ---
> Mimi, please pick up this patch instead of
>   "[PATCH] MAINTAINERS: use tab instead of spaces". Thanks.
> 
>  MAINTAINERS | 4 ++--
>  1 file changed, 2 insertions(+), 2 deletions(-)
> 
> diff --git a/MAINTAINERS b/MAINTAINERS
> index bf4965d6d5de..b4b62ea78eeb 100644
> --- a/MAINTAINERS
> +++ b/MAINTAINERS
> @@ -8405,8 +8405,8 @@ F:  security/keys/encrypted-keys/
> 
>  KEYS-TRUSTED
>  M:   James Bottomley 
> -M:  Jarkko Sakkinen 
> -M:   Mimi Zohar 
> +M:   Jarkko Sakkinen 
> +M:   Mimi Zohar 
>  L:   linux-integr...@vger.kernel.org
>  L:   keyri...@vger.kernel.org
>  S:   Supported
> -- 
> 2.17.1
> 



[PATCH 1/2] extcon-intel-cht-wc: Make charger detection co-existed with OTG host mode

2019-02-10 Thread Yauhen Kharuzhy
Whiskey Cove Cherry Trail PMIC requires disabling OTG host mode before
of charger detection procedure. Do this by manipulationg of CHGRCTRL1
register.

Source: APCI DSDT code of Lenovo Yoga Book YB1-X91L and open-sourced
Intel's drivers.

Signed-off-by: Yauhen Kharuzhy 
---
 drivers/extcon/extcon-intel-cht-wc.c | 38 +++-
 1 file changed, 37 insertions(+), 1 deletion(-)

diff --git a/drivers/extcon/extcon-intel-cht-wc.c 
b/drivers/extcon/extcon-intel-cht-wc.c
index 5ef215297101..4f6ba249bc30 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -29,7 +29,16 @@
 #define CHT_WC_CHGRCTRL0_DBPOFFBIT(6)
 #define CHT_WC_CHGRCTRL0_CHR_WDT_NOKICKBIT(7)
 
-#define CHT_WC_CHGRCTRL1   0x5e17
+#define CHT_WC_CHGRCTRL1   0x5e17
+#define CHT_WC_CHGRCTRL1_DBPEN_MASKBIT(7)
+#define CHT_WC_CHGRCTRL1_OTGMODE   BIT(6)
+#define CHT_WC_CHGRCTRL1_FTEMP_EVENT   BIT(5)
+#define CHT_WC_CHGRCTRL1_FUSB_INLMT_1500   BIT(4)
+#define CHT_WC_CHGRCTRL1_FUSB_INLMT_900BIT(3)
+#define CHT_WC_CHGRCTRL1_FUSB_INLMT_500BIT(2)
+#define CHT_WC_CHGRCTRL1_FUSB_INLMT_150BIT(1)
+#define CHT_WC_CHGRCTRL1_FUSB_INLMT_100BIT(0)
+
 
 #define CHT_WC_USBSRC  0x5e29
 #define CHT_WC_USBSRC_STS_MASK GENMASK(1, 0)
@@ -198,6 +207,29 @@ static void cht_wc_extcon_set_5v_boost(struct 
cht_wc_extcon_data *ext,
dev_err(ext->dev, "Error writing Vbus GPIO CTLO: %d\n", ret);
 }
 
+static void cht_wc_extcon_set_otgmode(struct cht_wc_extcon_data *ext,
+ bool enable)
+{
+   unsigned int chgrctrl1;
+   int ret;
+
+   ret = regmap_read(ext->regmap, CHT_WC_CHGRCTRL1, &chgrctrl1);
+   if (ret) {
+   dev_err(ext->dev, "Error reading CHGRCTRL1 reg: %d\n", ret);
+   return;
+   }
+
+   if (enable)
+   chgrctrl1 |= CHT_WC_CHGRCTRL1_OTGMODE;
+   else
+   chgrctrl1 &= ~(CHT_WC_CHGRCTRL1_OTGMODE);
+
+   ret = regmap_write(ext->regmap, CHT_WC_CHGRCTRL1, chgrctrl1);
+   if (ret)
+   dev_err(ext->dev,
+   "Error writing CHGRCTRL1 OTG mode bit: %d\n", ret);
+}
+
 /* Small helper to sync EXTCON_CHG_USB_SDP and EXTCON_USB state */
 static void cht_wc_extcon_set_state(struct cht_wc_extcon_data *ext,
unsigned int cable, bool state)
@@ -222,10 +254,14 @@ static void cht_wc_extcon_pwrsrc_event(struct 
cht_wc_extcon_data *ext)
 
id = cht_wc_extcon_get_id(ext, pwrsrc_sts);
if (id == USB_ID_GND) {
+   cht_wc_extcon_set_otgmode(ext, true);
+
/* The 5v boost causes a false VBUS / SDP detect, skip */
goto charger_det_done;
}
 
+   cht_wc_extcon_set_otgmode(ext, false);
+
/* Plugged into a host/charger or not connected? */
if (!(pwrsrc_sts & CHT_WC_PWRSRC_VBUS)) {
/* Route D+ and D- to PMIC for future charger detection */
-- 
2.20.1



linux-next: Fixes tag needs some work in the tip tree

2019-02-10 Thread Stephen Rothwell
Hi all,

In commit

  f6783319737f ("sched/fair: Fix insertion in rq->leaf_cfs_rq_list")

Fixes tag

  Fixes: 9c2791f936ef ("Fix hierarchical order in rq->leaf_cfs_rq_list")

has these problem(s):

  - Subject does not match target commit subject

-- 
Cheers,
Stephen Rothwell


pgpB5rDc2DmBz.pgp
Description: OpenPGP digital signature


[PATCH 0/2] extcon: Intel Cherry Trail Whiskey Cove PMIC and external charger tweaks

2019-02-10 Thread Yauhen Kharuzhy
At implementation of charging support for Lenovo Yoga Book (Intel Cherry Trail
based with Whiskey Cove PMIC), two pitfalls were found:

- for detection of charger type by PMIC, bit 6 in the CHGRCTRL1 register
  should be set in 0 (and set to 1 for Host mode). Pick up its definition
  and logic from from Intel code drop[1];

- "#CHARGE ENABLE" signal of external charger (bq25892) in Yoga Book is
  connected to one of PMIC outputs controlled by CHGDISCTRL register.
  Enable charging at driver initialization. Pick up this from Lenovo's code
  drop[2,3].

Please keep in mind that I have no docs for Whiskey Cove PMIC, so this patches
are based on some kind of reverse engineering and suppositions, correct me if
this semantic is wrong for common case.

[1]. 
https://github.com/01org/ProductionKernelQuilts/uefi/cht-m1stable/patches/0001-power_supply-intel-pmic-ccsm-driver.patch
[2]. 
https://github.com/jekhor/yogabook-linux-android-kernel/blob/b7aa015ab794b516da7b6cb76e5e2d427e3b8b0c/drivers/power/bq2589x_charger.c#L2257
[3]. 
https://github.com/01org/ProductionKernelQuilts/uefi/cht-m1stable/patches/EM-Charger-Disable-battery-charging-in-S3-and-enable.patch

Yauhen Kharuzhy (2):
  extcon-intel-cht-wc: Make charger detection co-existed with OTG host mode
  extcon intel-cht-wc: Enable external charger

 drivers/extcon/extcon-intel-cht-wc.c | 71 +++-
 1 file changed, 70 insertions(+), 1 deletion(-)

-- 
2.20.1



[PATCH 2/2] extcon intel-cht-wc: Enable external charger

2019-02-10 Thread Yauhen Kharuzhy
In some configuration external charge "#charge enable" signal is
connected to PMIC. Enable it at device probing to allow charging.

Tested at Lenovo Yoga Book (YB1-X91L).

Signed-off-by: Yauhen Kharuzhy 
---
 drivers/extcon/extcon-intel-cht-wc.c | 33 
 1 file changed, 33 insertions(+)

diff --git a/drivers/extcon/extcon-intel-cht-wc.c 
b/drivers/extcon/extcon-intel-cht-wc.c
index 4f6ba249bc30..00cb3084955e 100644
--- a/drivers/extcon/extcon-intel-cht-wc.c
+++ b/drivers/extcon/extcon-intel-cht-wc.c
@@ -57,6 +57,11 @@
 #define CHT_WC_USBSRC_TYPE_OTHER   8
 #define CHT_WC_USBSRC_TYPE_DCP_EXTPHY  9
 
+#define CHT_WC_CHGDISCTRL  0x5e2f
+#define CHT_WC_CHGDISCTRL_CCSM_DIS 0x11
+#define CHT_WC_CHGDISCTRL_CCSM_EN  0x00
+#define CHT_WC_CHGDISCTRL_CCSM_MASK0x51
+
 #define CHT_WC_PWRSRC_IRQ  0x6e03
 #define CHT_WC_PWRSRC_IRQ_MASK 0x6e0f
 #define CHT_WC_PWRSRC_STS  0x6e1e
@@ -230,6 +235,31 @@ static void cht_wc_extcon_set_otgmode(struct 
cht_wc_extcon_data *ext,
"Error writing CHGRCTRL1 OTG mode bit: %d\n", ret);
 }
 
+static void cht_wc_extcon_enable_charging(struct cht_wc_extcon_data *ext,
+ bool enable)
+{
+   unsigned int chgdisctrl;
+   int ret;
+
+   ret = regmap_read(ext->regmap, CHT_WC_CHGDISCTRL, &chgdisctrl);
+   if (ret) {
+   dev_err(ext->dev, "Error reading CHGDISCTRL reg: %d\n", ret);
+   return;
+   }
+
+   chgdisctrl &= CHT_WC_CHGDISCTRL_CCSM_MASK;
+
+   if (enable)
+   chgdisctrl |= CHT_WC_CHGDISCTRL_CCSM_EN;
+   else
+   chgdisctrl |= CHT_WC_CHGDISCTRL_CCSM_DIS;
+
+   dev_dbg(ext->dev, "Writing CHGDISCTRL: 0x%02x\n", chgdisctrl);
+   ret = regmap_write(ext->regmap, CHT_WC_CHGDISCTRL, chgdisctrl);
+   if (ret)
+   dev_err(ext->dev, "Error writing CHGDISCTRL: %d\n", ret);
+}
+
 /* Small helper to sync EXTCON_CHG_USB_SDP and EXTCON_USB state */
 static void cht_wc_extcon_set_state(struct cht_wc_extcon_data *ext,
unsigned int cable, bool state)
@@ -362,6 +392,9 @@ static int cht_wc_extcon_probe(struct platform_device *pdev)
 */
cht_wc_extcon_set_5v_boost(ext, false);
 
+   /* Allow charging by external battery charger*/
+   cht_wc_extcon_enable_charging(ext, true);
+
/* Enable sw control */
ret = cht_wc_extcon_sw_control(ext, true);
if (ret)
-- 
2.20.1



[PATCH 1/3] iio: light: Add driver for ap3216c

2019-02-10 Thread Robert Eshleman
This patch adds support for the ap3216c ambient light and proximity
sensor.

Supported features include:

* Illuminance (lux)
* Proximity (raw)
* IR (raw)
* Rising/falling threshold events for illuminance and proximity
* Calibration scale for illuminance
* Calibration bias for proximity

Signed-off-by: Robert Eshleman 
---
 drivers/iio/light/Kconfig   |  11 +
 drivers/iio/light/Makefile  |   1 +
 drivers/iio/light/ap3216c.c | 793 
 3 files changed, 805 insertions(+)
 create mode 100644 drivers/iio/light/ap3216c.c

diff --git a/drivers/iio/light/Kconfig b/drivers/iio/light/Kconfig
index 36f458433480..74688d19beb1 100644
--- a/drivers/iio/light/Kconfig
+++ b/drivers/iio/light/Kconfig
@@ -41,6 +41,17 @@ config AL3320A
 To compile this driver as a module, choose M here: the
 module will be called al3320a.
 
+config AP3216C
+   tristate "AP3216C Ambient Light and Proximity sensor"
+   select REGMAP_I2C
+   depends on I2C
+   help
+ Say Y here to build a driver for the AP3216C Ambient Light and
+ Proximity sensor.
+
+ To compile this driver as a module, choose M here: the
+ module will be called ap3216c.
+
 config APDS9300
tristate "APDS9300 ambient light sensor"
depends on I2C
diff --git a/drivers/iio/light/Makefile b/drivers/iio/light/Makefile
index 286bf3975372..7d2f8fa0f30d 100644
--- a/drivers/iio/light/Makefile
+++ b/drivers/iio/light/Makefile
@@ -7,6 +7,7 @@
 obj-$(CONFIG_ACPI_ALS) += acpi-als.o
 obj-$(CONFIG_ADJD_S311)+= adjd_s311.o
 obj-$(CONFIG_AL3320A)  += al3320a.o
+obj-$(CONFIG_AP3216C)  += ap3216c.o
 obj-$(CONFIG_APDS9300) += apds9300.o
 obj-$(CONFIG_APDS9960) += apds9960.o
 obj-$(CONFIG_BH1750)   += bh1750.o
diff --git a/drivers/iio/light/ap3216c.c b/drivers/iio/light/ap3216c.c
new file mode 100644
index ..12802b45c01c
--- /dev/null
+++ b/drivers/iio/light/ap3216c.c
@@ -0,0 +1,793 @@
+// SPDX-License-Identifier: GPL-2.0
+/*
+ * AP3216C Ambient Light and Infrared Proximity Sensor
+ *
+ * Copyright (c) 2019, Robert Eshleman.
+ *
+ * Datasheet: 
https://pdf-datasheet-datasheet.netdna-ssl.com/pdf-down/A/P/3/AP3216C-LITE-ON.pdf
+ *
+ * 7-bit I2C slave address 0x1E
+ */
+
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+#include 
+
+#define AP3216C_DRV_NAME "ap3216c"
+
+/* register addresses */
+#define AP3216C_SYS 0x0
+#define AP3216C_INT_STATUS 0x01
+#define AP3216C_INT_CLR 0x02
+#define AP3216C_IR_DATA_LO 0x0A
+#define AP3216C_IR_DATA_HI 0x0B
+#define AP3216C_ALS_DATA_LO 0x0C
+#define AP3216C_ALS_DATA_HI 0x0D
+#define AP3216C_PS_DATA_LO 0x0E
+#define AP3216C_PS_DATA_HI 0x0F
+#define AP3216C_ALS_CFG 0x10
+#define AP3216C_ALS_CALIB 0x19
+#define AP3216C_ALS_LO_THR_LO 0x1A
+#define AP3216C_ALS_LO_THR_HI 0x1B
+#define AP3216C_ALS_HI_THR_LO 0x1C
+#define AP3216C_ALS_HI_THR_HI 0x1D
+#define AP3216C_PS_CFG 0x20
+#define AP3216C_PS_CALIB_LO 0x28
+#define AP3216C_PS_CALIB_HI 0x29
+#define AP3216C_PS_LO_THR_LO 0x2A
+#define AP3216C_PS_LO_THR_HI 0x2B
+#define AP3216C_PS_HI_THR_LO 0x2C
+#define AP3216C_PS_HI_THR_HI 0x2D
+
+/* SYS_MODE mask and config value */
+#define AP3216C_SYS_MODE_ALS_PS GENMASK(1, 0)
+#define AP3216C_SYS_MODE_ALS_ONLY 0x01
+
+/* INT_STATUS masks and config value */
+#define AP3216C_INT_STATUS_ALS_MASK 1
+#define AP3216C_INT_STATUS_PS_MASK (1 << 1)
+#define AP3216C_INT_STATUS_CLR GENMASK(1, 0)
+#define AP3216C_INT_CLR_MANUAL 1
+
+/* IR_DATA mask/shift */
+#define AP3216C_IR_DATA_LO_MASK GENMASK(1, 0)
+#define AP3216C_IR_DATA_HI_SHIFT 2
+
+/* ALS_DATA shift and fractional helper */
+#define AP3216C_ALS_DATA_HI_SHIFT 8
+#define AP3216C_ALS_DATA_DENOM 10
+
+/* ALS_CALIB masks/shifts */
+#define AP3216C_ALS_CALIB_INT_MASK GENMASK(7, 6)
+#define AP3216C_ALS_CALIB_INT_SHIFT 6
+#define AP3216C_ALS_CALIB_DEC_MASK GENMASK(5, 0)
+
+/* PS_DATA shifts/masks/bits */
+#define AP3216C_PS_DATA_LO_MASK GENMASK(3, 0)
+#define AP3216C_PS_DATA_LO_IR_OF BIT(6)
+#define AP3216C_PS_DATA_HI_MASK GENMASK(5, 0)
+#define AP3216C_PS_DATA_HI_SHIFT 4
+#define AP3216C_PS_DATA_HI_IR_OF BIT(6)
+
+/* ALS_CFG masks */
+#define AP3216C_ALS_CFG_GAIN_MASK GENMASK(5, 4)
+
+/* ALS_CALIB shifts */
+#define AP3216C_ALS_CALIB_INT_SHIFT 6
+
+/* ALS_HI_THR masks and shifts */
+#define AP3216C_ALS_HI_THR_LO_MASK GENMASK(7, 0)
+#define AP3216C_ALS_HI_THR_HI_SHIFT 8
+#define AP3216C_ALS_HI_THR_HI_MASK GENMASK(7, 4)
+#define AP3216C_ALS_HI_THR_HI_SHIFT 8
+
+/* ALS_LO_THR masks and shifts */
+#define AP3216C_ALS_LO_THR_LO_MASK GENMASK(3, 0)
+#define AP3216C_ALS_LO_THR_HI_MASK GENMASK(7, 4)
+#define AP3216C_ALS_LO_THR_HI_SHIFT 8
+
+/* PS_CFG reg mask/shift/bit values */
+#define AP3216C_PS_CFG_GAIN_MASK GENMASK(3, 2)
+#define AP3216C_PS_CFG_GAIN_SHIFT 2
+#define AP3216C_PS_CFG_GAIN(val) \
+   (1 << ((val & AP3216C_PS_CFG_GAIN_MASK) >> AP3216C_PS_CFG_GAIN_SHIFT))
+
+/* PS_LO and PS_HI shift/mask and multipl

[PATCH 3/3] dt-bindings: iio: light: Add ap3216c

2019-02-10 Thread Robert Eshleman
Adds device tree bindings for the ap3216c ambient light and proximity
sensor.

Signed-off-by: Robert Eshleman 
---
 .../devicetree/bindings/iio/light/ap3216c.txt | 22 +++
 1 file changed, 22 insertions(+)
 create mode 100644 Documentation/devicetree/bindings/iio/light/ap3216c.txt

diff --git a/Documentation/devicetree/bindings/iio/light/ap3216c.txt 
b/Documentation/devicetree/bindings/iio/light/ap3216c.txt
new file mode 100644
index ..c5ae80c79dd8
--- /dev/null
+++ b/Documentation/devicetree/bindings/iio/light/ap3216c.txt
@@ -0,0 +1,22 @@
+* AP3216C Ambient Light and Proximity Sensor
+
+Required properties:
+  - compatible: should be "liteon,ap3216c"
+  - reg: the I2C address of the sensor (default is <0x1e>)
+
+Optional properties:
+  - interrupts: interrupt mapping for GPIO IRQ. Should be configured with
+IRQ_TYPE_EDGE_FALLING.
+
+Refer to interrupt-controller/interrupts.txt for generic interrupt client
+node bindings.
+
+Example:
+
+light-sensor@1e {
+   compatible = "liteon,ap3216c";
+   reg = <0x1e>;
+
+   interrupt-parent = <&gpio1>;
+   interrupts = <17 IRQ_TYPE_EDGE_FALLING>;
+};
-- 
2.20.1



[PATCH v4 0/3] sysctl: handle overflow for file-max

2019-02-10 Thread Christian Brauner
Hey Andrew,

You currently carry 
* sysctl-handle-overflow-in-proc_get_long.patch
* sysctl-handle-overflow-for-file-max.patch
in your http://www.ozlabs.org/~akpm/mmotm/ tree.

I recently pointed out that the current change can potentially lead to a
userspace facing change and asked you to please drop the second patch
(cf. [3]).
I think you might have missed that mail. This is the same patchset just
that the userspace facing change is split out into a separate commit.
Please take the first two commits as they fix the issue without any
userspace facing change. The third one is marked as RFC and we can
either take it now or punt on it until later.

Currently, when writing

echo 18446744073709551616 > /proc/sys/fs/file-max

/proc/sys/fs/file-max will overflow and be set to 0. That quickly
crashes the system.

The first version of this patch intended to detect the overflow and cap
at ULONG_MAX. However, we should not do this and rather return EINVAL on
overflow. The reasons are:
- this aligns with other sysctl handlers that simply reject overflows
  (cf. [1], [2], and a bunch of others)
- we already do a partial fail on overflow right now
  Namely, when the TMPBUFLEN is exceeded. So we already reject values
  such as 184467440737095516160 (21 chars) but accept values such as
  18446744073709551616 (20 chars) but both are overflows. So we should
  just always reject 64bit overflows and not special-case this based on
  the number of chars.

(This patchset is in reference to https://lkml.org/lkml/2018/10/11/585.)

Thanks!
Christian

[1]: fb910c42cceb ("sysctl: check for UINT_MAX before unsigned int min/max")
[2]: 196851bed522 ("s390/topology: correct topology mode proc handler")
[3]: https://lore.kernel.org/lkml/2019045140.lbmiz3w2f255u...@brauner.io/ 

Christian Brauner (3):
  sysctl: handle overflow in proc_get_long
  sysctl: handle overflow for file-max
  sysctl: return -EINVAL if val violates minmax

 kernel/sysctl.c | 49 ++---
 1 file changed, 46 insertions(+), 3 deletions(-)

-- 
2.20.1



[PATCH 2/3] dt-bindings: vendor-prefix: add prefix for Lite-On Corp.

2019-02-10 Thread Robert Eshleman
This patch adds a vendor-prefix for the Lite-On Semiconductor
Corporation.

Signed-off-by: Robert Eshleman 
---
 Documentation/devicetree/bindings/vendor-prefixes.txt | 1 +
 1 file changed, 1 insertion(+)

diff --git a/Documentation/devicetree/bindings/vendor-prefixes.txt 
b/Documentation/devicetree/bindings/vendor-prefixes.txt
index 389508584f48..e487a5d95ba9 100644
--- a/Documentation/devicetree/bindings/vendor-prefixes.txt
+++ b/Documentation/devicetree/bindings/vendor-prefixes.txt
@@ -219,6 +219,7 @@ linaro  Linaro Limited
 linksysBelkin International, Inc. (Linksys)
 linux  Linux-specific binding
 linx   Linx Technologies
+liteon  Lite-On Semiconductor Corporation
 lltc   Linear Technology Corporation
 logicpdLogic PD, Inc.
 lsiLSI Corp. (LSI Logic)
-- 
2.20.1



[PATCH v4 1/3] sysctl: handle overflow in proc_get_long

2019-02-10 Thread Christian Brauner
proc_get_long() is a funny function. It uses simple_strtoul() and for a
good reason. proc_get_long() wants to always succeed the parse and return
the maybe incorrect value and the trailing characters to check against a
pre-defined list of acceptable trailing values.
However, simple_strtoul() explicitly ignores overflows which can cause
funny things like the following to happen:

echo 18446744073709551616 > /proc/sys/fs/file-max
cat /proc/sys/fs/file-max
0

(Which will cause your system to silently die behind your back.)

On the other hand kstrtoul() does do overflow detection but does not return
the trailing characters, and also fails the parse when anything other than
'\n' is a trailing character whereas proc_get_long() wants to be more
lenient.

Now, before adding another kstrtoul() function let's simply add a static
parse strtoul_lenient() which:
- fails on overflow with -ERANGE
- returns the trailing characters to the caller

The reason why we should fail on ERANGE is that we already do a partial
fail on overflow right now. Namely, when the TMPBUFLEN is exceeded. So we
already reject values such as 184467440737095516160 (21 chars) but accept
values such as 18446744073709551616 (20 chars) but both are overflows. So
we should just always reject 64bit overflows and not special-case this
based on the number of chars.

Acked-by: Kees Cook 
Signed-off-by: Christian Brauner 
---
/* Changelog */
v3:
- (Kees) s/#include <../lib/kstrtox.h>/#include "../lib/kstrtox.h"/g
- (Kees) document strtoul_lenient()

v2:
- s/sysctl_cap_erange/sysctl_lenient/g
- consistenly fail on overflow

v1:
- s/sysctl_strtoul_lenient/strtoul_cap_erange/g
- (Al) remove bool overflow return argument from strtoul_cap_erange
- (Al) return ULONG_MAX on ERANGE from strtoul_cap_erange
- (Dominik) fix spelling in commit message
---
 kernel/sysctl.c | 40 +++-
 1 file changed, 39 insertions(+), 1 deletion(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index ba4d9e85feb8..70581ade3555 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -67,6 +67,8 @@
 #include 
 #include 
 
+#include "../lib/kstrtox.h"
+
 #include 
 #include 
 
@@ -2092,6 +2094,41 @@ static void proc_skip_char(char **buf, size_t *size, 
const char v)
}
 }
 
+/**
+ * strtoul_lenient - parse an ASCII formatted integer from a buffer and only
+ *   fail on overflow
+ *
+ * @cp: kernel buffer containing the string to parse
+ * @endp: pointer to store the trailing characters
+ * @base: the base to use
+ * @res: where the parsed integer will be stored
+ *
+ * In case of success 0 is returned and @res will contain the parsed integer,
+ * @endp will hold any trailing characters.
+ * This function will fail the parse on overflow. If there wasn't an overflow
+ * the function will defer the decision what characters count as invalid to the
+ * caller.
+ */
+static int strtoul_lenient(const char *cp, char **endp, unsigned int base,
+  unsigned long *res)
+{
+   unsigned long long result;
+   unsigned int rv;
+
+   cp = _parse_integer_fixup_radix(cp, &base);
+   rv = _parse_integer(cp, base, &result);
+   if ((rv & KSTRTOX_OVERFLOW) || (result != (unsigned long)result))
+   return -ERANGE;
+
+   cp += rv;
+
+   if (endp)
+   *endp = (char *)cp;
+
+   *res = (unsigned long)result;
+   return 0;
+}
+
 #define TMPBUFLEN 22
 /**
  * proc_get_long - reads an ASCII formatted integer from a user buffer
@@ -2135,7 +2172,8 @@ static int proc_get_long(char **buf, size_t *size,
if (!isdigit(*p))
return -EINVAL;
 
-   *val = simple_strtoul(p, &p, 0);
+   if (strtoul_lenient(p, &p, 0, val))
+   return -EINVAL;
 
len = p - tmp;
 
-- 
2.20.1



[RFC PATCH v4 3/3] sysctl: return -EINVAL if val violates minmax

2019-02-10 Thread Christian Brauner
Currently when userspace gives us a values that overflow e.g. file-max and
other callers of __do_proc_doulongvec_minmax() we simply
ignore the new value and leave the current value untouched. This can be
problematic as it gives the illusion that the limit has indeed be bumped
when in fact it failed.
This commit makes sure to return EINVAL when an overflow is detected.
Please note that this is a userspace facing change.

Signed-off-by: Christian Brauner 
---
/* Changelog */
v4:
- patch introduced

v1-v3:
- patch not present
---
 kernel/sysctl.c | 6 --
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index c4a44b7ccb8a..516bc8a2812d 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -2846,8 +2846,10 @@ static int __do_proc_doulongvec_minmax(void *data, 
struct ctl_table *table, int
if (neg)
continue;
val = convmul * val / convdiv;
-   if ((min && val < *min) || (max && val > *max))
-   continue;
+   if ((min && val < *min) || (max && val > *max)) {
+   err = -EINVAL;
+   break;
+   }
*i = val;
} else {
val = convdiv * (*i) / convmul;
-- 
2.20.1



[PATCH v4 2/3] sysctl: handle overflow for file-max

2019-02-10 Thread Christian Brauner
Currently, when writing

echo 18446744073709551616 > /proc/sys/fs/file-max

/proc/sys/fs/file-max will overflow and be set to 0. That quickly
crashes the system.
This commit sets the max and min value for file-max. The max value is set
to long int. Any higher value cannot currently be used as the percpu
counters are long ints and not unsigned integers.

Note that the file-max value is ultimately parsed via
__do_proc_doulongvec_minmax(). This function does not report error when min
or max are exceeded. Which means if a value largen that long int is written
userspace will not receive an error instead the old value will be kept.
There is an argument to be made that this should be changed and
__do_proc_doulongvec_minmax() should return an error when a dedicated min
or max value are exceeded. However this has the potential to break
userspace so let's defer this to an RFC patch.

Cc: Dominik Brodowski 
Signed-off-by: Christian Brauner 
Acked-by: Kees Cook 
---
v4:
- unchanged
  The prior version of the patch contained a generic change affecting all
  callers of __do_proc_doulongvec_minmax(). This part was split out into a
  separate RFC patch as it nees a proper discussion and consideration
  whether this would break userspace.

v3:
- unchanged

v1:
- consistenly fail on overflow

v1:
- if max value is < than ULONG_MAX use max as upper bound
- (Dominik) remove double "the" from commit message
---
 kernel/sysctl.c | 3 +++
 1 file changed, 3 insertions(+)

diff --git a/kernel/sysctl.c b/kernel/sysctl.c
index 70581ade3555..c4a44b7ccb8a 100644
--- a/kernel/sysctl.c
+++ b/kernel/sysctl.c
@@ -129,6 +129,7 @@ static int __maybe_unused one = 1;
 static int __maybe_unused two = 2;
 static int __maybe_unused four = 4;
 static unsigned long one_ul = 1;
+static unsigned long long_max = LONG_MAX;
 static int one_hundred = 100;
 static int one_thousand = 1000;
 #ifdef CONFIG_PRINTK
@@ -1724,6 +1725,8 @@ static struct ctl_table fs_table[] = {
.maxlen = sizeof(files_stat.max_files),
.mode   = 0644,
.proc_handler   = proc_doulongvec_minmax,
+   .extra1 = &zero,
+   .extra2 = &long_max,
},
{
.procname   = "nr_open",
-- 
2.20.1



linux-next: Fixes tag needs some work in the driver-core tree

2019-02-10 Thread Stephen Rothwell
Hi Greg,

In commit

  344c0152d878 ("selftests: firmware: fix verify_reqs() return value")

Fixes tag

  Fixes: a6a9be9270c87 ("selftests: firmware: return Kselftest Skip code for 
for skipped tests")

has these problem(s):

  - Subject does not match target commit subject

-- 
Cheers,
Stephen Rothwell


pgpAhjQ3w3w6B.pgp
Description: OpenPGP digital signature


Re: [PATCH 1/5] perf/arm-cci: Fix CPU hotplug race avoidance

2019-02-10 Thread Thomas Gleixner
On Mon, 4 Feb 2019, Robin Murphy wrote:
> +
> + cpus_read_lock();
> + cci_pmu->cpu = smp_processor_id();

That wants to be raw_smp_processor_id() because this is preemptible
context and debug_smp_processor_id() will complain. 

Thanks,

tglx


Re: [PATCH 3/5] perf/arm-ccn: Fix CPU hotplug race avoidance

2019-02-10 Thread Thomas Gleixner
On Mon, 4 Feb 2019, Robin Murphy wrote:
>   /* Pick one CPU which we will use to collect data from CCN... */
> - cpumask_set_cpu(get_cpu(), &ccn->dt.cpu);
> + cpus_read_lock();
> + ccn->dt.cpu = smp_processor_id();

Again raw_smp_processor_id()

Thanks,

tglx


Re: [PATCH net-next v2 00/16] net: Remove switchdev_ops

2019-02-10 Thread Florian Fainelli
Le 2/10/19 à 9:50 AM, Florian Fainelli a écrit :
> Hi all,
> 
> This patch series finishes by the removal of switchdev_ops. To get there
> we need to do a few things:
> 
> - get rid of the one and only call to switchdev_port_attr_get() which is
>   used to fetch the device's bridge port flags capabilities, instead we
>   can just check what flags are being programmed during the prepare
>   phase
> 
> - once we get rid of getting switchdev port attributes we convert the
>   setting of such attributes using a blocking notifier
> 
> And then remove switchdev_ops completely.
> 
> Please review and let me know what you think!

I am going to submit a v3 which moves the port_attr_{get,set} to a
switchdev notifier, but does not yet get rid of
switchdev_port_attr_get() entirely since there is not a clear path yet
to split the setting between non-sleeping and sleeping context.

> 
> Changes in v2:
> - fixed bisectability issues in patch #15
> - added Acked-by from Jiri where necessary
> - fixed a few minor issues according to Jiri's feedback:
>   - rename port_attr_event -> port_attr_set_event
>   - moved SWITCHDEV_PORT_ATTR_SET closer to other blocking events
> 
> Florian Fainelli (16):
>   Documentation: networking: switchdev: Update port parent ID section
>   mlxsw: spectrum: Check bridge flags during prepare phase
>   staging: fsl-dpaa2: ethsw: Check bridge port flags during set
>   net: dsa: Add setter for SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS
>   rocker: Check bridge flags during prepare phase
>   net: bridge: Stop calling switchdev_port_attr_get()
>   net: Remove SWITCHDEV_ATTR_ID_PORT_BRIDGE_FLAGS_SUPPORT
>   net: Get rid of switchdev_port_attr_get()
>   switchdev: Add SWITCHDEV_PORT_ATTR_SET
>   rocker: Handle SWITCHDEV_PORT_ATTR_SET
>   net: dsa: Handle SWITCHDEV_PORT_ATTR_SET
>   mlxsw: spectrum_switchdev: Handle SWITCHDEV_PORT_ATTR_SET
>   net: mscc: ocelot: Handle SWITCHDEV_PORT_ATTR_SET
>   staging: fsl-dpaa2: ethsw: Handle SWITCHDEV_PORT_ATTR_SET
>   net: switchdev: Replace port attr set SDO with a notification
>   net: Remove switchdev_ops
> 
>  Documentation/networking/switchdev.txt| 15 ++-
>  .../net/ethernet/mellanox/mlxsw/spectrum.c| 12 ---
>  .../net/ethernet/mellanox/mlxsw/spectrum.h|  2 -
>  .../mellanox/mlxsw/spectrum_switchdev.c   | 69 --
>  drivers/net/ethernet/mscc/ocelot.c| 21 +++-
>  drivers/net/ethernet/rocker/rocker_main.c | 95 ---
>  drivers/staging/fsl-dpaa2/ethsw/ethsw.c   | 48 --
>  include/linux/netdevice.h |  3 -
>  include/net/switchdev.h   | 36 ++-
>  net/bridge/br_switchdev.c | 20 +---
>  net/dsa/dsa_priv.h|  3 +
>  net/dsa/port.c| 10 ++
>  net/dsa/slave.c   | 40 
>  net/switchdev/switchdev.c | 92 +-
>  14 files changed, 170 insertions(+), 296 deletions(-)
> 


-- 
Florian


[PATCH v1 1/1] dt-binding: iio: remove rst node from NPCM ADC document

2019-02-10 Thread Tomer Maimon
Remove NPCM7xx rst node for preparing the NPCM ADC
document to describe ADC reset binding.

Signed-off-by: Tomer Maimon 
---
 .../devicetree/bindings/iio/adc/nuvoton,npcm-adc.txt  | 11 ---
 1 file changed, 11 deletions(-)

diff --git a/Documentation/devicetree/bindings/iio/adc/nuvoton,npcm-adc.txt 
b/Documentation/devicetree/bindings/iio/adc/nuvoton,npcm-adc.txt
index 1b8132cd9060..eb939fe77836 100644
--- a/Documentation/devicetree/bindings/iio/adc/nuvoton,npcm-adc.txt
+++ b/Documentation/devicetree/bindings/iio/adc/nuvoton,npcm-adc.txt
@@ -14,11 +14,6 @@ Optional properties:
   vref-supply is not added the ADC will use internal 
voltage
   reference.
 
-Required Node in the NPCM7xx BMC:
-An additional register is present in the NPCM7xx SOC which is
-assumed to be in the same device tree, with and marked as
-compatible with "nuvoton,npcm750-rst".
-
 Example:
 
 adc: adc@f000c000 {
@@ -27,9 +22,3 @@ adc: adc@f000c000 {
interrupts = ;
clocks = <&clk NPCM7XX_CLK_ADC>;
 };
-
-rst: rst@f0801000 {
-   compatible = "nuvoton,npcm750-rst", "syscon",
-   "simple-mfd";
-   reg = <0xf0801000 0x6C>;
-};
-- 
2.14.1



May God bless you

2019-02-10 Thread Mrs. KATHLEEN JACOB


Dear Friend,

I am Mrs.KATHLEEN JACOB. an aging widow suffering from Cancer illness.I have 
some funds Which I have inherited from my late husband, the sum of  ($5.5 
Million Dollars)  And I needed a very honest and
sincere Individual or co-operate organization that will use the fund for work 
of humanity, I found your email address from the Human resources data base and 
decided to contact you. Please if you would be
able to use the funds for the work of humanity as I have stated here in order 
to fulfill my late husband wishes please, kindly reply me back immediately 
through
my private email address (mrskathleenjaco...@yahoo.com )  for more details.

Yours in Christ
Mrs.KATHLEEN JACOB


Re: [PATCH net-next v2 00/16] net: Remove switchdev_ops

2019-02-10 Thread David Miller
From: Florian Fainelli 
Date: Sun, 10 Feb 2019 12:44:47 -0800

> I am going to submit a v3 which moves the port_attr_{get,set} to a
> switchdev notifier, but does not yet get rid of
> switchdev_port_attr_get() entirely since there is not a clear path yet
> to split the setting between non-sleeping and sleeping context.

Ok.


  1   2   3   4   >