[PATCH] fs: don't flush pagecache when expanding block device
When changing the size of a block device, its all caches are freed. It's necessary on shrinking to prevent spurious I/Os to the disappeared region. However, on expanding, such kind of I/Os doesn't happen. Similar things can be considered for btrfs filesystem resize and resize2fs, but they are designed not to cache drops when expanding. Therefore this patch removes unnecessary cache drop. Signed-off-by: Shunki Fujita --- fs/block_dev.c | 9 - 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/fs/block_dev.c b/fs/block_dev.c index fe09ef9..243f4002 100644 --- a/fs/block_dev.c +++ b/fs/block_dev.c @@ -1337,7 +1337,14 @@ void check_disk_size_change(struct gendisk *disk, struct block_device *bdev) "%s: detected capacity change from %lld to %lld\n", disk->disk_name, bdev_size, disk_size); i_size_write(bdev->bd_inode, disk_size); - flush_disk(bdev, false); + if (bdev_size > disk_size) { + flush_disk(bdev, false); + } else { + if (!bdev->bd_disk) + return; + if (disk_part_scan_enabled(bdev->bd_disk)) + bdev->bd_invalidated = 1; + } } } EXPORT_SYMBOL(check_disk_size_change); -- 2.7.4
Re: linux-next: manual merge of the net-next tree with the rdma-fixes tree
On Thu, 2018-03-15 at 21:18 -0400, Doug Ledford wrote: > On Fri, 2018-03-16 at 11:56 +1100, Stephen Rothwell wrote: > > Hi all, > > > > Today's linux-next merge of the net-next tree got a conflict in: > > > > drivers/infiniband/hw/mlx5/main.c > > > > between commit: > > > > 42cea83f9524 ("IB/mlx5: Fix cleanup order on unload") > > > > from the rdma-fixes tree and commit: > > > > b5ca15ad7e61 ("IB/mlx5: Add proper representors support") > > > > from the net-next tree. > > We are aware of the merge conflict. This is a result of the fact > that > code had been submitted to the for-next area (the representors > support) > and after that an issue was found by the syzkaller bot that deserved > rc > fix status and which conflicted. The fixup you list below is > insufficient to fix the merge conflict. The full fixup can be found > in > the rdma tree from where I merged the for-rc branch into the for-next > branch and created a complete fixup of the merge conflict. The > problem > is that one patch change the device init stage flow, while the other > patch duplicates the normal device init stage flow to the representor > device stage flow. To resolve the fix, you not only have to resolve > the > contextual diffs, but you have to duplicate the changes to the normal > device stage flow into the representor device stage flow. It is very > far from a trivial merge. We were planning on talking to Dave about > this issue tomorrow, but you beat us to raising the issue ;-). > > Here's the commit (from the rdma git repo) with the proper merge fix > (although it also has other minor merge stuff that needs to be > ignored): > > 2d873449a202 (Merge branch 'k.o/wip/dl-for-rc' into k.o/wip/dl-for- > next) > Dave, Will you be able to take care of this? you will see this once the rdma fix gets submitted to linus and you back merge rc into net-next. after that we need to verify that net-next merges cleanly with rdma- next (from mlx5 point of view) to make sure we won't run into trouble in the next merge window. I would like also to avoid such conflicts in the future, since now rdma-rc is active we are more likely to run into such issues, to solve this maybe the right way to go is to avoid touching rdma/netdev from mlx5 shared code pull requests and keep mlx5 core stuff clean, the idea is to run a pure mlx5 core incremental branch in parallel to netdev and rdma, this branch will include all pure updates to mlx5 core, mlx5 netdev or rdma patches will be sent to netdev and rdma branches separately they can be based on latest mlx5 core branch or not. This way you don't need to pull in rdma stuff from shared code and Doug/Jason won't need to pull in netdev stuff. it is more work for me, but for you and rdma, you will see only clean mlx5 core stuff from shared code, the stack part (netdev or rdma) will go only to the specific maintainer respectively. What do you think ? I can do a sample run in one of my next pull requests and see how it goes. Thanks, Saeed.
RE: [Blackfin removal] [PATCH 01/28] Blackfin arch: Remove Blackfin CPU arch general support
> -Original Message- > From: arndbergm...@gmail.com [mailto:arndbergm...@gmail.com] On > Behalf Of Arnd Bergmann > Sent: 2018年3月15日 22:46 > To: Arnd Bergmann ; linux-arch ; > Linux Kernel Mailing List ; Lennox Wu > ; Guenter Roeck ; Al Viro > ; Jonas Bonn ; Stefan > Kristiansson ; Stafford Horne > ; David Howells ; Peter Zijlstra > ; Wu, Aaron > Subject: Re: [Blackfin removal] [PATCH 01/28] Blackfin arch: Remove Blackfin > CPU arch general support > > > Signed-off-by: Aaron Wu > > > > Remove Blackfin CPU arch general support > > Hi Aaron, > > thanks a lot for your series. As you know, I've had almost the same patches in > my tree already, but now I've cross-checked the two versions, and found small > omissions or bugs in both. I ended up staying with my version, as that was > already reviewed by a number of people, and it had the conflicts with the > other > arch removal resolved, but I've folded in everything that your version had > that I > was missing, see below for the diff between my original version and the new > one. > > I've also added an 'Acked-by: Aaron Wu ' > to each patch that we both had. > > I hope that all works for you. > >Arnd > Hi Arnd, Sure, this works perfect for me. May patches are there as additional reference, exactly what we discussed earlier. Thanks very much for help handing/merging this. By the way, the patches email get bounced from vger, I may give it another try on reset of them except this arch one so more people can help to review/comment rest of them, mostly drivers. Best Regards, Aaron > --- > Documentation/driver-api/usb/writing_musb_glue_layer.rst |3 > drivers/misc/echo/echo.c | 73 > drivers/misc/echo/fir.h | 50 > drivers/usb/gadget/function/f_uac1_legacy.c |2 > drivers/usb/gadget/function/u_uac1_legacy.c |2 > drivers/usb/gadget/function/u_uac1_legacy.h |2 > drivers/usb/gadget/legacy/audio.c|2 > drivers/usb/host/isp1362.h |4 > drivers/usb/musb/musb_core.c |2 > drivers/usb/musb/musb_core.h | 13 -- > include/linux/cpuhotplug.h |1 > include/linux/fb.h |3 > 14 files changed, 3 insertions(+), 248 deletions(-) > > diff --git a/drivers/misc/echo/echo.c b/drivers/misc/echo/echo.c index > 9597e9523cac..8a5adc0d2e88 100644 > --- a/drivers/misc/echo/echo.c > +++ b/drivers/misc/echo/echo.c > @@ -115,78 +115,6 @@ > > /* adapting coeffs using the traditional stochastic descent (N)LMS algorithm > */ > > -#ifdef __bfin__ > -static inline void lms_adapt_bg(struct oslec_state *ec, int clean, int > shift) -{ > - int i; > - int offset1; > - int offset2; > - int factor; > - int exp; > - int16_t *phist; > - int n; > - > - if (shift > 0) > - factor = clean << shift; > - else > - factor = clean >> -shift; > - > - /* Update the FIR taps */ > - > - offset2 = ec->curr_pos; > - offset1 = ec->taps - offset2; > - phist = &ec->fir_state_bg.history[offset2]; > - > - /* st: and en: help us locate the assembler in echo.s */ > - > - /* asm("st:"); */ > - n = ec->taps; > - for (i = 0; i < n; i++) { > - exp = *phist++ * factor; > - ec->fir_taps16[1][i] += (int16_t) ((exp + (1 << 14)) >> 15); > - } > - /* asm("en:"); */ > - > - /* Note the asm for the inner loop above generated by Blackfin gcc > -4.1.1 is pretty good (note even parallel instructions used): > - > -R0 = W [P0++] (X); > -R0 *= R2; > -R0 = R0 + R3 (NS) || > -R1 = W [P1] (X) || > -nop; > -R0 >>>= 15; > -R0 = R0 + R1; > -W [P1++] = R0; > - > -A block based update algorithm would be much faster but the > -above can't be improved on much. Every instruction saved in > -the loop above is 2 MIPs/ch! The for loop above is where the > -Blackfin spends most of it's time - about 17 MIPs/ch measured > -with speedtest.c with 256 taps (32ms). Write-back and > -Write-through cache gave about the same performance. > - */ > -} > - > -/* > - IDEAS for further optimisation of lms_adapt_bg(): > - > - 1/ The rounding is quite costly. Could we keep as 32 bit coeffs > - then make filter pluck the MS 16-bits of the coeffs when filtering? > - However this would lower potential optimisation of filter, as I > - think the dual-MAC architecture requires packed 16 bit coeffs. > - > - 2/ Block based update would be more efficient, as per comments above, > - could use dual MAC architecture. > - > - 3/ Look for same sample Blackfin LMS code, see if we can get dual-MAC > - packing. > - > - 4/ Execute the whole e/c in a block of say 20ms rather than sample > - by sample. Processing a few samples every ms is inefficient. > -*/ > - > -#else > static inline void lms_adapt_bg(struct oslec_state *ec,
linux-next: Tree for Mar 16
Hi all, Changes since 20180315: The asm-generic tree gained a build failure for which I applied a patch. The net-next tree gained a conflict against the rdma-fixes tree. The akpm-current tree gained a conflict against Linus' tree. Non-merge commits (relative to Linus' tree): 7732 10128 files changed, 346647 insertions(+), 716295 deletions(-) I have created today's linux-next tree at git://git.kernel.org/pub/scm/linux/kernel/git/next/linux-next.git (patches at http://www.kernel.org/pub/linux/kernel/next/ ). If you are tracking the linux-next tree using git, you should not use "git pull" to do so as that will try to merge the new linux-next release with the old one. You should use "git fetch" and checkout or reset to the new master. You can see which trees have been included by looking in the Next/Trees file in the source. There are also quilt-import.log and merge.log files in the Next directory. Between each merge, the tree was built with a ppc64_defconfig for powerpc, an allmodconfig for x86_64, a multi_v7_defconfig for arm and a native build of tools/perf. After the final fixups (if any), I do an x86_64 modules_install followed by builds for x86_64 allnoconfig, powerpc allnoconfig (32 and 64 bit), ppc44x_defconfig, allyesconfig and pseries_le_defconfig and i386, sparc and sparc64 defconfig. And finally, a simple boot test of the powerpc pseries_le_defconfig kernel in qemu (with and without kvm enabled). Below is a summary of the state of the merge. I am currently merging 261 trees (counting Linus' and 44 trees of bug fix patches pending for the current merge release). Stats about the size of the tree over time can be seen at http://neuling.org/linux-next-size.html . Status of my local build tests will be at http://kisskb.ellerman.id.au/linux-next . If maintainers want to give advice about cross compilers/configs that work, we are always open to add more builds. Thanks to Randy Dunlap for doing many randconfig builds. And to Paul Gortmaker for triage and bug fixes. -- Cheers, Stephen Rothwell $ git checkout master $ git reset --hard stable Merging origin/master (e2c15aff5f35 Merge tag 'sound-4.16-rc6' of git://git.kernel.org/pub/scm/linux/kernel/git/tiwai/sound) Merging fixes/master (7928b2cbe55b Linux 4.16-rc1) Merging kbuild-current/fixes (55fe6da9efba kbuild: Handle builtin dtb file names containing hyphens) Merging arc-current/for-curr (661e50bc8532 Linux 4.16-rc4) Merging arm-current/fixes (091f02483df7 ARM: net: bpf: clarify tail_call index) Merging arm64-fixes/for-next/fixes (e21da1c99200 arm64: Relax ARM_SMCCC_ARCH_WORKAROUND_1 discovery) Merging m68k-current/for-linus (2334b1ac1235 MAINTAINERS: Add NuBus subsystem entry) Merging metag-fixes/fixes (b884a190afce metag/usercopy: Add missing fixups) Merging powerpc-fixes/fixes (e4b79900222b powerpc/64s: Fix NULL AT_BASE_PLATFORM when using DT CPU features) Merging sparc/master (aebb48f5e465 sparc64: fix typo in CONFIG_CRYPTO_DES_SPARC64 => CONFIG_CRYPTO_CAMELLIA_SPARC64) Merging fscrypt-current/for-stable (ae64f9bd1d36 Linux 4.15-rc2) Merging net/master (51d4740f88af net sched actions: return explicit error when tunnel_key mode is not specified) Merging bpf/master (b6b76dd62c56 error-injection: Fix to prohibit jump optimization) Merging ipsec/master (0dcd7876029b net: xfrm: use preempt-safe this_cpu_read() in ipcomp_alloc_tfms()) Merging netfilter/master (f89782c2d131 qed: Use after free in qed_rdma_free()) Merging ipvs/master (f7fb77fc1235 netfilter: nft_compat: check extension hook mask only if set) Merging wireless-drivers/master (87de1201ddaa Merge branch 'erspan-fixes') Merging mac80211/master (a78872363614 cfg80211: add missing dependency to CFG80211 suboptions) Merging rdma-fixes/for-rc (bd8602ca42f6 infiniband: bnxt_re: use BIT_ULL() for 64-bit bit masks) Merging sound-current/for-linus (db45dc9540ea Merge tag 'asoc-fix-v4.16-rc5' of https://git.kernel.org/pub/scm/linux/kernel/git/broonie/sound into for-linus) Merging pci-current/for-linus (fc110ebdd014 PCI: dwc: Fix enumeration end when reaching root subordinate) Merging driver-core.current/driver-core-linus (0c8efd610b58 Linux 4.16-rc5) Merging tty.current/tty-linus (5d7f77ec72d1 serial: imx: fix bogus dev_err) Merging usb.current/usb-linus (94e46a4f2d5e usb: musb: Fix external abort in musb_remove on omap2430) Merging usb-gadget-fixes/fixes (c6ba5084ce0d usb: gadget: udc: renesas_usb3: add binging for r8a77965) Merging usb-serial-fixes/usb-linus (7920a87c40db USB: serial: cp210x: add ELDAT Easywave RX09 id) Merging usb-chipidea-fixes/ci-for-usb-stable (964728f9f407 USB: chipidea: msm: fix ulpi-node lookup) Merging phy/fixes (59fba0869aca phy: qcom-ufs: add MODULE_LICENSE tag) Merging staging.current/staging-linus (740a5759bf22 staging: android: ashmem: Fix possible deadlock in ashmem_ioctl) Mergin
Re: [PATCH][RFC] kernel.h: provide array iterator
Le 16.03.2018 05:21, Kees Cook a écrit : On Thu, Mar 15, 2018 at 3:00 AM, Kieran Bingham wrote: Simplify array iteration with a helper to iterate each entry in an array. Utilise the existing ARRAY_SIZE macro to identify the length of the array and pointer arithmetic to process each item as a for loop. Signed-off-by: Kieran Bingham --- include/linux/kernel.h | 10 ++ 1 file changed, 10 insertions(+) The use of static arrays to store data is a common use case throughout the kernel. Along with that is the obvious need to iterate that data. In fact there are just shy of 5000 instances of iterating a static array: git grep "for .*ARRAY_SIZE" | wc -l 4943 I suspect the main question is "Does this macro make the code easier to read?" I think it does, and we have other kinds of iterators like this in the kernel already. Would it be worth building a Coccinelle script to do the 5000 replacements? Coccinelle should be able to replace the for loop header. Coccinelle could create the local macro. Coccinelle might not put the definition in exactly the right place. Before the function of the first use would be possible, or before any function. I don't think that Coccinelle could figure out how to split one loop into two as done here, unless that specific pattern is very common. I guess that the split is to add the flush_workqueue, and is not the main goal? julia -Kees When working on the UVC driver - I found that I needed to split one such iteration into two parts, and at the same time felt that this could be refactored to be cleaner / easier to read. I do however worry that this simple short patch might not be desired or could also be heavily bikeshedded due to it's potential wide spread use (though perhaps that would be a good thing to have more users) ... but here it is, along with an example usage below which is part of a separate series. The aim is to simplify iteration on static arrays, in the same way that we have iterators for lists. The use of the ARRAY_SIZE macro, provides all the protections given by "__must_be_array(arr)" to this macro too. Regards Kieran = Example Usage from a pending UVC development: +#define for_each_uvc_urb(uvc_urb, uvc_streaming) \ + for_each_array_element(uvc_urb, uvc_streaming->uvc_urb) /* * Uninitialize isochronous/bulk URBs and free transfer buffers. */ static void uvc_uninit_video(struct uvc_streaming *stream, int free_buffers) { - struct urb *urb; - unsigned int i; + struct uvc_urb *uvc_urb; uvc_video_stats_stop(stream); - for (i = 0; i < UVC_URBS; ++i) { - struct uvc_urb *uvc_urb = &stream->uvc_urb[i]; + for_each_uvc_urb(uvc_urb, stream) + usb_kill_urb(uvc_urb->urb); - urb = uvc_urb->urb; - if (urb == NULL) - continue; + flush_workqueue(stream->async_wq); - usb_kill_urb(urb); - usb_free_urb(urb); + for_each_uvc_urb(uvc_urb, stream) { + usb_free_urb(uvc_urb->urb); uvc_urb->urb = NULL; } if (free_buffers) uvc_free_urb_buffers(stream); } = diff --git a/include/linux/kernel.h b/include/linux/kernel.h index ce51455e2adf..95d7dae248b7 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -70,6 +70,16 @@ */ #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + __must_be_array(arr)) +/** + * for_each_array_element - Iterate all items in an array + * @elem: pointer of array type for iteration cursor + * @array: array to be iterated + */ +#define for_each_array_element(elem, array) \ + for (elem = &(array)[0]; \ +elem < &(array)[ARRAY_SIZE(array)]; \ +++elem) + #define u64_to_user_ptr(x) ( \ { \ typecheck(u64, x); \ -- 2.7.4
Re: [PATCH] ARM: dts: sun7i: Add pinmux settings for LCD0 RGB888 output.
Hi Giulio, On Thu, Mar 15, 2018 at 02:43:30PM +0100, Giulio Benetti wrote: > The A20 supports RGB888 with H/V sync from LCD0. Add a pinmux setting > for the needed pins. > > Signed-off-by: Giulio Benetti Like we discussed last time, we only merge this kind of patches if there's an immediate user. Maxime -- Maxime Ripard, Bootlin (formerly Free Electrons) Embedded Linux and Kernel engineering https://bootlin.com signature.asc Description: PGP signature
Re: [PATCH net-next] tuntap: XDP_TX can use native XDP
On 2018年03月15日 21:32, Michael S. Tsirkin wrote: On Thu, Mar 15, 2018 at 04:39:25PM +0800, Jason Wang wrote: On 2018年03月14日 11:37, Michael S. Tsirkin wrote: return NULL; case XDP_TX: - xdp_xmit = true; - /* fall through */ + get_page(alloc_frag->page); + alloc_frag->offset += buflen; + if (tun_xdp_xmit(tun->dev, &xdp)) + goto err_redirect; + tun_xdp_flush(tun->dev); Why do we have to flush here though? It might be a good idea to document the reason in a code comment. ndo_xdp_xmit() does not touch doorbell, so we need a ndo_xdp_flush() here. It's the assumption of XDP API I think, so not sure it's worth to mention it here. Thanks Can't one flush we called after multiple xmit calls? We can and could be another patch on top. But I want to unify it with the batching of XDP_REDIRECT by e.g let vhost submit more than one packets through msg.control in sendmsg(). Thanks
Re: [PATCH RFC 2/2] virtio_ring: support packed ring
On 2018年03月16日 14:10, Tiwei Bie wrote: On Fri, Mar 16, 2018 at 12:03:25PM +0800, Jason Wang wrote: On 2018年02月23日 19:18, Tiwei Bie wrote: Signed-off-by: Tiwei Bie --- drivers/virtio/virtio_ring.c | 699 +-- include/linux/virtio_ring.h | 8 +- 2 files changed, 618 insertions(+), 89 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index eb30f3e09a47..393778a2f809 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -58,14 +58,14 @@ struct vring_desc_state { void *data; /* Data for callback. */ - struct vring_desc *indir_desc; /* Indirect descriptor, if any. */ + void *indir_desc; /* Indirect descriptor, if any. */ + int num;/* Descriptor list length. */ }; struct vring_virtqueue { struct virtqueue vq; - /* Actual memory layout for this queue */ - struct vring vring; + bool packed; /* Can we use weak barriers? */ bool weak_barriers; @@ -87,11 +87,28 @@ struct vring_virtqueue { /* Last used index we've seen. */ u16 last_used_idx; - /* Last written value to avail->flags */ - u16 avail_flags_shadow; - - /* Last written value to avail->idx in guest byte order */ - u16 avail_idx_shadow; + union { + /* Available for split ring */ + struct { + /* Actual memory layout for this queue */ + struct vring vring; + + /* Last written value to avail->flags */ + u16 avail_flags_shadow; + + /* Last written value to avail->idx in +* guest byte order */ + u16 avail_idx_shadow; + }; + + /* Available for packed ring */ + struct { + /* Actual memory layout for this queue */ + struct vring_packed vring_packed; + u8 wrap_counter : 1; + bool chaining; + }; + }; /* How to notify other side. FIXME: commonalize hcalls! */ bool (*notify)(struct virtqueue *vq); @@ -201,26 +218,37 @@ static dma_addr_t vring_map_single(const struct vring_virtqueue *vq, cpu_addr, size, direction); } -static void vring_unmap_one(const struct vring_virtqueue *vq, - struct vring_desc *desc) +static void vring_unmap_one(const struct vring_virtqueue *vq, void *_desc) { Let's split the helpers to packed/split version like other helpers? (Consider the caller has already known the type of vq). Okay. [...] + desc[i].flags = flags; + + desc[i].addr = cpu_to_virtio64(_vq->vdev, addr); + desc[i].len = cpu_to_virtio32(_vq->vdev, sg->length); + desc[i].id = cpu_to_virtio32(_vq->vdev, head); If it's a part of chain, we only need to do this for last buffer I think. I'm not sure I've got your point about the "last buffer". But, yes, id just needs to be set for the last desc. Right, I think I meant "last descriptor" :) + prev = i; + i++; It looks to me prev is always i - 1? No. prev will be (vq->vring_packed.num - 1) when i becomes 0. Right, so prev = i ? i - 1 : vq->vring_packed.num - 1. + if (!indirect && i >= vq->vring_packed.num) { + i = 0; + vq->wrap_counter ^= 1; + } + } + } + for (; n < (out_sgs + in_sgs); n++) { + for (sg = sgs[n]; sg; sg = sg_next(sg)) { + dma_addr_t addr = vring_map_one_sg(vq, sg, DMA_FROM_DEVICE); + if (vring_mapping_error(vq, addr)) + goto unmap_release; + + flags = cpu_to_virtio16(_vq->vdev, VRING_DESC_F_NEXT | + VRING_DESC_F_WRITE | + VRING_DESC_F_AVAIL(vq->wrap_counter) | + VRING_DESC_F_USED(!vq->wrap_counter)); + if (!indirect && i == head) + head_flags = flags; + else + desc[i].flags = flags; + + desc[i].addr = cpu_to_virtio64(_vq->vdev, addr); + desc[i].len = cpu_to_virtio32(_vq->vdev, sg->length); + desc[i].id = cpu_to_virtio32(_vq->vdev, head); + prev = i; + i++; + if (!indirect && i >= vq->vring_packed.num) { + i = 0; + vq->wrap_counter
Re: [PATCH v10 4/5] iommu/arm-smmu: Add the device_link between masters and smmu
Hi Vivek, On Wed, Mar 14, 2018 at 5:14 PM, Vivek Gautam wrote: > From: Sricharan R > > Finally add the device link between the master device and > smmu, so that the smmu gets runtime enabled/disabled only when the > master needs it. This is done from add_device callback which gets > called once when the master is added to the smmu. > > Signed-off-by: Sricharan R > Signed-off-by: Vivek Gautam > Reviewed-by: Tomasz Figa > --- > > Changes since v9: > - Using device_link_del_dev() to delete the device link, instead of >doing it in two steps - device_link_find() to first find the link, and >then calling device_link_del(). > > drivers/iommu/arm-smmu.c | 24 > 1 file changed, 24 insertions(+) > > diff --git a/drivers/iommu/arm-smmu.c b/drivers/iommu/arm-smmu.c > index 56a04ae80bf3..4cf270ffd449 100644 > --- a/drivers/iommu/arm-smmu.c > +++ b/drivers/iommu/arm-smmu.c > @@ -1460,10 +1460,31 @@ static int arm_smmu_add_device(struct device *dev) > > iommu_device_link(&smmu->iommu, dev); > > + if (pm_runtime_enabled(smmu->dev)) { > + struct device_link *link; > + > + /* > +* Establish the link between smmu and master, so that the > +* smmu gets runtime enabled/disabled as per the master's > +* needs. > +*/ > + link = device_link_add(dev, smmu->dev, DL_FLAG_PM_RUNTIME); > + if (!link) { > + dev_warn(smmu->dev, > +"Unable to add link to the consumer %s\n", > +dev_name(dev)); > + ret = -ENODEV; > + goto out_unlink; > + } > + } If it's an error, we should use dev_err(). Also, as per Robin's comment for v9 could we make it as follows? if (pm_runtime_enabled(smmu->dev) && !device_link_add(dev, smmu->dev, DL_FLAG_PM_RUNTIME)) { dev_err(smmu->dev, "Unable to add link to the consumer %s\n", dev_name(dev)); ret = -ENODEV; goto out_unlink; } Best regards, Tomasz
Re: [PATCH 00/11] kexec_file: Clean up purgatory load
On 03/15/18 at 11:13am, Philipp Rudo wrote: > Hi Dave, > > On Thu, 15 Mar 2018 15:34:22 +0800 > Dave Young wrote: > > > On 03/12/18 at 03:40pm, Dave Young wrote: > > > Hi Philipp, > > > On 03/09/18 at 03:25pm, Philipp Rudo wrote: > > > > Hi Dave, > > > > > > > > On Fri, 9 Mar 2018 13:19:40 +0800 > > > > Dave Young wrote: > > > > > > > > > Hi Philipp, > > > > > On 02/26/18 at 04:16pm, Philipp Rudo wrote: > > > > > > > > > > > > Hi everybody > > > > > > > > > > > > following the discussion with Dave and AKASHI, here are the common > > > > > > code > > > > > > patches extracted from my recent patch set (Add kexec_file_load > > > > > > support to > > > > > > s390) [1]. The patches were extracted to allow upstream integration > > > > > > together > > > > > > with AKASHI's common code patches before the arch code gets > > > > > > adjusted to the > > > > > > new base. > > > > > > > > > > > > The reason for this series is to prepare common code for adding > > > > > > kexec_file_load to s390 as well as cleaning up the mis-use of the > > > > > > sh_offset > > > > > > field during purgatory load. In detail this series contains: > > > > > > > > > > > > Patch #1&2: Minor cleanups/fixes. > > > > > > > > > > > > Patch #3-9: Clean up the purgatory load/relocation code. Especially > > > > > > remove > > > > > > the mis-use of the purgatory_info->sechdrs->sh_offset field, > > > > > > currently > > > > > > holding a pointer into either kexec_purgatory (ro) or purgatory_buf > > > > > > (rw) > > > > > > depending on the section. With these patches the section address > > > > > > will be > > > > > > calculated verbosely and sh_offset will contain the offset of the > > > > > > section > > > > > > in the stripped purgatory binary (purgatory_buf). > > > > > > > > > > > > Patch #10: Allows architectures to set the purgatory load address. > > > > > > This > > > > > > patch is important for s390 as the kernel and purgatory have to be > > > > > > loaded > > > > > > to fixed addresses. In current code this is impossible as the > > > > > > purgatory > > > > > > load is opaque to the architecture. > > > > > > > > > > > > Patch #11: Moves x86 purgatories sha implementation to common lib/ > > > > > > directory to allow reuse in other architectures. > > > > > > > > > > > > The patches apply to v4.16-rc3. There are no changes compared to > > > > > > [1] (all > > > > > > requested changes only affected s390 code). Please note that I had > > > > > > to touch > > > > > > arch code for x86 and power a little. In theory this should not > > > > > > change the > > > > > > behavior but I don't have a way to test it. Cross-compiling with > > > > > > defconfig [2] works fine for both. > > > > > > > > > > > > Thanks > > > > > > Philipp > > > > > > > > > > > > [1] > > > > > > http://lists.infradead.org/pipermail/kexec/2018-February/019926.html > > > > > > [2] On x86 with the orc unwinder and stack validation turned off. > > > > > > objtool > > > > > > SEGFAULTs on s390... > > > > > > > > > > > > Philipp Rudo (11): > > > > > > kexec_file: Silence compile warnings > > > > > > kexec_file: Remove checks in kexec_purgatory_load > > > > > > kexec_file: Make purgatory_info->ehdr const > > > > > > kexec_file: Search symbols in read-only kexec_purgatory > > > > > > kexec_file: Use read-only sections in > > > > > > arch_kexec_apply_relocations* > > > > > > kexec_file: Split up __kexec_load_puragory > > > > > > kexec_file: Simplify kexec_purgatory_setup_sechdrs 1 > > > > > > kexec_file: Simplify kexec_purgatory_setup_sechdrs 2 > > > > > > kexec_file: Remove mis-use of sh_offset field > > > > > > kexec_file: Allow archs to set purgatory load address > > > > > > kexec_file: Move purgatories sha256 to common code > > > > > > > > > > > > arch/powerpc/kernel/kexec_elf_64.c | 9 +- > > > > > > arch/x86/kernel/kexec-bzimage64.c | 8 +- > > > > > > arch/x86/kernel/machine_kexec_64.c | 66 ++--- > > > > > > arch/x86/purgatory/Makefile| 3 + > > > > > > arch/x86/purgatory/purgatory.c | 2 +- > > > > > > include/linux/kexec.h | 38 +-- > > > > > > {arch/x86/purgatory => include/linux}/sha256.h | 10 +- > > > > > > kernel/kexec_file.c| 375 > > > > > > - > > > > > > {arch/x86/purgatory => lib}/sha256.c | 4 +- > > > > > > 9 files changed, 244 insertions(+), 271 deletions(-) > > > > > > rename {arch/x86/purgatory => include/linux}/sha256.h (63%) > > > > > > rename {arch/x86/purgatory => lib}/sha256.c (99%) > > > > > > > > > > > > -- > > > > > > 2.13.5 > > > > > > > > > > > > > > > > I did a test on x86, but it failed: > > > > > [ 15.636489] kexec: Undefined symbol: memcpy > > > > > [ 15.636496] kexec-bzImage64: Loading purgatory failed > > > > > [ 33.603356] kexec: Undefined symbol: memcpy > > > > > [ 33.603362] kexec-b
[PATCH] kernel/cpu: Move cpuhp_is_atomic_state() into #ifdef CONFIG_SMP
Commit 17a2f1ced028 ("cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states") removed the last use of cpuhp_is_atomic_state() in common case, that caused Kernel produced a warning: 'cpuhp_is_ap_state' defined but not used So, Move it into #ifdef CONFIG_SMP Reported-by: Stephen Rothwell Signed-off-by: Dou Liyang --- kernel/cpu.c | 18 +- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/kernel/cpu.c b/kernel/cpu.c index a1860d42aacf..db7ec7572348 100644 --- a/kernel/cpu.c +++ b/kernel/cpu.c @@ -126,15 +126,6 @@ struct cpuhp_step { static DEFINE_MUTEX(cpuhp_state_mutex); static struct cpuhp_step cpuhp_hp_states[]; -static bool cpuhp_is_ap_state(enum cpuhp_state state) -{ - /* -* The extra check for CPUHP_TEARDOWN_CPU is only for documentation -* purposes as that state is handled explicitly in cpu_down. -*/ - return state > CPUHP_BRINGUP_CPU && state != CPUHP_TEARDOWN_CPU; -} - static struct cpuhp_step *cpuhp_get_step(enum cpuhp_state state) { return cpuhp_hp_states + state; @@ -247,6 +238,15 @@ static inline void complete_ap_thread(struct cpuhp_cpu_state *st, bool bringup) complete(done); } +static bool cpuhp_is_ap_state(enum cpuhp_state state) +{ + /* +* The extra check for CPUHP_TEARDOWN_CPU is only for documentation +* purposes as that state is handled explicitly in cpu_down. +*/ + return state > CPUHP_BRINGUP_CPU && state != CPUHP_TEARDOWN_CPU; +} + /* * The former STARTING/DYING states, ran with IRQs disabled and must not fail. */ -- 2.14.3
Re: [PATCHv2 5/5] arm64: allwinner: a64: Add support for TERES-I laptop
Hi, On Thu, Mar 15, 2018 at 04:25:10PM +, Harald Geyer wrote: > The TERES-I is an open hardware laptop built by Olimex using the > Allwinner A64 SoC. > > Add the board specific .dts file, which includes the A64 .dtsi and > enables the peripherals that we support so far. > > Signed-off-by: Harald Geyer Received only patch 4 & 5 in my inbox, receive path was via linux-kernel rather than linux-arm-kernel, but in both archives all patches are seen (though threading seems not right), probably missing patches are due to issue gmail have with LKML, so had to pull the series from patchwork, for the series, Tested-by: afzal mohammed afzal
Re: [RFC v2 03/83] Add super.h.
On Thu, Mar 15, 2018 at 11:17:54PM -0700, Andiry Xu wrote: > On Thu, Mar 15, 2018 at 7:59 PM, Theodore Y. Ts'o wrote: > > On Thu, Mar 15, 2018 at 09:38:29PM +0100, Arnd Bergmann wrote: > >> > >> You could also have a resolution of less than a nanosecond. Note > >> that today, the file time stamps generated by the kernel are in > >> jiffies resolution, so at best one millisecond. However, most modern > >> file systems go with the 64+32 bit timestamps because it's not all > >> that expensive. > > > > It actually depends on the architecture and the accuracy/granularity > > of the timekeeping hardware available to the system, but it's possible > > for the granularity of file time stamps to be up to one nanosecond. > > So you can get results like this: > > > > % stat unix_io.o > > File: unix_io.o > > Size: 55000 Blocks: 112IO Block: 4096 regular file > > Device: fc01h/64513dInode: 19931278Links: 1 > > Access: (0644/-rw-r--r--) Uid: (15806/ tytso) Gid: (15806/ tytso) > > Access: 2018-03-15 18:09:21.679914182 -0400 > > Modify: 2018-03-15 18:09:21.639914089 -0400 > > Change: 2018-03-15 18:09:21.639914089 -0400 > > > > Thanks for all the suggestions. I think I will follow ext4's time > format. 2446 should be far away enough. If you do, try to avoid the encoding problems that ext4 (still) has: Not-fixed-by: a4dad1ae24f8 ("ext4: Fix handling of extended tv_sec") --D > Thanks, > Andiry
[PATCH 6/6] staging: ks7010: Factor out repeated request initialization code.
The code to initialize various different types of request structs is repeated multiple times. Factor this code out into a macro called INIT_REQUEST. Signed-off-by: Quytelda Kahja --- drivers/staging/ks7010/ks_hostif.c | 55 +++--- 1 file changed, 16 insertions(+), 39 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 6fc2c3647908..3e5016aad029 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -40,6 +40,17 @@ static inline unsigned int cnt_smeqbody(struct ks_wlan_private *priv) #define KS_WLAN_MEM_FLAG (GFP_ATOMIC) +#define INIT_REQUEST(pp, priv) +{( + pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); + pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); + pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); + pp->rate_set.size = priv->reg.rate_set.size; + pp->capability = ks_wlan_cap(priv); + memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], + priv->reg.rate_set.size); +)} + static inline u8 get_BYTE(struct ks_wlan_private *priv) { @@ -1412,14 +1423,7 @@ void hostif_ps_adhoc_set_request(struct ks_wlan_private *priv) if (!pp) return; - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); - pp->rate_set.size = priv->reg.rate_set.size; - pp->capability = ks_wlan_cap(priv); - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); + INIT_REQUEST(pp, priv); /* send to device request */ ps_confirm_wait_inc(priv); @@ -1437,16 +1441,9 @@ void hostif_infrastructure_set_request(struct ks_wlan_private *priv) if (!pp) return; - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - - pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); + INIT_REQUEST(pp, priv); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); - pp->capability = ks_wlan_cap(priv); pp->beacon_lost_count = cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); @@ -1486,16 +1483,9 @@ static void hostif_infrastructure_set2_request(struct ks_wlan_private *priv) if (!pp) return; - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - - pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); + INIT_REQUEST(pp, priv); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); - pp->capability = ks_wlan_cap(priv); pp->beacon_lost_count = cpu_to_le16((uint16_t)(priv->reg.beacon_lost_count)); pp->auth_type = cpu_to_le16((uint16_t)(priv->reg.authenticate_type)); @@ -1538,16 +1528,9 @@ void hostif_adhoc_set_request(struct ks_wlan_private *priv) if (!pp) return; - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - pp->channel = cpu_to_le16((uint16_t)(priv->reg.channel)); - pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); + INIT_REQUEST(pp, priv); pp->ssid.size = priv->reg.ssid.size; memcpy(&pp->ssid.body[0], &priv->reg.ssid.body[0], priv->reg.ssid.size); - pp->capability = ks_wlan_cap(priv); /* send to device request */ ps_confirm_wait_inc(priv); @@ -1565,15 +1548,9 @@ void hostif_adhoc_set2_request(struct ks_wlan_private *priv) if (!pp) return; - pp->phy_type = cpu_to_le16((uint16_t)(priv->reg.phy_type)); - pp->cts_mode = cpu_to_le16((uint16_t)(priv->reg.cts_mode)); - pp->scan_type = cpu_to_le16((uint16_t)(priv->reg.scan_type)); - pp->rate_set.size = priv->reg.rate_set.size; - memcpy(&pp->rate_set.body[0], &priv->reg.rate_set.body[0], - priv->reg.rate_set.size); +
[PATCH 5/6] staging: ks7010: Fix line over 80 characters.
There is no reason for comment describing the BSSID check for loop to be spaced so far to the right. Move it above the for loop. Signed-off-by: Quytelda Kahja --- drivers/staging/ks7010/ks_hostif.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 2de4dbbcd9de..6fc2c3647908 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -844,7 +844,8 @@ void hostif_scan_indication(struct ks_wlan_private *priv) ap_info = (struct ap_info_t *)(priv->rxp); if (priv->scan_ind_count) { - for (i = 0; i < priv->aplist.size; i++) { /* bssid check */ + /* bssid check */ + for (i = 0; i < priv->aplist.size; i++) { if (memcmp(ap_info->bssid, priv->aplist.ap[i].bssid, ETH_ALEN) != 0) continue; -- 2.16.2
[PATCH 3/6] staging: ks7010: Remove unnecessary parentheses.
Remove unnecessary parentheses highlighted by checkpatch. Signed-off-by: Quytelda Kahja --- drivers/staging/ks7010/ks_hostif.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 948d45280d18..00b97e8e9b4f 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -45,7 +45,7 @@ inline u8 get_BYTE(struct ks_wlan_private *priv) { u8 data; - data = *(priv->rxp)++; + data = *priv->rxp++; /* length check in advance ! */ --(priv->rx_size); return data; @@ -860,7 +860,7 @@ void hostif_scan_indication(struct ks_wlan_private *priv) DPRINTK(4, " scan_ind_count=%d :: aplist.size=%d\n", priv->scan_ind_count, priv->aplist.size); get_ap_information(priv, (struct ap_info_t *)(priv->rxp), - &(priv->aplist.ap[priv->scan_ind_count - 1])); + &priv->aplist.ap[priv->scan_ind_count - 1]); priv->aplist.size = priv->scan_ind_count; } else { DPRINTK(4, " count over :: scan_ind_count=%d\n", -- 2.16.2
[PATCH 2/6] staging: ks7010: Factor out code into helper methods.
Some cases in the switch statement in get_ap_information() are indented as much as five levels, which makes the code difficult to read because of all the wrapping. Factor them out into helper methods. Signed-off-by: Quytelda Kahja --- drivers/staging/ks7010/ks_hostif.c | 46 +- 1 file changed, 26 insertions(+), 20 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index a946ce76f899..948d45280d18 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -238,6 +238,30 @@ static u8 read_ie(unsigned char *bp, u8 max, u8 *body, char *name) return size; } +static void read_ie_ext_supp_rates(struct local_ap_t *ap, unsigned char *bp) +{ + if ((*(bp + 1) + ap->rate_set.size) <= RATE_SET_MAX_SIZE) { + memcpy(&ap->rate_set.body[ap->rate_set.size], + bp + 2, *(bp + 1)); + ap->rate_set.size += *(bp + 1); + } else { + DPRINTK(1, "size over :: rate size=%d\n", + (*(bp + 1) + ap->rate_set.size)); + memcpy(&ap->rate_set.body[ap->rate_set.size], bp + 2, + RATE_SET_MAX_SIZE - ap->rate_set.size); + ap->rate_set.size += (RATE_SET_MAX_SIZE - ap->rate_set.size); + } +} + +static void read_ie_wpa(struct local_ap_t *ap, unsigned char *bp) +{ + if (memcmp(bp + 2, CIPHER_ID_WPA_WEP40, 4) == 0) { /* WPA OUI check */ + ap->wpa_ie.id = *bp; + ap->wpa_ie.size = read_ie(bp, RSN_IE_BODY_MAX, + ap->wpa_ie.body, "wpa"); + } +} + static int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, struct local_ap_t *ap) @@ -273,20 +297,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, break; case WLAN_EID_SUPP_RATES: case WLAN_EID_EXT_SUPP_RATES: - if ((*(bp + 1) + ap->rate_set.size) <= - RATE_SET_MAX_SIZE) { - memcpy(&ap->rate_set.body[ap->rate_set.size], - bp + 2, *(bp + 1)); - ap->rate_set.size += *(bp + 1); - } else { - DPRINTK(1, "size over :: rate size=%d\n", - (*(bp + 1) + ap->rate_set.size)); - memcpy(&ap->rate_set.body[ap->rate_set.size], - bp + 2, - RATE_SET_MAX_SIZE - ap->rate_set.size); - ap->rate_set.size += - (RATE_SET_MAX_SIZE - ap->rate_set.size); - } + read_ie_ext_supp_rates(ap, bp); break; case WLAN_EID_DS_PARAMS: break; @@ -296,12 +307,7 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, ap->rsn_ie.body, "rsn"); break; case WLAN_EID_VENDOR_SPECIFIC: /* WPA */ - if (memcmp(bp + 2, CIPHER_ID_WPA_WEP40, 4) == 0) { /* WPA OUI check */ - ap->wpa_ie.id = *bp; - ap->wpa_ie.size = read_ie(bp, RSN_IE_BODY_MAX, - ap->wpa_ie.body, - "wpa"); - } + read_ie_wpa(ap, bp); break; case WLAN_EID_FH_PARAMS: -- 2.16.2
[PATCH 4/6] staging: ks7010: Remove unnecessary braces.
Braces aren't required for a single line if statement. Signed-off-by: Quytelda Kahja --- drivers/staging/ks7010/ks_hostif.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 00b97e8e9b4f..2de4dbbcd9de 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -1387,9 +1387,8 @@ static __le16 ks_wlan_cap(struct ks_wlan_private *priv) { u16 capability = 0x; - if (priv->reg.preamble == SHORT_PREAMBLE) { + if (priv->reg.preamble == SHORT_PREAMBLE) capability |= WLAN_CAPABILITY_SHORT_PREAMBLE; - } capability &= ~(WLAN_CAPABILITY_PBCC); /* pbcc not support */ -- 2.16.2
Re: [PATCH v3 07/11] mmc: sdhci: Program a relatively accurate SW timeout value
Hi, On Thursday 15 March 2018 06:43 PM, Adrian Hunter wrote: > On 07/03/18 15:20, Kishon Vijay Abraham I wrote: >> sdhci has a 10 second timeout to catch devices that stop responding. >> Instead of programming 10 second arbitrary value, calculate the total time >> it would take for the entire transfer to happen and program the timeout >> value accordingly. >> >> Signed-off-by: Kishon Vijay Abraham I >> --- >> drivers/mmc/host/sdhci.c | 47 >> --- >> drivers/mmc/host/sdhci.h | 10 ++ >> 2 files changed, 50 insertions(+), 7 deletions(-) >> >> diff --git a/drivers/mmc/host/sdhci.c b/drivers/mmc/host/sdhci.c >> index 1dd117cbeb6e..baab67bfa39b 100644 >> --- a/drivers/mmc/host/sdhci.c >> +++ b/drivers/mmc/host/sdhci.c >> @@ -709,6 +709,36 @@ static u32 sdhci_sdma_address(struct sdhci_host *host) >> return sg_dma_address(host->data->sg); >> } >> >> +static void sdhci_calc_sw_timeout(struct sdhci_host *host, >> + struct mmc_command *cmd, >> + unsigned int target_timeout) >> +{ >> +struct mmc_data *data = cmd->data; >> +struct mmc_host *mmc = host->mmc; >> +u64 transfer_time; >> +struct mmc_ios *ios = &mmc->ios; >> +unsigned char bus_width = 1 << ios->bus_width; >> +unsigned int blksz; >> +unsigned int freq; >> + >> +if (data) { >> +blksz = data->blksz; >> +freq = host->mmc->actual_clock ? : host->clock; >> +transfer_time = (u64)blksz * NSEC_PER_SEC * (8 / bus_width); >> +do_div(transfer_time, freq); >> +/* multiply by '2' to account for any unknowns */ >> +transfer_time = transfer_time * 2; >> +/* calculate timeout for the entire data */ >> +host->data_timeout = (data->blocks * ((target_timeout * >> + NSEC_PER_USEC) + >> + transfer_time)); > > (target_timeout * NSEC_PER_USEC) might be 32-bit and therefore overflow > for timeouts greater than about 4 seconds. > >> +} else { >> +host->data_timeout = (u64)target_timeout * NSEC_PER_USEC; >> +} >> + >> +host->data_timeout += MMC_CMD_TRANSFER_TIME; > > Need to allow for target_timeout == 0 so: > > if (host->data_timeout) > host->data_timeout += MMC_CMD_TRANSFER_TIME; > >> +} >> + >> static u8 sdhci_calc_timeout(struct sdhci_host *host, struct mmc_command >> *cmd) >> { >> u8 count; >> @@ -766,6 +796,7 @@ static u8 sdhci_calc_timeout(struct sdhci_host *host, >> struct mmc_command *cmd) >> if (count >= 0xF) >> break; >> } >> +sdhci_calc_sw_timeout(host, cmd, target_timeout); > > If you make the changes I suggest for patch 6, then this would > move sdhci_calc_sw_timeout() into sdhci_set_timeout(). > > I suggest you factor out the target_timeout calculation e.g. > > static unsigned int sdhci_target_timeout(struct sdhci_host *host, >struct mmc_command *cmd, >struct mmc_data *data) > { > unsigned int target_timeout; > > /* timeout in us */ > if (!data) > target_timeout = cmd->busy_timeout * 1000; > else { > target_timeout = DIV_ROUND_UP(data->timeout_ns, 1000); > if (host->clock && data->timeout_clks) { > unsigned long long val; > > /* >* data->timeout_clks is in units of clock cycles. >* host->clock is in Hz. target_timeout is in us. >* Hence, us = 100 * cycles / Hz. Round up. >*/ > val = 100ULL * data->timeout_clks; > if (do_div(val, host->clock)) > target_timeout++; > target_timeout += val; > } > } > > return target_timeout; > } > > And call it from sdhci_calc_sw_timeout() > >> >> return count; >> } >> @@ -1175,13 +1206,6 @@ void sdhci_send_command(struct sdhci_host *host, >> struct mmc_command *cmd) >> mdelay(1); >> } >> >> -timeout = jiffies; >> -if (!cmd->data && cmd->busy_timeout > 9000) >> -timeout += DIV_ROUND_UP(cmd->busy_timeout, 1000) * HZ + HZ; >> -else >> -timeout += 10 * HZ; >> -sdhci_mod_timer(host, cmd->mrq, timeout); >> - >> host->cmd = cmd; >> if (sdhci_data_line_cmd(cmd)) { >> WARN_ON(host->data_cmd); >> @@ -1221,6 +1245,15 @@ void sdhci_send_command(struct sdhci_host *host, >> struct mmc_command *cmd) >> cmd->opcode == MMC_SEND_TUNING_BLOCK_HS200) >> flags |= SDHCI_CMD_DATA; >> >> +timeout = jiffies; >> +if (host->data_timeout > 0) { > > This can be just: > >
Re: arm64: allwinner: Add support for TERES I laptop
Hi, On Thu, Mar 15, 2018 at 10:36:06PM +0530, afzal mohammed wrote: > Thanks for the patches > > w/ defconfig could reach to prompt via serial console using audio > jack. > > And just by enabling PWM_SUN4I & FB_SIMPLE, laptop could function > standalone as well. > > Suggestions (feel free to ignore): > > 1. seems currently only review comment pending is on simple > framebuffer, perhaps you can proceed removing just that so that a > basic bootable system can be achieved at the earliest (iiuc, anyway > drm would be the final solution for display) > > 2. in next revision (if), may be you can put keywords DIY and/or Open > Hardware (irrespective of whatever exactly that means) Laptop in the > subject itself, that might bring more interest/eyeballs, especially at > this time of ME & so on. Realizing now that your v2 patches & above mail crossed. afzal
[PATCH 1/6] staging: ks7010: Factor out repeated code.
Some of the code for reading IEs is replicated multiple times in the switch statement for get_ap_information(). Factor that code out into read_ie(). Signed-off-by: Quytelda Kahja --- drivers/staging/ks7010/ks_hostif.c | 48 +- 1 file changed, 22 insertions(+), 26 deletions(-) diff --git a/drivers/staging/ks7010/ks_hostif.c b/drivers/staging/ks7010/ks_hostif.c index 05f7be4638fe..a946ce76f899 100644 --- a/drivers/staging/ks7010/ks_hostif.c +++ b/drivers/staging/ks7010/ks_hostif.c @@ -223,6 +223,21 @@ int get_current_ap(struct ks_wlan_private *priv, struct link_ap_info_t *ap_info) return 0; } +static u8 read_ie(unsigned char *bp, u8 max, u8 *body, char *name) +{ + u8 size; + + if (*(bp + 1) <= max) { + size = *(bp + 1); + } else { + DPRINTK(1, "size over :: %s size=%d\n", name, *(bp + 1)); + size = max; + } + + memcpy(body, bp + 2, size); + return size; +} + static int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, struct local_ap_t *ap) @@ -253,14 +268,8 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, while (bsize > offset) { switch (*bp) { /* Information Element ID */ case WLAN_EID_SSID: - if (*(bp + 1) <= IEEE80211_MAX_SSID_LEN) { - ap->ssid.size = *(bp + 1); - } else { - DPRINTK(1, "size over :: ssid size=%d\n", - *(bp + 1)); - ap->ssid.size = IEEE80211_MAX_SSID_LEN; - } - memcpy(ap->ssid.body, bp + 2, ap->ssid.size); + ap->ssid.size = read_ie(bp, IEEE80211_MAX_SSID_LEN, + ap->ssid.body, "ssid"); break; case WLAN_EID_SUPP_RATES: case WLAN_EID_EXT_SUPP_RATES: @@ -283,28 +292,15 @@ int get_ap_information(struct ks_wlan_private *priv, struct ap_info_t *ap_info, break; case WLAN_EID_RSN: ap->rsn_ie.id = *bp; - if (*(bp + 1) <= RSN_IE_BODY_MAX) { - ap->rsn_ie.size = *(bp + 1); - } else { - DPRINTK(1, "size over :: rsn size=%d\n", - *(bp + 1)); - ap->rsn_ie.size = RSN_IE_BODY_MAX; - } - memcpy(ap->rsn_ie.body, bp + 2, ap->rsn_ie.size); + ap->rsn_ie.size = read_ie(bp, RSN_IE_BODY_MAX, + ap->rsn_ie.body, "rsn"); break; case WLAN_EID_VENDOR_SPECIFIC: /* WPA */ if (memcmp(bp + 2, CIPHER_ID_WPA_WEP40, 4) == 0) { /* WPA OUI check */ ap->wpa_ie.id = *bp; - if (*(bp + 1) <= RSN_IE_BODY_MAX) { - ap->wpa_ie.size = *(bp + 1); - } else { - DPRINTK(1, - "size over :: wpa size=%d\n", - *(bp + 1)); - ap->wpa_ie.size = RSN_IE_BODY_MAX; - } - memcpy(ap->wpa_ie.body, bp + 2, - ap->wpa_ie.size); + ap->wpa_ie.size = read_ie(bp, RSN_IE_BODY_MAX, + ap->wpa_ie.body, + "wpa"); } break; -- 2.16.2
Re: [RFC v2 03/83] Add super.h.
On Thu, Mar 15, 2018 at 7:59 PM, Theodore Y. Ts'o wrote: > On Thu, Mar 15, 2018 at 09:38:29PM +0100, Arnd Bergmann wrote: >> >> You could also have a resolution of less than a nanosecond. Note >> that today, the file time stamps generated by the kernel are in >> jiffies resolution, so at best one millisecond. However, most modern >> file systems go with the 64+32 bit timestamps because it's not all >> that expensive. > > It actually depends on the architecture and the accuracy/granularity > of the timekeeping hardware available to the system, but it's possible > for the granularity of file time stamps to be up to one nanosecond. > So you can get results like this: > > % stat unix_io.o > File: unix_io.o > Size: 55000 Blocks: 112IO Block: 4096 regular file > Device: fc01h/64513dInode: 19931278Links: 1 > Access: (0644/-rw-r--r--) Uid: (15806/ tytso) Gid: (15806/ tytso) > Access: 2018-03-15 18:09:21.679914182 -0400 > Modify: 2018-03-15 18:09:21.639914089 -0400 > Change: 2018-03-15 18:09:21.639914089 -0400 > Thanks for all the suggestions. I think I will follow ext4's time format. 2446 should be far away enough. Thanks, Andiry
Re: [PATCH v4.16-rc5 1/3] x86/vdso: on Intel, VDSO should handle CLOCK_MONOTONIC_RAW
Hi, Thank you for the patch! Yet something to improve: [auto build test ERROR on v4.16-rc4] [also build test ERROR on next-20180315] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/jason-vas-dias-gmail-com/x86-vdso-on-Intel-VDSO-should-handle-CLOCK_MONOTONIC_RAW/20180316-070319 config: x86_64-rhel (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): arch/x86/entry/vdso/vclock_gettime.o: In function `__vdso_clock_gettime': vclock_gettime.c:(.text+0xf7): undefined reference to `__x86_indirect_thunk_rax' /usr/bin/ld: arch/x86/entry/vdso/vclock_gettime.o: relocation R_X86_64_PC32 against undefined symbol `__x86_indirect_thunk_rax' can not be used when making a shared object; recompile with -fPIC /usr/bin/ld: final link failed: Bad value >> collect2: error: ld returned 1 exit status -- >> arch/x86/entry/vdso/vdso32.so.dbg: undefined symbols found -- >> objcopy: 'arch/x86/entry/vdso/vdso64.so.dbg': No such file --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: [PATCH RFC 2/2] virtio_ring: support packed ring
On Fri, Mar 16, 2018 at 12:03:25PM +0800, Jason Wang wrote: > On 2018年02月23日 19:18, Tiwei Bie wrote: > > Signed-off-by: Tiwei Bie > > --- > > drivers/virtio/virtio_ring.c | 699 > > +-- > > include/linux/virtio_ring.h | 8 +- > > 2 files changed, 618 insertions(+), 89 deletions(-) > > > > diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c > > index eb30f3e09a47..393778a2f809 100644 > > --- a/drivers/virtio/virtio_ring.c > > +++ b/drivers/virtio/virtio_ring.c > > @@ -58,14 +58,14 @@ > > struct vring_desc_state { > > void *data; /* Data for callback. */ > > - struct vring_desc *indir_desc; /* Indirect descriptor, if any. */ > > + void *indir_desc; /* Indirect descriptor, if any. */ > > + int num;/* Descriptor list length. */ > > }; > > struct vring_virtqueue { > > struct virtqueue vq; > > - /* Actual memory layout for this queue */ > > - struct vring vring; > > + bool packed; > > /* Can we use weak barriers? */ > > bool weak_barriers; > > @@ -87,11 +87,28 @@ struct vring_virtqueue { > > /* Last used index we've seen. */ > > u16 last_used_idx; > > - /* Last written value to avail->flags */ > > - u16 avail_flags_shadow; > > - > > - /* Last written value to avail->idx in guest byte order */ > > - u16 avail_idx_shadow; > > + union { > > + /* Available for split ring */ > > + struct { > > + /* Actual memory layout for this queue */ > > + struct vring vring; > > + > > + /* Last written value to avail->flags */ > > + u16 avail_flags_shadow; > > + > > + /* Last written value to avail->idx in > > +* guest byte order */ > > + u16 avail_idx_shadow; > > + }; > > + > > + /* Available for packed ring */ > > + struct { > > + /* Actual memory layout for this queue */ > > + struct vring_packed vring_packed; > > + u8 wrap_counter : 1; > > + bool chaining; > > + }; > > + }; > > /* How to notify other side. FIXME: commonalize hcalls! */ > > bool (*notify)(struct virtqueue *vq); > > @@ -201,26 +218,37 @@ static dma_addr_t vring_map_single(const struct > > vring_virtqueue *vq, > > cpu_addr, size, direction); > > } > > -static void vring_unmap_one(const struct vring_virtqueue *vq, > > - struct vring_desc *desc) > > +static void vring_unmap_one(const struct vring_virtqueue *vq, void *_desc) > > { > > Let's split the helpers to packed/split version like other helpers? > (Consider the caller has already known the type of vq). Okay. > > > + u64 addr; > > + u32 len; > > u16 flags; > > if (!vring_use_dma_api(vq->vq.vdev)) > > return; > > - flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); > > + if (vq->packed) { > > + struct vring_packed_desc *desc = _desc; > > + > > + addr = virtio64_to_cpu(vq->vq.vdev, desc->addr); > > + len = virtio32_to_cpu(vq->vq.vdev, desc->len); > > + flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); > > + } else { > > + struct vring_desc *desc = _desc; > > + > > + addr = virtio64_to_cpu(vq->vq.vdev, desc->addr); > > + len = virtio32_to_cpu(vq->vq.vdev, desc->len); > > + flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); > > + } > > if (flags & VRING_DESC_F_INDIRECT) { > > dma_unmap_single(vring_dma_dev(vq), > > -virtio64_to_cpu(vq->vq.vdev, desc->addr), > > -virtio32_to_cpu(vq->vq.vdev, desc->len), > > +addr, len, > > (flags & VRING_DESC_F_WRITE) ? > > DMA_FROM_DEVICE : DMA_TO_DEVICE); > > } else { > > dma_unmap_page(vring_dma_dev(vq), > > - virtio64_to_cpu(vq->vq.vdev, desc->addr), > > - virtio32_to_cpu(vq->vq.vdev, desc->len), > > + addr, len, > >(flags & VRING_DESC_F_WRITE) ? > >DMA_FROM_DEVICE : DMA_TO_DEVICE); > > } > > @@ -235,8 +263,9 @@ static int vring_mapping_error(const struct > > vring_virtqueue *vq, > > return dma_mapping_error(vring_dma_dev(vq), addr); > > } > > -static struct vring_desc *alloc_indirect(struct virtqueue *_vq, > > -unsigned int total_sg, gfp_t gfp) > > +static struct vring_desc *alloc_indirect_split(struct virtqueue *_vq, > > + unsigned int total_sg, > > + gfp_t gfp) > > { > > struct vring_desc *desc; > > unsigned int i; > > @@ -257,14
Re: linux-next: build warning after merge of the tip tree
Hi Stephen, At 03/16/2018 01:52 PM, Dou Liyang wrote: Hi Stephen, At 03/16/2018 01:37 PM, Stephen Rothwell wrote: Hi all, After merging the tip tree, yesterday's linux-next build (x86_64 allnoconfig) produced this warning: kernel/cpu.c:129:13: warning: 'cpuhp_is_ap_state' defined but not used [-Wunused-function] static bool cpuhp_is_ap_state(enum cpuhp_state state) ^ Yes, Jiangshan has replaced it with cpuhp_hp_states. So it is obsolete, it should be removed. I made a mistake, It also be called by cpuhp_thread_fun() and cpuhp_issue_call(), let me have a look carefully. Thanks, dou. Thanks, dou. Introduced by commit 17a2f1ced028 ("cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states")
Re: [PATCH 6/8] RCU, workqueue: Implement rcu_work
On Thu, Mar 15, 2018 at 3:45 AM, Tejun Heo wrote: > There are cases where RCU callback needs to be bounced to a sleepable > context. This is currently done by the RCU callback queueing a work > item, which can be cumbersome to write and confusing to read. > > This patch introduces rcu_work, a workqueue work variant which gets > executed after a RCU grace period, and converts the open coded > bouncing in fs/aio and kernel/cgroup. > > v3: Dropped queue_rcu_work_on(). Documented rcu grace period behavior > after queue_rcu_work(). > > v2: Use rcu_barrier() instead of synchronize_rcu() to wait for > completion of previously queued rcu callback as per Paul. > > Signed-off-by: Tejun Heo > Cc: "Paul E. McKenney" > Cc: Linus Torvalds > --- > include/linux/workqueue.h | 23 > kernel/workqueue.c| 54 > +++ > 2 files changed, 77 insertions(+) > > diff --git a/include/linux/workqueue.h b/include/linux/workqueue.h > index bc0cda1..d026f8f 100644 > --- a/include/linux/workqueue.h > +++ b/include/linux/workqueue.h > @@ -13,6 +13,7 @@ > #include > #include > #include > +#include > > struct workqueue_struct; > > @@ -120,6 +121,14 @@ struct delayed_work { > int cpu; > }; > > +struct rcu_work { > + struct work_struct work; > + struct rcu_head rcu; > + > + /* target workqueue ->rcu uses to queue ->work */ > + struct workqueue_struct *wq; > +}; > + > /** > * struct workqueue_attrs - A struct for workqueue attributes. > * > @@ -151,6 +160,11 @@ static inline struct delayed_work > *to_delayed_work(struct work_struct *work) > return container_of(work, struct delayed_work, work); > } > > +static inline struct rcu_work *to_rcu_work(struct work_struct *work) > +{ > + return container_of(work, struct rcu_work, work); > +} > + > struct execute_work { > struct work_struct work; > }; > @@ -266,6 +280,12 @@ static inline unsigned int work_static(struct > work_struct *work) { return 0; } > #define INIT_DEFERRABLE_WORK_ONSTACK(_work, _func) \ > __INIT_DELAYED_WORK_ONSTACK(_work, _func, TIMER_DEFERRABLE) > > +#define INIT_RCU_WORK(_work, _func)\ > + INIT_WORK(&(_work)->work, (_func)) > + > +#define INIT_RCU_WORK_ONSTACK(_work, _func)\ > + INIT_WORK_ONSTACK(&(_work)->work, (_func)) > + > /** > * work_pending - Find out whether a work item is currently pending > * @work: The work item in question > @@ -447,6 +467,7 @@ extern bool queue_delayed_work_on(int cpu, struct > workqueue_struct *wq, > struct delayed_work *work, unsigned long delay); > extern bool mod_delayed_work_on(int cpu, struct workqueue_struct *wq, > struct delayed_work *dwork, unsigned long delay); > +extern bool queue_rcu_work(struct workqueue_struct *wq, struct rcu_work > *rwork); > > extern void flush_workqueue(struct workqueue_struct *wq); > extern void drain_workqueue(struct workqueue_struct *wq); > @@ -463,6 +484,8 @@ extern bool flush_delayed_work(struct delayed_work > *dwork); > extern bool cancel_delayed_work(struct delayed_work *dwork); > extern bool cancel_delayed_work_sync(struct delayed_work *dwork); > > +extern bool flush_rcu_work(struct rcu_work *rwork); > + > extern void workqueue_set_max_active(struct workqueue_struct *wq, > int max_active); > extern struct work_struct *current_work(void); > diff --git a/kernel/workqueue.c b/kernel/workqueue.c > index bb9a519..7df85fa 100644 > --- a/kernel/workqueue.c > +++ b/kernel/workqueue.c > @@ -1604,6 +1604,40 @@ bool mod_delayed_work_on(int cpu, struct > workqueue_struct *wq, > } > EXPORT_SYMBOL_GPL(mod_delayed_work_on); > > +static void rcu_work_rcufn(struct rcu_head *rcu) > +{ > + struct rcu_work *rwork = container_of(rcu, struct rcu_work, rcu); > + > + /* read the comment in __queue_work() */ > + local_irq_disable(); > + __queue_work(WORK_CPU_UNBOUND, rwork->wq, &rwork->work); > + local_irq_enable(); > +} > + > +/** > + * queue_rcu_work - queue work after a RCU grace period > + * @wq: workqueue to use > + * @rwork: work to queue > + * > + * Return: %false if @rwork was already pending, %true otherwise. Note > + * that a full RCU grace period is guaranteed only after a %true return. > + * While @rwork is guarnateed to be executed after a %false return, the > + * execution may happen before a full RCU grace period has passed. > + */ LGTM Reviewed-by: Lai Jiangshan > +bool queue_rcu_work(struct workqueue_struct *wq, struct rcu_work *rwork) > +{ > + struct work_struct *work = &rwork->work; > + > + if (!test_and_set_bit(WORK_STRUCT_PENDING_BIT, work_data_bits(work))) > { > + rwork->wq = wq; > + call_rcu(&rwork->rcu, rcu_work_rcufn); > + return true; > + } > + > +
Re: [PATCH v2 1/2] hwmon: (ucd9000) Add gpio chip interface
Hi Christopher, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.16-rc5 next-20180315] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Eddie-James/hwmon-ucd9000-Add-gpio-and-debugfs-interfaces/20180316-125048 config: x86_64-randconfig-x017-201810 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All errors (new ones prefixed by >>): drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_probe': >> drivers/hwmon/pmbus/ucd9000.c:457:12: error: 'struct gpio_chip' has no >> member named 'of_node' data->gpio.of_node = client->dev.of_node; ^ vim +457 drivers/hwmon/pmbus/ucd9000.c 308 309 static int ucd9000_probe(struct i2c_client *client, 310 const struct i2c_device_id *id) 311 { 312 u8 block_buffer[I2C_SMBUS_BLOCK_MAX + 1]; 313 struct ucd9000_data *data; 314 struct pmbus_driver_info *info; 315 const struct i2c_device_id *mid; 316 enum chips chip; 317 int i, ret; 318 319 if (!i2c_check_functionality(client->adapter, 320 I2C_FUNC_SMBUS_BYTE_DATA | 321 I2C_FUNC_SMBUS_BLOCK_DATA)) 322 return -ENODEV; 323 324 ret = i2c_smbus_read_block_data(client, UCD9000_DEVICE_ID, 325 block_buffer); 326 if (ret < 0) { 327 dev_err(&client->dev, "Failed to read device ID\n"); 328 return ret; 329 } 330 block_buffer[ret] = '\0'; 331 dev_info(&client->dev, "Device ID %s\n", block_buffer); 332 333 for (mid = ucd9000_id; mid->name[0]; mid++) { 334 if (!strncasecmp(mid->name, block_buffer, strlen(mid->name))) 335 break; 336 } 337 if (!mid->name[0]) { 338 dev_err(&client->dev, "Unsupported device\n"); 339 return -ENODEV; 340 } 341 342 if (client->dev.of_node) 343 chip = (enum chips)of_device_get_match_data(&client->dev); 344 else 345 chip = id->driver_data; 346 347 if (chip != ucd9000 && chip != mid->driver_data) 348 dev_notice(&client->dev, 349 "Device mismatch: Configured %s, detected %s\n", 350 id->name, mid->name); 351 352 data = devm_kzalloc(&client->dev, sizeof(struct ucd9000_data), 353 GFP_KERNEL); 354 if (!data) 355 return -ENOMEM; 356 info = &data->info; 357 358 ret = i2c_smbus_read_byte_data(client, UCD9000_NUM_PAGES); 359 if (ret < 0) { 360 dev_err(&client->dev, 361 "Failed to read number of active pages\n"); 362 return ret; 363 } 364 info->pages = ret; 365 if (!info->pages) { 366 dev_err(&client->dev, "No pages configured\n"); 367 return -ENODEV; 368 } 369 370 /* The internal temperature sensor is always active */ 371 info->func[0] = PMBUS_HAVE_TEMP; 372 373 /* Everything else is configurable */ 374 ret = i2c_smbus_read_block_data(client, UCD9000_MONITOR_CONFIG, 375 block_buffer); 376 if (ret <= 0) { 377 dev_err(&client->dev, "Failed to read configuration data\n"); 378 return -ENODEV; 379 } 380 for (i = 0; i < ret; i++) { 381 int page = UCD9000_MON_PAGE(block_buffer[i]); 382 383 if (page >= info->pages) 384 continue; 385 386 switch (UCD9000_MON_TYPE(block_buffer[i])) { 387 case UCD9000_MON_VOLTAGE: 388 case UCD9000_MON_VOLTAGE_HW: 389 info->func[page] |= PMBUS_HAVE_VOUT 390| PMBUS_HAVE_STATUS_VOUT; 391 break; 392 case UCD9000_MON_TEMPERATURE: 393
Re: [PATCH v2 1/6] phy: rockchip-typec: fall back to working in host-mode if extcon is missing.
On Wednesday 14 March 2018 01:44 PM, Heiko Stübner wrote: > Hi Kishon, > > Am Donnerstag, 1. März 2018, 16:25:10 CET schrieb Enric Balletbo i Serra: >> Right now the rockchip type-c phy does fail probing when no extcon is >> detected. Some boards get the cable-state via the extcon interface and >> have this supported, other boards seem to use the fusb302 chip or >> another but the driver currently does not seem to utilize the extcon >> interface to report the cable-state. And, other, just connect the type-c >> to a standard USB-A port so use no controller at all. A missing extcon >> shouldn't fail to probe, instead, should just fall back to working in >> host-mode if it cannot get the extcon. >> >> Fixes: c301b327aea898af ("arm64: dts: rockchip: add usb3-phy otg-port >> support for rk3399") Reported-by: Vicente Bergas >> Signed-off-by: Enric Balletbo i Serra > > Reviewed-by: Heiko Stuebner > > I did revert the original commit mentioned in the fixes tag for 4.16-rc > but it would nevertheless be really cool if these 2 patches (code + binding) > could make it into your tree for 4.17 :-) > > And ideally also with the other 5 patches from Enric starting at > [PATCH v3 1/6] phy: rockchip-typec: deprecate some DT properties for > various register fields. > > from 2018-02-16. merged now, thanks! -Kishon
linux-next: manual merge of the akpm-current tree with Linus' tree
Hi Andrew, Today's linux-next merge of the akpm-current tree got a conflict in: mm/page_alloc.c between commit: 3e04040df6d4 ("Revert "mm/page_alloc: fix memmap_init_zone pageblock alignment"") from Linus' tree and commit: 45251b0909dc ("mm: remove unused arg from memblock_next_valid_pfn()") from the akpm-current tree. I fixed it up (see below) and can carry the fix as necessary. This is now fixed as far as linux-next is concerned, but any non trivial conflicts should be mentioned to your upstream maintainer when your tree is submitted for merging. You may also want to consider cooperating with the maintainer of the conflicting tree to minimise any particularly complex conflicts. -- Cheers, Stephen Rothwell diff --cc mm/page_alloc.c index b32488f10a46,3f9cb47974ed.. --- a/mm/page_alloc.c +++ b/mm/page_alloc.c @@@ -5361,9 -5487,14 +5489,9 @@@ void __meminit memmap_init_zone(unsigne /* * Skip to the pfn preceding the next valid one (or * end_pfn), such that we hit a valid pfn (or end_pfn) - * on our next iteration of the loop. Note that it needs - * to be pageblock aligned even when the region itself - * is not. move_freepages_block() can shift ahead of - * the valid region but still depends on correct page - * metadata. + * on our next iteration of the loop. */ - pfn = memblock_next_valid_pfn(pfn, end_pfn) - 1; - pfn = (memblock_next_valid_pfn(pfn) & - ~(pageblock_nr_pages-1)) - 1; ++ pfn = memblock_next_valid_pfn(pfn) - 1; #endif continue; } pgpgmsmmRQ0kf.pgp Description: OpenPGP digital signature
Re: [PATCH v1 1/2] arm: npcm: modify configuration for the NPCM7xx BMC.
On Thu, Mar 15, 2018 at 4:16 PM Tomer Maimon wrote: > Modify configuration and MakeFile > for the Nuvoton NPCM and NPCM7xx BMC. > Signed-off-by: Tomer Maimon > --- > arch/arm/mach-npcm/Kconfig | 40 +++- > arch/arm/mach-npcm/Makefile | 4 +++- > 2 files changed, 14 insertions(+), 30 deletions(-) Reviewed-by: Brendan Higgins
Re: [PATCH v3] vsprintf: Prevent crash when dereferencing invalid pointers
On (03/15/18 18:35), Linus Torvalds wrote: > On Thu, Mar 15, 2018 at 6:18 PM, Sergey Senozhatsky > wrote: > > > > Hm, may be sizeof(ptr) still won't suffice. It would be great if we > > could always look at spec.field_width, which can be up to 2 * sizeof(void > > *), > > and then just probe_kernel_read(spec.field_width). E.g., %b/%bl prints out a > > bitmap, accessing max_t(int, spec.field_width, 0) bits, which is good. But, > > for instance, %U (uuid printout) doesn't look at spec.field_width, and reads > > in 16 bytes from the given memory address. Then we have ipv4/ipv6, mac, etc. > > So I think that checking just 1 byte or sizeof(ptr) is not really enough if > > we want to fix vsprintf. What do you think? > > Honestly, I think it would be better to move the whole logic to the > functions that actually do the printout. > > Then you can do it right, and you don't need to have the strchr() either. > > There really isn't any commonality between the different versions. > field_width is meaningless, since it's about the size of the _printed_ > field, not the size in memory. Agreed! > Would it be a few more lines? Yes. But it would also clarify the code > and get all the cases right. Look at hex_string() for example, and > imagine fetching a byte at a time and just getting the corner cases > automatically right. So, basically, what I tried to say - any byte past the first sizeof(ptr) bytes or past the first byte that we check_access() can cause problems, which this patch is trying to address. As an example, FORMAT_TYPE_STR case printk("%.*s\n", p->buf) vsnprintf() string() Where ->buf is a _nearly always_ properly nul terminated char buf[128] array in struct foo. So moving that check_access() to every function that does printout sounds good to me, as well as checking every byte we access [assuming that we want to cure vsprintf], not just the first one or the first sizeof(ptr) bytes. -ss
Re: [PATCH v1 2/2] arm: npcm: Enable L2 Cache in NPCM7xx
On Thu, Mar 15, 2018 at 4:16 PM Tomer Maimon wrote: > Enable L2 Cache in Nuvoton NPCM7xx BMC. > Signed-off-by: Tomer Maimon > --- > arch/arm/mach-npcm/npcm7xx.c | 2 ++ > 1 file changed, 2 insertions(+) > diff --git a/arch/arm/mach-npcm/npcm7xx.c b/arch/arm/mach-npcm/npcm7xx.c > index 5f7cd88103ef..c5f77d854c4f 100644 > --- a/arch/arm/mach-npcm/npcm7xx.c > +++ b/arch/arm/mach-npcm/npcm7xx.c > @@ -17,4 +17,6 @@ static const char *const npcm7xx_dt_match[] = { > DT_MACHINE_START(NPCM7XX_DT, "NPCM7XX Chip family") > .atag_offset= 0x100, > .dt_compat = npcm7xx_dt_match, > + .l2c_aux_val= 0x0, > + .l2c_aux_mask = ~0x0, You need to limit this to the specific bit(s) you want to set and verify that the l2c driver does not already manage that bit appropriately and that it can not be specified via the dtsi. We discussed this a little while ago with Rob here: https://www.spinics.net/lists/arm-kernel/msg613372.html > MACHINE_END > -- > 2.14.1 Cheers
Re: linux-next: build warning after merge of the tip tree
Hi Stephen, At 03/16/2018 01:37 PM, Stephen Rothwell wrote: Hi all, After merging the tip tree, yesterday's linux-next build (x86_64 allnoconfig) produced this warning: kernel/cpu.c:129:13: warning: 'cpuhp_is_ap_state' defined but not used [-Wunused-function] static bool cpuhp_is_ap_state(enum cpuhp_state state) ^ Yes, Jiangshan has replaced it with cpuhp_hp_states. So it is obsolete, it should be removed. Thanks, dou. Introduced by commit 17a2f1ced028 ("cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states")
Re: [PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
On 03/16/2018 10:05 AM, Viresh Kumar wrote: > On 16-03-18, 09:38, Rajendra Nayak wrote: >> With genpd now expecting powerdomain drivers supporting performance >> state to support get/set performance state callbacks, add support for it >> in the rpmpd driver. >> >> Signed-off-by: Rajendra Nayak >> Signed-off-by: Viresh Kumar >> --- >> drivers/soc/qcom/rpmpd.c | 42 ++ >> 1 file changed, 42 insertions(+) >> >> diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c >> index c8754d867c33..4058c5b450c6 100644 >> --- a/drivers/soc/qcom/rpmpd.c >> +++ b/drivers/soc/qcom/rpmpd.c >> @@ -14,6 +14,7 @@ >> #include >> #include >> #include >> +#include >> #include >> >> #include >> @@ -29,6 +30,8 @@ >> #define KEY_ENABLE 0x6e657773 /* swen */ >> #define KEY_FLOOR_CORNER0x636676 /* vfc */ >> >> +#define MAX_RPMPD_STATE 6 >> + >> #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) >> \ >> static struct rpmpd _platform##_##_active; \ >> static struct rpmpd _platform##_##_name = { \ >> @@ -222,6 +225,43 @@ static int rpmpd_power_off(struct generic_pm_domain >> *domain) >> return ret; >> } >> >> +static int rpmpd_set_performance(struct generic_pm_domain *domain, >> + unsigned int state) >> +{ >> +int ret = 0; >> +struct rpmpd *pd = domain_to_rpmpd(domain); >> + >> +mutex_lock(&rpmpd_lock); >> + >> +if (state > MAX_RPMPD_STATE) >> +goto out; >> + >> +pd->corner = state; >> + >> +if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) >> +goto out; >> + >> +ret = rpmpd_aggregate_corner(pd); >> + >> +out: >> +mutex_unlock(&rpmpd_lock); >> + >> +return ret; >> +} >> + >> +static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, >> + struct dev_pm_opp *opp) >> +{ >> +struct device_node *np; >> +unsigned int corner = 0; >> + >> +np = dev_pm_opp_get_of_node(opp); >> +of_property_read_u32(np, "qcom,level", &corner); > > Don't we want to error out or do something else in case of an error ? yes, I missed the error checks, will add. -- Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
linux-next: build warning after merge of the tip tree
Hi all, After merging the tip tree, yesterday's linux-next build (x86_64 allnoconfig) produced this warning: kernel/cpu.c:129:13: warning: 'cpuhp_is_ap_state' defined but not used [-Wunused-function] static bool cpuhp_is_ap_state(enum cpuhp_state state) ^ Introduced by commit 17a2f1ced028 ("cpu/hotplug: Merge cpuhp_bp_states and cpuhp_ap_states") -- Cheers, Stephen Rothwell pgpECM6Qteoxu.pgp Description: OpenPGP digital signature
Re: [PATCH V7 00/13] drivers: Boot Constraint core
On 23-02-18, 15:53, Viresh Kumar wrote: > Hi Greg, > > The V7 version incorporates the organizational changes suggested by Olof > earlier. Everything else is same otherwise. > > I have tested the Hisilicon patches (again) on hikey 9660 board, IMX stuff was > earlier tested by Sascha (Pengutronix) on i.MX6 and Qualcomm stuff was earlier > tested by Rajendra (Qualcomm) on Dragonboard 410C (This required some more > patches related to display driver which Rajendra should be sending separately > later on). Hi Greg, Are you going to pick this one for 4.17 ? Thanks. -- viresh
Re: [PATCH v2] watchdog: aspeed: Allow configuring for alternate boot
On 03/15/2018 09:02 AM, Eddie James wrote: From: Milton Miller Allow the device tree to specify a watchdog to fallover to the alternate boot source. The aspeeed watchdog can set a latch directing flash chip select 0 to chip select 1, allowing boot from an alternate media if the watchdog is not reset in time. On the ast2400 bank 1 also goes to flash bank 1, while on the ast2500 the chip selects are swapped. Also clear the secondary boot bit during the machine restart operation. Otherwise, the system will switch to the alternate boot after every reboot, which is not desired. Signed-off-by: Milton Miller Signed-off-by: Eddie James Reviewed-by: Guenter Roeck --- Changes since v1: * Disable secondary boot before the restart operation. drivers/watchdog/aspeed_wdt.c | 4 1 file changed, 4 insertions(+) diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c index d1987d6..a5b8eb2 100644 --- a/drivers/watchdog/aspeed_wdt.c +++ b/drivers/watchdog/aspeed_wdt.c @@ -46,6 +46,7 @@ struct aspeed_wdt_config { #define WDT_RELOAD_VALUE 0x04 #define WDT_RESTART 0x08 #define WDT_CTRL 0x0C +#define WDT_CTRL_BOOT_SECONDARY BIT(7) #define WDT_CTRL_RESET_MODE_SOC (0x00 << 5) #define WDT_CTRL_RESET_MODE_FULL_CHIP (0x01 << 5) #define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5) @@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd, { struct aspeed_wdt *wdt = to_aspeed_wdt(wdd); + wdt->ctrl &= ~WDT_CTRL_BOOT_SECONDARY; aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000); mdelay(1000); @@ -245,6 +247,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev) } if (of_property_read_bool(np, "aspeed,external-signal")) wdt->ctrl |= WDT_CTRL_WDT_EXT; + if (of_property_read_bool(np, "aspeed,alt-boot")) + wdt->ctrl |= WDT_CTRL_BOOT_SECONDARY; if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE) { /*
Great News!
We have a great about your E-mail address!!! You Won $950,500.00 USD on Amnesty International UK online E-mail Promotion. For more details about your prize claims, file with the following; Names: Country: Tel: Regards, Mr. David Ford
Re: [PATCH v2 1/2] hwmon: (ucd9000) Add gpio chip interface
Hi Christopher, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.16-rc5 next-20180315] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Eddie-James/hwmon-ucd9000-Add-gpio-and-debugfs-interfaces/20180316-125048 config: x86_64-randconfig-x019-201810 (attached as .config) compiler: gcc-7 (Debian 7.3.0-1) 7.3.0 reproduce: # save the attached .config to linux build tree make ARCH=x86_64 All error/warnings (new ones prefixed by >>): >> drivers/hwmon/pmbus/ucd9000.c:69:19: error: field 'gpio' has incomplete type struct gpio_chip gpio; ^~~~ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_get': >> drivers/hwmon/pmbus/ucd9000.c:184:31: error: implicit declaration of >> function 'gpiochip_get_data'; did you mean 'gpio_get_value'? >> [-Werror=implicit-function-declaration] struct i2c_client *client = gpiochip_get_data(gc); ^ gpio_get_value >> drivers/hwmon/pmbus/ucd9000.c:184:31: warning: initialization makes pointer >> from integer without a cast [-Wint-conversion] drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_set': drivers/hwmon/pmbus/ucd9000.c:197:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] struct i2c_client *client = gpiochip_get_data(gc); ^ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_get_direction': drivers/hwmon/pmbus/ucd9000.c:240:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] struct i2c_client *client = gpiochip_get_data(gc); ^ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_gpio_set_direction': drivers/hwmon/pmbus/ucd9000.c:254:30: warning: initialization makes pointer from integer without a cast [-Wint-conversion] struct i2c_client *client = gpiochip_get_data(gc); ^ drivers/hwmon/pmbus/ucd9000.c: In function 'ucd9000_probe': >> drivers/hwmon/pmbus/ucd9000.c:460:9: error: implicit declaration of function >> 'devm_gpiochip_add_data'; did you mean 'devm_gpio_request'? >> [-Werror=implicit-function-declaration] ret = devm_gpiochip_add_data(&client->dev, &data->gpio, ^~ devm_gpio_request cc1: some warnings being treated as errors vim +/gpio +69 drivers/hwmon/pmbus/ucd9000.c 65 66 struct ucd9000_data { 67 u8 fan_data[UCD9000_NUM_FAN][I2C_SMBUS_BLOCK_MAX]; 68 struct pmbus_driver_info info; > 69 struct gpio_chip gpio; 70 }; 71 #define to_ucd9000_data(_info) container_of(_info, struct ucd9000_data, info) 72 73 static int ucd9000_get_fan_config(struct i2c_client *client, int fan) 74 { 75 int fan_config = 0; 76 struct ucd9000_data *data 77= to_ucd9000_data(pmbus_get_driver_info(client)); 78 79 if (data->fan_data[fan][3] & 1) 80 fan_config |= PB_FAN_2_INSTALLED; /* Use lower bit position */ 81 82 /* Pulses/revolution */ 83 fan_config |= (data->fan_data[fan][3] & 0x06) >> 1; 84 85 return fan_config; 86 } 87 88 static int ucd9000_read_byte_data(struct i2c_client *client, int page, int reg) 89 { 90 int ret = 0; 91 int fan_config; 92 93 switch (reg) { 94 case PMBUS_FAN_CONFIG_12: 95 if (page > 0) 96 return -ENXIO; 97 98 ret = ucd9000_get_fan_config(client, 0); 99 if (ret < 0) 100 return ret; 101 fan_config = ret << 4; 102 ret = ucd9000_get_fan_config(client, 1); 103 if (ret < 0) 104 return ret; 105 fan_config |= ret; 106 ret = fan_config; 107 break; 108 case PMBUS_FAN_CONFIG_34: 109 if (page > 0) 110 return -ENXIO; 111 112 ret = ucd9000_get_fan_config(client, 2); 113 if (ret < 0) 114 return ret; 115 fan_config = ret << 4; 116 ret = ucd9000_get_fan_config(client, 3); 117 if (ret <
Re: linux-next: build failure after merge of the y2038 tree
Hi Arnd, Do you want me to send the fix as a patch or should I re-post the series? Thanks, Deepa On Thu, Mar 15, 2018 at 7:25 PM, Stephen Rothwell wrote: > Hi Arnd, > > After merging the y2038 tree, today's linux-next build (s390 allnoconfig) > failed like this: > > In file included from include/linux/elf.h:5:0, > from include/linux/module.h:15, > from init/main.c:16: > arch/s390/include/asm/elf.h:138:1: error: unknown type name 's390_compat_regs' > > Caused by commit > > f00689038f71 ("include: Move compat_timespec/ timeval to compat_time.h") > > -- > Cheers, > Stephen Rothwell
Re: [PATCH v2] watchdog: aspeed: Allow configuring for alternate boot
On Fri, Mar 16, 2018 at 2:32 AM, Eddie James wrote: > From: Milton Miller > > Allow the device tree to specify a watchdog to fallover to > the alternate boot source. > > The aspeeed watchdog can set a latch directing flash chip select 0 to > chip select 1, allowing boot from an alternate media if the watchdog > is not reset in time. On the ast2400 bank 1 also goes to flash bank 1, > while on the ast2500 the chip selects are swapped. > > Also clear the secondary boot bit during the machine restart operation. > Otherwise, the system will switch to the alternate boot after every > reboot, which is not desired. > > Signed-off-by: Milton Miller > Signed-off-by: Eddie James That will do. Reviewed-by: Joel Stanley Cheers, Joel > --- > Changes since v1: > * Disable secondary boot before the restart operation. > > drivers/watchdog/aspeed_wdt.c | 4 > 1 file changed, 4 insertions(+) > > diff --git a/drivers/watchdog/aspeed_wdt.c b/drivers/watchdog/aspeed_wdt.c > index d1987d6..a5b8eb2 100644 > --- a/drivers/watchdog/aspeed_wdt.c > +++ b/drivers/watchdog/aspeed_wdt.c > @@ -46,6 +46,7 @@ struct aspeed_wdt_config { > #define WDT_RELOAD_VALUE 0x04 > #define WDT_RESTART0x08 > #define WDT_CTRL 0x0C > +#define WDT_CTRL_BOOT_SECONDARY BIT(7) > #define WDT_CTRL_RESET_MODE_SOC (0x00 << 5) > #define WDT_CTRL_RESET_MODE_FULL_CHIP(0x01 << 5) > #define WDT_CTRL_RESET_MODE_ARM_CPU (0x10 << 5) > @@ -158,6 +159,7 @@ static int aspeed_wdt_restart(struct watchdog_device *wdd, > { > struct aspeed_wdt *wdt = to_aspeed_wdt(wdd); > > + wdt->ctrl &= ~WDT_CTRL_BOOT_SECONDARY; > aspeed_wdt_enable(wdt, 128 * WDT_RATE_1MHZ / 1000); > > mdelay(1000); > @@ -245,6 +247,8 @@ static int aspeed_wdt_probe(struct platform_device *pdev) > } > if (of_property_read_bool(np, "aspeed,external-signal")) > wdt->ctrl |= WDT_CTRL_WDT_EXT; > + if (of_property_read_bool(np, "aspeed,alt-boot")) > + wdt->ctrl |= WDT_CTRL_BOOT_SECONDARY; > > if (readl(wdt->base + WDT_CTRL) & WDT_CTRL_ENABLE) { > /* > -- > 1.8.3.1 >
Re: [PATCH RFC rebase 3/9] powerpc/64: Use barrier_nospec in syscall entry
On Thu, 15 Mar 2018 20:15:52 +0100 Michal Suchanek wrote: > On powerpc syscall entry is done in assembly so patch in an explicit > barrier_nospec. Same comment as Linus for this -- the barriers are before the branch here, so is it possible the branch instruction can be speculative while the index is used to load the syscall table? Thanks, Nick > > Signed-off-by: Michal Suchanek > --- > arch/powerpc/kernel/entry_64.S | 3 +++ > 1 file changed, 3 insertions(+) > > diff --git a/arch/powerpc/kernel/entry_64.S b/arch/powerpc/kernel/entry_64.S > index 2cb5109a7ea3..7bfc4cf48af2 100644 > --- a/arch/powerpc/kernel/entry_64.S > +++ b/arch/powerpc/kernel/entry_64.S > @@ -36,6 +36,7 @@ > #include > #include > #include > +#include > #include > #ifdef CONFIG_PPC_BOOK3S > #include > @@ -159,6 +160,7 @@ system_call: /* label this so stack > traces look sane */ > andi. r11,r10,_TIF_SYSCALL_DOTRACE > bne .Lsyscall_dotrace /* does not return */ > cmpldi 0,r0,NR_syscalls > + barrier_nospec > bge-.Lsyscall_enosys > > .Lsyscall: > @@ -319,6 +321,7 @@ END_FTR_SECTION_IFSET(CPU_FTR_HAS_PPR) > ld r10,TI_FLAGS(r10) > > cmpldi r0,NR_syscalls > + barrier_nospec > blt+.Lsyscall > > /* Return code is already in r3 thanks to do_syscall_trace_enter() */
Re: [PATCH 4/4] mm/hmm: change CPU page table snapshot functions to simplify drivers
On 03/15/2018 11:37 AM, jgli...@redhat.com wrote: > From: Jérôme Glisse > > This change hmm_vma_fault() and hmm_vma_get_pfns() API to allow HMM > to directly write entry that can match any device page table entry > format. Device driver now provide an array of flags value and we use > enum to index this array for each flag. > > This also allow the device driver to ask for write fault on a per page > basis making API more flexible to service multiple device page faults > in one go. > Hi Jerome, This is a large patch, so I'm going to review it in two passes. The first pass is just an overview plus the hmm.h changes (now), and tomorrow I will review the hmm.c, which is where the real changes are. Overview: the hmm.c changes are doing several things, and it is difficult to review, because refactoring, plus new behavior, makes diffs less useful here. It would probably be good to split the hmm.c changes into a few patches, such as: -- HMM_PFN_FLAG_* changes, plus function signature changes (mm_range* being passed to functions), and -- New behavior in the page handling loops, and -- Refactoring into new routines (hmm_vma_handle_pte, and others) That way, reviewers can see more easily that things are correct. > Signed-off-by: Jérôme Glisse > Cc: Evgeny Baskakov > Cc: Ralph Campbell > Cc: Mark Hairgrove > Cc: John Hubbard > --- > include/linux/hmm.h | 130 +++-- > mm/hmm.c| 331 > +--- > 2 files changed, 249 insertions(+), 212 deletions(-) > > diff --git a/include/linux/hmm.h b/include/linux/hmm.h > index 61b0e1c05ee1..34e8a8c65bbd 100644 > --- a/include/linux/hmm.h > +++ b/include/linux/hmm.h > @@ -80,11 +80,10 @@ > struct hmm; > > /* > - * hmm_pfn_t - HMM uses its own pfn type to keep several flags per page > + * uint64_t - HMM uses its own pfn type to keep several flags per page This line now is a little odd, because it looks like it's trying to document uint64_t as an HMM pfn type. :) Maybe: * HMM pfns are of type uint64_t ...or else just delete it, either way. > * > * Flags: > * HMM_PFN_VALID: pfn is valid All of these are missing a _FLAG_ piece. The above should be HMM_PFN_FLAG_VALID, to match the enum below. > - * HMM_PFN_READ: CPU page table has read permission set So why is it that we don't need the _READ flag anymore? I looked at the corresponding hmm.c but still don't quite get it. Is it that we just expect that _READ is always set if there is an entry at all? Or something else? > * HMM_PFN_WRITE: CPU page table has write permission set > * HMM_PFN_ERROR: corresponding CPU page table entry points to poisoned > memory > * HMM_PFN_EMPTY: corresponding CPU page table entry is pte_none() > @@ -92,64 +91,94 @@ struct hmm; > * result of vm_insert_pfn() or vm_insert_page(). Therefore, it should > not > * be mirrored by a device, because the entry will never have > HMM_PFN_VALID > * set and the pfn value is undefined. > - * HMM_PFN_DEVICE_UNADDRESSABLE: unaddressable device memory (ZONE_DEVICE) > + * HMM_PFN_DEVICE_PRIVATE: private device memory (ZONE_DEVICE) > */ > -typedef unsigned long hmm_pfn_t; > +enum hmm_pfn_flag_e { > + HMM_PFN_FLAG_VALID = 0, > + HMM_PFN_FLAG_WRITE, > + HMM_PFN_FLAG_ERROR, > + HMM_PFN_FLAG_NONE, > + HMM_PFN_FLAG_SPECIAL, > + HMM_PFN_FLAG_DEVICE_PRIVATE, > + HMM_PFN_FLAG_MAX > +}; > + > +/* > + * struct hmm_range - track invalidation lock on virtual address range > + * > + * @vma: the vm area struct for the range > + * @list: all range lock are on a list > + * @start: range virtual start address (inclusive) > + * @end: range virtual end address (exclusive) > + * @pfns: array of pfns (big enough for the range) > + * @flags: pfn flags to match device driver page table > + * @valid: pfns array did not change since it has been fill by an HMM > function > + */ > +struct hmm_range { > + struct vm_area_struct *vma; > + struct list_headlist; > + unsigned long start; > + unsigned long end; > + uint64_t*pfns; > + const uint64_t *flags; > + uint8_t pfn_shift; > + boolvalid; > +}; > +#define HMM_RANGE_PFN_FLAG(f) (range->flags[HMM_PFN_FLAG_##f]) Please please please no. :) This breaks grep without actually adding any value. It's not as if you need to build up a whole set of symmetric macros like the Page* flags do, after all. So we can keep this very simple, instead. I've looked through the hmm.c and it's always just something like HMM_RANGE_PFN_FLAG(WRITE), so there really is no need for this macro at all. Just use HMM_PFN_FLAG_WRITE and friends directly, and enjoy the resulting clarity. > > -#define HMM_PFN_VALID (1 << 0) > -#define HMM_PFN_READ (1 << 1) > -#define HMM_PFN_WRITE (1 << 2) > -#define HMM_PFN_ERROR (1 << 3) > -#define HMM_PFN_EMPTY (1 << 4) > -
[PATCH] staging: media: davinci_vpfe: add error handling on kmalloc failure
There is no failure checking on the param value which will be allocated memory by kmalloc. Add a null pointer checking statement. Then goto error: and return -ENOMEM error code when kmalloc is failed. Signed-off-by: Ji-Hun Kim --- drivers/staging/media/davinci_vpfe/dm365_ipipe.c | 8 1 file changed, 8 insertions(+) diff --git a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c index 6a3434c..55a922c 100644 --- a/drivers/staging/media/davinci_vpfe/dm365_ipipe.c +++ b/drivers/staging/media/davinci_vpfe/dm365_ipipe.c @@ -1280,6 +1280,10 @@ static int ipipe_s_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) params = kmalloc(sizeof(struct ipipe_module_params), GFP_KERNEL); + if (!params) { + rval = -ENOMEM; + goto error; + } to = (void *)params + module_if->param_offset; size = module_if->param_size; @@ -1323,6 +1327,10 @@ static int ipipe_g_config(struct v4l2_subdev *sd, struct vpfe_ipipe_config *cfg) params = kmalloc(sizeof(struct ipipe_module_params), GFP_KERNEL); + if (!params) { + rval = -ENOMEM; + goto error; + } from = (void *)params + module_if->param_offset; size = module_if->param_size; -- 1.9.1
Re: [PATCH] [v2] Bluetooth: btrsi: rework dependencies
Arnd Bergmann writes: > On Thu, Mar 15, 2018 at 7:30 PM, Marcel Holtmann wrote: >> Hi Arnd, >> >>> The linkage between the bluetooth driver and the wireless >>> driver is not defined properly, leading to build problems >>> such as: >>> >>> warning: (BT_HCIRSI) selects RSI_COEX which has unmet direct >>> dependencies (NETDEVICES && WLAN && WLAN_VENDOR_RSI && BT_HCIRSI && >>> RSI_91X) >>> drivers/net/wireless/rsi/rsi_91x_main.o: In function `rsi_read_pkt': >>> (.text+0x205): undefined reference to `rsi_bt_ops' >>> >>> As the dependency is actually the reverse (RSI_91X uses >>> the BT_RSI driver, not the other way round), this changes >>> the dependency to match, and enables the bluetooth driver >>> from the RSI_COEX symbol. >>> >>> Fixes: 38aa4da50483 ("Bluetooth: btrsi: add new rsi bluetooth driver") >>> Signed-off-by: Arnd Bergmann >>> --- >>> v2: Pick a different from v1 >>> --- >>> drivers/bluetooth/Kconfig| 4 +--- >>> drivers/net/wireless/rsi/Kconfig | 4 +++- >>> 2 files changed, 4 insertions(+), 4 deletions(-) >> >> Acked-by: Marcel Holtmann >> >> Since I think Kalle still has to take it through his tree until the >> btrsi driver makes it into net-next. Yes, I have to take this as I haven't sent the original patch to Dave yet. > Kalle, please wait for v3 though, I just ran into another build > failure caused by a typo in v2. Ok, I saw it. -- Kalle Valo
Re: [PATCH 00/16] remove eight obsolete architectures
Hi, On Thu, Mar 15, 2018 at 10:56:48AM +0100, Arnd Bergmann wrote: > On Thu, Mar 15, 2018 at 10:42 AM, David Howells wrote: > > Do we have anything left that still implements NOMMU? Please don't kill !MMU. > Yes, plenty. > I've made an overview of the remaining architectures for my own reference[1]. > The remaining NOMMU architectures are: > > - arch/arm has ARMv7-M (Cortex-M microcontroller), which is actually > gaining traction ARMv7-R as well, also seems ARM is coming up with more !MMU's - v8-M, v8-R. In addition, though only of academic interest, ARM MMU capable platform's can run !MMU Linux. afzal > - arch/sh has an open-source J2 core that was added not that long ago, > it seems to > be the only SH compatible core that anyone is working on. > - arch/microblaze supports both MMU/NOMMU modes (most use an MMU) > - arch/m68k supports several NOMMU targets, both the coldfire SoCs and the > classic processors > - c6x has no MMU
Re: [PATCH 7/7] soc: qcom: rpmpd: Add a max vote on all corners at init
On 16-03-18, 09:38, Rajendra Nayak wrote: > As we move from no clients/consumers in kernel voting on corners, > to *some* voting and some not voting, we might end up in a situation > where the clients which remove votes can adversly impact others > who still don't have a way to vote. > > To avoid this situation, have a max vote on all corners at init. > This should/can be removed once we have all clients moved to > be able to vote/unvote for themselves. > > Signed-off-by: Rajendra Nayak > --- > drivers/soc/qcom/rpmpd.c | 9 + > 1 file changed, 9 insertions(+) > > diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c > index 4058c5b450c6..ebdcf9398441 100644 > --- a/drivers/soc/qcom/rpmpd.c > +++ b/drivers/soc/qcom/rpmpd.c > @@ -304,6 +304,15 @@ static int rpmpd_probe(struct platform_device *pdev) > pm_genpd_init(&rpmpds[i]->pd, NULL, true); > > data->domains[i] = &rpmpds[i]->pd; > + > + /* > + * Until we have all consumers voting on corners > + * just vote the max corner on all PDs > + * This should ideally be *removed* once we have > + * all (most) consumers being able to vote > + */ > + rpmpd_set_performance(&rpmpds[i]->pd, MAX_RPMPD_STATE); > + rpmpd_power_on(&rpmpds[i]->pd); > } > > return of_genpd_add_provider_onecell(pdev->dev.of_node, data); Acked-by: Viresh Kumar -- viresh
Re: [PATCH 6/7] mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state
On 16-03-18, 09:38, Rajendra Nayak wrote: > @@ -1540,6 +1571,9 @@ static int sdhci_msm_probe(struct platform_device *pdev) > pm_runtime_disable(&pdev->dev); > pm_runtime_set_suspended(&pdev->dev); > pm_runtime_put_noidle(&pdev->dev); > + dev_pm_opp_of_remove_table(&pdev->dev); You can't do this if there is no OPP table. Probably you should just make it part of the below if block. > + if (msm_host->opp_table) > + dev_pm_opp_put_clkname(msm_host->opp_table); > clk_disable: > clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), > msm_host->bulk_clks); > @@ -1564,6 +1598,9 @@ static int sdhci_msm_remove(struct platform_device > *pdev) > pm_runtime_get_sync(&pdev->dev); > pm_runtime_disable(&pdev->dev); > pm_runtime_put_noidle(&pdev->dev); > + dev_pm_opp_of_remove_table(&pdev->dev); And this too. > + if (msm_host->opp_table) > + dev_pm_opp_put_clkname(msm_host->opp_table); > > clk_bulk_disable_unprepare(ARRAY_SIZE(msm_host->bulk_clks), > msm_host->bulk_clks); Acked-by: Viresh Kumar -- viresh
Re: [PATCH v2 3/3] vfio/pci: Add ioeventfd support
On Thu, Mar 15, 2018 at 03:31:58PM -0600, Alex Williamson wrote: > The ioeventfd here is actually irqfd handling of an ioeventfd such as > supported in KVM. A user is able to pre-program a device write to > occur when the eventfd triggers. This is yet another instance of > eventfd-irqfd triggering between KVM and vfio. The impetus for this > is high frequency writes to pages which are virtualized in QEMU. > Enabling this near-direct write path for selected registers within > the virtualized page can improve performance and reduce overhead. > Specifically this is initially targeted at NVIDIA graphics cards where > the driver issues a write to an MMIO register within a virtualized > region in order to allow the MSI interrupt to re-trigger. > > Signed-off-by: Alex Williamson Reviewed-by: Peter Xu -- Peter Xu
[PATCH 1/1] iommu/vt-d: Use real PASID for flush in caching mode
If caching mode is supported, the hardware will cache none-present or erroneous translation entries. Hence, software should explicitly invalidate the PASID cache after a PASID table entry becomes present. We should issue such invalidation with the PASID value that we have changed. PASID 0 is not reserved for this case. Cc: Jacob Pan Cc: Kevin Tian Cc: Sankaran Rajesh Suggested-by: Ashok Raj Signed-off-by: Liu Yi L Signed-off-by: Lu Baolu --- drivers/iommu/intel-svm.c | 16 ++-- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/drivers/iommu/intel-svm.c b/drivers/iommu/intel-svm.c index 99bc9bd..b7b88b5 100644 --- a/drivers/iommu/intel-svm.c +++ b/drivers/iommu/intel-svm.c @@ -422,17 +422,13 @@ int intel_svm_bind_mm(struct device *dev, int *pasid, int flags, struct svm_dev_ iommu->pasid_table[svm->pasid].val = pasid_entry_val; wmb(); - /* In caching mode, we still have to flush with PASID 0 when -* a PASID table entry becomes present. Not entirely clear -* *why* that would be the case — surely we could just issue -* a flush with the PASID value that we've changed? The PASID -* is the index into the table, after all. It's not like domain -* IDs in the case of the equivalent context-entry change in -* caching mode. And for that matter it's not entirely clear why -* a VMM would be in the business of caching the PASID table -* anyway. Surely that can be left entirely to the guest? */ + + /* +* Flush PASID cache when a PASID table entry becomes +* present. +*/ if (cap_caching_mode(iommu->cap)) - intel_flush_pasid_dev(svm, sdev, 0); + intel_flush_pasid_dev(svm, sdev, svm->pasid); } list_add_rcu(&sdev->list, &svm->devs); -- 2.7.4
Re: [PATCH v4 08/24] fpga: add FPGA DFL PCIe device driver
On Thu, Mar 15, 2018 at 11:49:56AM -0700, Moritz Fischer wrote: > Hi Hao, > > On Tue, Feb 13, 2018 at 05:24:37PM +0800, Wu Hao wrote: > > From: Zhang Yi > > > > This patch implements the basic framework of the driver for FPGA PCIe > > device which implements the Device Feature List (DFL) in its MMIO space. > > This driver is verified on Intel(R) PCIe based FPGA DFL devices, including > > both integrated (e.g Intel Server Platform with In-package FPGA) and > > discrete (e.g Intel FPGA PCIe Acceleration Cards) solutions. > > > > Signed-off-by: Tim Whisonant > > Signed-off-by: Enno Luebbers > > Signed-off-by: Shiva Rao > > Signed-off-by: Christopher Rauer > > Signed-off-by: Zhang Yi > > Signed-off-by: Xiao Guangrong > > Signed-off-by: Wu Hao > > with module_pci_driver() fix: > > Acked-by: Moritz Fischer > > --- > > v2: move the code to drivers/fpga folder as suggested by Alan Tull. > > switch to GPLv2 license. > > fix comments from Moritz Fischer. > > v3: switch to pci_set_dma_mask/consistent_dma_mask() function. > > remove pci_save_state() in probe function. > > rename driver to INTEL_FPGA_DFL_PCI and intel-dfl-pci.c to indicate > > this driver supports Intel FPGA PCI devices which implement DFL. > > improve Kconfig description for INTEL_FPGA_DFL_PCI > > v4: rename to FPGA_DFL_PCI (dfl-pci.c) for better reuse. > > fix SPDX license issue. > > --- > > drivers/fpga/Kconfig | 15 ++ > > drivers/fpga/Makefile | 3 ++ > > drivers/fpga/dfl-pci.c | 127 > > + > > 3 files changed, 145 insertions(+) > > create mode 100644 drivers/fpga/dfl-pci.c > > > > diff --git a/drivers/fpga/Kconfig b/drivers/fpga/Kconfig > > index 01ad31f..87f3d44 100644 > > --- a/drivers/fpga/Kconfig > > +++ b/drivers/fpga/Kconfig > > @@ -140,4 +140,19 @@ config FPGA_DFL > > Gate Array (FPGA) solutions which implement Device Feature List. > > It provides enumeration APIs, and feature device infrastructure. > > > > +config FPGA_DFL_PCI > > + tristate "FPGA Device Feature List (DFL) PCIe Device Driver" > > + depends on PCI && FPGA_DFL > > + help > > + Select this option to enable PCIe driver for PCIe based > > + Field-Programmable Gate Array (FPGA) solutions which implemented > > + the Device Feature List (DFL). This driver provides interfaces > > + for userspace applications to configure, enumerate, open and access > > + FPGA accelerators on the FPGA DFL devices, enables system level > > + management functions such as FPGA partial reconfiguration, power > > + management, and virtualization with DFL framework and DFL feature > > + device drivers. > > + > > + To compile this as a module, choose M here. > > + > > endif # FPGA > > diff --git a/drivers/fpga/Makefile b/drivers/fpga/Makefile > > index c4c62b9..4375630 100644 > > --- a/drivers/fpga/Makefile > > +++ b/drivers/fpga/Makefile > > @@ -30,3 +30,6 @@ obj-$(CONFIG_OF_FPGA_REGION) += > > of-fpga-region.o > > > > # FPGA Device Feature List Support > > obj-$(CONFIG_FPGA_DFL) += dfl.o > > + > > +# Drivers for FPGAs which implement DFL > > +obj-$(CONFIG_FPGA_DFL_PCI) += dfl-pci.o > > diff --git a/drivers/fpga/dfl-pci.c b/drivers/fpga/dfl-pci.c > > new file mode 100644 > > index 000..d91ea42 > > --- /dev/null > > +++ b/drivers/fpga/dfl-pci.c > > @@ -0,0 +1,127 @@ > > +// SPDX-License-Identifier: GPL-2.0 > > +/* > > + * Driver for FPGA Device Feature List (DFL) PCIe device > > + * > > + * Copyright (C) 2017 Intel Corporation, Inc. > > + * > > + * Authors: > > + * Zhang Yi > > + * Xiao Guangrong > > + * Joseph Grecco > > + * Enno Luebbers > > + * Tim Whisonant > > + * Ananda Ravuri > > + * Henry Mitchel > > + */ > > + > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > +#include > > + > > +#define DRV_VERSION"0.8" > > +#define DRV_NAME "dfl-pci" > > + > > +/* PCI Device ID */ > > +#define PCIE_DEVICE_ID_PF_INT_5_X 0xBCBD > > +#define PCIE_DEVICE_ID_PF_INT_6_X 0xBCC0 > > +#define PCIE_DEVICE_ID_PF_DSC_1_X 0x09C4 > > +/* VF Device */ > > +#define PCIE_DEVICE_ID_VF_INT_5_X 0xBCBF > > +#define PCIE_DEVICE_ID_VF_INT_6_X 0xBCC1 > > +#define PCIE_DEVICE_ID_VF_DSC_1_X 0x09C5 > > + > > +static struct pci_device_id cci_pcie_id_tbl[] = { > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_INT_5_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_INT_5_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_INT_6_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_INT_6_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_PF_DSC_1_X),}, > > + {PCI_DEVICE(PCI_VENDOR_ID_INTEL, PCIE_DEVICE_ID_VF_DSC_1_X),}, > > + {0,} > > +}; > > +MODULE_DEVICE_TABLE(pci, cci_pcie_id_tbl); > > + > > +static > > +int cci_pci_probe(struct pci_dev *pcidev, const struct pci_device_id > > *pcidevid)
Re: [PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
On 16-03-18, 09:38, Rajendra Nayak wrote: > Add rpmpd device node and its OPP table > > Signed-off-by: Rajendra Nayak > Signed-off-by: Viresh Kumar > --- > arch/arm64/boot/dts/qcom/msm8996.dtsi | 46 > +++ > 1 file changed, 46 insertions(+) > > diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi > b/arch/arm64/boot/dts/qcom/msm8996.dtsi > index 0a6f7952bbb1..43757a078146 100644 > --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi > +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi > @@ -297,6 +297,52 @@ > #clock-cells = <1>; > }; > > + rpmpd: qcom,rpmpd { > + compatible = "qcom,rpmpd-msm8996"; > + #power-domain-cells = <1>; > + operating-points-v2 = <&rpmpd_opp_table>, /* cx > */ > + <&rpmpd_opp_table>, /* > cx_ao */ > + <&rpmpd_opp_table>, /* > cx_vfc */ > + <&rpmpd_opp_table>, /* mx > */ > + <&rpmpd_opp_table>, /* > mx_ao */ > + <&rpmpd_opp_table>, /* > sscx */ > + <&rpmpd_opp_table>; /* > sscx_vfc */ > + }; > + > + rpmpd_opp_table: opp-table { > + compatible = "operating-points-v2", > "operating-points-v2-qcom"; > + > + rpmpd_opp1: opp@1 { > + opp-hz = /bits/ 64 <1>; Actually this (magic values) isn't allowed right now. I will send a patchset to make this property optional later on separately (once the other series is accepted). > + qcom,level = <1>; > + }; > + > + rpmpd_opp2: opp@2 { > + opp-hz = /bits/ 64 <2>; > + qcom,level = <2>; > + }; > + > + rpmpd_opp3: opp@3 { > + opp-hz = /bits/ 64 <3>; > + qcom,level = <3>; > + }; > + > + rpmpd_opp4: opp@4 { > + opp-hz = /bits/ 64 <4>; > + qcom,level = <4>; > + }; > + > + rpmpd_opp5: opp@5 { > + opp-hz = /bits/ 64 <5>; > + qcom,level = <5>; > + }; > + > + rpmpd_opp6: opp@6 { > + opp-hz = /bits/ 64 <6>; > + qcom,level = <6>; > + }; > + }; > + > pm8994-regulators { > compatible = "qcom,rpm-pm8994-regulators"; > Everything else is fine. After you remove the opp-hz property from this table: Acked-by: Viresh Kumar -- viresh
Re: [PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
On 16-03-18, 09:38, Rajendra Nayak wrote: > With genpd now expecting powerdomain drivers supporting performance > state to support get/set performance state callbacks, add support for it > in the rpmpd driver. > > Signed-off-by: Rajendra Nayak > Signed-off-by: Viresh Kumar > --- > drivers/soc/qcom/rpmpd.c | 42 ++ > 1 file changed, 42 insertions(+) > > diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c > index c8754d867c33..4058c5b450c6 100644 > --- a/drivers/soc/qcom/rpmpd.c > +++ b/drivers/soc/qcom/rpmpd.c > @@ -14,6 +14,7 @@ > #include > #include > #include > +#include > #include > > #include > @@ -29,6 +30,8 @@ > #define KEY_ENABLE 0x6e657773 /* swen */ > #define KEY_FLOOR_CORNER 0x636676 /* vfc */ > > +#define MAX_RPMPD_STATE 6 > + > #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) > \ > static struct rpmpd _platform##_##_active; \ > static struct rpmpd _platform##_##_name = { \ > @@ -222,6 +225,43 @@ static int rpmpd_power_off(struct generic_pm_domain > *domain) > return ret; > } > > +static int rpmpd_set_performance(struct generic_pm_domain *domain, > + unsigned int state) > +{ > + int ret = 0; > + struct rpmpd *pd = domain_to_rpmpd(domain); > + > + mutex_lock(&rpmpd_lock); > + > + if (state > MAX_RPMPD_STATE) > + goto out; > + > + pd->corner = state; > + > + if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) > + goto out; > + > + ret = rpmpd_aggregate_corner(pd); > + > +out: > + mutex_unlock(&rpmpd_lock); > + > + return ret; > +} > + > +static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, > + struct dev_pm_opp *opp) > +{ > + struct device_node *np; > + unsigned int corner = 0; > + > + np = dev_pm_opp_get_of_node(opp); > + of_property_read_u32(np, "qcom,level", &corner); Don't we want to error out or do something else in case of an error ? > + of_node_put(np); > + > + return corner; > +} > + > static int rpmpd_probe(struct platform_device *pdev) > { > int i; > @@ -259,6 +299,8 @@ static int rpmpd_probe(struct platform_device *pdev) > rpmpds[i]->rpm = rpm; > rpmpds[i]->pd.power_off = rpmpd_power_off; > rpmpds[i]->pd.power_on = rpmpd_power_on; > + rpmpds[i]->pd.set_performance_state = rpmpd_set_performance; > + rpmpds[i]->pd.get_performance_state = rpmpd_get_performance; > pm_genpd_init(&rpmpds[i]->pd, NULL, true); > > data->domains[i] = &rpmpds[i]->pd; Acked-by: Viresh Kumar -- viresh
Re: [PATCH 3/7] dt-bindings: opp: Introduce qcom-opp bindings
On 16-03-18, 09:38, Rajendra Nayak wrote: > On Qualcomm platforms, an OPP node needs to describe an > additional level/corner value that is then communicated to > a remote microprocessor by the CPU, which then takes some > actions (like adjusting voltage values across various rails) > based on the value passed. > > Describe these bindings in the qcom-opp bindings document. > > Signed-off-by: Rajendra Nayak > --- > Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 > ++ > 1 file changed, 25 insertions(+) > create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt > > diff --git a/Documentation/devicetree/bindings/opp/qcom-opp.txt > b/Documentation/devicetree/bindings/opp/qcom-opp.txt > new file mode 100644 > index ..56fe87751881 > --- /dev/null > +++ b/Documentation/devicetree/bindings/opp/qcom-opp.txt > @@ -0,0 +1,25 @@ > +Qualcomm OPP bindings to descibe OPP nodes with corner/level values > + > +OPP tables for devices on qualcomm platforms require an additional > +platform specific corner/level value to be specified. > +This value is passed on to the RPM (Resource Power Manager) by > +the CPU, which then takes the necessary actions to set a voltage > +rail to a appropriate voltage based on the value passed. > + > +The bindings are based on top of the operating-points-v2 bindings > +described in Documentation/devicetree/bindings/opp/opp.txt > +Additional properties are described below. > + > +* OPP Table Node > + > +Required properties: > +- compatible: Allow OPPs to express their compatibility. It should be: > + "operating-points-v2-qcom" > + > +* OPP Node > + > +Required properties: > +- qcom,level: On Qualcomm platforms an OPP node can describe a positive value > +representing a corner/level thats comminicated with a remote microprocessor > +(Usually called the RPM) which then translates it into a certain voltage on > +a voltage rail. Acked-by: Viresh Kumar -- viresh
[PATCH v2] rbd: Remove VLA usage
As part of the effort to remove VLAs from the kernel[1], this moves the literal values into the stack array calculation instead of using a variable for the sizing. The resulting size can be found from sizeof(buf). [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Kyle Spiers --- drivers/block/rbd.c | 8 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/drivers/block/rbd.c b/drivers/block/rbd.c index 8e40da0..0e94e1f 100644 --- a/drivers/block/rbd.c +++ b/drivers/block/rbd.c @@ -3100,8 +3100,8 @@ static int __rbd_notify_op_lock(struct rbd_device *rbd_dev, { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; struct rbd_client_id cid = rbd_get_cid(rbd_dev); - int buf_size = 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN; - char buf[buf_size]; + char buf[4 + 4 + 8 + 8 + CEPH_ENCODING_START_BLK_LEN]; + int buf_size = sizeof(buf) void *p = buf; dout("%s rbd_dev %p notify_op %d\n", __func__, rbd_dev, notify_op); @@ -3619,8 +3619,8 @@ static void __rbd_acknowledge_notify(struct rbd_device *rbd_dev, u64 notify_id, u64 cookie, s32 *result) { struct ceph_osd_client *osdc = &rbd_dev->rbd_client->client->osdc; - int buf_size = 4 + CEPH_ENCODING_START_BLK_LEN; - char buf[buf_size]; + char buf[4 + CEPH_ENCODING_START_BLK_LEN]; + int buf_size = sizeof(buf); int ret; if (result) { -- 2.7.4
[PATCH v5 0/2] Remove false-positive VLAs when using max()
Patch 1 adds const_max_t(), patch 2 uses it in all the places max() was used for stack arrays. Commit log from patch 1: ---snip--- kernel.h: Introduce const_max_t() for VLA removal In the effort to remove all VLAs from the kernel[1], it is desirable to build with -Wvla. However, this warning is overly pessimistic, in that it is only happy with stack array sizes that are declared as constant expressions, and not constant values. One case of this is the evaluation of the max() macro which, due to its construction, ends up converting constant expression arguments into a constant value result. Attempts to adjust the behavior of max() ran afoul of version-dependent compiler behavior[2]. To work around this and still gain -Wvla coverage, this patch introduces a new macro, const_max_t(), for use in these cases of stack array size declaration, where the constant expressions are retained. Since this means losing the double-evaluation protections of the max() macro, this macro is designed to explicitly fail if used on non-constant arguments. Older compilers will fail with the unhelpful message: error: first argument to ‘__builtin_choose_expr’ not a constant Newer compilers will fail with a hopefully more helpful message: error: call to ‘__error_non_const_arg’ declared with attribute error: const_max_t() used with non-constant expression To gain the ability to compare differing types, the desired type must be explicitly declared, as with the existing max_t() macro. This is needed when comparing different enum types and to allow things like: int foo[const_max_t(size_t, 6, sizeof(something))]; [1] https://lkml.org/lkml/2018/3/7/621 [2] https://lkml.org/lkml/2018/3/10/170 ---eol--- Hopefully this reads well as a summary from all the things that got tried. I've tested this on allmodconfig builds with gcc 4.4.4 and 6.3.0, with and without -Wvla. -Kees v5: explicit type argument v4: forced size_t type
[PATCH v5 2/2] Remove false-positive VLAs when using max()
As part of removing VLAs from the kernel[1], we want to build with -Wvla, but it is overly pessimistic and only accepts constant expressions for stack array sizes, instead of also constant values. The max() macro triggers the warning, so this refactors these uses of max() to use the new const_max() instead. [1] https://lkml.org/lkml/2018/3/7/621 Signed-off-by: Kees Cook --- drivers/input/touchscreen/cyttsp4_core.c | 2 +- fs/btrfs/tree-checker.c | 3 ++- lib/vsprintf.c | 5 +++-- net/ipv4/proc.c | 8 net/ipv6/proc.c | 11 +-- 5 files changed, 15 insertions(+), 14 deletions(-) diff --git a/drivers/input/touchscreen/cyttsp4_core.c b/drivers/input/touchscreen/cyttsp4_core.c index 727c3232517c..7fb9bd48e41c 100644 --- a/drivers/input/touchscreen/cyttsp4_core.c +++ b/drivers/input/touchscreen/cyttsp4_core.c @@ -868,7 +868,7 @@ static void cyttsp4_get_mt_touches(struct cyttsp4_mt_data *md, int num_cur_tch) struct cyttsp4_touch tch; int sig; int i, j, t = 0; - int ids[max(CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; + int ids[const_max_t(size_t, CY_TMA1036_MAX_TCH, CY_TMA4XX_MAX_TCH)]; memset(ids, 0, si->si_ofs.tch_abs[CY_TCH_T].max * sizeof(int)); for (i = 0; i < num_cur_tch; i++) { diff --git a/fs/btrfs/tree-checker.c b/fs/btrfs/tree-checker.c index c3c8d48f6618..d83244e3821f 100644 --- a/fs/btrfs/tree-checker.c +++ b/fs/btrfs/tree-checker.c @@ -341,7 +341,8 @@ static int check_dir_item(struct btrfs_root *root, */ if (key->type == BTRFS_DIR_ITEM_KEY || key->type == BTRFS_XATTR_ITEM_KEY) { - char namebuf[max(BTRFS_NAME_LEN, XATTR_NAME_MAX)]; + char namebuf[const_max_t(size_t, BTRFS_NAME_LEN, +XATTR_NAME_MAX)]; read_extent_buffer(leaf, namebuf, (unsigned long)(di + 1), name_len); diff --git a/lib/vsprintf.c b/lib/vsprintf.c index d7a708f82559..12ff57a36171 100644 --- a/lib/vsprintf.c +++ b/lib/vsprintf.c @@ -744,8 +744,9 @@ char *resource_string(char *buf, char *end, struct resource *res, #define FLAG_BUF_SIZE (2 * sizeof(res->flags)) #define DECODED_BUF_SIZE sizeof("[mem - 64bit pref window disabled]") #define RAW_BUF_SIZE sizeof("[mem - flags 0x]") - char sym[max(2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, -2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; + char sym[const_max_t(size_t, +2*RSRC_BUF_SIZE + DECODED_BUF_SIZE, +2*RSRC_BUF_SIZE + FLAG_BUF_SIZE + RAW_BUF_SIZE)]; char *p = sym, *pend = sym + sizeof(sym); int decode = (fmt[0] == 'R') ? 1 : 0; diff --git a/net/ipv4/proc.c b/net/ipv4/proc.c index dc5edc8f7564..7f5c3b40dac9 100644 --- a/net/ipv4/proc.c +++ b/net/ipv4/proc.c @@ -46,7 +46,7 @@ #include #include -#define TCPUDP_MIB_MAX max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX) +#define TCPUDP_MIB_MAX const_max_t(size_t, UDP_MIB_MAX, TCP_MIB_MAX) /* * Report socket allocation statistics [m...@utu.fi] @@ -404,7 +404,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) struct net *net = seq->private; int i; - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, sizeof(buff)); seq_puts(seq, "\nTcp:"); for (i = 0; snmp4_tcp_list[i].name; i++) @@ -421,7 +421,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) seq_printf(seq, " %lu", buff[i]); } - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, sizeof(buff)); snmp_get_cpu_field_batch(buff, snmp4_udp_list, net->mib.udp_statistics); @@ -432,7 +432,7 @@ static int snmp_seq_show_tcp_udp(struct seq_file *seq, void *v) for (i = 0; snmp4_udp_list[i].name; i++) seq_printf(seq, " %lu", buff[i]); - memset(buff, 0, TCPUDP_MIB_MAX * sizeof(unsigned long)); + memset(buff, 0, sizeof(buff)); /* the UDP and UDP-Lite MIBs are the same */ seq_puts(seq, "\nUdpLite:"); diff --git a/net/ipv6/proc.c b/net/ipv6/proc.c index b67814242f78..b68c233de296 100644 --- a/net/ipv6/proc.c +++ b/net/ipv6/proc.c @@ -30,10 +30,9 @@ #include #include -#define MAX4(a, b, c, d) \ - max_t(u32, max_t(u32, a, b), max_t(u32, c, d)) -#define SNMP_MIB_MAX MAX4(UDP_MIB_MAX, TCP_MIB_MAX, \ - IPSTATS_MIB_MAX, ICMP_MIB_MAX) +#define SNMP_MIB_MAX const_max_t(u32, \ + const_max_t(u32, UDP_MIB_MAX, TCP_MIB_MAX), \ + const_max_t(u32, IPSTATS_MIB_MAX, ICMP_MIB_MAX)) static int sockstat6_seq_show(struct seq_file *seq, voi
[PATCH v5 1/2] kernel.h: Introduce const_max_t() for VLA removal
In the effort to remove all VLAs from the kernel[1], it is desirable to build with -Wvla. However, this warning is overly pessimistic, in that it is only happy with stack array sizes that are declared as constant expressions, and not constant values. One case of this is the evaluation of the max() macro which, due to its construction, ends up converting constant expression arguments into a constant value result. Attempts to adjust the behavior of max() ran afoul of version-dependent compiler behavior[2]. To work around this and still gain -Wvla coverage, this patch introduces a new macro, const_max_t(), for use in these cases of stack array size declaration, where the constant expressions are retained. Since this means losing the double-evaluation protections of the max() macro, this macro is designed to explicitly fail if used on non-constant arguments. Older compilers will fail with the unhelpful message: error: first argument to ‘__builtin_choose_expr’ not a constant Newer compilers will fail with a hopefully more helpful message: error: call to ‘__error_non_const_arg’ declared with attribute error: const_max_t() used with non-constant expression To gain the ability to compare differing types, the desired type must be explicitly declared, as with the existing max_t() macro. This is needed when comparing different enum types and to allow things like: int foo[const_max_t(size_t, 6, sizeof(something))]; [1] https://lkml.org/lkml/2018/3/7/621 [2] https://lkml.org/lkml/2018/3/10/170 Signed-off-by: Kees Cook --- include/linux/kernel.h | 19 +++ 1 file changed, 19 insertions(+) diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 3fd291503576..e14531781568 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h @@ -820,6 +820,25 @@ static inline void ftrace_dump(enum ftrace_dump_mode oops_dump_mode) { } x, y) /** + * const_max_t - return maximum of two compile-time constant expressions + * @type: type used for evaluation + * @x: first compile-time constant expression + * @y: second compile-time constant expression + * + * This has no multi-evaluation defenses, and must only ever be used with + * compile-time constant expressions (for example when calculating a stack + * array size). + */ +size_t __error_non_const_arg(void) \ +__compiletime_error("const_max_t() used with non-constant expression"); +#define const_max_t(type, x, y)\ + __builtin_choose_expr(__builtin_constant_p(x) &&\ + __builtin_constant_p(y), \ + (type)(x) > (type)(y) ? \ + (type)(x) : (type)(y), \ + __error_non_const_arg()) + +/** * min3 - return minimum of three values * @x: first value * @y: second value -- 2.7.4
Re: [PATCH][RFC] kernel.h: provide array iterator
On Thu, Mar 15, 2018 at 3:00 AM, Kieran Bingham wrote: > Simplify array iteration with a helper to iterate each entry in an array. > Utilise the existing ARRAY_SIZE macro to identify the length of the array > and pointer arithmetic to process each item as a for loop. > > Signed-off-by: Kieran Bingham > --- > include/linux/kernel.h | 10 ++ > 1 file changed, 10 insertions(+) > > The use of static arrays to store data is a common use case throughout the > kernel. Along with that is the obvious need to iterate that data. > > In fact there are just shy of 5000 instances of iterating a static array: > git grep "for .*ARRAY_SIZE" | wc -l > 4943 I suspect the main question is "Does this macro make the code easier to read?" I think it does, and we have other kinds of iterators like this in the kernel already. Would it be worth building a Coccinelle script to do the 5000 replacements? -Kees > > When working on the UVC driver - I found that I needed to split one such > iteration into two parts, and at the same time felt that this could be > refactored to be cleaner / easier to read. > > I do however worry that this simple short patch might not be desired or could > also be heavily bikeshedded due to it's potential wide spread use (though > perhaps that would be a good thing to have more users) ... but here it is, > along with an example usage below which is part of a separate series. > > The aim is to simplify iteration on static arrays, in the same way that we > have > iterators for lists. The use of the ARRAY_SIZE macro, provides all the > protections given by "__must_be_array(arr)" to this macro too. > > Regards > > Kieran > > = > Example Usage from a pending UVC development: > > +#define for_each_uvc_urb(uvc_urb, uvc_streaming) \ > + for_each_array_element(uvc_urb, uvc_streaming->uvc_urb) > > /* > * Uninitialize isochronous/bulk URBs and free transfer buffers. > */ > static void uvc_uninit_video(struct uvc_streaming *stream, int free_buffers) > { > - struct urb *urb; > - unsigned int i; > + struct uvc_urb *uvc_urb; > > uvc_video_stats_stop(stream); > > - for (i = 0; i < UVC_URBS; ++i) { > - struct uvc_urb *uvc_urb = &stream->uvc_urb[i]; > + for_each_uvc_urb(uvc_urb, stream) > + usb_kill_urb(uvc_urb->urb); > > - urb = uvc_urb->urb; > - if (urb == NULL) > - continue; > + flush_workqueue(stream->async_wq); > > - usb_kill_urb(urb); > - usb_free_urb(urb); > + for_each_uvc_urb(uvc_urb, stream) { > + usb_free_urb(uvc_urb->urb); > uvc_urb->urb = NULL; > } > > if (free_buffers) > uvc_free_urb_buffers(stream); > } > = > > > > > diff --git a/include/linux/kernel.h b/include/linux/kernel.h > index ce51455e2adf..95d7dae248b7 100644 > --- a/include/linux/kernel.h > +++ b/include/linux/kernel.h > @@ -70,6 +70,16 @@ > */ > #define ARRAY_SIZE(arr) (sizeof(arr) / sizeof((arr)[0]) + > __must_be_array(arr)) > > +/** > + * for_each_array_element - Iterate all items in an array > + * @elem: pointer of array type for iteration cursor > + * @array: array to be iterated > + */ > +#define for_each_array_element(elem, array) \ > + for (elem = &(array)[0]; \ > +elem < &(array)[ARRAY_SIZE(array)]; \ > +++elem) > + > #define u64_to_user_ptr(x) ( \ > { \ > typecheck(u64, x); \ > -- > 2.7.4 > -- Kees Cook Pixel Security
Re: [PATCH v10] mmc: Export host capabilities to debugfs.
On Thursday 15 March 2018 05:59 PM, Ulf Hansson wrote: > On 15 March 2018 at 11:26, Andy Shevchenko > wrote: >> On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: >>> On 13 March 2018 at 06:10, Harish Jenny K N >>> wrote: >>> Honestly, I don't like this, but maybe other people do, then I am fine >>> with this approach. >>> >>> If were to decide, I would just rather print the caps field in a >>> hexadecimal bit form and leave the translation to the user. >> A compromise would be to print both: >> >> 0x\n >> Description of each enabled field, one per line >> >> >> Another format would be: >> >> Bit XX: Description of a field > If we were to print the description, there is no point in printing the > bits in hex. Or is it? Yes. I also do not see the use of printing hex value if we are printing the description. > > As I said, if you and other folkz thinks this is valuable, then I am > fine as well. Just saying, it's not my preferred option. > > I just want to inform that the idea of printing the description came after discussion in https://www.spinics.net/lists/linux-mmc/msg48246.html, where it was decided adding utility in mmc-utils was not going to work ( reason: We may very well be changing the bit offsets for the caps and caps2 in the mmc kernel header, keeping a copy of them is not a good idea. It's just a matter of *when* it will break). On Thu, 2018-03-15 at 11:12 +0100, Ulf Hansson wrote: > If were to decide, I would just rather print the caps field in a hexadecimal > bit form and leave the translation to the user. I think translation becomes difficult for the above reason and hence I would prefer printing the description. Note: Printing values in Hex was the original idea and it is also available in https://www.spinics.net/lists/linux-mmc/msg48213.html just in case if it is required. Thanks & Regards, Harish Jenny K N
[PATCH 4/7] soc: qcom: rpmpd: Add support for get/set performance state
With genpd now expecting powerdomain drivers supporting performance state to support get/set performance state callbacks, add support for it in the rpmpd driver. Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- drivers/soc/qcom/rpmpd.c | 42 ++ 1 file changed, 42 insertions(+) diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index c8754d867c33..4058c5b450c6 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -14,6 +14,7 @@ #include #include #include +#include #include #include @@ -29,6 +30,8 @@ #define KEY_ENABLE 0x6e657773 /* swen */ #define KEY_FLOOR_CORNER 0x636676 /* vfc */ +#define MAX_RPMPD_STATE6 + #define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) \ static struct rpmpd _platform##_##_active; \ static struct rpmpd _platform##_##_name = { \ @@ -222,6 +225,43 @@ static int rpmpd_power_off(struct generic_pm_domain *domain) return ret; } +static int rpmpd_set_performance(struct generic_pm_domain *domain, +unsigned int state) +{ + int ret = 0; + struct rpmpd *pd = domain_to_rpmpd(domain); + + mutex_lock(&rpmpd_lock); + + if (state > MAX_RPMPD_STATE) + goto out; + + pd->corner = state; + + if (!pd->enabled && (pd->key != KEY_FLOOR_CORNER)) + goto out; + + ret = rpmpd_aggregate_corner(pd); + +out: + mutex_unlock(&rpmpd_lock); + + return ret; +} + +static unsigned int rpmpd_get_performance(struct generic_pm_domain *genpd, + struct dev_pm_opp *opp) +{ + struct device_node *np; + unsigned int corner = 0; + + np = dev_pm_opp_get_of_node(opp); + of_property_read_u32(np, "qcom,level", &corner); + of_node_put(np); + + return corner; +} + static int rpmpd_probe(struct platform_device *pdev) { int i; @@ -259,6 +299,8 @@ static int rpmpd_probe(struct platform_device *pdev) rpmpds[i]->rpm = rpm; rpmpds[i]->pd.power_off = rpmpd_power_off; rpmpds[i]->pd.power_on = rpmpd_power_on; + rpmpds[i]->pd.set_performance_state = rpmpd_set_performance; + rpmpds[i]->pd.get_performance_state = rpmpd_get_performance; pm_genpd_init(&rpmpds[i]->pd, NULL, true); data->domains[i] = &rpmpds[i]->pd; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 0/7] Add powerdomain driver for corners on msm8996
With performance state support for genpd merged, and with some more patches to add support for them in the OPP layer [1] under discussion, this is an effort to model a powerdomain driver to communicate corner/level values for qualcomm platforms to RPM (Remote Power Manager) This series adds data specific to msm8996 and is tested on the db820c. We also modify mmc as one of the first devices to move to using an OPP table and vote on corners using the performance state infrastructure. [1] https://lwn.net/Articles/742136/ Rajendra Nayak (6): soc: qcom: rpmpd: Add a powerdomain driver to model corners dt-bindings: opp: Introduce qcom-opp bindings soc: qcom: rpmpd: Add support for get/set performance state arm64: dts: msm8996: Add rpmpd device node mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state soc: qcom: rpmpd: Add a max vote on all corners at init Viresh Kumar (1): PM / OPP: Add dev_pm_opp_get_of_node() Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 ++ .../devicetree/bindings/power/qcom,rpmpd.txt | 14 + arch/arm64/boot/dts/qcom/msm8996.dtsi | 87 + drivers/clk/qcom/gcc-msm8996.c | 8 +- drivers/mmc/host/sdhci-msm.c | 57 +++- drivers/opp/of.c | 19 ++ drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 350 + include/linux/pm_opp.h | 5 + 10 files changed, 561 insertions(+), 14 deletions(-) create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt create mode 100644 drivers/soc/qcom/rpmpd.c -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 3/7] dt-bindings: opp: Introduce qcom-opp bindings
On Qualcomm platforms, an OPP node needs to describe an additional level/corner value that is then communicated to a remote microprocessor by the CPU, which then takes some actions (like adjusting voltage values across various rails) based on the value passed. Describe these bindings in the qcom-opp bindings document. Signed-off-by: Rajendra Nayak --- Documentation/devicetree/bindings/opp/qcom-opp.txt | 25 ++ 1 file changed, 25 insertions(+) create mode 100644 Documentation/devicetree/bindings/opp/qcom-opp.txt diff --git a/Documentation/devicetree/bindings/opp/qcom-opp.txt b/Documentation/devicetree/bindings/opp/qcom-opp.txt new file mode 100644 index ..56fe87751881 --- /dev/null +++ b/Documentation/devicetree/bindings/opp/qcom-opp.txt @@ -0,0 +1,25 @@ +Qualcomm OPP bindings to descibe OPP nodes with corner/level values + +OPP tables for devices on qualcomm platforms require an additional +platform specific corner/level value to be specified. +This value is passed on to the RPM (Resource Power Manager) by +the CPU, which then takes the necessary actions to set a voltage +rail to a appropriate voltage based on the value passed. + +The bindings are based on top of the operating-points-v2 bindings +described in Documentation/devicetree/bindings/opp/opp.txt +Additional properties are described below. + +* OPP Table Node + +Required properties: +- compatible: Allow OPPs to express their compatibility. It should be: + "operating-points-v2-qcom" + +* OPP Node + +Required properties: +- qcom,level: On Qualcomm platforms an OPP node can describe a positive value +representing a corner/level thats comminicated with a remote microprocessor +(Usually called the RPM) which then translates it into a certain voltage on +a voltage rail. -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 5/7] arm64: dts: msm8996: Add rpmpd device node
Add rpmpd device node and its OPP table Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- arch/arm64/boot/dts/qcom/msm8996.dtsi | 46 +++ 1 file changed, 46 insertions(+) diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi index 0a6f7952bbb1..43757a078146 100644 --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi @@ -297,6 +297,52 @@ #clock-cells = <1>; }; + rpmpd: qcom,rpmpd { + compatible = "qcom,rpmpd-msm8996"; + #power-domain-cells = <1>; + operating-points-v2 = <&rpmpd_opp_table>, /* cx */ + <&rpmpd_opp_table>, /* cx_ao */ + <&rpmpd_opp_table>, /* cx_vfc */ + <&rpmpd_opp_table>, /* mx */ + <&rpmpd_opp_table>, /* mx_ao */ + <&rpmpd_opp_table>, /* sscx */ + <&rpmpd_opp_table>; /* sscx_vfc */ + }; + + rpmpd_opp_table: opp-table { + compatible = "operating-points-v2", "operating-points-v2-qcom"; + + rpmpd_opp1: opp@1 { + opp-hz = /bits/ 64 <1>; + qcom,level = <1>; + }; + + rpmpd_opp2: opp@2 { + opp-hz = /bits/ 64 <2>; + qcom,level = <2>; + }; + + rpmpd_opp3: opp@3 { + opp-hz = /bits/ 64 <3>; + qcom,level = <3>; + }; + + rpmpd_opp4: opp@4 { + opp-hz = /bits/ 64 <4>; + qcom,level = <4>; + }; + + rpmpd_opp5: opp@5 { + opp-hz = /bits/ 64 <5>; + qcom,level = <5>; + }; + + rpmpd_opp6: opp@6 { + opp-hz = /bits/ 64 <6>; + qcom,level = <6>; + }; + }; + pm8994-regulators { compatible = "qcom,rpm-pm8994-regulators"; -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 6/7] mmc: sdhci-msm: Adapt the driver to use OPPs to set clocks/performance state
SDHCI driver needs to set a performance state along with scaling its clocks. Modify the driver to use the newly introduced powerdomain performance state based OPPs to scale clocks as well as set an appropriate powerdomain performance state. The patch also adds OPPs for sdhci device on msm8996. On platforms which don't specify an OPP table the driver falls back to just setting the clock rates (as is done today) Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar Cc: linux-...@vger.kernel.org --- arch/arm64/boot/dts/qcom/msm8996.dtsi | 41 + drivers/clk/qcom/gcc-msm8996.c| 8 ++--- drivers/mmc/host/sdhci-msm.c | 57 +-- 3 files changed, 92 insertions(+), 14 deletions(-) diff --git a/arch/arm64/boot/dts/qcom/msm8996.dtsi b/arch/arm64/boot/dts/qcom/msm8996.dtsi index 43757a078146..e880a8433596 100644 --- a/arch/arm64/boot/dts/qcom/msm8996.dtsi +++ b/arch/arm64/boot/dts/qcom/msm8996.dtsi @@ -569,8 +569,49 @@ <&gcc GCC_SDCC2_APPS_CLK>, <&xo_board>; bus-width = <4>; + power-domains = <&rpmpd 0>; + operating-points-v2 = <&sdhc_opp_table>; }; + sdhc_opp_table: opp_table { + compatible = "operating-points-v2"; + + opp@144000 { + opp-hz = /bits/ 64 <144000>; + required-opp = <&rpmpd_opp1>; + }; + + opp@400 { + opp-hz = /bits/ 64 <40>; + required-opp = <&rpmpd_opp1>; + }; + + opp@2000 { + opp-hz = /bits/ 64 <2000>; + required-opp = <&rpmpd_opp2>; + }; + + opp@2500 { + opp-hz = /bits/ 64 <2500>; + required-opp = <&rpmpd_opp2>; + }; + + opp@5000 { + opp-hz = /bits/ 64 <5000>; + required-opp = <&rpmpd_opp2>; + }; + + opp@1 { + opp-hz = /bits/ 64 <1>; + required-opp = <&rpmpd_opp3>; + }; + + opp@2 { + opp-hz = /bits/ 64 <2>; + required-opp = <&rpmpd_opp3>; + }; + }; + msmgpio: pinctrl@101 { compatible = "qcom,msm8996-pinctrl"; reg = <0x0101 0x30>; diff --git a/drivers/clk/qcom/gcc-msm8996.c b/drivers/clk/qcom/gcc-msm8996.c index 5d7451209206..fc90dbbdcd70 100644 --- a/drivers/clk/qcom/gcc-msm8996.c +++ b/drivers/clk/qcom/gcc-msm8996.c @@ -464,7 +464,7 @@ static struct clk_rcg2 sdcc1_apps_clk_src = { .name = "sdcc1_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4_gpll0_early_div, .num_parents = 4, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_ops, }, }; @@ -509,7 +509,7 @@ static struct clk_rcg2 sdcc2_apps_clk_src = { .name = "sdcc2_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4, .num_parents = 3, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_ops, }, }; @@ -523,7 +523,7 @@ static struct clk_rcg2 sdcc3_apps_clk_src = { .name = "sdcc3_apps_clk_src", .parent_names = gcc_xo_gpll0_gpll4, .num_parents = 3, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_ops, }, }; @@ -547,7 +547,7 @@ static struct clk_rcg2 sdcc4_apps_clk_src = { .name = "sdcc4_apps_clk_src", .parent_names = gcc_xo_gpll0, .num_parents = 2, - .ops = &clk_rcg2_floor_ops, + .ops = &clk_rcg2_ops, }, }; diff --git a/drivers/mmc/host/sdhci-msm.c b/drivers/mmc/host/sdhci-msm.c index c283291db705..8e6abc0a23c7 100644 --- a/drivers/mmc/host/sdhci-msm.c +++ b/drivers/mmc/host/sdhci-msm.c @@ -21,6 +21,7 @@ #include #include #include +#include #include "sdhci-pltfm.h" @@ -137,6 +138,7 @@ struct sdhci_msm_host { struct clk *bus_clk;/* SDHC bus voter clock */ struct clk *xo_clk; /* TCXO clk needed for FLL feature of cm_dll*/ struct clk_bulk_data bulk_clks[4]; /* core, iface, cal, sleep clocks */ + struct opp_table *opp_table; unsigned long clk_rate; struct mmc_host *mmc; bool use_14lpp_dll_reset; @@ -150,7 +152,7 @@ struct sdhci_m
[PATCH 7/7] soc: qcom: rpmpd: Add a max vote on all corners at init
As we move from no clients/consumers in kernel voting on corners, to *some* voting and some not voting, we might end up in a situation where the clients which remove votes can adversly impact others who still don't have a way to vote. To avoid this situation, have a max vote on all corners at init. This should/can be removed once we have all clients moved to be able to vote/unvote for themselves. Signed-off-by: Rajendra Nayak --- drivers/soc/qcom/rpmpd.c | 9 + 1 file changed, 9 insertions(+) diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c index 4058c5b450c6..ebdcf9398441 100644 --- a/drivers/soc/qcom/rpmpd.c +++ b/drivers/soc/qcom/rpmpd.c @@ -304,6 +304,15 @@ static int rpmpd_probe(struct platform_device *pdev) pm_genpd_init(&rpmpds[i]->pd, NULL, true); data->domains[i] = &rpmpds[i]->pd; + + /* +* Until we have all consumers voting on corners +* just vote the max corner on all PDs +* This should ideally be *removed* once we have +* all (most) consumers being able to vote +*/ + rpmpd_set_performance(&rpmpds[i]->pd, MAX_RPMPD_STATE); + rpmpd_power_on(&rpmpds[i]->pd); } return of_genpd_add_provider_onecell(pdev->dev.of_node, data); -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
[PATCH 2/7] soc: qcom: rpmpd: Add a powerdomain driver to model corners
The powerdomains for corners just pass the performance state set by the consumers to the RPM (Remote Power manager) which then takes care of setting the appropriate voltage on the corresponding rails to meet the performance needs. We add all powerdomain data needed on msm8996 here. This driver can easily be extended by adding data for other qualcomm SoCs as well. Signed-off-by: Rajendra Nayak Signed-off-by: Viresh Kumar --- .../devicetree/bindings/power/qcom,rpmpd.txt | 14 + drivers/soc/qcom/Kconfig | 9 + drivers/soc/qcom/Makefile | 1 + drivers/soc/qcom/rpmpd.c | 299 + 4 files changed, 323 insertions(+) create mode 100644 Documentation/devicetree/bindings/power/qcom,rpmpd.txt create mode 100644 drivers/soc/qcom/rpmpd.c diff --git a/Documentation/devicetree/bindings/power/qcom,rpmpd.txt b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt new file mode 100644 index ..4d7a4a1f054f --- /dev/null +++ b/Documentation/devicetree/bindings/power/qcom,rpmpd.txt @@ -0,0 +1,14 @@ +Qualcomm RPM Powerdomains + +* For RPM powerdomains, we communicate a performance state to RPM +which then translates it into a corresponding voltage on a rail + +Required Properties: + - compatible: Should be one of the following + * qcom,rpmpd-msm8996: RPM Powerdomain for the msm8996 family of SoC + - power-domain-cells: number of cells in power domain specifier + must be 1. + - domain-performance-state: One or more nodes describing the performance-states + supported by the powerdomain. + For domain-performance-state bindings refer to + Documentation/devicetree/bindings/power/power_domain.txt diff --git a/drivers/soc/qcom/Kconfig b/drivers/soc/qcom/Kconfig index e050eb83341d..6e1a0ed7ea3f 100644 --- a/drivers/soc/qcom/Kconfig +++ b/drivers/soc/qcom/Kconfig @@ -55,6 +55,15 @@ config QCOM_RMTFS_MEM Say y here if you intend to boot the modem remoteproc. +config QCOM_RPMPD + tristate "Qualcomm RPM Powerdomain driver" + depends on MFD_QCOM_RPM && QCOM_SMD_RPM + help + QCOM RPM powerdomain driver to support powerdomain with + performance states. The driver communicates a performance state + value to RPM which then translates it into corresponding voltage + for the voltage rail. + config QCOM_SMEM tristate "Qualcomm Shared Memory Manager (SMEM)" depends on ARCH_QCOM diff --git a/drivers/soc/qcom/Makefile b/drivers/soc/qcom/Makefile index dcebf2814e6d..12c48a3ea106 100644 --- a/drivers/soc/qcom/Makefile +++ b/drivers/soc/qcom/Makefile @@ -12,3 +12,4 @@ obj-$(CONFIG_QCOM_SMEM_STATE) += smem_state.o obj-$(CONFIG_QCOM_SMP2P) += smp2p.o obj-$(CONFIG_QCOM_SMSM)+= smsm.o obj-$(CONFIG_QCOM_WCNSS_CTRL) += wcnss_ctrl.o +obj-$(CONFIG_QCOM_RPMPD) += rpmpd.o diff --git a/drivers/soc/qcom/rpmpd.c b/drivers/soc/qcom/rpmpd.c new file mode 100644 index ..c8754d867c33 --- /dev/null +++ b/drivers/soc/qcom/rpmpd.c @@ -0,0 +1,299 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * Copyright (c) 2017-2018, The Linux Foundation. All rights reserved. + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +#define domain_to_rpmpd(domain) container_of(domain, struct rpmpd, pd) + +/* Resource types */ +#define RPMPD_SMPA 0x61706d73 +#define RPMPD_LDOA 0x616f646c + +/* Operation Keys */ +#define KEY_CORNER 0x6e726f63 /* corn */ +#define KEY_ENABLE 0x6e657773 /* swen */ +#define KEY_FLOOR_CORNER 0x636676 /* vfc */ + +#define DEFINE_RPMPD_CORN_SMPA(_platform, _name, _active, r_id) \ + static struct rpmpd _platform##_##_active; \ + static struct rpmpd _platform##_##_name = { \ + .pd = { .name = #_name, }, \ + .peer = &_platform##_##_active, \ + .res_type = RPMPD_SMPA, \ + .res_id = r_id, \ + .key = KEY_CORNER, \ + }; \ + static struct rpmpd _platform##_##_active = { \ + .pd = { .name = #_active, },\ + .peer = &_platform##_##_name, \ + .active_only = true,\ + .res_type = RPMPD_SMPA, \ + .res_id = r_id, \ + .key = KEY_CORNER, \ + } + +#define DEFINE_RPMPD_CORN_LDOA(_platform, _name, r_id) \ +
[PATCH 1/7] PM / OPP: Add dev_pm_opp_get_of_node()
From: Viresh Kumar This adds a new helper to let the power domain drivers to access opp->np, so that they can read platform specific properties from the node. Signed-off-by: Viresh Kumar Signed-off-by: Rajendra Nayak --- drivers/opp/of.c | 19 +++ include/linux/pm_opp.h | 5 + 2 files changed, 24 insertions(+) diff --git a/drivers/opp/of.c b/drivers/opp/of.c index 21265af55117..b17715bc3c0a 100644 --- a/drivers/opp/of.c +++ b/drivers/opp/of.c @@ -736,3 +736,22 @@ struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, return opp; } EXPORT_SYMBOL_GPL(of_dev_pm_opp_find_required_opp); + +/** + * dev_pm_opp_get_of_node() - Gets the DT node corresponding to an opp + * @opp: opp for which DT node has to be returned for + * + * Return: DT node corresponding to the opp, else 0 on success. + * + * The caller needs to put the node of_node_put() after using it. + */ +struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) +{ + if (IS_ERR_OR_NULL(opp)) { + pr_err("%s: Invalid parameters\n", __func__); + return NULL; + } + + return of_node_get(opp->np); +} +EXPORT_SYMBOL_GPL(dev_pm_opp_get_of_node); diff --git a/include/linux/pm_opp.h b/include/linux/pm_opp.h index 528a7d9cf2ef..099b31960dec 100644 --- a/include/linux/pm_opp.h +++ b/include/linux/pm_opp.h @@ -300,6 +300,7 @@ void dev_pm_opp_of_cpumask_remove_table(const struct cpumask *cpumask); int dev_pm_opp_of_get_sharing_cpus(struct device *cpu_dev, struct cpumask *cpumask); struct device_node *dev_pm_opp_of_get_opp_desc_node(struct device *dev); struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device *dev, struct device_node *np); +struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp); #else static inline int dev_pm_opp_of_add_table(struct device *dev) { @@ -338,6 +339,10 @@ static inline struct dev_pm_opp *of_dev_pm_opp_find_required_opp(struct device * { return NULL; } +static inline struct device_node *dev_pm_opp_get_of_node(struct dev_pm_opp *opp) +{ + return NULL; +} #endif #endif /* __LINUX_OPP_H__ */ -- QUALCOMM INDIA, on behalf of Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum, hosted by The Linux Foundation
Re: [PATCH RFC 2/2] virtio_ring: support packed ring
On 2018年02月23日 19:18, Tiwei Bie wrote: Signed-off-by: Tiwei Bie --- drivers/virtio/virtio_ring.c | 699 +-- include/linux/virtio_ring.h | 8 +- 2 files changed, 618 insertions(+), 89 deletions(-) diff --git a/drivers/virtio/virtio_ring.c b/drivers/virtio/virtio_ring.c index eb30f3e09a47..393778a2f809 100644 --- a/drivers/virtio/virtio_ring.c +++ b/drivers/virtio/virtio_ring.c @@ -58,14 +58,14 @@ struct vring_desc_state { void *data; /* Data for callback. */ - struct vring_desc *indir_desc; /* Indirect descriptor, if any. */ + void *indir_desc; /* Indirect descriptor, if any. */ + int num;/* Descriptor list length. */ }; struct vring_virtqueue { struct virtqueue vq; - /* Actual memory layout for this queue */ - struct vring vring; + bool packed; /* Can we use weak barriers? */ bool weak_barriers; @@ -87,11 +87,28 @@ struct vring_virtqueue { /* Last used index we've seen. */ u16 last_used_idx; - /* Last written value to avail->flags */ - u16 avail_flags_shadow; - - /* Last written value to avail->idx in guest byte order */ - u16 avail_idx_shadow; + union { + /* Available for split ring */ + struct { + /* Actual memory layout for this queue */ + struct vring vring; + + /* Last written value to avail->flags */ + u16 avail_flags_shadow; + + /* Last written value to avail->idx in +* guest byte order */ + u16 avail_idx_shadow; + }; + + /* Available for packed ring */ + struct { + /* Actual memory layout for this queue */ + struct vring_packed vring_packed; + u8 wrap_counter : 1; + bool chaining; + }; + }; /* How to notify other side. FIXME: commonalize hcalls! */ bool (*notify)(struct virtqueue *vq); @@ -201,26 +218,37 @@ static dma_addr_t vring_map_single(const struct vring_virtqueue *vq, cpu_addr, size, direction); } -static void vring_unmap_one(const struct vring_virtqueue *vq, - struct vring_desc *desc) +static void vring_unmap_one(const struct vring_virtqueue *vq, void *_desc) { Let's split the helpers to packed/split version like other helpers? (Consider the caller has already known the type of vq). + u64 addr; + u32 len; u16 flags; if (!vring_use_dma_api(vq->vq.vdev)) return; - flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); + if (vq->packed) { + struct vring_packed_desc *desc = _desc; + + addr = virtio64_to_cpu(vq->vq.vdev, desc->addr); + len = virtio32_to_cpu(vq->vq.vdev, desc->len); + flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); + } else { + struct vring_desc *desc = _desc; + + addr = virtio64_to_cpu(vq->vq.vdev, desc->addr); + len = virtio32_to_cpu(vq->vq.vdev, desc->len); + flags = virtio16_to_cpu(vq->vq.vdev, desc->flags); + } if (flags & VRING_DESC_F_INDIRECT) { dma_unmap_single(vring_dma_dev(vq), -virtio64_to_cpu(vq->vq.vdev, desc->addr), -virtio32_to_cpu(vq->vq.vdev, desc->len), +addr, len, (flags & VRING_DESC_F_WRITE) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } else { dma_unmap_page(vring_dma_dev(vq), - virtio64_to_cpu(vq->vq.vdev, desc->addr), - virtio32_to_cpu(vq->vq.vdev, desc->len), + addr, len, (flags & VRING_DESC_F_WRITE) ? DMA_FROM_DEVICE : DMA_TO_DEVICE); } @@ -235,8 +263,9 @@ static int vring_mapping_error(const struct vring_virtqueue *vq, return dma_mapping_error(vring_dma_dev(vq), addr); } -static struct vring_desc *alloc_indirect(struct virtqueue *_vq, -unsigned int total_sg, gfp_t gfp) +static struct vring_desc *alloc_indirect_split(struct virtqueue *_vq, + unsigned int total_sg, + gfp_t gfp) { struct vring_desc *desc; unsigned int i; @@ -257,14 +286,32 @@ static struct vring_desc *alloc_indirect(struct virtqueue *_vq, return desc; } -static inline int virtqueue_add(struct virtqueue *_vq, - struct scat
Re: [PATCH] KVM: x86: Fix device passthrough when SME is active
On 3/8/2018 5:17 PM, Tom Lendacky wrote: > When using device passthrough with SME active, the MMIO range that is > mapped for the device should not be mapped encrypted. Add a check in > set_spte() to insure that a page is not mapped encrypted if that page > is a device MMIO page as indicated by kvm_is_mmio_pfn(). > > Cc: # 4.14.x- > Signed-off-by: Tom Lendacky Any concerns with this fix? Thanks, Tom > --- > arch/x86/kvm/mmu.c |4 +++- > 1 file changed, 3 insertions(+), 1 deletion(-) > > diff --git a/arch/x86/kvm/mmu.c b/arch/x86/kvm/mmu.c > index f551962..763bb3b 100644 > --- a/arch/x86/kvm/mmu.c > +++ b/arch/x86/kvm/mmu.c > @@ -2770,8 +2770,10 @@ static int set_spte(struct kvm_vcpu *vcpu, u64 *sptep, > else > pte_access &= ~ACC_WRITE_MASK; > > + if (!kvm_is_mmio_pfn(pfn)) > + spte |= shadow_me_mask; > + > spte |= (u64)pfn << PAGE_SHIFT; > - spte |= shadow_me_mask; > > if (pte_access & ACC_WRITE_MASK) { > >
Re: [RFC PATCH V1 01/12] audit: add container id
On 2018-03-15 16:27, Stefan Berger wrote: > On 03/01/2018 02:41 PM, Richard Guy Briggs wrote: > > Implement the proc fs write to set the audit container ID of a process, > > emitting an AUDIT_CONTAINER record to document the event. > > > > This is a write from the container orchestrator task to a proc entry of > > the form /proc/PID/containerid where PID is the process ID of the newly > > created task that is to become the first task in a container, or an > > additional task added to a container. > > > > The write expects up to a u64 value (unset: 18446744073709551615). > > > > This will produce a record such as this: > > type=UNKNOWN[1333] msg=audit(1519903238.968:261): op=set pid=596 uid=0 > > subj=unconfined_u:unconfined_r:unconfined_t:s0-s0:c0.c1023 auid=0 tty=pts0 > > ses=1 opid=596 old-contid=18446744073709551615 contid=123455 res=0 > > > > The "op" field indicates an initial set. The "pid" to "ses" fields are > > the orchestrator while the "opid" field is the object's PID, the process > > being "contained". Old and new container ID values are given in the > > "contid" fields, while res indicates its success. > > > > It is not permitted to self-set, unset or re-set the container ID. A > > child inherits its parent's container ID, but then can be set only once > > after. > > > > See: https://github.com/linux-audit/audit-kernel/issues/32 > > > > > > /* audit_rule_data supports filter rules with both integer and string > >* fields. It corresponds with AUDIT_ADD_RULE, AUDIT_DEL_RULE and > > diff --git a/kernel/auditsc.c b/kernel/auditsc.c > > index 4e0a4ac..0ee1e59 100644 > > --- a/kernel/auditsc.c > > +++ b/kernel/auditsc.c > > @@ -2073,6 +2073,92 @@ int audit_set_loginuid(kuid_t loginuid) > > return rc; > > } > > > > +static int audit_set_containerid_perm(struct task_struct *task, u64 > > containerid) > > +{ > > + struct task_struct *parent; > > + u64 pcontainerid, ccontainerid; > > + pid_t ppid; > > + > > + /* Don't allow to set our own containerid */ > > + if (current == task) > > + return -EPERM; > > + /* Don't allow the containerid to be unset */ > > + if (!cid_valid(containerid)) > > + return -EINVAL; > > + /* if we don't have caps, reject */ > > + if (!capable(CAP_AUDIT_CONTROL)) > > + return -EPERM; > > + /* if containerid is unset, allow */ > > + if (!audit_containerid_set(task)) > > + return 0; > > I am wondering whether there should be a check for the target process that > will receive the containerid to not have CAP_SYS_ADMIN that would otherwise > allow it to arbitrarily unshare()/clone() and leave the set of namespaces > that may make up the container whose containerid we assign here? This is a reasonable question. This has been debated and I understood the conclusion was that without a clear definition of a "container", the task still remains in that container that just now has more sub-namespaces (in the case of hierarchical namespaces), we don't want to restrict it in such a way and that allows it to create nested containers. I see setns being more problematic if it could switch to another existing namespace that was set up by the orchestrator for a different container. The coming v2 patchset acknowledges this situation with the network namespace being potentially shared by multiple containers. This is the motivation for the code below that allows to set the containerid even if it is already inherited from its parent. > > + /* it is already set, and not inherited from the parent, reject */ > > + ccontainerid = audit_get_containerid(task); > > + rcu_read_lock(); > > + parent = rcu_dereference(task->real_parent); > > + rcu_read_unlock(); > > + task_lock(parent); > > + pcontainerid = audit_get_containerid(parent); > > + ppid = task_tgid_nr(parent); > > ppid not needed... Thanks for catching this. It was the vestige of a failed devel experiment that didn't flush that useless appendage. :-) > > + task_unlock(parent); > > + if (ccontainerid != pcontainerid) > > + return -EPERM; > > + return 0; > > +} > > + > > +static void audit_log_set_containerid(struct task_struct *task, u64 > > oldcontainerid, > > + u64 containerid, int rc) > > +{ > > + struct audit_buffer *ab; > > + uid_t uid; > > + struct tty_struct *tty; > > + > > + if (!audit_enabled) > > + return; > > + > > + ab = audit_log_start(NULL, GFP_KERNEL, AUDIT_CONTAINER); > > + if (!ab) > > + return; > > + > > + uid = from_kuid(&init_user_ns, task_uid(current)); > > + tty = audit_get_tty(current); > > + > > + audit_log_format(ab, "op=set pid=%d uid=%u", task_tgid_nr(current), > > uid); > > + audit_log_task_context(ab); > > + audit_log_format(ab, " auid=%u tty=%s ses=%u opid=%d old-contid=%llu > > contid=%llu res=%d", > > +from_kuid(&init_user_ns, audit_get_loginuid(current)), > > +tty ? tty_name
Re: mmotm 2018-03-14-16-24 uploaded (lustre)
On Thu, Mar 15 2018, Randy Dunlap wrote: > On 03/14/2018 04:24 PM, a...@linux-foundation.org wrote: >> The mm-of-the-moment snapshot 2018-03-14-16-24 has been uploaded to >> >>http://www.ozlabs.org/~akpm/mmotm/ > > (not from the mmotm patches, but in its linux-next.patch) > > CONFIG_LUSTRE_FS=y > # CONFIG_LUSTRE_DEBUG_EXPENSIVE_CHECK is not set > > > In file included from > ../drivers/staging/lustre/include/linux/libcfs/libcfs.h:42:0, > from > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:44: > ../drivers/staging/lustre/lustre/obdclass/lu_object.c: In function > 'lu_context_key_degister': > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1410:51: error: > dereferencing pointer to incomplete type > __func__, key->lct_owner ? key->lct_owner->name : "", >^ Thanks for the report. Arnd Bergmann posted a patch to fix this on Tuesday Message-Id: <20180313130425.3975930-1-a...@arndb.de> http://lkml.kernel.org/r/<20180313130425.3975930-1-a...@arndb.de> so the error should disappear soon. Thanks, NeilBrown > ../drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h:123:41: note: > in definition of macro '__CDEBUG' >libcfs_debug_msg(&msgdata, format, ## __VA_ARGS__); \ > ^ > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1409:3: note: in > expansion of macro 'CDEBUG' >CDEBUG(D_INFO, "%s: \"%s\" %p, %d\n", >^ > ../drivers/staging/lustre/lustre/obdclass/lu_object.c: In function > 'lu_context_key_quiesce': > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1550:42: error: > dereferencing pointer to incomplete type >key->lct_owner ? key->lct_owner->name : "", > ^ > ../drivers/staging/lustre/include/linux/libcfs/libcfs_debug.h:123:41: note: > in definition of macro '__CDEBUG' >libcfs_debug_msg(&msgdata, format, ## __VA_ARGS__); \ > ^ > ../drivers/staging/lustre/lustre/obdclass/lu_object.c:1548:4: note: in > expansion of macro 'CDEBUG' > CDEBUG(D_INFO, "%s: \"%s\" %p, %d (%d)\n", > ^ > > > > -- > ~Randy signature.asc Description: PGP signature
[PATCH v8 39/42] ARM: davinci: remove legacy clocks
This removes the unused legacy clock code from arch/arm/mach-davinci/. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - none v6 changes: - none arch/arm/mach-davinci/clock.c | 745 arch/arm/mach-davinci/clock.h | 72 --- arch/arm/mach-davinci/common.c | 2 - arch/arm/mach-davinci/devices.c | 1 - arch/arm/mach-davinci/include/mach/clock.h | 3 - arch/arm/mach-davinci/include/mach/common.h | 2 - arch/arm/mach-davinci/psc.c | 137 - arch/arm/mach-davinci/psc.h | 10 - arch/arm/mach-davinci/time.c| 2 - 9 files changed, 974 deletions(-) delete mode 100644 arch/arm/mach-davinci/clock.c delete mode 100644 arch/arm/mach-davinci/psc.c diff --git a/arch/arm/mach-davinci/clock.c b/arch/arm/mach-davinci/clock.c deleted file mode 100644 index f77a4f7..000 --- a/arch/arm/mach-davinci/clock.c +++ /dev/null @@ -1,745 +0,0 @@ -/* - * Clock and PLL control for DaVinci devices - * - * Copyright (C) 2006-2007 Texas Instruments. - * Copyright (C) 2008-2009 Deep Root Systems, LLC - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or - * (at your option) any later version. - */ - -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include - -#include -#include "psc.h" -#include -#include "clock.h" - -static LIST_HEAD(clocks); -static DEFINE_MUTEX(clocks_mutex); -static DEFINE_SPINLOCK(clockfw_lock); - -void davinci_clk_enable(struct clk *clk) -{ - if (clk->parent) - davinci_clk_enable(clk->parent); - if (clk->usecount++ == 0) { - if (clk->flags & CLK_PSC) - davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, - true, clk->flags); - else if (clk->clk_enable) - clk->clk_enable(clk); - } -} - -void davinci_clk_disable(struct clk *clk) -{ - if (WARN_ON(clk->usecount == 0)) - return; - if (--clk->usecount == 0) { - if (!(clk->flags & CLK_PLL) && (clk->flags & CLK_PSC)) - davinci_psc_config(clk->domain, clk->gpsc, clk->lpsc, - false, clk->flags); - else if (clk->clk_disable) - clk->clk_disable(clk); - } - if (clk->parent) - davinci_clk_disable(clk->parent); -} - -int davinci_clk_reset(struct clk *clk, bool reset) -{ - unsigned long flags; - - if (clk == NULL || IS_ERR(clk)) - return -EINVAL; - - spin_lock_irqsave(&clockfw_lock, flags); - if (clk->flags & CLK_PSC) - davinci_psc_reset(clk->gpsc, clk->lpsc, reset); - spin_unlock_irqrestore(&clockfw_lock, flags); - - return 0; -} -EXPORT_SYMBOL(davinci_clk_reset); - -int davinci_clk_reset_assert(struct clk *clk) -{ - if (clk == NULL || IS_ERR(clk) || !clk->reset) - return -EINVAL; - - return clk->reset(clk, true); -} -EXPORT_SYMBOL(davinci_clk_reset_assert); - -int davinci_clk_reset_deassert(struct clk *clk) -{ - if (clk == NULL || IS_ERR(clk) || !clk->reset) - return -EINVAL; - - return clk->reset(clk, false); -} -EXPORT_SYMBOL(davinci_clk_reset_deassert); - -int clk_enable(struct clk *clk) -{ - unsigned long flags; - - if (!clk) - return 0; - else if (IS_ERR(clk)) - return -EINVAL; - - spin_lock_irqsave(&clockfw_lock, flags); - davinci_clk_enable(clk); - spin_unlock_irqrestore(&clockfw_lock, flags); - - return 0; -} -EXPORT_SYMBOL(clk_enable); - -void clk_disable(struct clk *clk) -{ - unsigned long flags; - - if (clk == NULL || IS_ERR(clk)) - return; - - spin_lock_irqsave(&clockfw_lock, flags); - davinci_clk_disable(clk); - spin_unlock_irqrestore(&clockfw_lock, flags); -} -EXPORT_SYMBOL(clk_disable); - -unsigned long clk_get_rate(struct clk *clk) -{ - if (clk == NULL || IS_ERR(clk)) - return 0; - - return clk->rate; -} -EXPORT_SYMBOL(clk_get_rate); - -long clk_round_rate(struct clk *clk, unsigned long rate) -{ - if (clk == NULL || IS_ERR(clk)) - return 0; - - if (clk->round_rate) - return clk->round_rate(clk, rate); - - return clk->rate; -} -EXPORT_SYMBOL(clk_round_rate); - -/* Propagate rate to children */ -static void propagate_rate(struct clk *root) -{ - struct clk *clk; - - list_for_each_entry(clk, &root->children, childnode) { - if (clk->recalc) - clk->rate = clk->recalc(clk); - propagate_rate(clk); -
[PATCH v8 34/42] ARM: davinci: dm355: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/dm355.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/dm355.c | 357 -- 1 file changed, 357 deletions(-) diff --git a/arch/arm/mach-davinci/dm355.c b/arch/arm/mach-davinci/dm355.c index f53e07a..a2d1246 100644 --- a/arch/arm/mach-davinci/dm355.c +++ b/arch/arm/mach-davinci/dm355.c @@ -32,11 +32,6 @@ #include "davinci.h" #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - #define DM355_UART2_BASE (IO_PHYS + 0x206000) #define DM355_OSD_BASE (IO_PHYS + 0x70200) #define DM355_VENC_BASE(IO_PHYS + 0x70400) @@ -46,349 +41,6 @@ */ #define DM355_REF_FREQ 2400/* 24 or 36 MHz */ -#ifndef CONFIG_COMMON_CLK -static struct pll_data pll1_data = { - .num = 1, - .phys_base = DAVINCI_PLL1_BASE, - .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV, -}; - -static struct pll_data pll2_data = { - .num = 2, - .phys_base = DAVINCI_PLL2_BASE, - .flags = PLL_HAS_PREDIV, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - /* FIXME -- crystal rate is board-specific */ - .rate = DM355_REF_FREQ, -}; - -static struct clk pll1_clk = { - .name = "pll1", - .parent = &ref_clk, - .flags = CLK_PLL, - .pll_data = &pll1_data, -}; - -static struct clk pll1_aux_clk = { - .name = "pll1_aux_clk", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll1_sysclk1 = { - .name = "pll1_sysclk1", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll1_sysclk2 = { - .name = "pll1_sysclk2", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV2, -}; - -static struct clk pll1_sysclk3 = { - .name = "pll1_sysclk3", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV3, -}; - -static struct clk pll1_sysclk4 = { - .name = "pll1_sysclk4", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV4, -}; - -static struct clk pll1_sysclkbp = { - .name = "pll1_sysclkbp", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV -}; - -static struct clk vpss_dac_clk = { - .name = "vpss_dac", - .parent = &pll1_sysclk3, - .lpsc = DM355_LPSC_VPSS_DAC, -}; - -static struct clk vpss_master_clk = { - .name = "vpss_master", - .parent = &pll1_sysclk4, - .lpsc = DAVINCI_LPSC_VPSSMSTR, - .flags = CLK_PSC, -}; - -static struct clk vpss_slave_clk = { - .name = "vpss_slave", - .parent = &pll1_sysclk4, - .lpsc = DAVINCI_LPSC_VPSSSLV, -}; - -static struct clk clkout1_clk = { - .name = "clkout1", - .parent = &pll1_aux_clk, - /* NOTE: clkout1 can be externally gated by muxing GPIO-18 */ -}; - -static struct clk clkout2_clk = { - .name = "clkout2", - .parent = &pll1_sysclkbp, -}; - -static struct clk pll2_clk = { - .name = "pll2", - .parent = &ref_clk, - .flags = CLK_PLL, - .pll_data = &pll2_data, -}; - -static struct clk pll2_sysclk1 = { - .name = "pll2_sysclk1", - .parent = &pll2_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll2_sysclkbp = { - .name = "pll2_sysclkbp", - .parent = &pll2_clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV -}; - -static struct clk clkout3_clk = { - .name = "clkout3", - .parent = &pll2_sysclkbp, - /* NOTE: clkout3 can be externally gated by muxing GPIO-16 */ -}; - -static struct clk arm_clk = { - .name = "arm_clk", - .parent = &pll1_sysclk1, - .lpsc = DAVINCI_LPSC_ARM, - .flags = ALWAYS_ENABLED, -}; - -/* - * NOT LISTED below, and not touched by Linux - * - in SyncReset state by default - * .lpsc = DAVINCI_LPSC_TPCC, - * .lpsc = DAVINCI_LPSC_TPTC0, - * .lpsc = DAVINCI_LPSC_TPTC1, - * .lpsc = DAVINCI_LPSC_DDR_EMIF, .parent = &sysclk2_clk, - * .lpsc = DAVINCI_LPSC_MEMSTICK, - * - in Enabled state by default - * .lpsc = DAVINCI_LPSC_SYSTEM_SUBSYS, - * .lpsc = DAVINCI_LPSC_SCR2, // "bus" - * .lpsc = DAVINCI_LPSC_SCR3, // "bus" - * .lpsc = DAVINCI_LPSC_SCR4, // "bus" - * .lpsc = DAVINCI_LPSC_CROSSBAR, // "emulation" - * .lpsc = DAVINCI_LPSC_CFG27, // "test" - * .lpsc = DAVINCI_LPSC_CFG3, // "test" - * .lpsc = DAVINCI_LPSC_CFG5, // "test" - */ - -static struct clk mjcp_clk = { - .name = "mjcp", - .parent = &pll1_sysclk1, - .lpsc = DAVINCI_LPSC_IMCOP, -}; - -static struct clk uart0_clk = { - .name = "uart0", - .parent = &pll1_aux_c
[PATCH v8 40/42] ARM: davinci: add device tree support to timer
This adds device tree support to the davinci timer so that when clocks are moved to device tree, the timer will still work. Signed-off-by: David Lechner --- v8 changes: - none v7 changes: - add workaround for platform devices not available in early boot v6 changes: - none arch/arm/mach-davinci/Kconfig | 1 + arch/arm/mach-davinci/time.c | 31 +++ 2 files changed, 32 insertions(+) diff --git a/arch/arm/mach-davinci/Kconfig b/arch/arm/mach-davinci/Kconfig index ba9912b..da8a039 100644 --- a/arch/arm/mach-davinci/Kconfig +++ b/arch/arm/mach-davinci/Kconfig @@ -59,6 +59,7 @@ config MACH_DA8XX_DT default y depends on ARCH_DAVINCI_DA850 select PINCTRL + select TIMER_OF help Say y here to include support for TI DaVinci DA850 based using Flattened Device Tree. More information at Documentation/devicetree diff --git a/arch/arm/mach-davinci/time.c b/arch/arm/mach-davinci/time.c index d6a78f7..590b118 100644 --- a/arch/arm/mach-davinci/time.c +++ b/arch/arm/mach-davinci/time.c @@ -17,6 +17,7 @@ #include #include #include +#include #include #include @@ -405,3 +406,33 @@ void __init davinci_timer_init(struct clk *timer_clk) for (i=0; i< ARRAY_SIZE(timers); i++) timer32_config(&timers[i]); } + +static int __init of_davinci_timer_init(struct device_node *np) +{ + struct clk *clk; + + clk = of_clk_get(np, 0); + if (IS_ERR(clk)) { + struct of_phandle_args clkspec; + + /* +* Fall back to using ref_clk if the actual clock is not +* available. This currently always happens because platform +* clocks (i.e PLLs and PSCs) are registered as platform +* devices and therefore are not available at this point in +* the boot process. +*/ + clkspec.np = of_find_node_by_name(NULL, "ref_clk"); + if (IS_ERR(clkspec.np)) { + pr_err("%s: No clock available for timer!\n", __func__); + return PTR_ERR(clkspec.np); + } + clk = of_clk_get_from_provider(&clkspec); + of_node_put(clkspec.np); + } + + davinci_timer_init(clk); + + return 0; +} +TIMER_OF_DECLARE(davinci_timer, "ti,davinci-timer", of_davinci_timer_init); -- 2.7.4
[PATCH v8 37/42] ARM: davinci: dm646x: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/dm646x.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - rebased v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/dm646x.c | 329 - 1 file changed, 329 deletions(-) diff --git a/arch/arm/mach-davinci/dm646x.c b/arch/arm/mach-davinci/dm646x.c index 553782f..d14ffd6 100644 --- a/arch/arm/mach-davinci/dm646x.c +++ b/arch/arm/mach-davinci/dm646x.c @@ -31,11 +31,6 @@ #include "davinci.h" #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - #define DAVINCI_VPIF_BASE (0x01C12000) #define VDD3P3V_VID_MASK (BIT_MASK(3) | BIT_MASK(2) | BIT_MASK(1) |\ @@ -50,319 +45,6 @@ #define DM646X_EMAC_CNTRL_RAM_OFFSET 0x2000 #define DM646X_EMAC_CNTRL_RAM_SIZE 0x2000 -#ifndef CONFIG_COMMON_CLK -static struct pll_data pll1_data = { - .num = 1, - .phys_base = DAVINCI_PLL1_BASE, -}; - -static struct pll_data pll2_data = { - .num = 2, - .phys_base = DAVINCI_PLL2_BASE, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - /* rate is initialized in dm646x_init_time() */ -}; - -static struct clk aux_clkin = { - .name = "aux_clkin", - /* rate is initialized in dm646x_init_time() */ -}; - -static struct clk pll1_clk = { - .name = "pll1", - .parent = &ref_clk, - .pll_data = &pll1_data, - .flags = CLK_PLL, -}; - -static struct clk pll1_sysclk1 = { - .name = "pll1_sysclk1", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll1_sysclk2 = { - .name = "pll1_sysclk2", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV2, -}; - -static struct clk pll1_sysclk3 = { - .name = "pll1_sysclk3", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV3, -}; - -static struct clk pll1_sysclk4 = { - .name = "pll1_sysclk4", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV4, -}; - -static struct clk pll1_sysclk5 = { - .name = "pll1_sysclk5", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV5, -}; - -static struct clk pll1_sysclk6 = { - .name = "pll1_sysclk6", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV6, -}; - -static struct clk pll1_sysclk8 = { - .name = "pll1_sysclk8", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV8, -}; - -static struct clk pll1_sysclk9 = { - .name = "pll1_sysclk9", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV9, -}; - -static struct clk pll1_sysclkbp = { - .name = "pll1_sysclkbp", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV, -}; - -static struct clk pll1_aux_clk = { - .name = "pll1_aux_clk", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll2_clk = { - .name = "pll2_clk", - .parent = &ref_clk, - .pll_data = &pll2_data, - .flags = CLK_PLL, -}; - -static struct clk pll2_sysclk1 = { - .name = "pll2_sysclk1", - .parent = &pll2_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk dsp_clk = { - .name = "dsp", - .parent = &pll1_sysclk1, - .lpsc = DM646X_LPSC_C64X_CPU, - .usecount = 1, /* REVISIT how to disable? */ -}; - -static struct clk arm_clk = { - .name = "arm", - .parent = &pll1_sysclk2, - .lpsc = DM646X_LPSC_ARM, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_cc_clk = { - .name = "edma_cc", - .parent = &pll1_sysclk2, - .lpsc = DM646X_LPSC_TPCC, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc0_clk = { - .name = "edma_tc0", - .parent = &pll1_sysclk2, - .lpsc = DM646X_LPSC_TPTC0, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc1_clk = { - .name = "edma_tc1", - .parent = &pll1_sysclk2, - .lpsc = DM646X_LPSC_TPTC1, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc2_clk = { - .name = "edma_tc2", - .parent = &pll1_sysclk2, - .lpsc = DM646X_LPSC_TPTC2, - .flags = ALWAYS_ENABLED, -}; - -static struct clk edma_tc3_clk = { - .name = "edma_tc3", - .parent = &pll1_sysclk2, - .lpsc = DM646X_LPSC_TPTC3, - .flags = ALWAYS_ENABLED, -}; - -static struct clk uart0_clk = { - .name = "uart0", - .parent = &aux_clkin, - .lpsc = DM646X_LPSC_UART0, -}; - -static struct clk uart1_clk = { - .name = "uart1", - .parent = &aux_clkin, - .lpsc = DM646X_LPSC_UART1, -}; - -static struct clk uart2_clk = { - .name = "uart2", - .parent = &aux_clkin, - .
[PATCH v8 38/42] ARM: davinci: da8xx: Remove legacy USB and SATA clock init
This removes the unused legacy USB and SATA clock init code from arch/arm/mach-davinci/{devices,usb}-da8xx}.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - rebased - add davinci prefix to commit message - mention SATA and USB in commit message v6 changes: - rebased arch/arm/mach-davinci/devices-da8xx.c | 29 arch/arm/mach-davinci/include/mach/da8xx.h | 3 - arch/arm/mach-davinci/usb-da8xx.c | 238 - 3 files changed, 270 deletions(-) diff --git a/arch/arm/mach-davinci/devices-da8xx.c b/arch/arm/mach-davinci/devices-da8xx.c index 73de449..1fd3619 100644 --- a/arch/arm/mach-davinci/devices-da8xx.c +++ b/arch/arm/mach-davinci/devices-da8xx.c @@ -30,11 +30,6 @@ #include "cpuidle.h" #include "sram.h" -#ifndef CONFIG_COMMON_CLK -#include -#include "clock.h" -#endif - #define DA8XX_TPCC_BASE0x01c0 #define DA8XX_TPTC0_BASE 0x01c08000 #define DA8XX_TPTC1_BASE 0x01c08400 @@ -1045,29 +1040,6 @@ int __init da8xx_register_spi_bus(int instance, unsigned num_chipselect) } #ifdef CONFIG_ARCH_DAVINCI_DA850 -#ifndef CONFIG_COMMON_CLK -static struct clk sata_refclk = { - .name = "sata_refclk", - .set_rate = davinci_simple_set_rate, -}; - -static struct clk_lookup sata_refclk_lookup = - CLK("ahci_da850", "refclk", &sata_refclk); - -int __init da850_register_sata_refclk(int rate) -{ - int ret; - - sata_refclk.rate = rate; - ret = clk_register(&sata_refclk); - if (ret) - return ret; - - clkdev_add(&sata_refclk_lookup); - - return 0; -} -#else int __init da850_register_sata_refclk(int rate) { struct clk *clk; @@ -1078,7 +1050,6 @@ int __init da850_register_sata_refclk(int rate) return clk_register_clkdev(clk, "refclk", "ahci_da850"); } -#endif static struct resource da850_sata_resources[] = { { diff --git a/arch/arm/mach-davinci/include/mach/da8xx.h b/arch/arm/mach-davinci/include/mach/da8xx.h index 5d7b1de..ab4a57f 100644 --- a/arch/arm/mach-davinci/include/mach/da8xx.h +++ b/arch/arm/mach-davinci/include/mach/da8xx.h @@ -103,9 +103,6 @@ int da8xx_register_watchdog(void); int da8xx_register_usb_phy(void); int da8xx_register_usb20(unsigned mA, unsigned potpgt); int da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata); -int da8xx_register_usb_refclkin(int rate); -int da8xx_register_usb20_phy_clk(bool use_usb_refclkin); -int da8xx_register_usb11_phy_clk(bool use_usb_refclkin); int da8xx_register_usb_phy_clocks(void); int da850_register_sata_refclk(int rate); int da8xx_register_emac(void); diff --git a/arch/arm/mach-davinci/usb-da8xx.c b/arch/arm/mach-davinci/usb-da8xx.c index d0ba725..b17253f 100644 --- a/arch/arm/mach-davinci/usb-da8xx.c +++ b/arch/arm/mach-davinci/usb-da8xx.c @@ -20,11 +20,6 @@ #include #include -#ifndef CONFIG_COMMON_CLK -#include -#include "clock.h" -#endif - #define DA8XX_USB0_BASE0x01e0 #define DA8XX_USB1_BASE0x01e25000 @@ -89,11 +84,6 @@ static struct platform_device da8xx_usb20_dev = { .name = "musb-da8xx", .id = -1, .dev = { - /* -* Setting init_name so that clock lookup will work in -* usb20_phy_clk_enable() even if this device is not registered. -*/ - .init_name = "musb-da8xx", .platform_data = &usb_data, .dma_mask = &usb_dmamask, .coherent_dma_mask = DMA_BIT_MASK(32), @@ -142,234 +132,6 @@ int __init da8xx_register_usb11(struct da8xx_ohci_root_hub *pdata) return platform_device_register(&da8xx_usb11_device); } -#ifndef CONFIG_COMMON_CLK -static struct clk usb_refclkin = { - .name = "usb_refclkin", - .set_rate = davinci_simple_set_rate, -}; - -static struct clk_lookup usb_refclkin_lookup = - CLK(NULL, "usb_refclkin", &usb_refclkin); - -/** - * da8xx_register_usb_refclkin - register USB_REFCLKIN clock - * - * @rate: The clock rate in Hz - * - * This clock is only needed if the board provides an external USB_REFCLKIN - * signal, in which case it will be used as the parent of usb20_phy_clk and/or - * usb11_phy_clk. - */ -int __init da8xx_register_usb_refclkin(int rate) -{ - int ret; - - usb_refclkin.rate = rate; - ret = clk_register(&usb_refclkin); - if (ret) - return ret; - - clkdev_add(&usb_refclkin_lookup); - - return 0; -} - -static void usb20_phy_clk_enable(struct clk *clk) -{ - u32 val; - u32 timeout = 50; /* 500 msec */ - - val = readl(DA8XX_SYSCFG0_VIRT(DA8XX_CFGCHIP2_REG)); - - /* The USB 2.O PLL requires that the USB 2.O PSC is enabled as well. */ - davinci_clk_enable(usb20_clk); - - /* -* Turn on t
[PATCH v8 42/42] ARM: dts: da850: Add clocks
This adds clock provider nodes for da850 and wires them up to all of the devices. Signed-off-by: David Lechner --- v8 changes: - fix typo in clock-names property of psc0 - added power-domains properties to nodes that define that property in their device tree bindings v7 changes: - move ref_clk frequency to board-specific DT files - enable sata_refclk in da850-lcdk.dts - drop async2 fixed factor clock - add power-domains for devices that use them - fix USB PHY clock-names property - move assigned-clocks to PSC device node - drop clocks property from devices that don't use it (e.g. EDMA) - add clock to RTC node - add clock-ranges to usb0 and aemif nodes - add clock-names property to aemif node - fix typo in psc1 clock-names v6 changes: - updated for device tree bindings changes earlier in this series - use single async2 clock instead of duplicate fixed factor clocks - add clock-names property to mdio node arch/arm/boot/dts/da850-enbw-cmc.dts | 4 + arch/arm/boot/dts/da850-evm.dts | 4 + arch/arm/boot/dts/da850-lcdk.dts | 9 ++ arch/arm/boot/dts/da850-lego-ev3.dts | 4 + arch/arm/boot/dts/da850.dtsi | 167 +++ 5 files changed, 188 insertions(+) diff --git a/arch/arm/boot/dts/da850-enbw-cmc.dts b/arch/arm/boot/dts/da850-enbw-cmc.dts index 14dff3e..0102ffc 100644 --- a/arch/arm/boot/dts/da850-enbw-cmc.dts +++ b/arch/arm/boot/dts/da850-enbw-cmc.dts @@ -35,6 +35,10 @@ }; }; +&ref_clk { + clock-frequency = <2400>; +}; + &edma0 { ti,edma-reserved-slot-ranges = <32 50>; }; diff --git a/arch/arm/boot/dts/da850-evm.dts b/arch/arm/boot/dts/da850-evm.dts index c82368c..38a53dd 100644 --- a/arch/arm/boot/dts/da850-evm.dts +++ b/arch/arm/boot/dts/da850-evm.dts @@ -200,6 +200,10 @@ }; }; +&ref_clk { + clock-frequency = <2400>; +}; + /include/ "tps6507x.dtsi" &tps { diff --git a/arch/arm/boot/dts/da850-lcdk.dts b/arch/arm/boot/dts/da850-lcdk.dts index a1f4d6d..90b917c 100644 --- a/arch/arm/boot/dts/da850-lcdk.dts +++ b/arch/arm/boot/dts/da850-lcdk.dts @@ -123,6 +123,10 @@ }; }; +&ref_clk { + clock-frequency = <2400>; +}; + &pmx_core { status = "okay"; @@ -175,6 +179,11 @@ status = "okay"; }; +&sata_refclk { + status = "okay"; + clock-frequency = <1>; +}; + &sata { status = "okay"; }; diff --git a/arch/arm/boot/dts/da850-lego-ev3.dts b/arch/arm/boot/dts/da850-lego-ev3.dts index 1ffd877..4425cb4 100644 --- a/arch/arm/boot/dts/da850-lego-ev3.dts +++ b/arch/arm/boot/dts/da850-lego-ev3.dts @@ -203,6 +203,10 @@ }; }; +&ref_clk { + clock-frequency = <2400>; +}; + &pmx_core { status = "okay"; diff --git a/arch/arm/boot/dts/da850.dtsi b/arch/arm/boot/dts/da850.dtsi index c66cf78..e8117c7 100644 --- a/arch/arm/boot/dts/da850.dtsi +++ b/arch/arm/boot/dts/da850.dtsi @@ -21,6 +21,26 @@ #interrupt-cells = <1>; ti,intc-size = <101>; reg = <0xfffee000 0x2000>; + clocks = <&psc0 6>; + }; + }; + clocks: clocks { + ref_clk: ref_clk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "ref_clk"; + }; + sata_refclk: sata_refclk { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "sata_refclk"; + status = "disabled"; + }; + usb_refclkin: usb_refclkin { + compatible = "fixed-clock"; + #clock-cells = <0>; + clock-output-names = "usb_refclkin"; + status = "disabled"; }; }; dsp: dsp@1180 { @@ -33,6 +53,7 @@ reg-names = "l2sram", "l1pram", "l1dram", "host1cfg", "chipsig"; interrupt-parent = <&intc>; interrupts = <28>; + clocks = <&psc0 15>; status = "disabled"; }; soc@1c0 { @@ -43,6 +64,37 @@ ranges = <0x0 0x01c0 0x40>; interrupt-parent = <&intc>; + psc0: clock-controller@1 { + compatible = "ti,da850-psc0"; + reg = <0x1 0x1000>; + #clock-cells = <1>; + #power-domain-cells = <1>; + clocks = <&pll0_sysclk 1>, <&pll0_sysclk 2>, +<&pll0_sysclk 4>, <&pll0_sysclk 6>, +<&async1_clk>; + clock-names = "pll0_sysclk1", "pll0_sysclk2", + "pll0_sysclk4", "pll0_sysclk6", + "async1"; + }; +
[PATCH v8 30/42] ARM: davinci_all_defconfig: remove CONFIG_DAVINCI_RESET_CLOCKS
This removes CONFIG_DAVINCI_RESET_CLOCKS. The option has been removed from the kernel. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - none v6 changes: - none arch/arm/configs/davinci_all_defconfig | 1 - 1 file changed, 1 deletion(-) diff --git a/arch/arm/configs/davinci_all_defconfig b/arch/arm/configs/davinci_all_defconfig index c302a04..0f4d20b 100644 --- a/arch/arm/configs/davinci_all_defconfig +++ b/arch/arm/configs/davinci_all_defconfig @@ -31,7 +31,6 @@ CONFIG_MACH_MITYOMAPL138=y CONFIG_MACH_OMAPL138_HAWKBOARD=y CONFIG_DAVINCI_MUX_DEBUG=y CONFIG_DAVINCI_MUX_WARNINGS=y -CONFIG_DAVINCI_RESET_CLOCKS=y CONFIG_PREEMPT=y CONFIG_AEABI=y CONFIG_CMA=y -- 2.7.4
[PATCH v8 31/42] ARM: davinci: switch to common clock framework
This switches ARCH_DAVINCI to use the common clock framework. The legacy clock code in arch/arm/mach-davinci/ is no longer used. New drivers in drivers/clk/davinci/ are used instead. A few macros had to be moved to prevent compilation errors. Signed-off-by: David Lechner --- v8 changes: - none v7 changes: - s/compile/compilation and space instead of tab - add PM_GENERIC_DOMAINS dependencies v6 changes: - clean up indent on Common objects section arch/arm/Kconfig| 5 - arch/arm/mach-davinci/Makefile | 4 ++-- arch/arm/mach-davinci/clock.h | 4 arch/arm/mach-davinci/davinci.h | 4 arch/arm/mach-davinci/psc.h | 2 -- 5 files changed, 10 insertions(+), 9 deletions(-) diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig index 7e3d535..563fade 100644 --- a/arch/arm/Kconfig +++ b/arch/arm/Kconfig @@ -608,13 +608,16 @@ config ARCH_S3C24XX config ARCH_DAVINCI bool "TI DaVinci" select ARCH_HAS_HOLES_MEMORYMODEL - select CLKDEV_LOOKUP + select COMMON_CLK select CPU_ARM926T select GENERIC_ALLOCATOR select GENERIC_CLOCKEVENTS select GENERIC_IRQ_CHIP select GPIOLIB select HAVE_IDE + select PM_GENERIC_DOMAINS if PM + select PM_GENERIC_DOMAINS_OF if PM && OF + select RESET_CONTROLLER select USE_OF select ZONE_DMA help diff --git a/arch/arm/mach-davinci/Makefile b/arch/arm/mach-davinci/Makefile index 4e81780..8725d8b 100644 --- a/arch/arm/mach-davinci/Makefile +++ b/arch/arm/mach-davinci/Makefile @@ -5,8 +5,8 @@ # # Common objects -obj-y := time.o clock.o serial.o psc.o \ - usb.o common.o sram.o aemif.o +obj-y := time.o serial.o usb.o \ + common.o sram.o aemif.o obj-$(CONFIG_DAVINCI_MUX) += mux.o diff --git a/arch/arm/mach-davinci/clock.h b/arch/arm/mach-davinci/clock.h index d7894d5..2d05856 100644 --- a/arch/arm/mach-davinci/clock.h +++ b/arch/arm/mach-davinci/clock.h @@ -12,10 +12,6 @@ #ifndef __ARCH_ARM_DAVINCI_CLOCK_H #define __ARCH_ARM_DAVINCI_CLOCK_H -#define DAVINCI_PLL1_BASE 0x01c40800 -#define DAVINCI_PLL2_BASE 0x01c40c00 -#define MAX_PLL 2 - /* PLL/Reset register offsets */ #define PLLCTL 0x100 #define PLLCTL_PLLENBIT(0) diff --git a/arch/arm/mach-davinci/davinci.h b/arch/arm/mach-davinci/davinci.h index a200977..a227f80 100644 --- a/arch/arm/mach-davinci/davinci.h +++ b/arch/arm/mach-davinci/davinci.h @@ -35,6 +35,10 @@ #include #include +#define DAVINCI_PLL1_BASE 0x01c40800 +#define DAVINCI_PLL2_BASE 0x01c40c00 +#define DAVINCI_PWR_SLEEP_CNTRL_BASE 0x01c41000 + #define DAVINCI_SYSTEM_MODULE_BASE 0x01c4 #define SYSMOD_VDAC_CONFIG 0x2c #define SYSMOD_VIDCLKCTL 0x38 diff --git a/arch/arm/mach-davinci/psc.h b/arch/arm/mach-davinci/psc.h index 8af9f09..b58707c 100644 --- a/arch/arm/mach-davinci/psc.h +++ b/arch/arm/mach-davinci/psc.h @@ -27,8 +27,6 @@ #ifndef __ASM_ARCH_PSC_H #define __ASM_ARCH_PSC_H -#defineDAVINCI_PWR_SLEEP_CNTRL_BASE0x01C41000 - /* Power and Sleep Controller (PSC) Domains */ #define DAVINCI_GPSC_ARMDOMAIN 0 #define DAVINCI_GPSC_DSPDOMAIN 1 -- 2.7.4
[PATCH v8 36/42] ARM: davinci: dm644x: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/dm644x.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/dm644x.c | 300 - 1 file changed, 300 deletions(-) diff --git a/arch/arm/mach-davinci/dm644x.c b/arch/arm/mach-davinci/dm644x.c index 64f5193..6d3a0e8 100644 --- a/arch/arm/mach-davinci/dm644x.c +++ b/arch/arm/mach-davinci/dm644x.c @@ -29,11 +29,6 @@ #include "davinci.h" #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - /* * Device specific clocks */ @@ -46,292 +41,6 @@ #define DM644X_EMAC_CNTRL_RAM_OFFSET 0x2000 #define DM644X_EMAC_CNTRL_RAM_SIZE 0x2000 -#ifndef CONFIG_COMMON_CLK -static struct pll_data pll1_data = { - .num = 1, - .phys_base = DAVINCI_PLL1_BASE, -}; - -static struct pll_data pll2_data = { - .num = 2, - .phys_base = DAVINCI_PLL2_BASE, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - .rate = DM644X_REF_FREQ, -}; - -static struct clk pll1_clk = { - .name = "pll1", - .parent = &ref_clk, - .pll_data = &pll1_data, - .flags = CLK_PLL, -}; - -static struct clk pll1_sysclk1 = { - .name = "pll1_sysclk1", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll1_sysclk2 = { - .name = "pll1_sysclk2", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV2, -}; - -static struct clk pll1_sysclk3 = { - .name = "pll1_sysclk3", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV3, -}; - -static struct clk pll1_sysclk5 = { - .name = "pll1_sysclk5", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV5, -}; - -static struct clk pll1_aux_clk = { - .name = "pll1_aux_clk", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll1_sysclkbp = { - .name = "pll1_sysclkbp", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV -}; - -static struct clk pll2_clk = { - .name = "pll2", - .parent = &ref_clk, - .pll_data = &pll2_data, - .flags = CLK_PLL, -}; - -static struct clk pll2_sysclk1 = { - .name = "pll2_sysclk1", - .parent = &pll2_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV1, -}; - -static struct clk pll2_sysclk2 = { - .name = "pll2_sysclk2", - .parent = &pll2_clk, - .flags = CLK_PLL, - .div_reg = PLLDIV2, -}; - -static struct clk pll2_sysclkbp = { - .name = "pll2_sysclkbp", - .parent = &pll2_clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg = BPDIV -}; - -static struct clk dsp_clk = { - .name = "dsp", - .parent = &pll1_sysclk1, - .lpsc = DAVINCI_LPSC_GEM, - .domain = DAVINCI_GPSC_DSPDOMAIN, - .usecount = 1, /* REVISIT how to disable? */ -}; - -static struct clk arm_clk = { - .name = "arm", - .parent = &pll1_sysclk2, - .lpsc = DAVINCI_LPSC_ARM, - .flags = ALWAYS_ENABLED, -}; - -static struct clk vicp_clk = { - .name = "vicp", - .parent = &pll1_sysclk2, - .lpsc = DAVINCI_LPSC_IMCOP, - .domain = DAVINCI_GPSC_DSPDOMAIN, - .usecount = 1, /* REVISIT how to disable? */ -}; - -static struct clk vpss_master_clk = { - .name = "vpss_master", - .parent = &pll1_sysclk3, - .lpsc = DAVINCI_LPSC_VPSSMSTR, - .flags = CLK_PSC, -}; - -static struct clk vpss_slave_clk = { - .name = "vpss_slave", - .parent = &pll1_sysclk3, - .lpsc = DAVINCI_LPSC_VPSSSLV, -}; - -static struct clk uart0_clk = { - .name = "uart0", - .parent = &pll1_aux_clk, - .lpsc = DAVINCI_LPSC_UART0, -}; - -static struct clk uart1_clk = { - .name = "uart1", - .parent = &pll1_aux_clk, - .lpsc = DAVINCI_LPSC_UART1, -}; - -static struct clk uart2_clk = { - .name = "uart2", - .parent = &pll1_aux_clk, - .lpsc = DAVINCI_LPSC_UART2, -}; - -static struct clk emac_clk = { - .name = "emac", - .parent = &pll1_sysclk5, - .lpsc = DAVINCI_LPSC_EMAC_WRAPPER, -}; - -static struct clk i2c_clk = { - .name = "i2c", - .parent = &pll1_aux_clk, - .lpsc = DAVINCI_LPSC_I2C, -}; - -static struct clk ide_clk = { - .name = "ide", - .parent = &pll1_sysclk5, - .lpsc = DAVINCI_LPSC_ATA, -}; - -static struct clk asp_clk = { - .name = "asp0", - .parent = &pll1_sysclk5, - .lpsc = DAVINCI_LPSC_McBSP, -}; - -static struct clk mmcsd_clk = { - .name = "mmcsd", - .parent = &pll1_sysclk5, - .lpsc = DAVINCI_LPSC_MMC_SD, -}; - -static struct clk spi_clk = { - .name = "spi", - .parent = &pll1_sysclk5, - .lps
[PATCH v8 41/42] ARM: davinci: da8xx-dt: switch to device tree clocks
This removes all of the clock init code from da8xx-dt.c. This includes all of the OF_DEV_AUXDATA that was just used for looking up clocks. Signed-off-by: David Lechner --- v8 changes: - none v7 changes: - rebased - drop of_platform_default_populate(NULL, NULL, NULL) - add change in pm_domain.c Note: I didn't see this until it was too late, but Bartosz has an interesting alternative for the legacy PM domain stuff at https://github.com/brgl/linux/commit/0197b11512e44206708f4bd320c369a2a163e82d v6 changes: - removed misleading statement from commit message arch/arm/mach-davinci/da8xx-dt.c | 58 --- arch/arm/mach-davinci/pm_domain.c | 5 2 files changed, 5 insertions(+), 58 deletions(-) diff --git a/arch/arm/mach-davinci/da8xx-dt.c b/arch/arm/mach-davinci/da8xx-dt.c index 088bc5c..23ac410 100644 --- a/arch/arm/mach-davinci/da8xx-dt.c +++ b/arch/arm/mach-davinci/da8xx-dt.c @@ -19,67 +19,10 @@ #include "cp_intc.h" #include -static struct of_dev_auxdata da850_aemif_auxdata_lookup[] = { - OF_DEV_AUXDATA("ti,davinci-nand", 0x6200, "davinci-nand.0", NULL), - {} -}; - -static struct aemif_platform_data aemif_data = { - .dev_lookup = da850_aemif_auxdata_lookup, -}; - -static struct of_dev_auxdata da850_auxdata_lookup[] __initdata = { - OF_DEV_AUXDATA("ti,davinci-i2c", 0x01c22000, "i2c_davinci.1", NULL), - OF_DEV_AUXDATA("ti,davinci-i2c", 0x01e28000, "i2c_davinci.2", NULL), - OF_DEV_AUXDATA("ti,davinci-wdt", 0x01c21000, "davinci-wdt", NULL), - OF_DEV_AUXDATA("ti,da830-mmc", 0x01c4, "da830-mmc.0", NULL), - OF_DEV_AUXDATA("ti,da850-ehrpwm", 0x01f0, "ehrpwm.0", NULL), - OF_DEV_AUXDATA("ti,da850-ehrpwm", 0x01f02000, "ehrpwm.1", NULL), - OF_DEV_AUXDATA("ti,da850-ecap", 0x01f06000, "ecap.0", NULL), - OF_DEV_AUXDATA("ti,da850-ecap", 0x01f07000, "ecap.1", NULL), - OF_DEV_AUXDATA("ti,da850-ecap", 0x01f08000, "ecap.2", NULL), - OF_DEV_AUXDATA("ti,da830-spi", 0x01c41000, "spi_davinci.0", NULL), - OF_DEV_AUXDATA("ti,da830-spi", 0x01f0e000, "spi_davinci.1", NULL), - OF_DEV_AUXDATA("ns16550a", 0x01c42000, "serial8250.0", NULL), - OF_DEV_AUXDATA("ns16550a", 0x01d0c000, "serial8250.1", NULL), - OF_DEV_AUXDATA("ns16550a", 0x01d0d000, "serial8250.2", NULL), - OF_DEV_AUXDATA("ti,davinci_mdio", 0x01e24000, "davinci_mdio.0", NULL), - OF_DEV_AUXDATA("ti,davinci-dm6467-emac", 0x01e2, "davinci_emac.1", - NULL), - OF_DEV_AUXDATA("ti,da830-mcasp-audio", 0x01d0, "davinci-mcasp.0", NULL), - OF_DEV_AUXDATA("ti,da850-aemif", 0x6800, "ti-aemif", &aemif_data), - OF_DEV_AUXDATA("ti,da850-tilcdc", 0x01e13000, "da8xx_lcdc.0", NULL), - OF_DEV_AUXDATA("ti,da830-ohci", 0x01e25000, "ohci-da8xx", NULL), - OF_DEV_AUXDATA("ti,da830-musb", 0x01e0, "musb-da8xx", NULL), - OF_DEV_AUXDATA("ti,da830-usb-phy", 0x01c1417c, "da8xx-usb-phy", NULL), - OF_DEV_AUXDATA("ti,da850-ahci", 0x01e18000, "ahci_da850", NULL), - OF_DEV_AUXDATA("ti,da850-vpif", 0x01e17000, "vpif", NULL), - OF_DEV_AUXDATA("ti,da850-dsp", 0x1180, "davinci-rproc.0", NULL), - {} -}; - #ifdef CONFIG_ARCH_DAVINCI_DA850 static void __init da850_init_machine(void) { - /* All existing boards use 100MHz SATA refclkpn */ - static const unsigned long sata_refclkpn = 100 * 1000 * 1000; - - int ret; - - da850_register_clocks(); - - ret = da8xx_register_usb_phy_clocks(); - if (ret) - pr_warn("%s: USB PHY CLK registration failed: %d\n", - __func__, ret); - - ret = da850_register_sata_refclk(sata_refclkpn); - if (ret) - pr_warn("%s: registering SATA REFCLK failed: %d", - __func__, ret); - - of_platform_default_populate(NULL, da850_auxdata_lookup, NULL); davinci_pm_init(); pdata_quirks_init(); } @@ -94,7 +37,6 @@ static const char *const da850_boards_compat[] __initconst = { DT_MACHINE_START(DA850_DT, "Generic DA850/OMAP-L138/AM18x") .map_io = da850_init, - .init_time = da850_init_time, .init_machine = da850_init_machine, .dt_compat = da850_boards_compat, .init_late = davinci_init_late, diff --git a/arch/arm/mach-davinci/pm_domain.c b/arch/arm/mach-davinci/pm_domain.c index 78eac2c..e251fd5 100644 --- a/arch/arm/mach-davinci/pm_domain.c +++ b/arch/arm/mach-davinci/pm_domain.c @@ -13,6 +13,7 @@ #include #include #include +#include static struct dev_pm_domain davinci_pm_domain = { .ops = { @@ -28,6 +29,10 @@ static struct pm_clk_notifier_block platform_bus_notifier = { static int __init davinci_pm_runtime_init(void) { + if (of_have_populated_dt()) + return 0; + + /* Use pm_clk as fallback if we're not using genpd. */ pm_clk_add_notifier(&platform_bus_type, &platform_bus_noti
[PATCH v8 33/42] ARM: davinci: da850: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/da850.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - rebased v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/board-omapl138-hawk.c | 12 +- arch/arm/mach-davinci/da850.c | 653 +--- arch/arm/mach-davinci/da8xx-dt.c| 12 +- 3 files changed, 3 insertions(+), 674 deletions(-) diff --git a/arch/arm/mach-davinci/board-omapl138-hawk.c b/arch/arm/mach-davinci/board-omapl138-hawk.c index 6a866d2..6c997c5 100644 --- a/arch/arm/mach-davinci/board-omapl138-hawk.c +++ b/arch/arm/mach-davinci/board-omapl138-hawk.c @@ -231,22 +231,12 @@ static __init void omapl138_hawk_usb_init(void) pr_warn("%s: USB 1.1 PinMux setup failed: %d\n", __func__, ret); return; } -#ifdef CONFIG_COMMON_CLK + ret = da8xx_register_usb_phy_clocks(); if (ret) pr_warn("%s: USB PHY CLK registration failed: %d\n", __func__, ret); -#else - ret = da8xx_register_usb20_phy_clk(false); - if (ret) - pr_warn("%s: USB 2.0 PHY CLK registration failed: %d\n", - __func__, ret); - ret = da8xx_register_usb11_phy_clk(false); - if (ret) - pr_warn("%s: USB 1.1 PHY CLK registration failed: %d\n", - __func__, ret); -#endif ret = da8xx_register_usb_phy(); if (ret) pr_warn("%s: USB PHY registration failed: %d\n", diff --git a/arch/arm/mach-davinci/da850.c b/arch/arm/mach-davinci/da850.c index ae7c429..3f27d46 100644 --- a/arch/arm/mach-davinci/da850.c +++ b/arch/arm/mach-davinci/da850.c @@ -37,559 +37,12 @@ #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - #define DA850_PLL1_BASE0x01e1a000 #define DA850_TIMER64P2_BASE 0x01f0c000 #define DA850_TIMER64P3_BASE 0x01f0d000 #define DA850_REF_FREQ 2400 -#ifndef CONFIG_COMMON_CLK -static int da850_set_armrate(struct clk *clk, unsigned long rate); -static int da850_round_armrate(struct clk *clk, unsigned long rate); -static int da850_set_pll0rate(struct clk *clk, unsigned long armrate); - -static struct pll_data pll0_data = { - .num= 1, - .phys_base = DA8XX_PLL0_BASE, - .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - .rate = DA850_REF_FREQ, - .set_rate = davinci_simple_set_rate, -}; - -static struct clk pll0_clk = { - .name = "pll0", - .parent = &ref_clk, - .pll_data = &pll0_data, - .flags = CLK_PLL, - .set_rate = da850_set_pll0rate, -}; - -static struct clk pll0_aux_clk = { - .name = "pll0_aux_clk", - .parent = &pll0_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll0_sysclk1 = { - .name = "pll0_sysclk1", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV1, -}; - -static struct clk pll0_sysclk2 = { - .name = "pll0_sysclk2", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV2, -}; - -static struct clk pll0_sysclk3 = { - .name = "pll0_sysclk3", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV3, - .set_rate = davinci_set_sysclk_rate, - .maxrate= 1, -}; - -static struct clk pll0_sysclk4 = { - .name = "pll0_sysclk4", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV4, -}; - -static struct clk pll0_sysclk5 = { - .name = "pll0_sysclk5", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV5, -}; - -static struct clk pll0_sysclk6 = { - .name = "pll0_sysclk6", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV6, -}; - -static struct clk pll0_sysclk7 = { - .name = "pll0_sysclk7", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV7, -}; - -static struct pll_data pll1_data = { - .num= 2, - .phys_base = DA850_PLL1_BASE, - .flags = PLL_HAS_POSTDIV, -}; - -static struct clk pll1_clk = { - .name = "pll1", - .parent = &ref_clk, - .pll_data = &pll1_data, - .flags = CLK_PLL, -}; - -static struct clk pll1_aux_clk = { - .name = "pll1_aux_clk", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -
[PATCH v8 32/42] ARM: davinci: da830: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/da830.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/board-da830-evm.c | 12 - arch/arm/mach-davinci/da830.c | 412 2 files changed, 424 deletions(-) diff --git a/arch/arm/mach-davinci/board-da830-evm.c b/arch/arm/mach-davinci/board-da830-evm.c index 6e77c45..d283fae 100644 --- a/arch/arm/mach-davinci/board-da830-evm.c +++ b/arch/arm/mach-davinci/board-da830-evm.c @@ -110,23 +110,11 @@ static __init void da830_evm_usb_init(void) { int ret; -#ifdef CONFIG_COMMON_CLK ret = da8xx_register_usb_phy_clocks(); if (ret) pr_warn("%s: USB PHY CLK registration failed: %d\n", __func__, ret); -#else - /* USB_REFCLKIN is not used. */ - ret = da8xx_register_usb20_phy_clk(false); - if (ret) - pr_warn("%s: USB 2.0 PHY CLK registration failed: %d\n", - __func__, ret); - ret = da8xx_register_usb11_phy_clk(false); - if (ret) - pr_warn("%s: USB 1.1 PHY CLK registration failed: %d\n", - __func__, ret); -#endif ret = da8xx_register_usb_phy(); if (ret) pr_warn("%s: USB PHY registration failed: %d\n", diff --git a/arch/arm/mach-davinci/da830.c b/arch/arm/mach-davinci/da830.c index c1c2604..470ae48 100644 --- a/arch/arm/mach-davinci/da830.c +++ b/arch/arm/mach-davinci/da830.c @@ -23,11 +23,6 @@ #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - /* Offsets of the 8 compare registers on the da830 */ #define DA830_CMP12_0 0x60 #define DA830_CMP12_1 0x64 @@ -40,404 +35,6 @@ #define DA830_REF_FREQ 2400 -#ifndef CONFIG_COMMON_CLK -static struct pll_data pll0_data = { - .num= 1, - .phys_base = DA8XX_PLL0_BASE, - .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - .rate = DA830_REF_FREQ, -}; - -static struct clk pll0_clk = { - .name = "pll0", - .parent = &ref_clk, - .pll_data = &pll0_data, - .flags = CLK_PLL, -}; - -static struct clk pll0_aux_clk = { - .name = "pll0_aux_clk", - .parent = &pll0_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll0_sysclk2 = { - .name = "pll0_sysclk2", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV2, -}; - -static struct clk pll0_sysclk3 = { - .name = "pll0_sysclk3", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV3, -}; - -static struct clk pll0_sysclk4 = { - .name = "pll0_sysclk4", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV4, -}; - -static struct clk pll0_sysclk5 = { - .name = "pll0_sysclk5", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV5, -}; - -static struct clk pll0_sysclk6 = { - .name = "pll0_sysclk6", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV6, -}; - -static struct clk pll0_sysclk7 = { - .name = "pll0_sysclk7", - .parent = &pll0_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV7, -}; - -static struct clk i2c0_clk = { - .name = "i2c0", - .parent = &pll0_aux_clk, -}; - -static struct clk timerp64_0_clk = { - .name = "timer0", - .parent = &pll0_aux_clk, -}; - -static struct clk timerp64_1_clk = { - .name = "timer1", - .parent = &pll0_aux_clk, -}; - -static struct clk arm_rom_clk = { - .name = "arm_rom", - .parent = &pll0_sysclk2, - .lpsc = DA8XX_LPSC0_ARM_RAM_ROM, - .flags = ALWAYS_ENABLED, -}; - -static struct clk scr0_ss_clk = { - .name = "scr0_ss", - .parent = &pll0_sysclk2, - .lpsc = DA8XX_LPSC0_SCR0_SS, - .flags = ALWAYS_ENABLED, -}; - -static struct clk scr1_ss_clk = { - .name = "scr1_ss", - .parent = &pll0_sysclk2, - .lpsc = DA8XX_LPSC0_SCR1_SS, - .flags = ALWAYS_ENABLED, -}; - -static struct clk scr2_ss_clk = { - .name = "scr2_ss", - .parent = &pll0_sysclk2, - .lpsc = DA8XX_LPSC0_SCR2_SS, - .flags = ALWAYS_ENABLED, -}; - -static struct clk dmax_clk = { - .name
[PATCH v8 35/42] ARM: davinci: dm365: Remove legacy clock init
This removes the unused legacy clock init code from arch/arm/mach-davinci/dm365.c. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- v8 changes: - none v7 changes: - rebased - add davinci prefix to commit message v6 changes: - rebased arch/arm/mach-davinci/dm365.c | 449 -- 1 file changed, 449 deletions(-) diff --git a/arch/arm/mach-davinci/dm365.c b/arch/arm/mach-davinci/dm365.c index 93067e1..aa458a9 100644 --- a/arch/arm/mach-davinci/dm365.c +++ b/arch/arm/mach-davinci/dm365.c @@ -37,11 +37,6 @@ #include "davinci.h" #include "mux.h" -#ifndef CONFIG_COMMON_CLK -#include "clock.h" -#include "psc.h" -#endif - #define DM365_REF_FREQ 2400/* 24 MHz on the DM365 EVM */ #define DM365_RTC_BASE 0x01c69000 #define DM365_KEYSCAN_BASE 0x01c69400 @@ -57,441 +52,6 @@ #define DM365_EMAC_CNTRL_RAM_OFFSET0x1000 #define DM365_EMAC_CNTRL_RAM_SIZE 0x2000 -#ifndef CONFIG_COMMON_CLK -static struct pll_data pll1_data = { - .num= 1, - .phys_base = DAVINCI_PLL1_BASE, - .flags = PLL_HAS_POSTDIV | PLL_HAS_PREDIV, -}; - -static struct pll_data pll2_data = { - .num= 2, - .phys_base = DAVINCI_PLL2_BASE, - .flags = PLL_HAS_POSTDIV | PLL_HAS_PREDIV, -}; - -static struct clk ref_clk = { - .name = "ref_clk", - .rate = DM365_REF_FREQ, -}; - -static struct clk pll1_clk = { - .name = "pll1", - .parent = &ref_clk, - .flags = CLK_PLL, - .pll_data = &pll1_data, -}; - -static struct clk pll1_aux_clk = { - .name = "pll1_aux_clk", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll1_sysclkbp = { - .name = "pll1_sysclkbp", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, - .div_reg= BPDIV -}; - -static struct clk clkout0_clk = { - .name = "clkout0", - .parent = &pll1_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll1_sysclk1 = { - .name = "pll1_sysclk1", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV1, -}; - -static struct clk pll1_sysclk2 = { - .name = "pll1_sysclk2", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV2, -}; - -static struct clk pll1_sysclk3 = { - .name = "pll1_sysclk3", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV3, -}; - -static struct clk pll1_sysclk4 = { - .name = "pll1_sysclk4", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV4, -}; - -static struct clk pll1_sysclk5 = { - .name = "pll1_sysclk5", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV5, -}; - -static struct clk pll1_sysclk6 = { - .name = "pll1_sysclk6", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV6, -}; - -static struct clk pll1_sysclk7 = { - .name = "pll1_sysclk7", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV7, -}; - -static struct clk pll1_sysclk8 = { - .name = "pll1_sysclk8", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV8, -}; - -static struct clk pll1_sysclk9 = { - .name = "pll1_sysclk9", - .parent = &pll1_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV9, -}; - -static struct clk pll2_clk = { - .name = "pll2", - .parent = &ref_clk, - .flags = CLK_PLL, - .pll_data = &pll2_data, -}; - -static struct clk pll2_aux_clk = { - .name = "pll2_aux_clk", - .parent = &pll2_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk clkout1_clk = { - .name = "clkout1", - .parent = &pll2_clk, - .flags = CLK_PLL | PRE_PLL, -}; - -static struct clk pll2_sysclk1 = { - .name = "pll2_sysclk1", - .parent = &pll2_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV1, -}; - -static struct clk pll2_sysclk2 = { - .name = "pll2_sysclk2", - .parent = &pll2_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV2, -}; - -static struct clk pll2_sysclk3 = { - .name = "pll2_sysclk3", - .parent = &pll2_clk, - .flags = CLK_PLL, - .div_reg= PLLDIV3, -}; - -static struct clk p
Re: [PATCH v3 7/7] kbuild: link vmlinux only once for CONFIG_TRIM_UNUSED_KSYMS
On Fri, 16 Mar 2018, Masahiro Yamada wrote: > If CONFIG_TRIM_UNUSED_KSYMS is enabled and the kernel is built from > a pristine state, the vmlinux is linked twice. > > [1] A user runs "make" > > [2] First build with empty autoksyms.h > > [3] adjust_autoksyms.sh updates autoksyms.h and recurses "make vmlinux" > > (begin sub-make) > [4] Second build with new autoksyms.h > > [5] link-vmlinux.sh is invoked because "vmlinux" is missing > -(end sub-make)- > > [6] link-vmlinux.sh is invoked again despite "vmlinux" is up-to-date. > > The reason of [6] is probably because Make already decided to update > "vmlinux" at the time of [2] because "vmlinux" was missing when Make > built up the dependency graph. > > Because 'if_changed' is implemented based on '$?', this issue can be > narrowed down to how Make handles '$?'. > > You can test it with the following simple code: > > [Test Makefile] > A: B > @echo newer prerequisite: $? > cp B A > > B: C > cp C B > touch A > > [Result] > $ rm -f A B > $ touch C > $ make > cp C B > touch A > newer prerequisite: B > cp B A > > Here, 'A' has been touched in the recipe of 'B'. So, the dependency > 'A: B' has already been met before the recipe of 'A' is executed. > However, Make does not notice the fact that the recipe of 'B' also > updates 'A' as a side-effect. > > The situation is similar in this case; 'vmlinux' has actually been > updated in the 'vmlinux_prereq' target. Make cannot predict this, so > judges 'vmlinux' is old. > > link-vmlinus.sh is costly, so it is better to not run it when unneeded. > Split CONFIG_TRIM_UNUSED_KSYMS recursion to a dedicated target. > > The reason of commit 2441e78b1919 ("kbuild: better abstract vmlinux > sequential prerequisites") was to cater to CONFIG_BUILD_DOCSRC, but > it was later removed by commit 184892925118 ("samples: move blackfin > gptimers-example from Documentation"). > > Signed-off-by: Masahiro Yamada Acked-by: Nicolas Pitre > --- > > Changes in v3: > - autoksyms_recursive should be surrounded by > ifdef CONFIG_TRIM_UNUSED_KSYMS > > Changes in v2: > - Discard my wrong change to adjust_autoksyms.sh > - Add more commit log to explain how Make is working > > Makefile | 22 ++ > 1 file changed, 10 insertions(+), 12 deletions(-) > > diff --git a/Makefile b/Makefile > index 5fee703..ff62b8e 100644 > --- a/Makefile > +++ b/Makefile > @@ -998,17 +998,9 @@ export KBUILD_ALLDIRS := $(sort $(filter-out > arch/%,$(vmlinux-alldirs)) arch Doc > > vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) > $(KBUILD_VMLINUX_LIBS) > > -# Include targets which we want to execute sequentially if the rest of the > -# kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be > -# evaluated more than once. > -PHONY += vmlinux_prereq > -vmlinux_prereq: $(vmlinux-deps) FORCE > -ifdef CONFIG_HEADERS_CHECK > - $(Q)$(MAKE) -f $(srctree)/Makefile headers_check > -endif > -ifdef CONFIG_GDB_SCRIPTS > - $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) > -endif > +# Recurse until adjust_autoksyms.sh is satisfied > +PHONY += autoksyms_recursive > +autoksyms_recursive: $(vmlinux-deps) > ifdef CONFIG_TRIM_UNUSED_KSYMS > $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ > "$(MAKE) -f $(srctree)/Makefile vmlinux" > @@ -1034,7 +1026,13 @@ cmd_link-vmlinux = > \ > $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ;\ > $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) > > -vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE > +vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE > +ifdef CONFIG_HEADERS_CHECK > + $(Q)$(MAKE) -f $(srctree)/Makefile headers_check > +endif > +ifdef CONFIG_GDB_SCRIPTS > + $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) > +endif > +$(call if_changed,link-vmlinux) > > # Build samples along the rest of the kernel > -- > 2.7.4 > >
Re: [PATCH v1 1/2] tracing: Improve design of preemptirq tracepoints and its users
On Thu, Mar 15, 2018 at 8:13 PM, kbuild test robot wrote: > Hi Joel, > > Thank you for the patch! Yet something to improve: > > [auto build test ERROR on linus/master] > [also build test ERROR on v4.16-rc5 next-20180314] > [if your patch is applied to the wrong git tree, please drop us a note to > help improve the system] > > url: > https://github.com/0day-ci/linux/commits/Joel-Fernandes/tracing-Improve-design-of-preemptirq-tracepoints-and-its-users/20180316-012211 > config: i386-randconfig-a1-201810 (attached as .config) > compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4 > reproduce: > # save the attached .config to linux build tree > make ARCH=i386 > > All errors (new ones prefixed by >>): > >kernel/locking/lockdep.c: In function 'lockdep_init': >>> kernel/locking/lockdep.c:4325:2: error: implicit declaration of function >>> 'register_trace_irq_disable' [-Werror=implicit-function-declaration] > register_trace_irq_disable(lockdep_hardirqs_off, NULL); > ^ >>> kernel/locking/lockdep.c:4326:2: error: implicit declaration of function >>> 'register_trace_irq_enable' [-Werror=implicit-function-declaration] > register_trace_irq_enable(lockdep_hardirqs_on, NULL); > ^ >cc1: some warnings being treated as errors > > vim +/register_trace_irq_disable +4325 kernel/locking/lockdep.c Can't reproduce this. Kbuild bot might be testing old patches. With the latest patches and the config kbuild shared, I don't get any errors. thanks, - Joel
[PATCH v3 7/7] kbuild: link vmlinux only once for CONFIG_TRIM_UNUSED_KSYMS
If CONFIG_TRIM_UNUSED_KSYMS is enabled and the kernel is built from a pristine state, the vmlinux is linked twice. [1] A user runs "make" [2] First build with empty autoksyms.h [3] adjust_autoksyms.sh updates autoksyms.h and recurses "make vmlinux" (begin sub-make) [4] Second build with new autoksyms.h [5] link-vmlinux.sh is invoked because "vmlinux" is missing -(end sub-make)- [6] link-vmlinux.sh is invoked again despite "vmlinux" is up-to-date. The reason of [6] is probably because Make already decided to update "vmlinux" at the time of [2] because "vmlinux" was missing when Make built up the dependency graph. Because 'if_changed' is implemented based on '$?', this issue can be narrowed down to how Make handles '$?'. You can test it with the following simple code: [Test Makefile] A: B @echo newer prerequisite: $? cp B A B: C cp C B touch A [Result] $ rm -f A B $ touch C $ make cp C B touch A newer prerequisite: B cp B A Here, 'A' has been touched in the recipe of 'B'. So, the dependency 'A: B' has already been met before the recipe of 'A' is executed. However, Make does not notice the fact that the recipe of 'B' also updates 'A' as a side-effect. The situation is similar in this case; 'vmlinux' has actually been updated in the 'vmlinux_prereq' target. Make cannot predict this, so judges 'vmlinux' is old. link-vmlinus.sh is costly, so it is better to not run it when unneeded. Split CONFIG_TRIM_UNUSED_KSYMS recursion to a dedicated target. The reason of commit 2441e78b1919 ("kbuild: better abstract vmlinux sequential prerequisites") was to cater to CONFIG_BUILD_DOCSRC, but it was later removed by commit 184892925118 ("samples: move blackfin gptimers-example from Documentation"). Signed-off-by: Masahiro Yamada --- Changes in v3: - autoksyms_recursive should be surrounded by ifdef CONFIG_TRIM_UNUSED_KSYMS Changes in v2: - Discard my wrong change to adjust_autoksyms.sh - Add more commit log to explain how Make is working Makefile | 22 ++ 1 file changed, 10 insertions(+), 12 deletions(-) diff --git a/Makefile b/Makefile index 5fee703..ff62b8e 100644 --- a/Makefile +++ b/Makefile @@ -998,17 +998,9 @@ export KBUILD_ALLDIRS := $(sort $(filter-out arch/%,$(vmlinux-alldirs)) arch Doc vmlinux-deps := $(KBUILD_LDS) $(KBUILD_VMLINUX_INIT) $(KBUILD_VMLINUX_MAIN) $(KBUILD_VMLINUX_LIBS) -# Include targets which we want to execute sequentially if the rest of the -# kernel build went well. If CONFIG_TRIM_UNUSED_KSYMS is set, this might be -# evaluated more than once. -PHONY += vmlinux_prereq -vmlinux_prereq: $(vmlinux-deps) FORCE -ifdef CONFIG_HEADERS_CHECK - $(Q)$(MAKE) -f $(srctree)/Makefile headers_check -endif -ifdef CONFIG_GDB_SCRIPTS - $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) -endif +# Recurse until adjust_autoksyms.sh is satisfied +PHONY += autoksyms_recursive +autoksyms_recursive: $(vmlinux-deps) ifdef CONFIG_TRIM_UNUSED_KSYMS $(Q)$(CONFIG_SHELL) $(srctree)/scripts/adjust_autoksyms.sh \ "$(MAKE) -f $(srctree)/Makefile vmlinux" @@ -1034,7 +1026,13 @@ cmd_link-vmlinux = \ $(CONFIG_SHELL) $< $(LD) $(LDFLAGS) $(LDFLAGS_vmlinux) ;\ $(if $(ARCH_POSTLINK), $(MAKE) -f $(ARCH_POSTLINK) $@, true) -vmlinux: scripts/link-vmlinux.sh vmlinux_prereq $(vmlinux-deps) FORCE +vmlinux: scripts/link-vmlinux.sh autoksyms_recursive $(vmlinux-deps) FORCE +ifdef CONFIG_HEADERS_CHECK + $(Q)$(MAKE) -f $(srctree)/Makefile headers_check +endif +ifdef CONFIG_GDB_SCRIPTS + $(Q)ln -fsn $(abspath $(srctree)/scripts/gdb/vmlinux-gdb.py) +endif +$(call if_changed,link-vmlinux) # Build samples along the rest of the kernel -- 2.7.4
[PATCH] acpi, numa: fix pxm to online numa node associations
Commit 99759869faf1 "acpi: Add acpi_map_pxm_to_online_node()" added support for mapping a given proximity to its nearest, by SLIT distance, online node. However, it sometimes returns unexpected results due to the fact that it switches from comparing the PXM node to the last node that was closer than the current max. for_each_online_node(n) { dist = node_distance(node, n); if (dist < min_dist) { min_dist = dist; node = n; < from this point we're using the wrong node for node_distance() Fixes: 99759869faf1 ("acpi: Add acpi_map_pxm_to_online_node()") Cc: Cc: Toshi Kani Cc: Rafael J. Wysocki > Signed-off-by: Dan Williams --- Rafael, I can take this through the nvdimm tree with your ack. I have a few other nvdimm fixes pending for 4.16. drivers/acpi/numa.c | 10 ++ 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/drivers/acpi/numa.c b/drivers/acpi/numa.c index 8ccaae3550d2..85167603b9c9 100644 --- a/drivers/acpi/numa.c +++ b/drivers/acpi/numa.c @@ -103,25 +103,27 @@ int acpi_map_pxm_to_node(int pxm) */ int acpi_map_pxm_to_online_node(int pxm) { - int node, n, dist, min_dist; + int node, min_node; node = acpi_map_pxm_to_node(pxm); if (node == NUMA_NO_NODE) node = 0; + min_node = node; if (!node_online(node)) { - min_dist = INT_MAX; + int min_dist = INT_MAX, dist, n; + for_each_online_node(n) { dist = node_distance(node, n); if (dist < min_dist) { min_dist = dist; - node = n; + min_node = n; } } } - return node; + return min_node; } EXPORT_SYMBOL(acpi_map_pxm_to_online_node);
Re: [PATCH v1 1/2] tracing: Improve design of preemptirq tracepoints and its users
Hi Joel, Thank you for the patch! Yet something to improve: [auto build test ERROR on linus/master] [also build test ERROR on v4.16-rc5 next-20180314] [if your patch is applied to the wrong git tree, please drop us a note to help improve the system] url: https://github.com/0day-ci/linux/commits/Joel-Fernandes/tracing-Improve-design-of-preemptirq-tracepoints-and-its-users/20180316-012211 config: i386-randconfig-a1-201810 (attached as .config) compiler: gcc-4.9 (Debian 4.9.4-2) 4.9.4 reproduce: # save the attached .config to linux build tree make ARCH=i386 All errors (new ones prefixed by >>): kernel/locking/lockdep.c: In function 'lockdep_init': >> kernel/locking/lockdep.c:4325:2: error: implicit declaration of function >> 'register_trace_irq_disable' [-Werror=implicit-function-declaration] register_trace_irq_disable(lockdep_hardirqs_off, NULL); ^ >> kernel/locking/lockdep.c:4326:2: error: implicit declaration of function >> 'register_trace_irq_enable' [-Werror=implicit-function-declaration] register_trace_irq_enable(lockdep_hardirqs_on, NULL); ^ cc1: some warnings being treated as errors vim +/register_trace_irq_disable +4325 kernel/locking/lockdep.c 4321 4322 void __init lockdep_init(void) 4323 { 4324 #ifdef CONFIG_PROVE_LOCKING > 4325 register_trace_irq_disable(lockdep_hardirqs_off, NULL); > 4326 register_trace_irq_enable(lockdep_hardirqs_on, NULL); 4327 #endif 4328 printk("Lock dependency validator: Copyright (c) 2006 Red Hat, Inc., Ingo Molnar\n"); 4329 4330 printk("... MAX_LOCKDEP_SUBCLASSES: %lu\n", MAX_LOCKDEP_SUBCLASSES); 4331 printk("... MAX_LOCK_DEPTH: %lu\n", MAX_LOCK_DEPTH); 4332 printk("... MAX_LOCKDEP_KEYS:%lu\n", MAX_LOCKDEP_KEYS); 4333 printk("... CLASSHASH_SIZE: %lu\n", CLASSHASH_SIZE); 4334 printk("... MAX_LOCKDEP_ENTRIES: %lu\n", MAX_LOCKDEP_ENTRIES); 4335 printk("... MAX_LOCKDEP_CHAINS: %lu\n", MAX_LOCKDEP_CHAINS); 4336 printk("... CHAINHASH_SIZE: %lu\n", CHAINHASH_SIZE); 4337 4338 printk(" memory used by lock dependency info: %lu kB\n", 4339 (sizeof(struct lock_class) * MAX_LOCKDEP_KEYS + 4340 sizeof(struct list_head) * CLASSHASH_SIZE + 4341 sizeof(struct lock_list) * MAX_LOCKDEP_ENTRIES + 4342 sizeof(struct lock_chain) * MAX_LOCKDEP_CHAINS + 4343 sizeof(struct list_head) * CHAINHASH_SIZE 4344 #ifdef CONFIG_PROVE_LOCKING 4345 + sizeof(struct circular_queue) 4346 #endif 4347 ) / 1024 4348 ); 4349 4350 printk(" per task-struct memory footprint: %lu bytes\n", 4351 sizeof(struct held_lock) * MAX_LOCK_DEPTH); 4352 } 4353 --- 0-DAY kernel test infrastructureOpen Source Technology Center https://lists.01.org/pipermail/kbuild-all Intel Corporation .config.gz Description: application/gzip
Re: New -Werror=restrict error with incremental gcc
On Thu, Mar 15, 2018 at 08:06:26AM -0700, Laura Abbott wrote: > This only showed up with the very latest rawhide snapshot, .17 worked and > .18 started failing. I had to download .18 manually to test locally > https://koji.fedoraproject.org/koji/packageinfo?packageID=40 I also see the error with the latest gcc master branch. The code is harmless, but maybe the warning is useful in other places, so here's one way to fix it. From: Josh Poimboeuf Subject: [PATCH] objtool, perf: Fix GCC 8 -Wrestrict error Starting with recent GCC 8 builds, objtool and perf fail to build with the following error: ../str_error_r.c: In function ‘str_error_r’: ../str_error_r.c:25:3: error: passing argument 1 to restrict-qualified parameter aliases with argument 5 [-Werror=restrict] snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err); The code seems harmless, but there's probably no benefit in printing the 'buf' pointer in this situation anyway, so just remove it to make GCC happy. Signed-off-by: Josh Poimboeuf --- tools/lib/str_error_r.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/lib/str_error_r.c b/tools/lib/str_error_r.c index d6d65537b0d9..6aad8308a0ac 100644 --- a/tools/lib/str_error_r.c +++ b/tools/lib/str_error_r.c @@ -22,6 +22,6 @@ char *str_error_r(int errnum, char *buf, size_t buflen) { int err = strerror_r(errnum, buf, buflen); if (err) - snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, %p, %zd)=%d", errnum, buf, buflen, err); + snprintf(buf, buflen, "INTERNAL ERROR: strerror_r(%d, [buf], %zd)=%d", errnum, buflen, err); return buf; } -- 2.14.3
Re: [PATCH v8 12/42] clk: davinci: Add platform information for TI DA850 PSC
On 03/15/2018 09:52 PM, David Lechner wrote: This adds platform-specific declarations for the PSC clocks on TI DA850/ OMAP-L138/AM18XX SoCs. Signed-off-by: David Lechner Reviewed-by: Sekhar Nori --- This Reviewed-by: was supposed to be dropped. This file has had some significant changes.
[git pull] drm fixes for 4.16-rc6
Hi Linus, i915 has a backlight fix for some panels, a pm and a fencing fix, along with some GVT fixes. amdgpu has a backlight fix across suspend/resume, an object destruction ordering issue fix, and a displayport fix nouveau has two backlight fixes, and a fix for some lockups. Pretty quiet week, seems like everyone was fixing backlights. Dave. The following changes since commit 0c8efd610b58cb23cefdfa12015799079aef94ae: Linux 4.16-rc5 (2018-03-11 17:25:09 -0700) are available in the Git repository at: git://people.freedesktop.org/~airlied/linux tags/drm-fixes-for-v4.16-rc6 for you to fetch changes up to 3a1b5de36fdf403d1b004e537dc13997633d65df: Merge tag 'drm-intel-fixes-2018-03-15' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes (2018-03-16 12:51:35 +1000) i915, amd and nouveau fixes Alex Deucher (1): drm/amdgpu: save/restore backlight level in legacy dce code Chris Wilson (2): drm/i915: Only prune fences after wait-for-all drm/i915: Kick the rps worker when changing the boost frequency Christian König (2): drm/amdgpu: fix prime teardown order drm/radeon: fix prime teardown order Dave Airlie (4): Merge branch 'drm-fixes-4.16' of git://people.freedesktop.org/~agd5f/linux into drm-fixes Merge tag 'drm-intel-fixes-2018-03-14' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes Merge branch 'linux-4.16' of git://github.com/skeggsb/linux into drm-fixes Merge tag 'drm-intel-fixes-2018-03-15' of git://anongit.freedesktop.org/drm/drm-intel into drm-fixes Karol Herbst (1): drm/nouveau/bl: fix backlight regression Lukas Wunner (1): drm/nouveau/bl: Fix oops on driver unbind Michel Dänzer (1): drm/amdgpu/dce: Don't turn off DP sink when disconnected Min He (1): drm/i915/gvt: keep oa config in shadow ctx Mustamin B Mustaffa (1): drm/i915: Enable VBT based BL control for DP Māris Nartišs (1): drm/nouveau/mmu: ALIGN_DOWN correct variable Rodrigo Vivi (1): Merge tag 'gvt-fixes-2018-03-15' of https://github.com/intel/gvt-linux into drm-intel-fixes Xiong Zhang (1): drm/i915/gvt: Add runtime_pm_get/put into gvt_switch_mmio Zhenyu Wang (1): drm/i915/gvt: fix user copy warning by whitelist workload rb_tail field fred gao (1): drm/i915/gvt: Correct the privilege shadow batch buffer address drivers/gpu/drm/amd/amdgpu/amdgpu_connectors.c | 31 +-- drivers/gpu/drm/amd/amdgpu/amdgpu_gem.c| 2 - drivers/gpu/drm/amd/amdgpu/amdgpu_mode.h | 1 + drivers/gpu/drm/amd/amdgpu/amdgpu_object.c | 2 + drivers/gpu/drm/amd/amdgpu/atombios_encoders.c | 4 +- drivers/gpu/drm/amd/amdgpu/atombios_encoders.h | 5 ++ drivers/gpu/drm/amd/amdgpu/dce_v10_0.c | 8 +++ drivers/gpu/drm/amd/amdgpu/dce_v11_0.c | 8 +++ drivers/gpu/drm/amd/amdgpu/dce_v6_0.c | 8 +++ drivers/gpu/drm/amd/amdgpu/dce_v8_0.c | 8 +++ drivers/gpu/drm/i915/gvt/cmd_parser.c | 8 +++ drivers/gpu/drm/i915/gvt/mmio_context.c| 2 + drivers/gpu/drm/i915/gvt/scheduler.c | 71 -- drivers/gpu/drm/i915/gvt/scheduler.h | 5 ++ drivers/gpu/drm/i915/i915_gem.c| 16 -- drivers/gpu/drm/i915/i915_sysfs.c | 10 +++- drivers/gpu/drm/i915/intel_dp.c| 10 ++-- drivers/gpu/drm/nouveau/nouveau_backlight.c| 14 ++--- drivers/gpu/drm/nouveau/nvkm/subdev/mmu/vmm.c | 2 +- drivers/gpu/drm/radeon/radeon_gem.c| 2 - drivers/gpu/drm/radeon/radeon_object.c | 2 + 21 files changed, 169 insertions(+), 50 deletions(-)
Re: [PATCH v4 1/2] kernel.h: Introduce const_max() for VLA removal
On Fri, Mar 16, 2018 at 12:49 AM, Kees Cook wrote: > On Thu, Mar 15, 2018 at 4:46 PM, Linus Torvalds > wrote: >> What I'm *not* so much ok with is "const_max(5,sizeof(x))" erroring >> out, or silently causing insane behavior due to hidden subtle type >> casts.. > > Yup! I like it as an explicit argument. Thanks! > What about something like this? #define INTMAXT_MAX LLONG_MAX typedef int64_t intmax_t; #define const_max(x, y) \ __builtin_choose_expr(\ !__builtin_constant_p(x) || !__builtin_constant_p(y), \ __error_not_const_arg(), \ __builtin_choose_expr(\ (x) > INTMAXT_MAX || (y) > INTMAXT_MAX, \ __error_too_big(),\ __builtin_choose_expr(\ (intmax_t)(x) >= (intmax_t)(y), \ (x), \ (y) \ ) \ ) \ ) Works for different types, allows to mix negatives and positives and returns the original type, e.g.: const_max(-1, sizeof(char)); is of type 'long unsigned int', but: const_max(2, sizeof(char)); is of type 'int'. While I am not a fan that the return type depends on the arguments, it is useful if you are going to use the expression in something that needs expects a precise (a printk() for instance?). The check against the INTMAXT_MAX is there to avoid complexity (if we do not handle those cases, it is safe to use intmax_t for the comparison; otherwise you have to have another compile time branch for the case positive-positive using uintmax_t) and also avoids odd warnings for some cases above LLONG_MAX about comparisons with 0 for unsigned expressions being always true. On the positive side, it prevents using the macro for thing like "(size_t)-1". Cheers, Miguel
Re: [RFC v2 03/83] Add super.h.
On Thu, Mar 15, 2018 at 09:38:29PM +0100, Arnd Bergmann wrote: > > You could also have a resolution of less than a nanosecond. Note > that today, the file time stamps generated by the kernel are in > jiffies resolution, so at best one millisecond. However, most modern > file systems go with the 64+32 bit timestamps because it's not all > that expensive. It actually depends on the architecture and the accuracy/granularity of the timekeeping hardware available to the system, but it's possible for the granularity of file time stamps to be up to one nanosecond. So you can get results like this: % stat unix_io.o File: unix_io.o Size: 55000 Blocks: 112IO Block: 4096 regular file Device: fc01h/64513dInode: 19931278Links: 1 Access: (0644/-rw-r--r--) Uid: (15806/ tytso) Gid: (15806/ tytso) Access: 2018-03-15 18:09:21.679914182 -0400 Modify: 2018-03-15 18:09:21.639914089 -0400 Change: 2018-03-15 18:09:21.639914089 -0400 Cheers, - Ted
[PATCH v8 02/42] clk: davinci: New driver for davinci PLL clocks
This adds a new driver for mach-davinci PLL clocks. This is porting the code from arch/arm/mach-davinci/clock.c to the common clock framework. Additionally, it adds device tree support for these clocks. The ifeq ($(CONFIG_COMMON_CLK), y) in the Makefile is needed to prevent compile errors until the clock code in arch/arm/mach-davinci is removed. Note: although there are similar clocks for TI Keystone we are not able to share the code for a few reasons. The keystone clocks are device tree only and use legacy one-node-per-clock bindings. Also the register layouts are a bit different, which would add even more if/else mess to the keystone clocks. And the keystone PLL driver doesn't support setting clock rates. Signed-off-by: David Lechner --- v8 changes: - use platform data to pass CFGCHIP from legacy board files - change div_info parameter to array of pointer instead of array of struct v7 changes: - convert to platform device driver - rename PLL_HAS_OSCIN to PLL_HAS_CLKMODE - add comments to clarify which clock domain "oscin" is v6 changes: - Added R: Sekhar Nori to MAINTAINERS - Split main PLL clock into oscdiv, prediv, pllout, postdiv and pllen clocks - Added min/max rate checking for pllout in set_rate - Added min/max PLLM value checking for pllout in set_rate - Fixed sysclk set_rate (checking GOSTAT and setting GOSET) - Added *_clk_info structs for passing controller-specific info - Added quirks for optional PREDIV and POSTDIV registers - Added quirk for DM355 broken PREDIV register - Added quirk for DM365 2x PLLM register - Handle unlocking PLL registers via CFGCHIP - Use pr_fmt macro MAINTAINERS | 7 + drivers/clk/Makefile | 1 + drivers/clk/davinci/Makefile | 5 + drivers/clk/davinci/pll.c | 888 ++ drivers/clk/davinci/pll.h | 120 include/linux/platform_data/clk-davinci-pll.h | 21 + 6 files changed, 1042 insertions(+) create mode 100644 drivers/clk/davinci/Makefile create mode 100644 drivers/clk/davinci/pll.c create mode 100644 drivers/clk/davinci/pll.h create mode 100644 include/linux/platform_data/clk-davinci-pll.h diff --git a/MAINTAINERS b/MAINTAINERS index 93a12af..161fdba 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -13793,6 +13793,13 @@ F: arch/arm/mach-davinci/ F: drivers/i2c/busses/i2c-davinci.c F: arch/arm/boot/dts/da850* +TI DAVINCI SERIES CLOCK DRIVER +M: David Lechner +R: Sekhar Nori +S: Maintained +F: Documentation/devicetree/bindings/clock/ti/davinci/ +F: drivers/clk/davinci/ + TI DAVINCI SERIES GPIO DRIVER M: Keerthy L: linux-g...@vger.kernel.org diff --git a/drivers/clk/Makefile b/drivers/clk/Makefile index 71ec41e..07ac0fdb 100644 --- a/drivers/clk/Makefile +++ b/drivers/clk/Makefile @@ -61,6 +61,7 @@ obj-$(CONFIG_ARCH_ARTPEC) += axis/ obj-$(CONFIG_ARC_PLAT_AXS10X) += axs10x/ obj-y += bcm/ obj-$(CONFIG_ARCH_BERLIN) += berlin/ +obj-$(CONFIG_ARCH_DAVINCI) += davinci/ obj-$(CONFIG_H8300)+= h8300/ obj-$(CONFIG_ARCH_HISI)+= hisilicon/ obj-y += imgtec/ diff --git a/drivers/clk/davinci/Makefile b/drivers/clk/davinci/Makefile new file mode 100644 index 000..d9673bd --- /dev/null +++ b/drivers/clk/davinci/Makefile @@ -0,0 +1,5 @@ +# SPDX-License-Identifier: GPL-2.0 + +ifeq ($(CONFIG_COMMON_CLK), y) +obj-y += pll.o +endif diff --git a/drivers/clk/davinci/pll.c b/drivers/clk/davinci/pll.c new file mode 100644 index 000..22ee95c --- /dev/null +++ b/drivers/clk/davinci/pll.c @@ -0,0 +1,888 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PLL clock driver for TI Davinci SoCs + * + * Copyright (C) 2018 David Lechner + * + * Based on arch/arm/mach-davinci/clock.c + * Copyright (C) 2006-2007 Texas Instruments. + * Copyright (C) 2008-2009 Deep Root Systems, LLC + */ + +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pll.h" + +#define MAX_NAME_SIZE 20 +#define OSCIN_CLK_NAME "oscin" + +#define REVID 0x000 +#define PLLCTL 0x100 +#define OCSEL 0x104 +#define PLLSECCTL 0x108 +#define PLLM 0x110 +#define PREDIV 0x114 +#define PLLDIV10x118 +#define PLLDIV20x11c +#define PLLDIV30x120 +#define OSCDIV 0x124 +#define POSTDIV0x128 +#define BPDIV 0x12c +#define PLLCMD 0x138 +#define PLLSTAT0x13c +#define ALNCTL 0x140 +#define DCHANGE0x144 +#define CKEN 0x148 +#define CKSTAT 0x14c +#define SYSTAT 0x150 +#define PLLDIV40x160 +#define PLLDIV50x164 +#define PLLDI
[PATCH v8 00/42] ARM: davinci: convert to common clock framework
This series converts mach-davinci to use the common clock framework. The series works like this, the first 19 patches create new clock drivers using the common clock framework. There are basically 3 groups of clocks - PLL, PSC and CFGCHIP (syscon). There are six different SoCs that each have unique init data, which is the reason for so many patches. Then, starting with "ARM: davinci: pass clock as parameter to davinci_timer_init()", we get the mach code ready for the switch by adding the code needed for the new clock drivers and adding #ifndef CONFIG_COMMON_CLK around the legacy clocks so that we can switch easily between the old and the new. "ARM: davinci: switch to common clock framework" actually flips the switch to start using the new clock drivers. Then the next 8 patches remove all of the old clock code. The final three patches add device tree clock support to the one SoC that supports it. This series has been tested on LEGO MINDSTORMS EV3 (device tree) and TI OMAP-L138 LCDK (both device tree and legacy board file). Changes: v8 changes (also see individual patches for details): - Rebased on linux-davinci/master - Dropped use of __init and __initconst attributes in clk drivers - Add clkdev lookups for PLL SYSCLKs - Fix genpd clock reference counting issue - Fix PSC clock driver loading order issue - Fix typo in device tree and add more power-domains properties v7 changes (also see individual patches for details): - Rebased on linux-davinci/master (v4.16-rc) - Convert clock drivers to platform devices - New patch "ARM: davinci: pass clock as parameter to davinci_timer_init()" - Fix issues with lcdk and aemif clock lookups and power domains - Fixed other minor issues brought up in v6 review v6 changes (also see individual patches for details): - All of the device tree bindings are changed - All of the clock drivers are changed significantly - Fixed issues brought up during review of v5 - "ARM: davinci: move davinci_clk_init() to init_time" is removed from this series and submitted separately v5 changes: - Basically, this is an entirely new series - Patches are broken up into bite-sized pieces - Converted PSC clock driver to use regmap - Restored "force" flag for certain DA850 clocks - Added device tree bindings - Moved more of the clock init to drivers/clk - Fixed frequency scaling (maybe*) * I have frequency scaling using cpufreq-dt, so I know the clocks are doing what they need to do to make this work, but I haven't figured out how to test davinci-cpufreq driver yet. (Patches to make cpufreq-dt work will be sent separately after this series has landed.) Dependencies: - "ARM: davinci: fix the GPIO lookup for omapl138-hawk"[1] (in linux-davinci/fixes) - "drm/tilcdc: Fix setting clock divider for omap-l138"[2] (new) - "ARM: davinci: DA8XX: fix oops in USB PHY driver due to stack allocated platform platform_data"[3] (new) - "ARM: davinci: DA8XX: simplify CFGCHIP regmap_config"[4] (new) - "clk: divider: export clk_div_mask() helper"[5] (in clk/fixes) - "clk: divider: read-only divider can propagate rate change"[6] (in clk/fixes) - "gpio: Handle deferred probing in of_find_gpio() properly"[7] (in v4.16-rc4) - "gpiolib: Keep returning EPROBE_DEFER when we should"[8] (in v4.16-rc4) [1]: https://git.kernel.org/pub/scm/linux/kernel/git/nsekhar/linux-davinci.git/commit/?h=fixes&id=c4dc56be7e26040bfc60ce73425353516a356955 [2]: https://patchwork.freedesktop.org/patch/210696/ [3]: https://patchwork.kernel.org/patch/10285679/ [4]: https://patchwork.kernel.org/patch/10285605/ [5]: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/commit/?h=clk-next&id=e6d3cc7b1fac3d7f1313faf8ac9b23830113e3ec [6]: https://git.kernel.org/pub/scm/linux/kernel/git/clk/linux.git/commit/?h=clk-next&id=b15ee490e16324c35b51f04bad54ae45a2cefd29 [7]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=ce27fb2c56db6ccfe8099343bb4afdab15e77e7b [8]: https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=6662ae6af82df10259a70c7569b4c12ea7f3ba93 You can find a working branch with everything included (plus a few extras, like cpufreq-dt) in the "common-clk-v8" branch of https://github.com/dlech/ev3dev-kernel.git. Testing/debugging for the uninitiated: I only have one device to test with, which is based on da850, so I will have to rely on others to do some testing here. Since we are dealing with clocks, if something isn't working, you most likely won't see output on the serial port. To figure out what is going on, you need to enable... CONFIG_DEBUG_LL=y CONFIG_EARLY_PRINTK=y and add "earlyprintk clk_ignore_unused" to the kernel command line options. You may need to select a different UART for this depending on your board. I think UART1 is the default in the kernel configuration. On da850 devices comment out the lines: else clk_set_parent(clk, parent->clk); in da850.c or, if using device tree, comment out the l
[PATCH v8 04/42] clk: davinci: Add platform information for TI DA850 PLL
This adds platform-specific declarations for the PLL clocks on TI DA850/ OMAP-L138/AM18XX SoCs. Signed-off-by: David Lechner --- v8 changes: - drop __init and __initconst attributes - add a clkdev lookup for each SYSCLK v7 changes: - include clkdev lookup registration here instead of in mach-davinci - split registration functions for each PLL - Add platform_device_id lookup v6 changes: - Added da850_pll{0,1}_info with controller-specific information - Added OBSCLK data - Add empty lines between function calls drivers/clk/davinci/Makefile| 1 + drivers/clk/davinci/pll-da850.c | 212 drivers/clk/davinci/pll.c | 4 + drivers/clk/davinci/pll.h | 5 + 4 files changed, 222 insertions(+) create mode 100644 drivers/clk/davinci/pll-da850.c diff --git a/drivers/clk/davinci/Makefile b/drivers/clk/davinci/Makefile index 9061e19..13049d4 100644 --- a/drivers/clk/davinci/Makefile +++ b/drivers/clk/davinci/Makefile @@ -3,4 +3,5 @@ ifeq ($(CONFIG_COMMON_CLK), y) obj-y += pll.o obj-$(CONFIG_ARCH_DAVINCI_DA830) += pll-da830.o +obj-$(CONFIG_ARCH_DAVINCI_DA850) += pll-da850.o endif diff --git a/drivers/clk/davinci/pll-da850.c b/drivers/clk/davinci/pll-da850.c new file mode 100644 index 000..2a038b7 --- /dev/null +++ b/drivers/clk/davinci/pll-da850.c @@ -0,0 +1,212 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PLL clock descriptions for TI DA850/OMAP-L138/AM18XX + * + * Copyright (C) 2018 David Lechner + */ + +#include +#include +#include +#include +#include +#include +#include +#include + +#include "pll.h" + +#define OCSEL_OCSRC_OSCIN 0x14 +#define OCSEL_OCSRC_PLL0_SYSCLK(n) (0x16 + (n)) +#define OCSEL_OCSRC_PLL1_OBSCLK0x1e +#define OCSEL_OCSRC_PLL1_SYSCLK(n) (0x16 + (n)) + +static const struct davinci_pll_clk_info da850_pll0_info = { + .name = "pll0", + .unlock_reg = CFGCHIP(0), + .unlock_mask = CFGCHIP0_PLL_MASTER_LOCK, + .pllm_mask = GENMASK(4, 0), + .pllm_min = 4, + .pllm_max = 32, + .pllout_min_rate = 3, + .pllout_max_rate = 6, + .flags = PLL_HAS_CLKMODE | PLL_HAS_PREDIV | PLL_HAS_POSTDIV | +PLL_HAS_EXTCLKSRC, +}; + +/* + * NB: Technically, the clocks flagged as SYSCLK_FIXED_DIV are "fixed ratio", + * meaning that we could change the divider as long as we keep the correct + * ratio between all of the clocks, but we don't support that because there is + * currently not a need for it. + */ + +SYSCLK(1, pll0_sysclk1, pll0_pllen, 5, SYSCLK_FIXED_DIV); +SYSCLK(2, pll0_sysclk2, pll0_pllen, 5, SYSCLK_FIXED_DIV); +SYSCLK(3, pll0_sysclk3, pll0_pllen, 5, 0); +SYSCLK(4, pll0_sysclk4, pll0_pllen, 5, SYSCLK_FIXED_DIV); +SYSCLK(5, pll0_sysclk5, pll0_pllen, 5, 0); +SYSCLK(6, pll0_sysclk6, pll0_pllen, 5, SYSCLK_ARM_RATE | SYSCLK_FIXED_DIV); +SYSCLK(7, pll0_sysclk7, pll0_pllen, 5, 0); + +static const char * const da850_pll0_obsclk_parent_names[] = { + "oscin", + "pll0_sysclk1", + "pll0_sysclk2", + "pll0_sysclk3", + "pll0_sysclk4", + "pll0_sysclk5", + "pll0_sysclk6", + "pll0_sysclk7", + "pll1_obsclk", +}; + +static u32 da850_pll0_obsclk_table[] = { + OCSEL_OCSRC_OSCIN, + OCSEL_OCSRC_PLL0_SYSCLK(1), + OCSEL_OCSRC_PLL0_SYSCLK(2), + OCSEL_OCSRC_PLL0_SYSCLK(3), + OCSEL_OCSRC_PLL0_SYSCLK(4), + OCSEL_OCSRC_PLL0_SYSCLK(5), + OCSEL_OCSRC_PLL0_SYSCLK(6), + OCSEL_OCSRC_PLL0_SYSCLK(7), + OCSEL_OCSRC_PLL1_OBSCLK, +}; + +static const struct davinci_pll_obsclk_info da850_pll0_obsclk_info = { + .name = "pll0_obsclk", + .parent_names = da850_pll0_obsclk_parent_names, + .num_parents = ARRAY_SIZE(da850_pll0_obsclk_parent_names), + .table = da850_pll0_obsclk_table, + .ocsrc_mask = GENMASK(4, 0), +}; + +int da850_pll0_init(struct device *dev, void __iomem *base) +{ + struct clk *clk; + + davinci_pll_clk_register(dev, &da850_pll0_info, "ref_clk", base); + + clk = davinci_pll_sysclk_register(dev, &pll0_sysclk1, base); + clk_register_clkdev(clk, "pll0_sysclk1", "da850-psc0"); + + clk = davinci_pll_sysclk_register(dev, &pll0_sysclk2, base); + clk_register_clkdev(clk, "pll0_sysclk2", "da850-psc0"); + clk_register_clkdev(clk, "pll0_sysclk2", "da850-psc1"); + clk_register_clkdev(clk, "pll0_sysclk2", "da850-async3-clksrc"); + + clk = davinci_pll_sysclk_register(dev, &pll0_sysclk3, base); + clk_register_clkdev(clk, "pll0_sysclk3", "da850-async1-clksrc"); + + clk = davinci_pll_sysclk_register(dev, &pll0_sysclk4, base); + clk_register_clkdev(clk, "pll0_sysclk4", "da850-psc0"); + clk_register_clkdev(clk, "pll0_sysclk4", "da850-psc1"); + + davinci_pll_sysclk_register(dev, &pll0_sysclk5, base); + + clk = davinci_pll_sysclk_register(dev, &pll0_sysclk6, base); + clk_register_clkdev(clk, "pll0_sysclk6", "da850-psc0"); + +
[PATCH v8 06/42] clk: davinci: Add platform information for TI DM365 PLL
This adds platform-specific declarations for the PLL clocks on TI DM365 based systems. Signed-off-by: David Lechner --- v8 changes: - drop __init and __initconst attributes - add a clkdev lookup for each SYSCLK v7 changes: - split registration functions for each PLL - Add platform_device_id lookup v6 changes: - Added dm365_pll{1,2}_info with controller-specific information - Changed OBSCLK data - Add empty lines between function calls drivers/clk/davinci/Makefile| 1 + drivers/clk/davinci/pll-dm365.c | 145 drivers/clk/davinci/pll.c | 2 + drivers/clk/davinci/pll.h | 3 + 4 files changed, 151 insertions(+) create mode 100644 drivers/clk/davinci/pll-dm365.c diff --git a/drivers/clk/davinci/Makefile b/drivers/clk/davinci/Makefile index 6720bd0..353aa02 100644 --- a/drivers/clk/davinci/Makefile +++ b/drivers/clk/davinci/Makefile @@ -5,4 +5,5 @@ obj-y += pll.o obj-$(CONFIG_ARCH_DAVINCI_DA830) += pll-da830.o obj-$(CONFIG_ARCH_DAVINCI_DA850) += pll-da850.o obj-$(CONFIG_ARCH_DAVINCI_DM355) += pll-dm355.o +obj-$(CONFIG_ARCH_DAVINCI_DM365) += pll-dm365.o endif diff --git a/drivers/clk/davinci/pll-dm365.c b/drivers/clk/davinci/pll-dm365.c new file mode 100644 index 000..5f8d9f4 --- /dev/null +++ b/drivers/clk/davinci/pll-dm365.c @@ -0,0 +1,145 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PLL clock descriptions for TI DM365 + * + * Copyright (C) 2018 David Lechner + */ + +#include +#include +#include +#include +#include + +#include "pll.h" + +#define OCSEL_OCSRC_ENABLE 0 + +static const struct davinci_pll_clk_info dm365_pll1_info = { + .name = "pll1", + .pllm_mask = GENMASK(9, 0), + .pllm_min = 1, + .pllm_max = 1023, + .flags = PLL_HAS_CLKMODE | PLL_HAS_PREDIV | PLL_HAS_POSTDIV | +PLL_POSTDIV_ALWAYS_ENABLED | PLL_PLLM_2X, +}; + +SYSCLK(1, pll1_sysclk1, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED); +SYSCLK(2, pll1_sysclk2, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED); +SYSCLK(3, pll1_sysclk3, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED); +SYSCLK(4, pll1_sysclk4, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED); +SYSCLK(5, pll1_sysclk5, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED); +SYSCLK(6, pll1_sysclk6, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED); +SYSCLK(7, pll1_sysclk7, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED); +SYSCLK(8, pll1_sysclk8, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED); +SYSCLK(9, pll1_sysclk9, pll1_pllen, 5, SYSCLK_ALWAYS_ENABLED); + +/* + * This is a bit of a hack to make OCSEL[OCSRC] on DM365 look like OCSEL[OCSRC] + * on DA850. On DM365, OCSEL[OCSRC] is just an enable/disable bit instead of a + * multiplexer. By modeling it as a single parent mux clock, the clock code will + * still do the right thing in this case. + */ +static const char * const dm365_pll_obsclk_parent_names[] = { + "oscin", +}; + +static u32 dm365_pll_obsclk_table[] = { + OCSEL_OCSRC_ENABLE, +}; + +static const struct davinci_pll_obsclk_info dm365_pll1_obsclk_info = { + .name = "pll1_obsclk", + .parent_names = dm365_pll_obsclk_parent_names, + .num_parents = ARRAY_SIZE(dm365_pll_obsclk_parent_names), + .table = dm365_pll_obsclk_table, + .ocsrc_mask = BIT(4), +}; + +int dm365_pll1_init(struct device *dev, void __iomem *base) +{ + struct clk *clk; + + davinci_pll_clk_register(dev, &dm365_pll1_info, "ref_clk", base); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base); + clk_register_clkdev(clk, "pll1_sysclk1", "dm365-psc"); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk2, base); + clk_register_clkdev(clk, "pll1_sysclk2", "dm365-psc"); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk3, base); + clk_register_clkdev(clk, "pll1_sysclk3", "dm365-psc"); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk4, base); + clk_register_clkdev(clk, "pll1_sysclk4", "dm365-psc"); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk5, base); + clk_register_clkdev(clk, "pll1_sysclk5", "dm365-psc"); + + davinci_pll_sysclk_register(dev, &pll1_sysclk6, base); + + davinci_pll_sysclk_register(dev, &pll1_sysclk7, base); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk8, base); + clk_register_clkdev(clk, "pll1_sysclk8", "dm365-psc"); + + davinci_pll_sysclk_register(dev, &pll1_sysclk9, base); + + clk = davinci_pll_auxclk_register(dev, "pll1_auxclk", base); + clk_register_clkdev(clk, "pll1_auxclk", "dm355-psc"); + + davinci_pll_sysclkbp_clk_register(dev, "pll1_sysclkbp", base); + + davinci_pll_obsclk_register(dev, &dm365_pll1_obsclk_info, base); + + return 0; +} + +static const struct davinci_pll_clk_info dm365_pll2_info = { + .name = "pll2", + .pllm_mask = GENMASK(9, 0), + .pllm_min = 1, + .pllm_max = 1023, + .flags = PLL_HAS_PREDIV | PLL_HAS_POSTDIV | PLL_POSTDIV_ALWAYS_ENABLED | +PLL_PLLM_2X, +
[PATCH v8 05/42] clk: davinci: Add platform information for TI DM355 PLL
This adds platform-specific declarations for the PLL clocks on TI DM355 based systems. Signed-off-by: David Lechner --- v8 changes: - drop __init and __initconst attributes - add a clkdev lookup for each SYSCLK v7 changes: - split registration functions for each PLL - Add platform_device_id lookup v6 changes: - Added dm355_pll{1,2}_info with controller-specific information - Add empty lines between function calls drivers/clk/davinci/Makefile| 1 + drivers/clk/davinci/pll-dm355.c | 79 + drivers/clk/davinci/pll.c | 2 ++ drivers/clk/davinci/pll.h | 3 ++ 4 files changed, 85 insertions(+) create mode 100644 drivers/clk/davinci/pll-dm355.c diff --git a/drivers/clk/davinci/Makefile b/drivers/clk/davinci/Makefile index 13049d4..6720bd0 100644 --- a/drivers/clk/davinci/Makefile +++ b/drivers/clk/davinci/Makefile @@ -4,4 +4,5 @@ ifeq ($(CONFIG_COMMON_CLK), y) obj-y += pll.o obj-$(CONFIG_ARCH_DAVINCI_DA830) += pll-da830.o obj-$(CONFIG_ARCH_DAVINCI_DA850) += pll-da850.o +obj-$(CONFIG_ARCH_DAVINCI_DM355) += pll-dm355.o endif diff --git a/drivers/clk/davinci/pll-dm355.c b/drivers/clk/davinci/pll-dm355.c new file mode 100644 index 000..5345f82 --- /dev/null +++ b/drivers/clk/davinci/pll-dm355.c @@ -0,0 +1,79 @@ +// SPDX-License-Identifier: GPL-2.0 +/* + * PLL clock descriptions for TI DM355 + * + * Copyright (C) 2018 David Lechner + */ + +#include +#include +#include +#include + +#include "pll.h" + +static const struct davinci_pll_clk_info dm355_pll1_info = { + .name = "pll1", + .pllm_mask = GENMASK(7, 0), + .pllm_min = 92, + .pllm_max = 184, + .flags = PLL_HAS_CLKMODE | PLL_HAS_PREDIV | PLL_PREDIV_ALWAYS_ENABLED | +PLL_PREDIV_FIXED8 | PLL_HAS_POSTDIV | +PLL_POSTDIV_ALWAYS_ENABLED | PLL_POSTDIV_FIXED_DIV, +}; + +SYSCLK(1, pll1_sysclk1, pll1, 5, SYSCLK_FIXED_DIV | SYSCLK_ALWAYS_ENABLED); +SYSCLK(2, pll1_sysclk2, pll1, 5, SYSCLK_FIXED_DIV | SYSCLK_ALWAYS_ENABLED); +SYSCLK(3, pll1_sysclk3, pll1, 5, SYSCLK_ALWAYS_ENABLED); +SYSCLK(4, pll1_sysclk4, pll1, 5, SYSCLK_ALWAYS_ENABLED); + +int dm355_pll1_init(struct device *dev, void __iomem *base) +{ + struct clk *clk; + + davinci_pll_clk_register(dev, &dm355_pll1_info, "ref_clk", base); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk1, base); + clk_register_clkdev(clk, "pll1_sysclk1", "dm355-psc"); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk2, base); + clk_register_clkdev(clk, "pll1_sysclk2", "dm355-psc"); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk3, base); + clk_register_clkdev(clk, "pll1_sysclk3", "dm355-psc"); + + clk = davinci_pll_sysclk_register(dev, &pll1_sysclk4, base); + clk_register_clkdev(clk, "pll1_sysclk4", "dm355-psc"); + + clk = davinci_pll_auxclk_register(dev, "pll1_auxclk", base); + clk_register_clkdev(clk, "pll1_auxclk", "dm355-psc"); + + davinci_pll_sysclkbp_clk_register(dev, "pll1_sysclkbp", base); + + return 0; +} + +static const struct davinci_pll_clk_info dm355_pll2_info = { + .name = "pll2", + .pllm_mask = GENMASK(7, 0), + .pllm_min = 92, + .pllm_max = 184, + .flags = PLL_HAS_PREDIV | PLL_PREDIV_ALWAYS_ENABLED | PLL_HAS_POSTDIV | +PLL_POSTDIV_ALWAYS_ENABLED | PLL_POSTDIV_FIXED_DIV, +}; + +SYSCLK(1, pll2_sysclk1, pll2, 5, SYSCLK_FIXED_DIV); +SYSCLK(2, pll2_sysclk2, pll2, 5, SYSCLK_FIXED_DIV | SYSCLK_ALWAYS_ENABLED); + +int dm355_pll2_init(struct device *dev, void __iomem *base) +{ + davinci_pll_clk_register(dev, &dm355_pll2_info, "oscin", base); + + davinci_pll_sysclk_register(dev, &pll2_sysclk1, base); + + davinci_pll_sysclk_register(dev, &pll2_sysclk2, base); + + davinci_pll_sysclkbp_clk_register(dev, "pll2_sysclkbp", base); + + return 0; +} diff --git a/drivers/clk/davinci/pll.c b/drivers/clk/davinci/pll.c index 535f725..305d2e9 100644 --- a/drivers/clk/davinci/pll.c +++ b/drivers/clk/davinci/pll.c @@ -780,6 +780,8 @@ static const struct platform_device_id davinci_pll_id_table[] = { { .name = "da830-pll", .driver_data = (kernel_ulong_t)da830_pll_init }, { .name = "da850-pll0", .driver_data = (kernel_ulong_t)da850_pll0_init }, { .name = "da850-pll1", .driver_data = (kernel_ulong_t)da850_pll1_init }, + { .name = "dm355-pll1", .driver_data = (kernel_ulong_t)dm355_pll1_init }, + { .name = "dm355-pll2", .driver_data = (kernel_ulong_t)dm355_pll2_init }, { } }; diff --git a/drivers/clk/davinci/pll.h b/drivers/clk/davinci/pll.h index 53b8d51..d90d308 100644 --- a/drivers/clk/davinci/pll.h +++ b/drivers/clk/davinci/pll.h @@ -126,4 +126,7 @@ int da850_pll1_init(struct device *dev, void __iomem *base); int of_da850_pll0_init(struct device *dev, void __iomem *base); int of_da850_pll1_init(struct device *dev, void __iomem *base); +int dm355_pll1_init